Home 3. Result -> Option
Post
Cancel

3. Result -> Option

Convert Result to Option easily.

1
2
3
let r: Result<u32,()> = Ok(200u32);
let o: Option<u32> = r.ok();
assert_eq!(o, Some(200u32));
This post is licensed under CC BY 4.0 by the author.