Support derivation of Hash for Str and List

This commit is contained in:
Ayaz Hafiz 2022-10-04 14:07:16 -05:00
parent 294244ae25
commit 5b833e57b5
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
9 changed files with 143 additions and 28 deletions

View file

@ -56,7 +56,14 @@ impl DeriveKey {
pub enum Derived {
/// If a derived implementation name is well-known ahead-of-time, we can inline the symbol
/// directly rather than associating a key for an implementation to be made later on.
///
/// Immediates refer to ability members that are "inlined" at the derivation call site.
Immediate(Symbol),
/// Like an [Derived::Immediate], but with the additional constraint that the immediate
/// symbol is statically known to have exactly one lamdba set.
/// This unlocks some optimization opportunities, as regioned lambda sets do not need to be
/// chased.
SingleLambdaSetImmediate(Symbol),
/// Key of the derived implementation to use. This allows association of derived implementation
/// names to a key, when the key is known ahead-of-time but the implementation (and it's name)
/// is yet-to-be-made.
@ -100,7 +107,9 @@ impl Derived {
FlatDecodable::Key(repr) => Ok(Derived::Key(DeriveKey::Decoder(repr))),
},
DeriveBuiltin::Hash => match hash::FlatHash::from_var(subs, var)? {
FlatHash::Immediate(imm) => Ok(Derived::Immediate(imm)),
FlatHash::SingleLambdaSetImmediate(imm) => {
Ok(Derived::SingleLambdaSetImmediate(imm))
}
FlatHash::Key(repr) => Ok(Derived::Key(DeriveKey::Hash(repr))),
},
}