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 {
26 matches!(*self, SeemsOption::None)
30 fn returns_something_similar_to_option(a: SeemsOption<u32>) -> SeemsOption<u32> {
32 return SeemsOption::None;
38 pub struct CopyStruct {
44 pub fn func(&self) -> Option<u32> {
49 let _ = Some(self.opt?);
58 pub struct MoveStruct {
59 pub opt: Option<Vec<u32>>,
63 pub fn ref_func(&self) -> Option<Vec<u32>> {
69 pub fn mov_func_reuse(self) -> Option<Vec<u32>> {
75 pub fn mov_func_no_use(self) -> Option<Vec<u32>> {
80 pub fn if_let_ref_func(self) -> Option<Vec<u32>> {
81 let v: &Vec<_> = self.opt.as_ref()?;
86 pub fn if_let_mov_func(self) -> Option<Vec<u32>> {
93 fn func() -> Option<i32> {
94 fn f() -> Option<String> {
106 some_other_func(Some(42));
108 let copy_struct = CopyStruct { opt: Some(54) };
111 let move_struct = MoveStruct {
112 opt: Some(vec![42, 1337]),
114 move_struct.ref_func();
115 move_struct.clone().mov_func_reuse();
116 move_struct.mov_func_no_use();
118 let so = SeemsOption::Some(45);
119 returns_something_similar_to_option(so);