doc.rust-lang.org
primitive i128
...i128 is intended to always match __int128 and does not attempt to match _BitInt(128) on platforms without __int128.
primitive
std
Stable since 1.26.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn starts_with<P>(&self, pat: P) -> bool
str::starts_with — Returns true if the given pattern matches a prefix of this string slice.
Returns false if it does not.
The pattern can be a &str, in which case this function will return true if the &str is a prefix of this string slice.
The pattern can also...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn strip_circumfix<P, S>(&self, prefix: P, suffix: S) -> Option<&str>
...Unlike trim_start_matches and trim_end_matches, this method removes both the prefix and suffix exactly once.
If the string does not start with prefix, does not end with suffix, or the prefix and suffix overlap in the string, returns None.
Each pattern can be a &str, char, a...
method
core
Stable since 1.98.0
Version 1.100.0-nightly
doc.rust-lang.org
pub macro unreachable!
...Examples
Match arms:
fn foo(x: Option<i32>) {
match x {
Some(n) if n >= 0 => println!("Some(Non-negative)"),
Some(n) if n < 0 => println!("Some(Negative)"),
Some(_) => unreachable!(), // compile error if commented out
None => println!("None")
}
}
Iterators:
fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations...
macro
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn rsplit_terminator<P>(&self, pat: P) -> RSplitTerminator<'_, P>
str::rsplit_terminator — Returns an iterator over substrings of self, separated by characters matched by a pattern and yielded in reverse order.
The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches.
Equivalent to split, except that the...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub type Result<T> = crate::result::Result<T, Box<dyn Any + Send + 'static>>
...or in case the thread is intended to be a subsystem boundary that is supposed to isolate system-level failures, match on the Err variant and handle the panic in an appropriate way
A thread that completes without panicking is considered to exit successfully.
Examples
Matching on the result of...
type_alias
std
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct MatchIndices<'a, P>
MatchIndices — Created with the method match_indices.
struct
core
Stable since 1.5.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn rsplit<P>(&self, pat: P) -> RSplit<'_, P>
str::rsplit — Returns an iterator over substrings of the given string slice, separated by characters matched by a pattern and yielded in reverse order.
The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches.
Iterator behavior
The returned...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn split_terminator<P>(&self, pat: P) -> SplitTerminator<'_, P>
str::split_terminator — Returns an iterator over substrings of the given string slice, separated by characters matched by a pattern.
The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches.
Equivalent to split, except that the trailing substring...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn eq_ignore_ascii_case(&self, other: &[u8]) -> bool
slice::eq_ignore_ascii_case — Checks that two slices are an ASCII case-insensitive match.
Same as to_ascii_lowercase(a) == to_ascii_lowercase(b), but without allocating and copying temporaries.
method
core
Stable since 1.23.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn shrink_to_fit(&mut self)
String::shrink_to_fit — Shrinks the capacity of this String to match its length.
Examples
let mut s = String::from("foo");
s.reserve(100);
assert!(s.capacity() >= 100);
s.shrink_to_fit();
assert_eq!(3, s.capacity());
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn eq_ignore_ascii_case(&self, other: &u8) -> bool
u8::eq_ignore_ascii_case — Checks that two values are an ASCII case-insensitive match.
This is equivalent to to_ascii_lowercase(a) == to_ascii_lowercase(b).
Examples
let lowercase_a = 97u8;
let uppercase_a = 65u8;
assert!(lowercase_a.eq_ignore_ascii_case(&uppercase_a));
method
core
Stable since 1.23.0
Version 1.100.0-nightly
doc.rust-lang.org
fn eq_ignore_ascii_case(&self, other: &Self) -> bool
AsciiExt::eq_ignore_ascii_case — Checks that two values are an ASCII case-insensitive match.
Same as to_ascii_lowercase(a) == to_ascii_lowercase(b), but without allocating and copying temporaries.
Note
This method is deprecated in favor of the identically-named inherent methods on u8, char, [u8] and str.
method
std
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn shrink_to_fit(&mut self)
OsString::shrink_to_fit — Shrinks the capacity of the OsString to match its length.
See the main OsString documentation information about encoding and capacity units.
Examples
use std::ffi::OsString;
let mut s = OsString::from("foo");
s.reserve(100);
assert!(s.capacity() >= 100);
s.shrink_to_fit();
assert_eq!(3...
method
std
Stable since 1.19.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct SplitMut<'a, T, P>
SplitMut — An iterator over the mutable subslices of the vector which are separated by elements that match pred.
This struct is created by the split_mut method on slices.
Example
let mut v = [10, 40, 30, 20, 60, 50];
let iter = v.split_mut(|num| *num % 3 == 0);
struct
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub macro try!
...fn write_to_file_using_match() -> Result<(), MyError> {
let mut file = r#try!(File::create("my_best_friends.txt"));
match file.write_all(b"This is a list of my best friends.") {
Ok(v) => v,
Err(e) => return Err(From::from(e)),
}
Ok(())
}
macro
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct Split<'a, T, P>
Split — An iterator over subslices separated by elements that match a predicate function.
This struct is created by the split method on slices.
Example
let slice = [10, 40, 33, 20];
let mut iter = slice.split(|num| num % 3 == 0);
assert_eq!(iter.next(), Some(&[10, 40][..]));
assert_eq!(iter.next...
struct
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn split<P>(&self, pat: P) -> Split<'_, P>
str::split — Returns an iterator over substrings of this string slice, separated by characters matched by a pattern.
The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches.
If there are no matches the full string slice is...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct SplitNMut<'a, T, P>
SplitNMut — 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_mut method on slices.
Example
let mut slice = [10, 40, 30, 20, 60, 50];
let iter = slice.splitn_mut(2, |num| *num % 3...
struct
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn eq_ignore_ascii_case(&self, other: &char) -> bool
char::eq_ignore_ascii_case — Checks that two values are an ASCII case-insensitive match.
Equivalent to to_ascii_lowercase(a) == to_ascii_lowercase(b).
Examples
let upper_a = 'A';
let lower_a = 'a';
let lower_z = 'z';
assert!(upper_a.eq_ignore_ascii_case(&lower_a));
assert!(upper_a...
method
core
Stable since 1.23.0
Version 1.100.0-nightly