devela::_dep::_std::option

Enum Option

1.0.0 · Source
pub enum Option<T> {
    None,
    Some(T),
}
Available on crate feature std only.
Expand description

The Option type. See the module level documentation for more.

Variants§

§1.0.0

None

No value.

§1.0.0

Some(T)

Some value of type T.

Implementations§

Source§

impl<T> Option<T>

1.0.0 (const: 1.48.0) · Source

pub const fn is_some(&self) -> bool

Returns true if the option is a Some value.

§Examples
let x: Option<u32> = Some(2);
assert_eq!(x.is_some(), true);

let x: Option<u32> = None;
assert_eq!(x.is_some(), false);
1.70.0 · Source

pub fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool

Returns true if the option is a Some and the value inside of it matches a predicate.

§Examples
let x: Option<u32> = Some(2);
assert_eq!(x.is_some_and(|x| x > 1), true);

let x: Option<u32> = Some(0);
assert_eq!(x.is_some_and(|x| x > 1), false);

let x: Option<u32> = None;
assert_eq!(x.is_some_and(|x| x > 1), false);
1.0.0 (const: 1.48.0) · Source

pub const fn is_none(&self) -> bool

Returns true if the option is a None value.

§Examples
let x: Option<u32> = Some(2);
assert_eq!(x.is_none(), false);

let x: Option<u32> = None;
assert_eq!(x.is_none(), true);
1.82.0 · Source

pub fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool

Returns true if the option is a None or the value inside of it matches a predicate.

§Examples
let x: Option<u32> = Some(2);
assert_eq!(x.is_none_or(|x| x > 1), true);

let x: Option<u32> = Some(0);
assert_eq!(x.is_none_or(|x| x > 1), false);

let x: Option<u32> = None;
assert_eq!(x.is_none_or(|x| x > 1), true);
1.0.0 (const: 1.48.0) · Source

pub const fn as_ref(&self) -> Option<&T>

Converts from &Option<T> to Option<&T>.

§Examples

Calculates the length of an Option<String> as an Option<usize> without moving the String. The map method takes the self argument by value, consuming the original, so this technique uses as_ref to first take an Option to a reference to the value inside the original.

let text: Option<String> = Some("Hello, world!".to_string());
// First, cast `Option<String>` to `Option<&String>` with `as_ref`,
// then consume *that* with `map`, leaving `text` on the stack.
let text_length: Option<usize> = text.as_ref().map(|s| s.len());
println!("still can print text: {text:?}");
1.0.0 (const: 1.83.0) · Source

pub const fn as_mut(&mut self) -> Option<&mut T>

Converts from &mut Option<T> to Option<&mut T>.

§Examples
let mut x = Some(2);
match x.as_mut() {
    Some(v) => *v = 42,
    None => {},
}
assert_eq!(x, Some(42));
1.33.0 (const: 1.84.0) · Source

pub const fn as_pin_ref(self: Pin<&Option<T>>) -> Option<Pin<&T>>

Converts from Pin<&Option<T>> to Option<Pin<&T>>.

1.33.0 (const: 1.84.0) · Source

pub const fn as_pin_mut(self: Pin<&mut Option<T>>) -> Option<Pin<&mut T>>

Converts from Pin<&mut Option<T>> to Option<Pin<&mut T>>.

1.75.0 (const: 1.84.0) · Source

pub const fn as_slice(&self) -> &[T]

Returns a slice of the contained value, if any. If this is None, an empty slice is returned. This can be useful to have a single type of iterator over an Option or slice.

Note: Should you have an Option<&T> and wish to get a slice of T, you can unpack it via opt.map_or(&[], std::slice::from_ref).

§Examples
assert_eq!(
    [Some(1234).as_slice(), None.as_slice()],
    [&[1234][..], &[][..]],
);

The inverse of this function is (discounting borrowing) [_]::first:

for i in [Some(1234_u16), None] {
    assert_eq!(i.as_ref(), i.as_slice().first());
}
1.75.0 (const: 1.84.0) · Source

pub const fn as_mut_slice(&mut self) -> &mut [T]

Returns a mutable slice of the contained value, if any. If this is None, an empty slice is returned. This can be useful to have a single type of iterator over an Option or slice.

Note: Should you have an Option<&mut T> instead of a &mut Option<T>, which this method takes, you can obtain a mutable slice via opt.map_or(&mut [], std::slice::from_mut).

§Examples
assert_eq!(
    [Some(1234).as_mut_slice(), None.as_mut_slice()],
    [&mut [1234][..], &mut [][..]],
);

The result is a mutable slice of zero or one items that points into our original Option:

let mut x = Some(1234);
x.as_mut_slice()[0] += 1;
assert_eq!(x, Some(1235));

The inverse of this method (discounting borrowing) is [_]::first_mut:

assert_eq!(Some(123).as_mut_slice().first_mut(), Some(&mut 123))
1.0.0 (const: 1.83.0) · Source

pub const fn expect(self, msg: &str) -> T

Returns the contained Some value, consuming the self value.

§Panics

Panics if the value is a None with a custom panic message provided by msg.

§Examples
let x = Some("value");
assert_eq!(x.expect("fruits are healthy"), "value");
let x: Option<&str> = None;
x.expect("fruits are healthy"); // panics with `fruits are healthy`

We recommend that expect messages are used to describe the reason you expect the Option should be Some.

let item = slice.get(0)
    .expect("slice should not be empty");

Hint: If you’re having trouble remembering how to phrase expect error messages remember to focus on the word “should” as in “env variable should be set by blah” or “the given binary should be available and executable by the current user”.

For more detail on expect message styles and the reasoning behind our recommendation please refer to the section on “Common Message Styles” in the std::error module docs.

1.0.0 (const: 1.83.0) · Source

pub const fn unwrap(self) -> T

Returns the contained Some value, consuming the self value.

Because this function may panic, its use is generally discouraged. Panics are meant for unrecoverable errors, and may abort the entire program.

Instead, prefer to use pattern matching and handle the None case explicitly, or call unwrap_or, unwrap_or_else, or unwrap_or_default. In functions returning Option, you can use the ? (try) operator.

§Panics

Panics if the self value equals None.

§Examples
let x = Some("air");
assert_eq!(x.unwrap(), "air");
let x: Option<&str> = None;
assert_eq!(x.unwrap(), "air"); // fails
1.0.0 · Source

pub fn unwrap_or(self, default: T) -> T

Returns the contained Some value or a provided default.

Arguments passed to unwrap_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use unwrap_or_else, which is lazily evaluated.

§Examples
assert_eq!(Some("car").unwrap_or("bike"), "car");
assert_eq!(None.unwrap_or("bike"), "bike");
1.0.0 · Source

pub fn unwrap_or_else<F>(self, f: F) -> T
where F: FnOnce() -> T,

Returns the contained Some value or computes it from a closure.

§Examples
let k = 10;
assert_eq!(Some(4).unwrap_or_else(|| 2 * k), 4);
assert_eq!(None.unwrap_or_else(|| 2 * k), 20);
1.0.0 · Source

pub fn unwrap_or_default(self) -> T
where T: Default,

Returns the contained Some value or a default.

Consumes the self argument then, if Some, returns the contained value, otherwise if None, returns the default value for that type.

§Examples
let x: Option<u32> = None;
let y: Option<u32> = Some(12);

assert_eq!(x.unwrap_or_default(), 0);
assert_eq!(y.unwrap_or_default(), 12);
1.58.0 (const: 1.83.0) · Source

pub const unsafe fn unwrap_unchecked(self) -> T

Returns the contained Some value, consuming the self value, without checking that the value is not None.

§Safety

Calling this method on None is undefined behavior.

§Examples
let x = Some("air");
assert_eq!(unsafe { x.unwrap_unchecked() }, "air");
let x: Option<&str> = None;
assert_eq!(unsafe { x.unwrap_unchecked() }, "air"); // Undefined behavior!
1.0.0 · Source

pub fn map<U, F>(self, f: F) -> Option<U>
where F: FnOnce(T) -> U,

Maps an Option<T> to Option<U> by applying a function to a contained value (if Some) or returns None (if None).

§Examples

Calculates the length of an Option<String> as an Option<usize>, consuming the original:

let maybe_some_string = Some(String::from("Hello, World!"));
// `Option::map` takes self *by value*, consuming `maybe_some_string`
let maybe_some_len = maybe_some_string.map(|s| s.len());
assert_eq!(maybe_some_len, Some(13));

let x: Option<&str> = None;
assert_eq!(x.map(|s| s.len()), None);
1.76.0 · Source

pub fn inspect<F>(self, f: F) -> Option<T>
where F: FnOnce(&T),

Calls a function with a reference to the contained value if Some.

Returns the original option.

§Examples
let list = vec![1, 2, 3];

// prints "got: 2"
let x = list
    .get(1)
    .inspect(|x| println!("got: {x}"))
    .expect("list should be long enough");

// prints nothing
list.get(5).inspect(|x| println!("got: {x}"));
1.0.0 · Source

pub fn map_or<U, F>(self, default: U, f: F) -> U
where F: FnOnce(T) -> U,

Returns the provided default result (if none), or applies a function to the contained value (if any).

Arguments passed to map_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use map_or_else, which is lazily evaluated.

§Examples
let x = Some("foo");
assert_eq!(x.map_or(42, |v| v.len()), 3);

