Get DeriveBuiltin from symbol

This commit is contained in:
Ayaz Hafiz 2022-08-01 16:44:27 -05:00
parent 44984d289c
commit 61d34a4225
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 19 additions and 4 deletions

View file

@ -65,6 +65,18 @@ pub enum DeriveBuiltin {
Decoder,
}
impl TryFrom<Symbol> for DeriveBuiltin {
type Error = Symbol;
fn try_from(value: Symbol) -> Result<Self, Self::Error> {
match value {
Symbol::ENCODE_TO_ENCODER => Ok(DeriveBuiltin::ToEncoder),
Symbol::DECODE_DECODER => Ok(DeriveBuiltin::Decoder),
_ => Err(value),
}
}
}
impl Derived {
pub fn builtin(
builtin: DeriveBuiltin,