about summary refs log tree commit diff
path: root/tvix/nix-compat-derive-tests/tests/ui/deserialize_try_from_error_not_display.rs
blob: 7f8ad6bbfc4e451fabc3dd8828ed977f881e9459 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use nix_compat_derive::NixDeserialize;

#[derive(NixDeserialize)]
#[nix(try_from = "u64")]
pub struct Test;

impl TryFrom<u64> for Test {
    type Error = ();

    fn try_from(value: u64) -> Result<Test, Self::Error> {
        if value == 42 {
            Ok(Test)
        } else {
            Err(())
        }
    }
}

fn main() {}