let x: Option<&str> = None;
assert_eq!(x.map_or(42, |v| v.len()), 42);
1.0.0 · Source

pub fn map_or_else<U, D, F>(self, default: D, f: F) -> U
where D: FnOnce() -> U, F: FnOnce(T) -> U,

Computes a default function result (if none), or applies a different function to the contained value (if any).

§Basic examples
let k = 21;

let x = Some("foo");
assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 3);

let x: Option<&str> = None;
assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 42);
§Handling a Result-based fallback

A somewhat common occurrence when dealing with optional values in combination with Result<T, E> is the case where one wants to invoke a fallible fallback if the option is not present. This example parses a command line argument (if present), or the contents of a file to an integer. However, unlike accessing the command line argument, reading the file is fallible, so it must be wrapped with Ok.

let v: u64 = std::env::args()
   .nth(1)
   .map_or_else(|| std::fs::read_to_string("/etc/someconfig.conf"), Ok)?
   .parse()?;
1.0.0 · Source

pub fn ok_or<E>(self, err: E) -> Result<T, E>

Transforms the Option<T> into a Result<T, E>, mapping Some(v) to Ok(v) and None to Err(err).

Arguments passed to ok_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use ok_or_else, which is lazily evaluated.

§Examples
let x = Some("foo");
assert_eq!(x.ok_or(0), Ok("foo"));

let x: Option<&str> = None;
assert_eq!(x.ok_or(0), Err(0));
1.0.0 · Source

pub fn ok_or_else<E, F>(self, err: F) -> Result<T, E>
where F: FnOnce() -> E,

Transforms the Option<T> into a Result<T, E>, mapping Some(v) to Ok(v) and None to Err(err()).

§Examples
let x = Some("foo");
assert_eq!(x.ok_or_else(|| 0), Ok("foo"));

let x: Option<&str> = None;
assert_eq!(x.ok_or_else(|| 0), Err(0));
1.40.0 · Source

pub fn as_deref(&self) -> Option<&<T as Deref>::Target>
where T: Deref,

Converts from Option<T> (or &Option<T>) to Option<&T::Target>.

Leaves the original Option in-place, creating a new one with a reference to the original one, additionally coercing the contents via Deref.

§Examples
let x: Option<String> = Some("hey".to_owned());
assert_eq!(x.as_deref(), Some("hey"));

let x: Option<String> = None;
assert_eq!(x.as_deref(), None);
1.40.0 · Source

pub fn as_deref_mut(&mut self) -> Option<&mut <T as Deref>::Target>
where T: DerefMut,

Converts from Option<T> (or &mut Option<T>) to Option<&mut T::Target>.

Leaves the original Option in-place, creating a new one containing a mutable reference to the inner type’s Deref::Target type.

§Examples
let mut x: Option<String> = Some("hey".to_owned());
assert_eq!(x.as_deref_mut().map(|x| {
    x.make_ascii_uppercase();
    x
}), Some("HEY".to_owned().as_mut_str()));
1.0.0 · Source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the possibly contained value.

§Examples
let x = Some(4);
assert_eq!(x.iter().next(), Some(&4));

let x: Option<u32> = None;
assert_eq!(x.iter().next(), None);
1.0.0 · Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Returns a mutable iterator over the possibly contained value.

§Examples
let mut x = Some(4);
match x.iter_mut().next() {
    Some(v) => *v = 42,
    None => {},
}
assert_eq!(x, Some(42));

let mut x: Option<u32> = None;
assert_eq!(x.iter_mut().next(), None);
1.0.0 · Source

pub fn and<U>(self, optb: Option<U>) -> Option<U>

Returns None if the option is None, otherwise returns optb.

Arguments passed to and are eagerly evaluated; if you are passing the result of a function call, it is recommended to use and_then, which is lazily evaluated.

§Examples
let x = Some(2);
let y: Option<&str> = None;
assert_eq!(x.and(y), None);

let x: Option<u32> = None;
let y = Some("foo");
assert_eq!(x.and(y), None);

let x = Some(2);
let y = Some("foo");
assert_eq!(x.and(y), Some("foo"));

let x: Option<u32> = None;
let y: Option<&str> = None;
assert_eq!(x.and(y), None);
1.0.0 · Source

pub fn and_then<U, F>(self, f: F) -> Option<U>
where F: FnOnce(T) -> Option<U>,

Returns None if the option is None, otherwise calls f with the wrapped value and returns the result.

Some languages call this operation flatmap.

§Examples
fn sq_then_to_string(x: u32) -> Option<String> {
    x.checked_mul(x).map(|sq| sq.to_string())
}

assert_eq!(Some(2).and_then(sq_then_to_string), Some(4.to_string()));
assert_eq!(Some(1_000_000).and_then(sq_then_to_string), None); // overflowed!
assert_eq!(None.and_then(sq_then_to_string), None);

Often used to chain fallible operations that may return None.

let arr_2d = [["A0", "A1"], ["B0", "B1"]];

let item_0_1 = arr_2d.get(0).and_then(|row| row.get(1));
assert_eq!(item_0_1, Some(&"A1"));

let item_2_0 = arr_2d.get(2).and_then(|row| row.get(0));
assert_eq!(item_2_0, None);
1.27.0 · Source

pub fn filter<P>(self, predicate: P) -> Option<T>
where P: FnOnce(&T) -> bool,

Returns None if the option is None, otherwise calls predicate with the wrapped value and returns:

  • Some(t) if predicate returns true (where t is the wrapped value), and
  • None if predicate returns false.

This function works similar to Iterator::filter(). You can imagine the Option<T> being an iterator over one or zero elements. filter() lets you decide which elements to keep.

§Examples
fn is_even(n: &i32) -> bool {
    n % 2 == 0
}

assert_eq!(None.filter(is_even), None);
assert_eq!(Some(3).filter(is_even), None);
assert_eq!(Some(4).filter(is_even), Some(4));
1.0.0 · Source

pub fn or(self, optb: Option<T>) -> Option<T>

Returns the option if it contains a value, otherwise returns optb.

Arguments passed to or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use or_else, which is lazily evaluated.

§Examples
let x = Some(2);
let y = None;
assert_eq!(x.or(y), Some(2));

let x = None;
let y = Some(100);
assert_eq!(x.or(y), Some(100));

let x = Some(2);
let y = Some(100);
assert_eq!(x.or(y), Some(2));

let x: Option<u32> = None;
let y = None;
assert_eq!(x.or(y), None);
1.0.0 · Source

pub fn or_else<F>(self, f: F) -> Option<T>
where F: FnOnce() -> Option<T>,

Returns the option if it contains a value, otherwise calls f and returns the result.

§Examples
fn nobody() -> Option<&'static str> { None }
fn vikings() -> Option<&'static str> { Some("vikings") }

assert_eq!(Some("barbarians").or_else(vikings), Some("barbarians"));
assert_eq!(None.or_else(vikings), Some("vikings"));
assert_eq!(None.or_else(nobody), None);
1.37.0 · Source

pub fn xor(self, optb: Option<T>) -> Option<T>

Returns Some if exactly one of self, optb is Some, otherwise returns None.

§Examples
let x = Some(2);
let y: Option<u32> = None;
assert_eq!(x.xor(y), Some(2));

let x: Option<u32> = None;
let y = Some(2);
assert_eq!(x.xor(y), Some(2));

let x = Some(2);
let y = Some(2);
assert_eq!(x.xor(y), None);

let x: Option<u32> = None;
let y: Option<u32> = None;
assert_eq!(x.xor(y), None);
1.53.0 · Source

pub fn insert(&mut self, value: T) -> &mut T

Inserts value into the option, then returns a mutable reference to it.

If the option already contains a value, the old value is dropped.

See also Option::get_or_insert, which doesn’t update the value if the option already contains Some.

§Example
let mut opt = None;
let val = opt.insert(1);
assert_eq!(*val, 1);
assert_eq!(opt.unwrap(), 1);
let val = opt.insert(2);
assert_eq!(*val, 2);
*val = 3;
assert_eq!(opt.unwrap(), 3);
1.20.0 · Source

pub fn get_or_insert(&mut self, value: T) -> &mut T

Inserts value into the option if it is None, then returns a mutable reference to the contained value.

See also Option::insert, which updates the value even if the option already contains Some.

§Examples
let mut x = None;

{
    let y: &mut u32 = x.get_or_insert(5);
    assert_eq!(y, &5);

    *y = 7;
}

assert_eq!(x, Some(7));
1.83.0 · Source

pub fn get_or_insert_default(&mut self) -> &mut T
where T: Default,

Inserts the default value into the option if it is None, then returns a mutable reference to the contained value.

§Examples
let mut x = None;

{
    let y: &mut u32 = x.get_or_insert_default();
    assert_eq!(y, &0);

    *y = 7;
}

assert_eq!(x, Some(7));
1.20.0 · Source

pub fn get_or_insert_with<F>(&mut self, f: F) -> &mut T
where F: FnOnce() -> T,

Inserts a value computed from f into the option if it is None, then returns a mutable reference to the contained value.

§Examples
let mut x = None;

{
    let y: &mut u32 = x.get_or_insert_with(|| 5);
    assert_eq!(y, &5);

    *y = 7;
}

assert_eq!(x, Some(7));
1.0.0 (const: 1.83.0) · Source

pub const fn take(&mut self) -> Option<T>

Takes the value out of the option, leaving a None in its place.

