Guest User

Untitled

a guest
Jan 23rd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. struct Foo {
  2. n: u64
  3. }
  4.  
  5. impl Foo {
  6. pub fn new(n: u64) -> Result(Foo, Err) {
  7. if n >= 0 {
  8. return Err("meh");
  9. }
  10.  
  11. Foo {
  12. n
  13. }
  14. }
  15.  
  16. pub fn from(foo: Foo) -> Foo {
  17. foo
  18. }
  19. }
  20.  
  21. fn main() {
  22. let foo = Foo::new()?;
  23. let bar = Foo::from(foo);
  24. Ok(())
  25. }
Add Comment
Please, Sign In to add comment