2 #![allow(unreachable_code)]
3 #![allow(clippy::unnecessary_wraps)]
5 fn some_func(a: Option<u32>) -> Option<u32> {
13 fn some_other_func(a: Option<u32>) -> Option<u32> {
22 pub enum SeemsOption<T> {
27 impl<T> SeemsOption<T> {
28 pub fn is_none(&self) -> bool {
30 SeemsOption::None => true,
31 SeemsOption::Some(_) => false,
36 fn returns_something_similar_to_option(a: SeemsOption<u32>) -> SeemsOption<u32> {
38 return SeemsOption::None;
44 pub struct CopyStruct {
50 pub fn func(&self) -> Option<u32> {
51 if (self.opt).is_none() {
55 if self.opt.is_none() {
59 let _ = if self.opt.is_none() {
65 let _ = if let Some(x) = self.opt {
76 pub struct MoveStruct {
77 pub opt: Option<Vec<u32>>,
81 pub fn ref_func(&self) -> Option<Vec<u32>> {
82 if self.opt.is_none() {
89 pub fn mov_func_reuse(self) -> Option<Vec<u32>> {
90 if self.opt.is_none() {
97 pub fn mov_func_no_use(self) -> Option<Vec<u32>> {
98 if self.opt.is_none() {
104 pub fn if_let_ref_func(self) -> Option<Vec<u32>> {
105 let v: &Vec<_> = if let Some(ref v) = self.opt {
114 pub fn if_let_mov_func(self) -> Option<Vec<u32>> {
115 let v = if let Some(v) = self.opt {
125 fn func() -> Option<i32> {
126 fn f() -> Option<String> {
137 fn result_func(x: Result<i32, &str>) -> Result<i32, &str> {
138 let _ = if let Ok(x) = x { x } else { return x };
145 let y = if let Ok(x) = x {
148 return Err("some error");
157 some_other_func(Some(42));
159 let copy_struct = CopyStruct { opt: Some(54) };
162 let move_struct = MoveStruct {
163 opt: Some(vec![42, 1337]),
165 move_struct.ref_func();
166 move_struct.clone().mov_func_reuse();
167 move_struct.mov_func_no_use();
169 let so = SeemsOption::Some(45);
170 returns_something_similar_to_option(so);
174 let _ = result_func(Ok(42));