§Examples
let mut x = Some(2);
let y = x.take();
assert_eq!(x, None);
assert_eq!(y, Some(2));

let mut x: Option<u32> = None;
let y = x.take();
assert_eq!(x, None);
assert_eq!(y, None);
1.80.0 · Source

pub fn take_if<P>(&mut self, predicate: P) -> Option<T>
where P: FnOnce(&mut T) -> bool,

Takes the value out of the option, but only if the predicate evaluates to true on a mutable reference to the value.

In other words, replaces self with None if the predicate returns true. This method operates similar to Option::take but conditional.

§Examples
let mut x = Some(42);

let prev = x.take_if(|v| if *v == 42 {
    *v += 1;
    false
} else {
    false
});
assert_eq!(x, Some(43));
assert_eq!(prev, None);

let prev = x.take_if(|v| *v == 43);
assert_eq!(x, None);
assert_eq!(prev, Some(43));
1.31.0 (const: 1.83.0) · Source

pub const fn replace(&mut self, value: T) -> Option<T>

Replaces the actual value in the option by the value given in parameter, returning the old value if present, leaving a Some in its place without deinitializing either one.

§Examples
let mut x = Some(2);
let old = x.replace(5);
assert_eq!(x, Some(5));
assert_eq!(old, Some(2));

let mut x = None;
let old = x.replace(3);
assert_eq!(x, Some(3));
assert_eq!(old, None);
1.46.0 · Source

pub fn zip<U>(self, other: Option<U>) -> Option<(T, U)>

Zips self with another Option.

If self is Some(s) and other is Some(o), this method returns Some((s, o)). Otherwise, None is returned.

§Examples
let x = Some(1);
let y = Some("hi");
let z = None::<u8>;

assert_eq!(x.zip(y), Some((1, "hi")));
assert_eq!(x.zip(z), None);
Source

pub fn zip_with<U, F, R>(self, other: Option<U>, f: F) -> Option<R>
where F: FnOnce(T, U) -> R,

🔬This is a nightly-only experimental API. (option_zip)

Zips self and another Option with function f.

If self is Some(s) and other is Some(o), this method returns Some(f(s, o)). Otherwise, None is returned.

§Examples
#![feature(option_zip)]

#[derive(Debug, PartialEq)]
struct Point {
    x: f64,
    y: f64,
}

impl Point {
    fn new(x: f64, y: f64) -> Self {
        Self { x, y }
    }
}

let x = Some(17.5);
let y = Some(42.7);

assert_eq!(x.zip_with(y, Point::new), Some(Point { x: 17.5, y: 42.7 }));
assert_eq!(x.zip_with(None, Point::new), None);
Source§

impl<T, U> Option<(T, U)>

1.66.0 · Source

pub fn unzip(self) -> (Option<T>, Option<U>)

Unzips an option containing a tuple of two options.

If self is Some((a, b)) this method returns (Some(a), Some(b)). Otherwise, (None, None) is returned.

§Examples
let x = Some((1, "hi"));
let y = None::<(u8, u32)>;

assert_eq!(x.unzip(), (Some(1), Some("hi")));
assert_eq!(y.unzip(), (None, None));
Source§

impl<T> Option<&T>

1.35.0 (const: 1.83.0) · Source

pub const fn copied(self) -> Option<T>
where T: Copy,

Maps an Option<&T> to an Option<T> by copying the contents of the option.

§Examples
let x = 12;
let opt_x = Some(&x);
assert_eq!(opt_x, Some(&12));
let copied = opt_x.copied();
assert_eq!(copied, Some(12));
1.0.0 · Source

pub fn cloned(self) -> Option<T>
where T: Clone,

Maps an Option<&T> to an Option<T> by cloning the contents of the option.

§Examples
let x = 12;
let opt_x = Some(&x);
assert_eq!(opt_x, Some(&12));
let cloned = opt_x.cloned();
assert_eq!(cloned, Some(12));
Source§

impl<T> Option<&mut T>

1.35.0 (const: 1.83.0) · Source

pub const fn copied(self) -> Option<T>
where T: Copy,

Maps an Option<&mut T> to an Option<T> by copying the contents of the option.

§Examples
let mut x = 12;
let opt_x = Some(&mut x);
assert_eq!(opt_x, Some(&mut 12));
let copied = opt_x.copied();
assert_eq!(copied, Some(12));
1.26.0 · Source

pub fn cloned(self) -> Option<T>
where T: Clone,

Maps an Option<&mut T> to an Option<T> by cloning the contents of the option.

§Examples
let mut x = 12;
let opt_x = Some(&mut x);
assert_eq!(opt_x, Some(&mut 12));
let cloned = opt_x.cloned();
assert_eq!(cloned, Some(12));
Source§

impl<T, E> Option<Result<T, E>>

1.33.0 (const: 1.83.0) · Source

pub const fn transpose(self) -> Result<Option<T>, E>

Transposes an Option of a Result into a Result of an Option.

None will be mapped to Ok(None). Some(Ok(_)) and Some(Err(_)) will be mapped to Ok(Some(_)) and Err(_).

§Examples
#[derive(Debug, Eq, PartialEq)]
struct SomeErr;

let x: Result<Option<i32>, SomeErr> = Ok(Some(5));
let y: Option<Result<i32, SomeErr>> = Some(Ok(5));
assert_eq!(x, y.transpose());
Source§

impl<T> Option<Option<T>>

1.40.0 (const: 1.83.0) · Source

pub const fn flatten(self) -> Option<T>

Converts from Option<Option<T>> to Option<T>.

§Examples

Basic usage:

let x: Option<Option<u32>> = Some(Some(6));
assert_eq!(Some(6), x.flatten());

let x: Option<Option<u32>> = Some(None);
assert_eq!(None, x.flatten());

let x: Option<Option<u32>> = None;
assert_eq!(None, x.flatten());

Flattening only removes one level of nesting at a time:

let x: Option<Option<Option<u32>>> = Some(Some(Some(6)));
assert_eq!(Some(Some(6)), x.flatten());
assert_eq!(Some(6), x.flatten().flatten());

Trait Implementations§

§

impl<T> Archive for Option<T>
where T: Archive,

§

type Archived = ArchivedOption<<T as Archive>::Archived>

The archived representation of this type. Read more
§

type Resolver = Option<<T as Archive>::Resolver>

The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type.
§

fn resolve( &self, resolver: <Option<T> as Archive>::Resolver, out: Place<<Option<T> as Archive>::Archived>, )

Creates the archived version of this value at the given position and writes it to the given output. Read more
§

const COPY_OPTIMIZATION: CopyOptimization<Self> = _

An optimization flag that allows the bytes of this type to be copied directly to a writer instead of calling serialize. Read more
§

impl<T> ArchiveWith<Option<Box<T>>> for Niche

§

type Archived = ArchivedOptionBox<<T as ArchiveUnsized>::Archived>

The archived type of Self with F.
§

type Resolver = OptionBoxResolver

The resolver of a Self with F.
§

