doc.rust-lang.org
pub struct RSplitMut<'a, T, P>
RSplitMut — An iterator over the subslices of the vector which are separated by elements that match pred, starting from the end of the slice.
This struct is created by the rsplit_mut method on slices.
Example
let mut slice = [11, 22, 33, 0, 44, 55];
let iter = slice.rsplit_mut...
struct
core
Stable since 1.27.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn eq_ignore_ascii_case<S>(&self, other: S) -> bool
OsStr::eq_ignore_ascii_case — Checks that two strings are an ASCII case-insensitive match.
Same as to_ascii_lowercase(a) == to_ascii_lowercase(b), but without allocating and copying temporaries.
Examples
use std::ffi::OsString;
assert!(OsString::from("Ferris").eq_ignore_ascii_case("FERRIS"));
assert!(OsString::from("Ferrös").eq...
method
std
Stable since 1.53.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct RSplitNMut<'a, T, P>
RSplitNMut — An iterator over subslices separated by elements that match a predicate function, limited to a given number of splits, starting from the end of the slice.
This struct is created by the rsplitn_mut method on slices.
Example
let mut slice = [10, 40, 30, 20, 60, 50];
let iter...
struct
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct RSplit<'a, T, P>
RSplit — An iterator over subslices separated by elements that match a predicate function, starting from the end of the slice.
This struct is created by the rsplit method on slices.
Example
let slice = [11, 22, 33, 0, 44, 55];
let mut iter = slice.rsplit(|num| *num == 0);
assert_eq!(iter...
struct
core
Stable since 1.27.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct SplitN<'a, T, P>
SplitN — An iterator over subslices separated by elements that match a predicate function, limited to a given number of splits.
This struct is created by the splitn method on slices.
Example
let slice = [10, 40, 30, 20, 60, 50];
let mut iter = slice.splitn(2, |num| *num % 3 == 0);
assert...
struct
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub mod option
...f64) -> Option<f64> {
if denominator == 0.0 {
None
} else {
Some(numerator / denominator)
}
}
// The return value of the function is an option
let result = divide(2.0, 3.0);
// Pattern match to retrieve the value
match result {
// The division was valid
Some(x) => println!("Result: {x}"),
// The division was invalid
None...
module
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn strip_prefix<P>(&self, prefix: P) -> Option<&str>
...Unlike trim_start_matches, this method removes the prefix exactly once.
If the string does not start with prefix, returns None.
The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches.
Examples
assert_eq!("foo:bar".strip_prefix...
method
core
Stable since 1.45.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn strip_suffix<P>(&self, suffix: P) -> Option<&str>
...Unlike trim_end_matches, this method removes the suffix exactly once.
If the string does not end with suffix, returns None.
The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches.
Examples
assert_eq!("bar:foo".strip_suffix...
method
core
Stable since 1.45.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct RSplitN<'a, T, P>
RSplitN — An iterator over subslices separated by elements that match a predicate function, limited to a given number of splits, starting from the end of the slice.
This struct is created by the rsplitn method on slices.
Example
let slice = [10, 40, 30, 20, 60, 50];
let mut iter = slice...
struct
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn is_none_or(self, f: impl ~const FnOnce(T) -> bool) -> bool
Option::is_none_or — 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...
method
core
Stable since 1.82.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn is_some_and(self, f: impl ~const FnOnce(T) -> bool) -> bool
Option::is_some_and — 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...
method
core
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn is_ok_and<F>(self, f: F) -> bool
Result::is_ok_and — Returns true if the result is Ok and the value inside of it matches a predicate.
Examples
let x: Result<u32, &str> = Ok(2);
assert_eq!(x.is_ok_and(|x| x > 1), true);
let x: Result<u32, &str> = Ok(0);
assert_eq!(x.is_ok...
method
core
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct PrefixComponent<'a>
...Instances of this struct can be obtained by matching against the Prefix variant on Component.
Does not occur on Unix.
Examples
use std::path::{Component, Path, Prefix};
use std::ffi::OsStr;
let path = Path::new(r"c:\you\later\");
match path.components().next().unwrap() {
Component::Prefix(prefix_component) => {
assert_eq...
struct
std
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn next_if_map<R>(&mut self, f: impl FnOnce(<I as >::Item) -> Result<R, <I as >::Item>) -> Option<R>
...let mut iter = "125 GOTO 10".chars().peekable();
let mut line_num = 0_u32;
while let Some(digit) = iter.next_if_map(|c| c.to_digit(10).ok_or(c)) {
line_num = line_num * 10 + digit;
}
assert_eq!(line_num, 125);
assert_eq!(iter.collect::<String>(), " GOTO 10");
Matching custom...
method
core
Stable since 1.94.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn div_euclid(self, rhs: f32) -> f32
f32::div_euclid — Calculates Euclidean division, the matching method for rem_euclid.
This computes the integer n such that self = n * rhs + self.rem_euclid(rhs). In other words, the result is self / rhs rounded to the integer n such that self >= n * rhs.
Precision
The result of this operation...
method
std
Stable since 1.38.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn div_euclid(self, rhs: f64) -> f64
f64::div_euclid — Calculates Euclidean division, the matching method for rem_euclid.
This computes the integer n such that self = n * rhs + self.rem_euclid(rhs). In other words, the result is self / rhs rounded to the integer n such that self >= n * rhs.
Precision
The result of this operation...
method
std
Stable since 1.38.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn is_err_and<F>(self, f: F) -> bool
Result::is_err_and — Returns true if the result is Err and the value inside of it matches a predicate.
Examples
use std::io::{Error, ErrorKind};
let x: Result<u32, Error> = Err(Error::new(ErrorKind::NotFound, "!"));
assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), true);
let x...
method
core
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub macro pin!
...let mut pinned_fut = pin!(fut);
loop {
match pinned_fut.as_mut().poll(&mut cx) {
Poll::Pending => thread::park(),
Poll::Ready(res) => return res,
}
}
}
With Coroutines
#![feature(coroutines)]
#![feature(coroutine_trait)]
use core::{
ops::{Coroutine, CoroutineState},
pin::pin,
};
fn coroutine_fn() -> impl Coroutine<Yield = usize, Return = ()> /* not Unpin */ {
// Allow coroutine...
macro
core
Stable since 1.68.0
Version 1.100.0-nightly
doc.rust-lang.org
fn all<F>(&mut self, f: F) -> bool
Iterator::all — Tests if every element of the iterator matches a predicate.
all() takes a closure that returns true or false. It applies this closure to each element of the iterator, and if they all return true, then so does all(). If any of them return false, it returns false...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
fn any<F>(&mut self, f: F) -> bool
Iterator::any — Tests if any element of the iterator matches a predicate.
any() takes a closure that returns true or false. It applies this closure to each element of the iterator, and if any of them return true, then so does any(). If they all return false, it returns false...
method
core
Stable since 1.0.0
Version 1.100.0-nightly