ΑZ
let n = match n {
Some(n) => n;
None => return;
}
println!("{}", n);Size: a a a
ΑZ
let n = match n {
Some(n) => n;
None => return;
}
println!("{}", n);gо
NE
gо
n.unwrap_or_return!()ΑZ
gо
gо
ΑZ
NE
ΑZ
ΑZ
#[unstable(feature = "try_trait_v2", issue = "84277")]
impl<T> ops::TryV2 for Option<T> {
type Output = T;
type Residual = Option<convert::Infallible>;
#[inline]
fn from_output(output: Self::Output) -> Self {
Some(output)
}
#[inline]
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
match self {
Some(v) => ControlFlow::Continue(v),
None => ControlFlow::Break(None),
}
}
}
Кто мне кстати объяснит почему тут Option<!> вместо ()? :)NE
AG
ΑZ
let n = n?;
// .. 1000 строк кода
println!("{}", n);NE
ΑZ
fn foo() {
let n = call_something_really_imporant()?;
... то же самое что раньше
}NE
ΑZ
FooΑZ
ΑZ
error[E0282]: type annotations needed🤔
--> src\main.rs:29:5
|
29 | handle_path(todo!(), |bar: Bar| "()");
| ^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the function `handle_path`
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
--> src\main.rs:32:19
|
32 | handle_path::<Bar>(todo!(), |bar: Bar| "()");
| ^^^ explicit generic argument not allowed