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> {
110 some_other_func(Some(42));
112 let copy_struct = CopyStruct { opt: Some(54) };
115 let move_struct = MoveStruct {
116 opt: Some(vec![42, 1337]),
118 move_struct.ref_func();
119 move_struct.clone().mov_func_reuse();
120 move_struct.mov_func_no_use();
122 let so = SeemsOption::Some(45);
123 returns_something_similar_to_option(so);