This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn nested_match(unpack: Option<Option<i32>>) -> Result<Option<i32>, String> { | |
| return Ok(match unpack { | |
| None => None, | |
| Some(option) => { | |
| let unpack_again = match option { | |
| Some(int) => int, | |
| None => return Err("ERROR".to_owned()), | |
| }; | |
| Some(unpack_again) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::ptr; | |
| pub struct Error { | |
| description: String, | |
| } | |
| pub unsafe extern "C" fn assign_error(error_t_t: *mut *mut Error) { | |
| let error_ptr = Box::new(Error { | |
| description: "This is an error".to_owned(), | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub trait GenericError { | |
| fn description(&self) -> String { | |
| return "GenericError".to_owned(); | |
| } | |
| } | |
| pub trait Error: GenericError { | |
| } | |
| pub struct MyError {} |