fn resolve_with( field: &Option<Box<T>>, resolver: <Niche as ArchiveWith<Option<Box<T>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<Box<T>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl ArchiveWith<Option<NonZero<i128>>> for Niche

§

type Archived = ArchivedOptionNonZeroI128

The archived type of Self with F.
§

type Resolver = ()

The resolver of a Self with F.
§

fn resolve_with( field: &Option<NonZero<i128>>, _: <Niche as ArchiveWith<Option<NonZero<i128>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<NonZero<i128>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl ArchiveWith<Option<NonZero<i16>>> for Niche

§

type Archived = ArchivedOptionNonZeroI16

The archived type of Self with F.
§

type Resolver = ()

The resolver of a Self with F.
§

fn resolve_with( field: &Option<NonZero<i16>>, _: <Niche as ArchiveWith<Option<NonZero<i16>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<NonZero<i16>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl ArchiveWith<Option<NonZero<i32>>> for Niche

§

type Archived = ArchivedOptionNonZeroI32

The archived type of Self with F.
§

type Resolver = ()

The resolver of a Self with F.
§

fn resolve_with( field: &Option<NonZero<i32>>, _: <Niche as ArchiveWith<Option<NonZero<i32>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<NonZero<i32>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl ArchiveWith<Option<NonZero<i64>>> for Niche

§

type Archived = ArchivedOptionNonZeroI64

The archived type of Self with F.
§

type Resolver = ()

The resolver of a Self with F.
§

fn resolve_with( field: &Option<NonZero<i64>>, _: <Niche as ArchiveWith<Option<NonZero<i64>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<NonZero<i64>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl ArchiveWith<Option<NonZero<i8>>> for Niche

§

type Archived = ArchivedOptionNonZeroI8

The archived type of Self with F.
§

type Resolver = ()

The resolver of a Self with F.
§

fn resolve_with( field: &Option<NonZero<i8>>, _: <Niche as ArchiveWith<Option<NonZero<i8>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<NonZero<i8>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl ArchiveWith<Option<NonZero<isize>>> for Niche

§

type Archived = ArchivedOptionNonZeroI32

The archived type of Self with F.
§

type Resolver = ()

The resolver of a Self with F.
§

fn resolve_with( field: &Option<NonZero<isize>>, _: <Niche as ArchiveWith<Option<NonZero<isize>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<NonZero<isize>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl ArchiveWith<Option<NonZero<u128>>> for Niche

§

type Archived = ArchivedOptionNonZeroU128

The archived type of Self with F.
§

type Resolver = ()

The resolver of a Self with F.
§

fn resolve_with( field: &Option<NonZero<u128>>, _: <Niche as ArchiveWith<Option<NonZero<u128>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<NonZero<u128>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl ArchiveWith<Option<NonZero<u16>>> for Niche

§

type Archived = ArchivedOptionNonZeroU16

The archived type of Self with F.
§

type Resolver = ()

The resolver of a Self with F.
§

fn resolve_with( field: &Option<NonZero<u16>>, _: <Niche as ArchiveWith<Option<NonZero<u16>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<NonZero<u16>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl ArchiveWith<Option<NonZero<u32>>> for Niche

§

type Archived = ArchivedOptionNonZeroU32

The archived type of Self with F.
§

type Resolver = ()

The resolver of a Self with F.
§

fn resolve_with( field: &Option<NonZero<u32>>, _: <Niche as ArchiveWith<Option<NonZero<u32>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<NonZero<u32>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl ArchiveWith<Option<NonZero<u64>>> for Niche

§

type Archived = ArchivedOptionNonZeroU64

The archived type of Self with F.
§

type Resolver = ()

The resolver of a Self with F.
§

fn resolve_with( field: &Option<NonZero<u64>>, _: <Niche as ArchiveWith<Option<NonZero<u64>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<NonZero<u64>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl ArchiveWith<Option<NonZero<u8>>> for Niche

§

type Archived = ArchivedOptionNonZeroU8

The archived type of Self with F.
§

type Resolver = ()

The resolver of a Self with F.
§

fn resolve_with( field: &Option<NonZero<u8>>, _: <Niche as ArchiveWith<Option<NonZero<u8>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<NonZero<u8>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl ArchiveWith<Option<NonZero<usize>>> for Niche

§

type Archived = ArchivedOptionNonZeroU32

The archived type of Self with F.
§

type Resolver = ()

The resolver of a Self with F.
§

fn resolve_with( field: &Option<NonZero<usize>>, _: <Niche as ArchiveWith<Option<NonZero<usize>>>>::Resolver, out: Place<<Niche as ArchiveWith<Option<NonZero<usize>>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl<A, O> ArchiveWith<Option<O>> for Map<A>
where A: ArchiveWith<O>,

§

type Archived = ArchivedOption<<A as ArchiveWith<O>>::Archived>

The archived type of Self with F.
§

type Resolver = Option<<A as ArchiveWith<O>>::Resolver>

The resolver of a Self with F.
§

fn resolve_with( field: &Option<O>, resolver: <Map<A> as ArchiveWith<Option<O>>>::Resolver, out: Place<<Map<A> as ArchiveWith<Option<O>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl<T> ArchiveWith<Option<T>> for DefaultNiche

§

type Archived = NichedOption<<T as Archive>::Archived, DefaultNiche>

The archived type of Self with F.
§

type Resolver = Option<<T as Archive>::Resolver>

The resolver of a Self with F.
§

fn resolve_with( field: &Option<T>, resolver: <DefaultNiche as ArchiveWith<Option<T>>>::Resolver, out: Place<<DefaultNiche as ArchiveWith<Option<T>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl<T, W, N> ArchiveWith<Option<T>> for MapNiche<W, N>
where W: ArchiveWith<T> + ?Sized, N: Niching<<W as ArchiveWith<T>>::Archived> + ?Sized,

§

type Archived = NichedOption<<W as ArchiveWith<T>>::Archived, N>

The archived type of Self with F.
§

type Resolver = Option<<W as ArchiveWith<T>>::Resolver>

The resolver of a Self with F.
§

fn resolve_with( field: &Option<T>, resolver: <MapNiche<W, N> as ArchiveWith<Option<T>>>::Resolver, out: Place<<MapNiche<W, N> as ArchiveWith<Option<T>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl<T, N> ArchiveWith<Option<T>> for NicheInto<N>
where T: Archive, N: Niching<<T as Archive>::Archived> + ?Sized,

§

type Archived = NichedOption<<T as Archive>::Archived, N>

The archived type of Self with F.
§

type Resolver = Option<<T as Archive>::Resolver>

The resolver of a Self with F.
§

fn resolve_with( field: &Option<T>, resolver: <NicheInto<N> as ArchiveWith<Option<T>>>::Resolver, out: Place<<NicheInto<N> as ArchiveWith<Option<T>>>::Archived>, )

Resolves the archived type using a reference to the field type F.
§

impl<T> AsPyPointer for Option<T>
where T: AsPyPointer,

Convert None into a null pointer.

§

fn as_ptr(&self) -> *mut PyObject

Returns the underlying FFI pointer as a borrowed pointer.
1.0.0 · Source§

impl<T> Clone for Option<T>
where T: Clone,

Source§

fn clone(&self) -> Option<T>

Returns a copy of the value. Read more
Source§

fn clone_from(&mut self, source: &Option<T>)

Performs copy-assignment from source. Read more
Source§

impl<T: ConstDefault> ConstDefault for Option<T>

Source§

const DEFAULT: Self

Returns the compile-time “default value” for a type.
1.0.0 · Source§

impl<T> Debug for Option<T>
where T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
1.0.0 · Source§

impl<T> Default for Option<T>

Source§

fn default() -> Option<T>

Returns None.

§Examples
let opt: Option<u32> = Option::default();
assert!(opt.is_none());
Source§

impl<'de, T> Deserialize<'de> for Option<T>
where T: Deserialize<'de>,

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Option<T>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl<T, D> Deserialize<Option<T>, D> for ArchivedOption<<T as Archive>::Archived>
where T: Archive, <T as Archive>::Archived: Deserialize<T, D>, D: Fallible + ?Sized,

§

fn deserialize( &self, deserializer: &mut D, ) -> Result<Option<T>, <D as Fallible>::Error>

Deserializes using the given deserializer
§

impl<T, N, D> Deserialize<Option<T>, D> for NichedOption<<T as Archive>::Archived, N>
where T: Archive, <T as Archive>::Archived: Deserialize<T, D>, N: Niching<<T as Archive>::Archived> + ?Sized, D: Fallible + ?Sized,

§

fn deserialize( &self, deserializer: &mut D, ) -> Result<Option<T>, <D as Fallible>::Error>

Deserializes using the given deserializer
§

impl<A, O, D> DeserializeWith<ArchivedOption<<A as ArchiveWith<O>>::Archived>, Option<O>, D> for Map<A>
where D: Fallible + ?Sized, A: ArchiveWith<O> + DeserializeWith<<A as ArchiveWith<O>>::Archived, O, D>,

§

fn deserialize_with( field: &ArchivedOption<<A as ArchiveWith<O>>::Archived>, d: &mut D, ) -> Result<Option<O>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<T, D> DeserializeWith<ArchivedOptionBox<<T as ArchiveUnsized>::Archived>, Option<Box<T>>, D> for Niche

§

fn deserialize_with( field: &ArchivedOptionBox<<T as ArchiveUnsized>::Archived>, deserializer: &mut D, ) -> Result<Option<Box<T>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<D> DeserializeWith<ArchivedOptionNonZeroI128, Option<NonZero<i128>>, D> for Niche
where D: Fallible + ?Sized,

§

fn deserialize_with( field: &ArchivedOptionNonZeroI128, _: &mut D, ) -> Result<Option<NonZero<i128>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<D> DeserializeWith<ArchivedOptionNonZeroI16, Option<NonZero<i16>>, D> for Niche
where D: Fallible + ?Sized,

§

fn deserialize_with( field: &ArchivedOptionNonZeroI16, _: &mut D, ) -> Result<Option<NonZero<i16>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<D> DeserializeWith<ArchivedOptionNonZeroI32, Option<NonZero<i32>>, D> for Niche
where D: Fallible + ?Sized,

§

fn deserialize_with( field: &ArchivedOptionNonZeroI32, _: &mut D, ) -> Result<Option<NonZero<i32>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<D> DeserializeWith<ArchivedOptionNonZeroI32, Option<NonZero<isize>>, D> for Niche
where D: Fallible + ?Sized,

§

fn deserialize_with( field: &ArchivedOptionNonZeroI32, _: &mut D, ) -> Result<Option<NonZero<isize>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<D> DeserializeWith<ArchivedOptionNonZeroI64, Option<NonZero<i64>>, D> for Niche
where D: Fallible + ?Sized,

§

fn deserialize_with( field: &ArchivedOptionNonZeroI64, _: &mut D, ) -> Result<Option<NonZero<i64>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<D> DeserializeWith<ArchivedOptionNonZeroI8, Option<NonZero<i8>>, D> for Niche
where D: Fallible + ?Sized,

§

fn deserialize_with( field: &ArchivedOptionNonZeroI8, _: &mut D, ) -> Result<Option<NonZero<i8>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<D> DeserializeWith<ArchivedOptionNonZeroU128, Option<NonZero<u128>>, D> for Niche
where D: Fallible + ?Sized,

§

fn deserialize_with( field: &ArchivedOptionNonZeroU128, _: &mut D, ) -> Result<Option<NonZero<u128>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<D> DeserializeWith<ArchivedOptionNonZeroU16, Option<NonZero<u16>>, D> for Niche
where D: Fallible + ?Sized,

§

fn deserialize_with( field: &ArchivedOptionNonZeroU16, _: &mut D, ) -> Result<Option<NonZero<u16>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<D> DeserializeWith<ArchivedOptionNonZeroU32, Option<NonZero<u32>>, D> for Niche
where D: Fallible + ?Sized,

§

fn deserialize_with( field: &ArchivedOptionNonZeroU32, _: &mut D, ) -> Result<Option<NonZero<u32>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<D> DeserializeWith<ArchivedOptionNonZeroU32, Option<NonZero<usize>>, D> for Niche
where D: Fallible + ?Sized,

§

fn deserialize_with( field: &ArchivedOptionNonZeroU32, _: &mut D, ) -> Result<Option<NonZero<usize>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<D> DeserializeWith<ArchivedOptionNonZeroU64, Option<NonZero<u64>>, D> for Niche
where D: Fallible + ?Sized,

§

fn deserialize_with( field: &ArchivedOptionNonZeroU64, _: &mut D, ) -> Result<Option<NonZero<u64>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<D> DeserializeWith<ArchivedOptionNonZeroU8, Option<NonZero<u8>>, D> for Niche
where D: Fallible + ?Sized,

§

fn deserialize_with( field: &ArchivedOptionNonZeroU8, _: &mut D, ) -> Result<Option<NonZero<u8>>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<T, D> DeserializeWith<NichedOption<<T as Archive>::Archived, DefaultNiche>, Option<T>, D> for DefaultNiche

§

fn deserialize_with( field: &NichedOption<<T as Archive>::Archived, DefaultNiche>, deserializer: &mut D, ) -> Result<Option<T>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<T, N, D> DeserializeWith<NichedOption<<T as Archive>::Archived, N>, Option<T>, D> for NicheInto<N>
where T: Archive, <T as Archive>::Archived: Deserialize<T, D>, N: Niching<<T as Archive>::Archived> + ?Sized, D: Fallible + ?Sized,

§

fn deserialize_with( field: &NichedOption<<T as Archive>::Archived, N>, deserializer: &mut D, ) -> Result<Option<T>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
§

impl<T, W, N, D> DeserializeWith<NichedOption<<W as ArchiveWith<T>>::Archived, N>, Option<T>, D> for MapNiche<W, N>
where W: ArchiveWith<T> + DeserializeWith<<W as ArchiveWith<T>>::Archived, T, D>, N: Niching<<W as ArchiveWith<T>>::Archived> + ?Sized, D: Fallible + ?Sized,

§

fn deserialize_with( field: &NichedOption<<W as ArchiveWith<T>>::Archived, N>, deserializer: &mut D, ) -> Result<Option<T>, <D as Fallible>::Error>

Deserializes the field type F using the given deserializer.
Source§

impl<T> ExtOption<T> for Option<T>

Source§

fn contains<U: PartialEq<T>>(&self, x: &U) -> bool

Returns true if the option is a Some value containing the given value. Read more
Source§

fn reduce<F: FnOnce(T, T) -> T>(self, other: Option<T>, f: F) -> Option<T>

Merges self with another Option. Read more
Source§

fn fmt_or_empty(&self) -> OptionFmt<'_, T>

Format some value, or display an empty string if it’s None. Read more
Source§

fn fmt_or<U: Display>(&self, u: U) -> OptionFmtOr<'_, T, U>

Format some value, or an alternative if it’s None. Read more
Source§

fn fmt_or_else<U: Display, F: Fn() -> U>( &self, f: F, ) -> OptionFmtOrElse<'_, T, F>

Format some value, or run an alternative closure if it’s None. Read more
§

impl<'a> From<&'a Current> for Option<&'a Id>

§

fn from(cur: &'a Current) -> Option<&'a Id>

Converts to this type from the input type.
§

impl<'a> From<&'a Current> for Option<&'static Metadata<'static>>

§

fn from(cur: &'a Current) -> Option<&'static Metadata<'static>>

Converts to this type from the input type.
§

impl<'a> From<&'a Current> for Option<Id>

§

fn from(cur: &'a Current) -> Option<Id>

Converts to this type from the input type.
§

impl<'a> From<&'a EnteredSpan> for Option<&'a Id>

§

fn from(span: &'a EnteredSpan) -> Option<&'a Id>

Converts to this type from the input type.
§

impl<'a> From<&'a EnteredSpan> for Option<Id>

§

fn from(span: &'a EnteredSpan) -> Option<Id>

Converts to this type from the input type.
§

impl<'a> From<&'a Id> for Option<Id>

§

fn from(id: &'a Id) -> Option<Id>

Converts to this type from the input type.
1.30.0 · Source§

impl<'a, T> From<&'a Option<T>> for Option<&'a T>

Source§

fn from(o: &'a Option<T>) -> Option<&'a T>

Converts from &Option<T> to Option<&T>.

§Examples

Converts an Option<String> into an Option<usize>, preserving the original. The map method takes the self argument by value, consuming the original, so this technique uses from to first take an Option to a reference to the value inside the original.

let s: Option<String> = Some(String::from("Hello, Rustaceans!"));
let o: Option<usize> = Option::from(&s).map(|ss: &String| ss.len());

println!("Can still print s: {s:?}");

assert_eq!(o, Some(18));
§

impl<'a> From<&'a Span> for Option<&'a Id>

§

fn from(span: &'a Span) -> Option<&'a Id>

Converts to this type from the input type.
§

impl<'a> From<&'a Span> for Option<Id>

§

fn from(span: &'a Span) -> Option<Id>

Converts to this type from the input type.
1.30.0 · Source§

impl<'a, T> From<&'a mut Option<T>> for Option<&'a mut T>

Source§

fn from(o: &'a mut Option<T>) -> Option<&'a mut T>

Converts from &mut Option<T> to Option<&mut T>

§Examples
let mut s = Some(String::from("Hello"));
let o: Option<&mut String> = Option::from(&mut s);

match o {
    Some(t) => *t = String::from("Hello, Rustaceans!"),
    None => (),
}

assert_eq!(s, Some(String::from("Hello, Rustaceans!")));
§

impl From<Current> for Option<Id>

§

fn from(cur: Current) -> Option<Id>

Converts to this type from the input type.
§

impl From<LevelFilter> for Option<Level>

§

fn from(filter: LevelFilter) -> Option<Level>

Converts to this type from the input type.
§

impl From<Option<Level>> for LevelFilter

§

fn from(level: Option<Level>) -> LevelFilter

Converts to this type from the input type.
Source§

impl<T> From<Option<T>> for JsValue
where JsValue: From<T>,

Source§

fn from(s: Option<T>) -> JsValue

Converts to this type from the input type.
§

impl From<Span> for Option<Id>

§

fn from(span: Span) -> Option<Id>

Converts to this type from the input type.
1.12.0 · Source§

impl<T> From<T> for Option<T>

Source§

fn from(val: T) -> Option<T>

Moves val into a new Some.

§Examples
let o: Option<u8> = Option::from(67);

assert_eq!(Some(67), o);
1.0.0 · Source§

impl<A, V> FromIterator<Option<A>> for Option<V>
where V: FromIterator<A>,

Source§

fn from_iter<I>(iter: I) -> Option<V>
where I: IntoIterator<Item = Option<A>>,

Takes each element in the Iterator: if it is None, no further elements are taken, and the None is returned. Should no None occur, a container of type V containing the values of each Option is returned.

§Examples

Here is an example which increments every integer in a vector. We use the checked variant of add that returns None when the calculation would result in an overflow.

let items = vec![0_u16, 1, 2];

let res: Option<Vec<u16>> = items
    .iter()
    .map(|x| x.checked_add(1))
    .collect();

assert_eq!(res, Some(vec![1, 2, 3]));

As you can see, this will return the expected, valid items.

Here is another example that tries to subtract one from another list of integers, this time checking for underflow:

let items = vec![2_u16, 1, 0];

let res: Option<Vec<u16>> = items
    .iter()
    .map(|x| x.checked_sub(1))
    .collect();

assert_eq!(res, None);

Since the last element is zero, it would underflow. Thus, the resulting value is None.

Here is a variation on the previous example, showing that no further elements are taken from iter after the first None.

let items = vec![3_u16, 2, 1, 10];

let mut shared = 0;

let res: Option<Vec<u16>> = items
    .iter()
    .map(|x| { shared += x; x.checked_sub(2) })
    .collect();

assert_eq!(res, None);
assert_eq!(shared, 6);

Since the third element caused an underflow, no further elements were taken, so the final value of shared is 6 (= 3 + 2 + 1), not 16.

§

impl<T, V> FromIteratorIn<Option<T>> for Option<V>
where V: FromIteratorIn<T>,

§

type Alloc = <V as FromIteratorIn<T>>::Alloc

The allocator type
§

fn from_iter_in<I>( iter: I, alloc: <Option<V> as FromIteratorIn<Option<T>>>::Alloc, ) -> Option<V>
where I: IntoIterator<Item = Option<T>>,

Similar to FromIterator::from_iter, but with a given allocator. Read more
§

impl<C, T> FromParallelIterator<Option<T>> for Option<C>
where C: FromParallelIterator<T>, T: Send,

Collect an arbitrary Option-wrapped collection.

If any item is None, then all previous items collected are discarded, and it returns only None.

§

fn from_par_iter<I>(par_iter: I) -> Option<C>
where I: IntoParallelIterator<Item = Option<T>>,

Creates an instance of the collection from the parallel iterator par_iter. Read more
§

impl<'py, T> FromPyObject<'py> for Option<T>
where T: FromPyObject<'py>,

§

fn extract_bound(obj: &Bound<'py, PyAny>) -> Result<Option<T>, PyErr>

Extracts Self from the bound smart pointer obj. Read more
Source§

impl<T> FromResidual<Option<Infallible>> for Option<T>

Source§

fn from_residual(residual: Option<Infallible>) -> Option<T>

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from a compatible Residual type. Read more
Source§

impl<T> FromResidual<Yeet<()>> for Option<T>

Source§

fn from_residual(_: Yeet<()>) -> Option<T>

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from a compatible Residual type. Read more
Source§

impl<T> FromWasmAbi for Option<*const T>

Source§

type Abi = f64

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: f64) -> Option<*const T>

Recover a Self from Self::Abi. Read more
Source§

impl<T> FromWasmAbi for Option<*mut T>

Source§

type Abi = f64

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: f64) -> Option<*mut T>

Recover a Self from Self::Abi. Read more
Source§

impl<T> FromWasmAbi for Option<T>

Source§

type Abi = <T as FromWasmAbi>::Abi

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: <T as FromWasmAbi>::Abi) -> Option<T>

Recover a Self from Self::Abi. Read more
Source§

impl FromWasmAbi for Option<f32>

Source§

type Abi = f64

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: <Option<f32> as FromWasmAbi>::Abi) -> Option<f32>

Recover a Self from Self::Abi. Read more
Source§

impl FromWasmAbi for Option<f64>

Source§

type Abi = Option<f64>

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: <Option<f64> as FromWasmAbi>::Abi) -> Option<f64>

Recover a Self from Self::Abi. Read more
Source§

impl FromWasmAbi for Option<i128>

Source§

type Abi = Option<i128>

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: <Option<i128> as FromWasmAbi>::Abi) -> Option<i128>

Recover a Self from Self::Abi. Read more
Source§

impl FromWasmAbi for Option<i32>

Source§

type Abi = f64

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: <Option<i32> as FromWasmAbi>::Abi) -> Option<i32>

Recover a Self from Self::Abi. Read more
Source§

impl FromWasmAbi for Option<i64>

Source§

type Abi = Option<i64>

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: <Option<i64> as FromWasmAbi>::Abi) -> Option<i64>

Recover a Self from Self::Abi. Read more
Source§

impl FromWasmAbi for Option<isize>

Source§

type Abi = f64

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: <Option<isize> as FromWasmAbi>::Abi) -> Option<isize>

Recover a Self from Self::Abi. Read more
Source§

impl FromWasmAbi for Option<u128>

Source§

type Abi = Option<u128>

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: <Option<u128> as FromWasmAbi>::Abi) -> Option<u128>

Recover a Self from Self::Abi. Read more
Source§

impl FromWasmAbi for Option<u32>

Source§

type Abi = f64

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: <Option<u32> as FromWasmAbi>::Abi) -> Option<u32>

Recover a Self from Self::Abi. Read more
Source§

impl FromWasmAbi for Option<u64>

Source§

type Abi = Option<u64>

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: <Option<u64> as FromWasmAbi>::Abi) -> Option<u64>

Recover a Self from Self::Abi. Read more
Source§

impl FromWasmAbi for Option<usize>

Source§

type Abi = f64

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: <Option<usize> as FromWasmAbi>::Abi) -> Option<usize>

Recover a Self from Self::Abi. Read more
1.0.0 · Source§

impl<T> Hash for Option<T>
where T: Hash,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
1.4.0 · Source§

impl<'a, T> IntoIterator for &'a Option<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Iter<'a, T>

Creates an iterator from a value. Read more
1.4.0 · Source§

impl<'a, T> IntoIterator for &'a mut Option<T>

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> IterMut<'a, T>

Creates an iterator from a value. Read more
1.0.0 · Source§

impl<T> IntoIterator for Option<T>

Source§

fn into_iter(self) -> IntoIter<T>

Returns a consuming iterator over the possibly contained value.

§Examples
let x = Some("string");
let v: Vec<&str> = x.into_iter().collect();
assert_eq!(v, ["string"]);

let x = None;
let v: Vec<&str> = x.into_iter().collect();
assert!(v.is_empty());
Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
§

impl IntoOptionalRegion for Option<Region>

§

fn into_optional_region(self) -> Option<Region>

Converts the type into an Option<Region>.
§

impl<'a, T> IntoParallelIterator for &'a Option<T>
where T: Sync,

§

type Item = &'a T

The type of item that the parallel iterator will produce.
§

type Iter = Iter<'a, T>

The parallel iterator type that will be created.
§

fn into_par_iter(self) -> <&'a Option<T> as IntoParallelIterator>::Iter

Converts self into a parallel iterator. Read more
§

impl<'a, T> IntoParallelIterator for &'a mut Option<T>
where T: Send,

§

type Item = &'a mut T

The type of item that the parallel iterator will produce.
§

type Iter = IterMut<'a, T>

The parallel iterator type that will be created.
§

fn into_par_iter(self) -> <&'a mut Option<T> as IntoParallelIterator>::Iter

Converts self into a parallel iterator. Read more
§

impl<T> IntoParallelIterator for Option<T>
where T: Send,

§

type Item = T

The type of item that the parallel iterator will produce.
§

type Iter = IntoIter<T>

The parallel iterator type that will be created.
§

fn into_par_iter(self) -> <Option<T> as IntoParallelIterator>::Iter

Converts self into a parallel iterator. Read more
§

impl<T> IntoPy<Py<PyAny>> for Option<T>
where T: IntoPy<Py<PyAny>>,

§

fn into_py(self, py: Python<'_>) -> Py<PyAny>

👎Deprecated since 0.23.0: IntoPy is going to be replaced by IntoPyObject. See the migration guide (https://pyo3.rs/v0.23.0/migration) for more information.
Performs the conversion.
§

impl<'a, 'py, T> IntoPyObject<'py> for &'a Option<T>
where &'a T: IntoPyObject<'py>,

§

type Target = PyAny

The Python output type
§

type Output = Bound<'py, <&'a Option<T> as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
§

type Error = <&'a T as IntoPyObject<'py>>::Error

The type returned in the event of a conversion error.
§

fn into_pyobject( self, py: Python<'py>, ) -> Result<<&'a Option<T> as IntoPyObject<'py>>::Output, <&'a Option<T> as IntoPyObject<'py>>::Error>

Performs the conversion.
§

impl<'py, T> IntoPyObject<'py> for Option<T>
where T: IntoPyObject<'py>,

§

type Target = PyAny

The Python output type
§

type Output = Bound<'py, <Option<T> as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
§

type Error = <T as IntoPyObject<'py>>::Error

The type returned in the event of a conversion error.
§

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Option<T> as IntoPyObject<'py>>::Output, <Option<T> as IntoPyObject<'py>>::Error>

Performs the conversion.
Source§

impl<T> IntoWasmAbi for Option<*const T>

Source§

type Abi = f64

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> f64

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl<T> IntoWasmAbi for Option<*mut T>

Source§

type Abi = f64

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> f64

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl<T> IntoWasmAbi for Option<T>

Source§

type Abi = <T as IntoWasmAbi>::Abi

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> <T as IntoWasmAbi>::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl IntoWasmAbi for Option<f32>

Source§

type Abi = f64

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> <Option<f32> as IntoWasmAbi>::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl IntoWasmAbi for Option<f64>

Source§

type Abi = Option<f64>

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> <Option<f64> as IntoWasmAbi>::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl IntoWasmAbi for Option<i128>

Source§

type Abi = Option<i128>

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> <Option<i128> as IntoWasmAbi>::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl IntoWasmAbi for Option<i32>

Source§

type Abi = f64

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> <Option<i32> as IntoWasmAbi>::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl IntoWasmAbi for Option<i64>

Source§

type Abi = Option<i64>

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> <Option<i64> as IntoWasmAbi>::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl IntoWasmAbi for Option<isize>

Source§

type Abi = f64

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> <Option<isize> as IntoWasmAbi>::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl IntoWasmAbi for Option<u128>

Source§

type Abi = Option<u128>

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> <Option<u128> as IntoWasmAbi>::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl IntoWasmAbi for Option<u32>

Source§

type Abi = f64

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> <Option<u32> as IntoWasmAbi>::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl IntoWasmAbi for Option<u64>

Source§

type Abi = Option<u64>

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> <Option<u64> as IntoWasmAbi>::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl IntoWasmAbi for Option<usize>

Source§

type Abi = f64

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> <Option<usize> as IntoWasmAbi>::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl MemPod for Option<NonZeroI128>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
Source§

impl MemPod for Option<NonZeroI16>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
Source§

impl MemPod for Option<NonZeroI32>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
Source§

impl MemPod for Option<NonZeroI64>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
Source§

impl MemPod for Option<NonZeroI8>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
Source§

impl MemPod for Option<NonZeroIsize>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
Source§

impl MemPod for Option<NonZeroU128>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
Source§

impl MemPod for Option<NonZeroU16>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
Source§

impl MemPod for Option<NonZeroU32>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
Source§

impl MemPod for Option<NonZeroU64>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
Source§

impl MemPod for Option<NonZeroU8>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
Source§

impl MemPod for Option<NonZeroUsize>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
Source§

impl<T: MemPod> MemPod for Option<T>

Available on crate feature unsafe_layout only.
Source§

fn zeroed() -> Self

Returns a new instance contrcuted from zeroes.
Source§

fn from_bytes(bytes: &[u8]) -> Self

Returns a new instance constructed from the given bytes. Read more
Source§

fn as_bytes(&self) -> &[u8]

Returns the instance’s data as a slice of bytes.
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the instance’s data as a mutable slice of bytes.
§

impl<T> OptionExt<T> for Option<T>

§

fn into_error<E>(self) -> Result<T, E>
where E: Source,

Returns a Result with an error indicating that Some was expected but None was found. Read more
§

fn into_trace<E, R>(self, trace: R) -> Result<T, E>
where E: Source, R: Debug + Display + Send + Sync + 'static,

Returns a Result with an error indicating that Some was expected but None was found, and with an additional trace message added. Read more
§

fn into_with_trace<E, R, F>(self, f: F) -> Result<T, E>
where E: Source, R: Debug + Display + Send + Sync + 'static, F: FnOnce() -> R,

Returns a Result with an error indicating that Some was expected but None was found, and with an additional trace message added by evaluating the given function f. The function is evaluated only if an error occurred. Read more
1.0.0 · Source§

impl<T> Ord for Option<T>
where T: Ord,

Source§

fn cmp(&self, other: &Option<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

impl<T, U> PartialEq<Option<Box<T>>> for ArchivedOptionBox<U>
where U: ArchivePointee + PartialEq<T> + ?Sized, T: ?Sized,

§

fn eq(&self, other: &Option<Box<T>>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T, N, Rhs> PartialEq<Option<Rhs>> for NichedOption<T, N>
where T: PartialEq<Rhs>, N: Niching<T> + ?Sized,

§

fn eq(&self, other: &Option<Rhs>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T, U> PartialEq<Option<T>> for ArchivedOption<U>
where U: PartialEq<T>,

§

fn eq(&self, other: &Option<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.0.0 · Source§

impl<T> PartialEq for Option<T>
where T: PartialEq,

Source§

fn eq(&self, other: &Option<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T, U> PartialOrd<Option<T>> for ArchivedOption<U>
where U: PartialOrd<T>,

§

fn partial_cmp(&self, other: &Option<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.0.0 · Source§

impl<T> PartialOrd for Option<T>
where T: PartialOrd,

Source§

fn partial_cmp(&self, other: &Option<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.37.0 · Source§

impl<T, U> Product<Option<U>> for Option<T>
where T: Product<U>,

Source§

fn product<I>(iter: I) -> Option<T>
where I: Iterator<Item = Option<U>>,

Takes each element in the Iterator: if it is a None, no further elements are taken, and the None is returned. Should no None occur, the product of all elements is returned.

§Examples

This multiplies each number in a vector of strings, if a string could not be parsed the operation returns None:

let nums = vec!["5", "10", "1", "2"];
let total: Option<usize> = nums.iter().map(|w| w.parse::<usize>().ok()).product();
assert_eq!(total, Some(100));
let nums = vec!["5", "10", "one", "2"];
let total: Option<usize> = nums.iter().map(|w| w.parse::<usize>().ok()).product();
assert_eq!(total, None);
Source§

impl<T> Residual<T> for Option<Infallible>

Source§

type TryType = Option<T>

🔬This is a nightly-only experimental API. (try_trait_v2_residual)
The “return” type of this meta-function.
§

impl<T, S> Serialize<S> for Option<T>
where T: Serialize<S>, S: Fallible + ?Sized,

§

fn serialize( &self, serializer: &mut S, ) -> Result<<Option<T> as Archive>::Resolver, <S as Fallible>::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.
Source§

impl<T> Serialize for Option<T>
where T: Serialize,

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl<T, S> SerializeWith<Option<Box<T>>, S> for Niche

§

fn serialize_with( field: &Option<Box<T>>, serializer: &mut S, ) -> Result<<Niche as ArchiveWith<Option<Box<T>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<S> SerializeWith<Option<NonZero<i128>>, S> for Niche
where S: Fallible + ?Sized,

§

fn serialize_with( _: &Option<NonZero<i128>>, _: &mut S, ) -> Result<<Niche as ArchiveWith<Option<NonZero<i128>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<S> SerializeWith<Option<NonZero<i16>>, S> for Niche
where S: Fallible + ?Sized,

§

fn serialize_with( _: &Option<NonZero<i16>>, _: &mut S, ) -> Result<<Niche as ArchiveWith<Option<NonZero<i16>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<S> SerializeWith<Option<NonZero<i32>>, S> for Niche
where S: Fallible + ?Sized,

§

fn serialize_with( _: &Option<NonZero<i32>>, _: &mut S, ) -> Result<<Niche as ArchiveWith<Option<NonZero<i32>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<S> SerializeWith<Option<NonZero<i64>>, S> for Niche
where S: Fallible + ?Sized,

§

fn serialize_with( _: &Option<NonZero<i64>>, _: &mut S, ) -> Result<<Niche as ArchiveWith<Option<NonZero<i64>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<S> SerializeWith<Option<NonZero<i8>>, S> for Niche
where S: Fallible + ?Sized,

§

fn serialize_with( _: &Option<NonZero<i8>>, _: &mut S, ) -> Result<<Niche as ArchiveWith<Option<NonZero<i8>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<S> SerializeWith<Option<NonZero<isize>>, S> for Niche
where S: Fallible + ?Sized,

§

fn serialize_with( _: &Option<NonZero<isize>>, _: &mut S, ) -> Result<<Niche as ArchiveWith<Option<NonZero<isize>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<S> SerializeWith<Option<NonZero<u128>>, S> for Niche
where S: Fallible + ?Sized,

§

fn serialize_with( _: &Option<NonZero<u128>>, _: &mut S, ) -> Result<<Niche as ArchiveWith<Option<NonZero<u128>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<S> SerializeWith<Option<NonZero<u16>>, S> for Niche
where S: Fallible + ?Sized,

§

fn serialize_with( _: &Option<NonZero<u16>>, _: &mut S, ) -> Result<<Niche as ArchiveWith<Option<NonZero<u16>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<S> SerializeWith<Option<NonZero<u32>>, S> for Niche
where S: Fallible + ?Sized,

§

fn serialize_with( _: &Option<NonZero<u32>>, _: &mut S, ) -> Result<<Niche as ArchiveWith<Option<NonZero<u32>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<S> SerializeWith<Option<NonZero<u64>>, S> for Niche
where S: Fallible + ?Sized,

§

fn serialize_with( _: &Option<NonZero<u64>>, _: &mut S, ) -> Result<<Niche as ArchiveWith<Option<NonZero<u64>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<S> SerializeWith<Option<NonZero<u8>>, S> for Niche
where S: Fallible + ?Sized,

§

fn serialize_with( _: &Option<NonZero<u8>>, _: &mut S, ) -> Result<<Niche as ArchiveWith<Option<NonZero<u8>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<S> SerializeWith<Option<NonZero<usize>>, S> for Niche
where S: Fallible + ?Sized,

§

fn serialize_with( _: &Option<NonZero<usize>>, _: &mut S, ) -> Result<<Niche as ArchiveWith<Option<NonZero<usize>>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<A, O, S> SerializeWith<Option<O>, S> for Map<A>
where S: Fallible + ?Sized, A: ArchiveWith<O> + SerializeWith<O, S>,

§

fn serialize_with( field: &Option<O>, s: &mut S, ) -> Result<<Map<A> as ArchiveWith<Option<O>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<T, S> SerializeWith<Option<T>, S> for DefaultNiche

§

fn serialize_with( field: &Option<T>, serializer: &mut S, ) -> Result<<DefaultNiche as ArchiveWith<Option<T>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<T, W, N, S> SerializeWith<Option<T>, S> for MapNiche<W, N>
where W: SerializeWith<T, S> + ?Sized, N: Niching<<W as ArchiveWith<T>>::Archived> + ?Sized, S: Fallible + ?Sized,

§

fn serialize_with( field: &Option<T>, serializer: &mut S, ) -> Result<<MapNiche<W, N> as ArchiveWith<Option<T>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
§

impl<T, N, S> SerializeWith<Option<T>, S> for NicheInto<N>
where T: Serialize<S>, N: Niching<<T as Archive>::Archived> + ?Sized, S: Fallible + ?Sized,

§

fn serialize_with( field: &Option<T>, serializer: &mut S, ) -> Result<<NicheInto<N> as ArchiveWith<Option<T>>>::Resolver, <S as Fallible>::Error>

Serializes the field type F using the given serializer.
1.37.0 · Source§

impl<T, U> Sum<Option<U>> for Option<T>
where T: Sum<U>,

Source§

fn sum<I>(iter: I) -> Option<T>
where I: Iterator<Item = Option<U>>,

Takes each element in the Iterator: if it is a None, no further elements are taken, and the None is returned. Should no None occur, the sum of all elements is returned.

§Examples

This sums up the position of the character ‘a’ in a vector of strings, if a word did not have the character ‘a’ the operation returns None:

let words = vec!["have", "a", "great", "day"];
let total: Option<usize> = words.iter().map(|w| w.find('a')).sum();
assert_eq!(total, Some(5));
let words = vec!["have", "a", "good", "day"];
let total: Option<usize> = words.iter().map(|w| w.find('a')).sum();
assert_eq!(total, None);
§

impl<T> ToPyObject for Option<T>
where T: ToPyObject,

Option::Some<T> is converted like T. Option::None is converted to Python None.

§

fn to_object(&self, py: Python<'_>) -> Py<PyAny>

👎Deprecated since 0.23.0: ToPyObject is going to be replaced by IntoPyObject. See the migration guide (https://pyo3.rs/v0.23.0/migration) for more information.
Converts self into a Python object.
Source§

impl<T> Try for Option<T>

Source§

type Output = T

🔬This is a nightly-only experimental API. (try_trait_v2)
The type of the value produced by ? when not short-circuiting.
Source§

type Residual = Option<Infallible>

🔬This is a nightly-only experimental API. (try_trait_v2)
The type of the value passed to FromResidual::from_residual as part of ? when short-circuiting. Read more
Source§

fn from_output(output: <Option<T> as Try>::Output) -> Option<T>

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from its Output type. Read more
Source§

fn branch( self, ) -> ControlFlow<<Option<T> as Try>::Residual, <Option<T> as Try>::Output>

🔬This is a nightly-only experimental API. (try_trait_v2)
Used in ? to decide whether the operator should produce a value (because this returned ControlFlow::Continue) or propagate a value back to the caller (because this returned ControlFlow::Break). Read more
Source§

impl<T> UnwrapThrowExt<T> for Option<T>

Source§

fn unwrap_throw(self) -> T

Unwrap this Option or Result, but instead of panicking on failure, throw an exception to JavaScript.
Source§

fn expect_throw(self, message: &str) -> T

Unwrap this container’s T value, or throw an error to JS with the given message if the T value is unavailable (e.g. an Option<T> is None).
§

impl<T> Value for Option<T>
where T: Value,

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
Source§

impl<T> WasmAbi for Option<T>
where T: WasmAbi<Prim4 = ()>,

Source§

type Prim1 = u32

Whether this Option is a Some value.

Source§

type Prim2 = <T as WasmAbi>::Prim1

Source§

type Prim3 = <T as WasmAbi>::Prim2

Source§

type Prim4 = <T as WasmAbi>::Prim3

Source§

fn split( self, ) -> (u32, <T as WasmAbi>::Prim1, <T as WasmAbi>::Prim2, <T as WasmAbi>::Prim3)

Splits this type up into primitives to be sent over the ABI.
Source§

fn join( is_some: u32, prim1: <T as WasmAbi>::Prim1, prim2: <T as WasmAbi>::Prim2, prim3: <T as WasmAbi>::Prim3, ) -> Option<T>

Reconstructs this type from primitives received over the ABI.
§

impl<T> Zeroable for Option<T>

§

fn zeroed() -> Self

1.0.0 · Source§

impl<T> Copy for Option<T>
where T: Copy,

1.0.0 · Source§

impl<T> Eq for Option<T>
where T: Eq,

§

impl<T> Pod for Option<T>
where T: PodInOption,

1.0.0 · Source§

impl<T> StructuralPartialEq for Option<T>

Auto Trait Implementations§

§

impl<T> Freeze for Option<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Option<T>
where T: RefUnwindSafe,

§

impl<T> Send for Option<T>
where T: Send,

§

impl<T> Sync for Option<T>
where T: Sync,

§

impl<T> Unpin for Option<T>
where T: Unpin,

§

impl<T> UnwindSafe for Option<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
§

impl<T> ArchiveUnsized for T
where T: Archive,

§

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized. Read more
§

fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata

Creates the archived version of the metadata for this value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByteSized for T

Source§

const BYTE_ALIGN: usize = _

The alignment of this type in bytes.
Source§

const BYTE_SIZE: usize = _

The size of this type in bytes.
Source§

fn byte_align(&self) -> usize

Returns the alignment of this type in bytes.
Source§

fn byte_size(&self) -> usize

Returns the size of this type in bytes. Read more
Source§

fn ptr_size_ratio(&self) -> [usize; 2]

Returns the size ratio between Ptr::BYTES and BYTE_SIZE. Read more
Source§

impl<T, R> Chain<R> for T
where T: ?Sized,

Source§

fn chain<F>(self, f: F) -> R
where F: FnOnce(Self) -> R, Self: Sized,

Chain a function which takes the parameter by value.
Source§

fn chain_ref<F>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Chain a function which takes the parameter by shared reference.
Source§

fn chain_mut<F>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Chain a function which takes the parameter by exclusive reference.
§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> ExtAny for T
where T: Any + ?Sized,

Source§

fn type_id() -> TypeId

Returns the TypeId of Self. Read more
Source§

fn type_of(&self) -> TypeId

Returns the TypeId of self. Read more
Source§

fn type_name(&self) -> &'static str

Returns the type name of self. Read more
Source§

fn type_is<T: 'static>(&self) -> bool

Returns true if Self is of type T. Read more
Source§

fn as_any_ref(&self) -> &dyn Any
where Self: Sized,

Upcasts &self as &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any
where Self: Sized,

Upcasts &mut self as &mut dyn Any. Read more
Source§

fn as_any_box(self: Box<Self>) -> Box<dyn Any>
where Self: Sized,

Upcasts Box<self> as Box<dyn Any>. Read more
Source§

fn downcast_ref<T: 'static>(&self) -> Option<&T>

Available on crate feature unsafe_layout only.
Returns some shared reference to the inner value if it is of type T. Read more
Source§

fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>

Available on crate feature unsafe_layout only.
Returns some exclusive reference to the inner value if it is of type T. Read more
Source§

impl<T> ExtMem for T
where T: ?Sized,

Source§

const NEEDS_DROP: bool = _

Know whether dropping values of this type matters, in compile-time.
Source§

fn mem_align_of<T>() -> usize

Returns the minimum alignment of the type in bytes. Read more
Source§

fn mem_align_of_val(&self) -> usize

Returns the alignment of the pointed-to value in bytes. Read more
Source§

fn mem_size_of<T>() -> usize

Returns the size of a type in bytes. Read more
Source§

fn mem_size_of_val(&self) -> usize

Returns the size of the pointed-to value in bytes. Read more
Source§

fn mem_copy(&self) -> Self
where Self: Copy,

Bitwise-copies a value. Read more
Source§

fn mem_needs_drop(&self) -> bool

Returns true if dropping values of this type matters. Read more
Source§

fn mem_drop(self)
where Self: Sized,

Drops self by running its destructor. Read more
Source§

fn mem_forget(self)
where Self: Sized,

Forgets about self without running its destructor. Read more
Source§

fn mem_replace(&mut self, other: Self) -> Self
where Self: Sized,

Replaces self with other, returning the previous value of self. Read more
Source§

fn mem_take(&mut self) -> Self
where Self: Default,

Replaces self with its default value, returning the previous value of self. Read more
Source§

fn mem_swap(&mut self, other: &mut Self)
where Self: Sized,

Swaps the value of self and other without deinitializing either one. Read more
Source§

unsafe fn mem_zeroed<T>() -> T

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Source§

unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Source§

fn mem_as_bytes(&self) -> &[u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &[u8]. Read more
Source§

fn mem_as_bytes_mut(&mut self) -> &mut [u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &mut [u8]. Read more
Source§

impl<T> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<'py, T> FromPyObjectBound<'_, 'py> for T
where T: FromPyObject<'py>,

§

fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

Source§

impl<T> Hook for T

Source§

fn hook_ref<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Applies a function which takes the parameter by shared reference, and then returns the (possibly) modified owned value. Read more
Source§

fn hook_mut<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Applies a function which takes the parameter by exclusive reference, and then returns the (possibly) modified owned value. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<'data, I> IntoParallelRefIterator<'data> for I
where I: 'data + ?Sized, &'data I: IntoParallelIterator,

§

type Iter = <&'data I as IntoParallelIterator>::Iter

The type of the parallel iterator that will be returned.
§

type Item = <&'data I as IntoParallelIterator>::Item

The type of item that the parallel iterator will produce. This will typically be an &'data T reference type.
§

fn par_iter(&'data self) -> <I as IntoParallelRefIterator<'data>>::Iter

Converts self into a parallel iterator. Read more
§

impl<'data, I> IntoParallelRefMutIterator<'data> for I

§

type Iter = <&'data mut I as IntoParallelIterator>::Iter

The type of iterator that will be created.
§

type Item = <&'data mut I as IntoParallelIterator>::Item

The type of item that will be produced; this is typically an &'data mut T reference.
§

fn par_iter_mut( &'data mut self, ) -> <I as IntoParallelRefMutIterator<'data>>::Iter

Creates the parallel iterator from self. Read more
§

impl<'py, T, I> IntoPyDict<'py> for I
where T: PyDictItem<'py>, I: IntoIterator<Item = T>,

§

fn into_py_dict(self, py: Python<'py>) -> Result<Bound<'py, PyDict>, PyErr>

Converts self into a PyDict object pointer. Whether pointer owned or borrowed depends on implementation.
§

fn into_py_dict_bound(self, py: Python<'py>) -> Bound<'py, PyDict>

👎Deprecated since 0.23.0: renamed to IntoPyDict::into_py_dict
Deprecated name for IntoPyDict::into_py_dict.
§

impl<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. Read more
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
§

impl<T> PyErrArguments for T
where T: for<'py> IntoPyObject<'py> + Send + Sync,

§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
Source§

impl<T> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
§

impl<T, S> SerializeUnsized<S> for T
where T: Serialize<S>, S: Fallible + Writer + ?Sized,

§

fn serialize_unsized( &self, serializer: &mut S, ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> NoUninit for T
where T: Pod,

§

impl<T> Ungil for T
where T: Send,