2 #![allow(unreachable_code)]
4 fn some_func(a: Option<u32>) -> Option<u32> {
12 fn some_other_func(a: Option<u32>) -> Option<u32> {
21 pub enum SeemsOption<T> {
26 impl<T> SeemsOption<T> {
27 pub fn is_none(&self) -> bool {
28 matches!(*self, SeemsOption::None)
32 fn returns_something_similar_to_option(a: SeemsOption<u32>) -> SeemsOption<u32> {
34 return SeemsOption::None;
40 pub struct CopyStruct {
46 pub fn func(&self) -> Option<u32> {
47 if (self.opt).is_none() {
51 if self.opt.is_none() {
55 let _ = if self.opt.is_none() {
61 let _ = if let Some(x) = self.opt {
72 pub struct MoveStruct {
73 pub opt: Option<Vec<u32>>,
77 pub fn ref_func(&self) -> Option<Vec<u32>> {
78 if self.opt.is_none() {
85 pub fn mov_func_reuse(self) -> Option<Vec<u32>> {
86 if self.opt.is_none() {
93 pub fn mov_func_no_use(self) -> Option<Vec<u32>> {
94 if self.opt.is_none() {
100 pub fn if_let_ref_func(self) -> Option<Vec<u32>> {
101 let v: &Vec<_> = if let Some(ref v) = self.opt {
110 pub fn if_let_mov_func(self) -> Option<Vec<u32>> {
111 let v = if let Some(v) = self.opt {
121 fn func() -> Option<i32> {
122 fn f() -> Option<String> {
136 some_other_func(Some(42));
138 let copy_struct = CopyStruct { opt: Some(54) };
141 let move_struct = MoveStruct {
142 opt: Some(vec![42, 1337]),
144 move_struct.ref_func();
145 move_struct.clone().mov_func_reuse();
146 move_struct.mov_func_no_use();
148 let so = SeemsOption::Some(45);
149 returns_something_similar_to_option(so);