2 #![allow(unreachable_code)]
4 fn some_func(a: Option<u32>) -> Option<u32> {
10 fn some_other_func(a: Option<u32>) -> Option<u32> {
19 pub enum SeemsOption<T> {
24 impl<T> SeemsOption<T> {
25 pub fn is_none(&self) -> bool {
27 SeemsOption::None => true,
28 SeemsOption::Some(_) => false,
33 fn returns_something_similar_to_option(a: SeemsOption<u32>) -> SeemsOption<u32> {
35 return SeemsOption::None;
41 pub struct CopyStruct {
47 pub fn func(&self) -> Option<u32> {
52 let _ = Some(self.opt?);
61 pub struct MoveStruct {
62 pub opt: Option<Vec<u32>>,
66 pub fn ref_func(&self) -> Option<Vec<u32>> {
72 pub fn mov_func_reuse(self) -> Option<Vec<u32>> {
78 pub fn mov_func_no_use(self) -> Option<Vec<u32>> {
83 pub fn if_let_ref_func(self) -> Option<Vec<u32>> {
84 let v: &Vec<_> = self.opt.as_ref()?;
89 pub fn if_let_mov_func(self) -> Option<Vec<u32>> {
99 some_other_func(Some(42));
101 let copy_struct = CopyStruct { opt: Some(54) };
104 let move_struct = MoveStruct {
105 opt: Some(vec![42, 1337]),
107 move_struct.ref_func();
108 move_struct.clone().mov_func_reuse();
109 move_struct.mov_func_no_use();
111 let so = SeemsOption::Some(45);
112 returns_something_similar_to_option(so);