Random stuff, testing things, and so on.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
655 B

#[derive(Debug)]
enum MyType {
SomethingWrong,
SomethingGood,
}
enum SomeError {
Bad,
}
impl From<SomeError> for MyType {
fn from(value: SomeError) -> Self {
MyType::SomethingWrong
}
}
fn validate(s: &str) -> Result<(), SomeError> {
if s == "bad" {
Err(SomeError::Bad)
} else {
Ok(())
}
}
fn check(response: &str) -> MyType {
let inner = validate(&response)?;
println!("Inner: {:?}", inner);
inner
}
fn main() {
let results = ["good", "bad", "good"];
for variant in results {
let response = check(&variant);
println!("{} = {:?}", variant, response);
}
}