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 {
124 fn func() -> Option<i32> {
125 fn f() -> Option<String> {
139 some_other_func(Some(42));
141 let copy_struct = CopyStruct { opt: Some(54) };
144 let move_struct = MoveStruct {
145 opt: Some(vec![42, 1337]),
147 move_struct.ref_func();
148 move_struct.clone().mov_func_reuse();
149 move_struct.mov_func_no_use();
151 let so = SeemsOption::Some(45);
152 returns_something_similar_to_option(so);