-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove set_unconditionally
& BeValue
#1131
Conversation
This apparently only existed to get around the orphan rules for `Persistable`, but we can just do that by moving the implementation into the same crate that defines that trait (`fontir`). In the process of this work I discovered that avar needs special handling, because it is the one in this context that is allowed to explicitly be `None`. This had previously been handled by `BeValue`; to support this use case I also added an explicit `PersistableOption` type, but thinking about it more now I think this is unnecesary? Shouldn't it be fine to just serialize an empty avar? But my quick attempt to do this ran into some confusing test failures, so this seems fine for now.
This method had a TODO saying it shouldn't be necessary, which sounded like a challange.
Oh nice, if we now have partialeq everywhere we should be able to tear down a bunch of that indeed. Memory is failing me wrt avar weirdness. |
fontbe/src/avar.rs
Outdated
@@ -17,6 +18,42 @@ use crate::{ | |||
orchestration::{AnyWorkId, BeWork, Context, WorkId}, | |||
}; | |||
|
|||
/// Avar is a special case where sometimes we want to explicitly have an empty one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note in comment why this exists, e.g. why not just Option<Avar>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely looks like an improvement and makes sense if write-fonts now has partialeq we shouldn't need to work around it not having it.
As you suggest, I don't think we need to special case avar so. Maybe as a follow-on we can delete that enum and let avar be like everything else?
I tried just deleting the option but it broke some tests that did not seem immediately related, so I settled on this. |
Instead of having a general purpose 'maybe missing' type we can just treat the avar as a singular special case, which is simpler.
bbb0b19
to
3c79244
Compare
How this happened:
set_unconditionally
, instead of justset
write-fonts
types don't implPartialEq
BeValue
Persistable
trait for the write-fonts types in the same crate where the trait is defined (fontir
)avar
we want to be able to store an explicitOption<T>
(the only case like this) and we were repurposing theBeValue
to also do that jobso I added aPersistableOption
type to explicitly handle this case (which I still do not fully understand)MaybeEmptyAvar
type.Bonus:
Why do we have this special case for avar? why do we need an explicit option? Why can't we just serialize an empty table in the case where we want to have an empty table in the final font? cc @rsheeter