2 #![allow(unreachable_code)]
3 #![allow(clippy::unnecessary_wraps)]
6 use std::path::PathBuf;
8 fn some_func(a: Option<u32>) -> Option<u32> {
14 fn some_other_func(a: Option<u32>) -> Option<u32> {
23 pub enum SeemsOption<T> {
28 impl<T> SeemsOption<T> {
29 pub fn is_none(&self) -> bool {
31 SeemsOption::None => true,
32 SeemsOption::Some(_) => false,
37 fn returns_something_similar_to_option(a: SeemsOption<u32>) -> SeemsOption<u32> {
39 return SeemsOption::None;
45 pub struct CopyStruct {
51 pub fn func(&self) -> Option<u32> {
56 let _ = Some(self.opt?);
65 pub struct MoveStruct {
66 pub opt: Option<Vec<u32>>,
70 pub fn ref_func(&self) -> Option<Vec<u32>> {
76 pub fn mov_func_reuse(self) -> Option<Vec<u32>> {
82 pub fn mov_func_no_use(self) -> Option<Vec<u32>> {
87 pub fn if_let_ref_func(self) -> Option<Vec<u32>> {
88 let v: &Vec<_> = self.opt.as_ref()?;
93 pub fn if_let_mov_func(self) -> Option<Vec<u32>> {
100 fn func() -> Option<i32> {
101 fn f() -> Option<String> {
110 fn func_returning_result() -> Result<i32, String> {
114 fn result_func(x: Result<i32, String>) -> Result<i32, String> {
120 let y = if let Ok(x) = x {
123 return Err("some error".to_string());
128 let _ = if let Ok(x) = func_returning_result() {
131 return Err("some error".to_string());
134 if func_returning_result().is_err() {
135 return func_returning_result();
144 some_other_func(Some(42));
146 let copy_struct = CopyStruct { opt: Some(54) };
149 let move_struct = MoveStruct {
150 opt: Some(vec![42, 1337]),
152 move_struct.ref_func();
153 move_struct.clone().mov_func_reuse();
154 move_struct.mov_func_no_use();
156 let so = SeemsOption::Some(45);
157 returns_something_similar_to_option(so);
161 let _ = result_func(Ok(42));