1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
use std::str::FromStr; use nix_compat_derive::NixDeserialize; #[derive(NixDeserialize)] #[nix(from_str)] pub struct Test; impl FromStr for Test { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { if s == "test" { Ok(Test) } else { Err(()) } } } fn main() {}