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 {
29 SeemsOption::None => true,
30 SeemsOption::Some(_) => false,
35 fn returns_something_similar_to_option(a: SeemsOption<u32>) -> SeemsOption<u32> {
37 return SeemsOption::None;
43 pub struct CopyStruct {
49 pub fn func(&self) -> Option<u32> {
50 if (self.opt).is_none() {
54 if self.opt.is_none() {
58 let _ = if self.opt.is_none() {
64 let _ = if let Some(x) = self.opt {
75 pub struct MoveStruct {
76 pub opt: Option<Vec<u32>>,
80 pub fn ref_func(&self) -> Option<Vec<u32>> {
81 if self.opt.is_none() {
88 pub fn mov_func_reuse(self) -> Option<Vec<u32>> {
89 if self.opt.is_none() {
96 pub fn mov_func_no_use(self) -> Option<Vec<u32>> {
97 if self.opt.is_none() {
103 pub fn if_let_ref_func(self) -> Option<Vec<u32>> {
104 let v: &Vec<_> = if let Some(ref v) = self.opt {
113 pub fn if_let_mov_func(self) -> Option<Vec<u32>> {
114 let v = if let Some(v) = self.opt {
127 some_other_func(Some(42));
129 let copy_struct = CopyStruct { opt: Some(54) };
132 let move_struct = MoveStruct {
133 opt: Some(vec![42, 1337]),
135 move_struct.ref_func();
136 move_struct.clone().mov_func_reuse();
137 move_struct.mov_func_no_use();
139 let so = SeemsOption::Some(45);
140 returns_something_similar_to_option(so);