2 #![allow(unreachable_code)]
3 #![allow(clippy::unnecessary_wraps)]
5 fn some_func(a: Option<u32>) -> Option<u32> {
11 fn some_other_func(a: Option<u32>) -> Option<u32> {
20 pub enum SeemsOption<T> {
25 impl<T> SeemsOption<T> {
26 pub fn is_none(&self) -> bool {
28 SeemsOption::None => true,
29 SeemsOption::Some(_) => false,
34 fn returns_something_similar_to_option(a: SeemsOption<u32>) -> SeemsOption<u32> {
36 return SeemsOption::None;
42 pub struct CopyStruct {
48 pub fn func(&self) -> Option<u32> {
53 let _ = Some(self.opt?);
62 pub struct MoveStruct {
63 pub opt: Option<Vec<u32>>,
67 pub fn ref_func(&self) -> Option<Vec<u32>> {
73 pub fn mov_func_reuse(self) -> Option<Vec<u32>> {
79 pub fn mov_func_no_use(self) -> Option<Vec<u32>> {
84 pub fn if_let_ref_func(self) -> Option<Vec<u32>> {
85 let v: &Vec<_> = self.opt.as_ref()?;
90 pub fn if_let_mov_func(self) -> Option<Vec<u32>> {
97 fn func() -> Option<i32> {
98 fn f() -> Option<String> {
107 fn result_func(x: Result<i32, &str>) -> Result<i32, &str> {
113 let y = if let Ok(x) = x {
116 return Err("some error");
125 some_other_func(Some(42));
127 let copy_struct = CopyStruct { opt: Some(54) };
130 let move_struct = MoveStruct {
131 opt: Some(vec![42, 1337]),
133 move_struct.ref_func();
134 move_struct.clone().mov_func_reuse();
135 move_struct.mov_func_no_use();
137 let so = SeemsOption::Some(45);
138 returns_something_similar_to_option(so);
142 let _ = result_func(Ok(42));