pub trait Gettable {
type Res;
// Required method
fn get(self) -> Self::Res;
}
Required Associated Types§
Required Methods§
Implementations on Foreign Types§
Source§impl<T: Empty> Gettable for Option<T>
impl<T: Empty> Gettable for Option<T>
Source§fn get(self) -> T
fn get(self) -> T
Moves the value v
out of the Roption<T>
if it is Some(v)
.
§Panics
Panics if the self value equals None
.
§Safety note
In general, because this function may panic, its use is discouraged.
Instead, prefer to use pattern matching and handle the None
case explicitly.
§Examples
let x = Some("air");
assert_eq!(x.get(), "air");
let x: Roption<&str> = None;
assert_eq!(x.get(), "air"); // fails