File: fallible.rs

package info (click to toggle)
rust-buildstructor 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 532 kB
  • sloc: makefile: 2
file content (20 lines) | stat: -rw-r--r-- 369 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use buildstructor::buildstructor;

use std::error::Error;

pub struct Fallible {
    simple: usize,
}

#[buildstructor]
impl Fallible {
    #[builder]
    fn new(simple: usize) -> Result<Fallible, Box<dyn Error>> {
        Ok(Self { simple })
    }
}

fn main() {
    let fallible = Fallible::builder().simple(2).build().unwrap();
    assert_eq!(fallible.simple, 2);
}