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 func_returning_result() -> Result<i32, i32> {
141 fn result_func(x: Result<i32, i32>) -> Result<i32, i32> {
142 let _ = if let Ok(x) = x { x } else { return x };
149 let y = if let Ok(x) = x {
157 let _ = if let Ok(x) = func_returning_result() {
164 if func_returning_result().is_err() {
165 return func_returning_result();
178 fn obj(_: i32) -> Result<(), NotOption> {
179 Err(NotOption::First)
182 fn f() -> NotOption {
184 return NotOption::None;
192 some_other_func(Some(42));
194 let copy_struct = CopyStruct { opt: Some(54) };
197 let move_struct = MoveStruct {
198 opt: Some(vec![42, 1337]),
200 move_struct.ref_func();
201 move_struct.clone().mov_func_reuse();
202 move_struct.mov_func_no_use();
204 let so = SeemsOption::Some(45);
205 returns_something_similar_to_option(so);
209 let _ = result_func(Ok(42));