~kmaasrud/pimalaya-webfinger

60568901a8c19a8afe723255f832a96f48a89e36 — Knut Magnus Aasrud 10 months ago 38c80b3
feat: add TryFrom<&str> for Rel
1 files changed, 12 insertions(+), 0 deletions(-)

M src/rel.rs
M src/rel.rs => src/rel.rs +12 -0
@@ 9,7 9,19 @@ macro_rules! rel {
                #[serde(rename = $name)]
                $variant
            ),*
        }

        impl TryFrom<&str> for Rel {
            type Error = ();

            fn try_from(value: &str) -> Result<Self, Self::Error> {
                match value {
                    $(
                        $name => Ok(Self::$variant),
                    )*
                    _ => Err(()),
                }
            }
        }

        impl AsRef<str> for Rel {