Skip to main content

RangeInclusive

Struct RangeInclusive 

1.96.0 ยท Source
pub struct RangeInclusive<Idx> {
    pub start: Idx,
    pub last: Idx,
}
Expand description

A range bounded inclusively below and above.

The RangeInclusive contains all values with x >= start and x <= last. It is empty unless start <= last.

ยงExamples

use core::range::RangeInclusive;

assert_eq!(RangeInclusive::from(3..=5), RangeInclusive { start: 3, last: 5 });
assert_eq!(3 + 4 + 5, RangeInclusive::from(3..=5).into_iter().sum());

ยงEdition notes

It is planned that the syntax start..=last will construct this type in a future edition, but it does not do so today.

Fieldsยง

ยงstart: Idx

The lower bound of the range (inclusive).

ยงlast: Idx

The upper bound of the range (inclusive).

Implementationsยง

Sourceยง

impl<Idx> RangeInclusive<Idx>
where Idx: PartialOrd,

1.95.0 (const: unstable) ยท Source

pub fn contains<U>(&self, item: &U) -> bool
where Idx: PartialOrd<U>, U: PartialOrd<Idx> + ?Sized,

Returns true if item is contained in the range.

ยงExamples
use core::range::RangeInclusive;

assert!(!RangeInclusive::from(3..=5).contains(&2));
assert!( RangeInclusive::from(3..=5).contains(&3));
assert!( RangeInclusive::from(3..=5).contains(&4));
assert!( RangeInclusive::from(3..=5).contains(&5));
assert!(!RangeInclusive::from(3..=5).contains(&6));

assert!( RangeInclusive::from(3..=3).contains(&3));
assert!(!RangeInclusive::from(3..=2).contains(&3));

assert!( RangeInclusive::from(0.0..=1.0).contains(&1.0));
assert!(!RangeInclusive::from(0.0..=1.0).contains(&f32::NAN));
assert!(!RangeInclusive::from(0.0..=f32::NAN).contains(&0.0));
assert!(!RangeInclusive::from(f32::NAN..=1.0).contains(&1.0));
1.95.0 (const: unstable) ยท Source

pub fn is_empty(&self) -> bool
where Idx: PartialOrd,

Returns true if the range contains no items.

ยงExamples
use core::range::RangeInclusive;

assert!(!RangeInclusive::from(3..=5).is_empty());
assert!(!RangeInclusive::from(3..=3).is_empty());
assert!( RangeInclusive::from(3..=2).is_empty());

The range is empty if either side is incomparable:

use core::range::RangeInclusive;

assert!(!RangeInclusive::from(3.0..=5.0).is_empty());
assert!( RangeInclusive::from(3.0..=f32::NAN).is_empty());
assert!( RangeInclusive::from(f32::NAN..=5.0).is_empty());
Sourceยง

impl<Idx> RangeInclusive<Idx>
where Idx: Step,

1.95.0 ยท Source

pub fn iter(&self) -> RangeInclusiveIter<Idx> โ“˜

Creates an iterator over the elements within this range.

Shorthand for .clone().into_iter()

ยงExamples
use core::range::RangeInclusive;

let mut i = RangeInclusive::from(3..=8).iter().map(|n| n*n);
assert_eq!(i.next(), Some(9));
assert_eq!(i.next(), Some(16));
assert_eq!(i.next(), Some(25));

Trait Implementationsยง

1.95.0 ยท Sourceยง

impl<Idx> Clone for RangeInclusive<Idx>
where Idx: Clone,

Sourceยง

fn clone(&self) -> RangeInclusive<Idx>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.95.0 ยท Sourceยง

impl<Idx> Copy for RangeInclusive<Idx>
where Idx: Copy,

1.95.0 ยท Sourceยง

impl<Idx> Debug for RangeInclusive<Idx>
where Idx: Debug,

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Distribution<i8> for RangeInclusive<i8>

Sourceยง

fn sample(&self, source: &mut (impl Rng + ?Sized)) -> i8

๐Ÿ”ฌThis is a nightly-only experimental API. (random #130703)

Chooses a random number within the range.

Every possible result value is equally likely. In other words, this operation uses unbiased uniform sampling.

ยงPanics

Panics if the range is empty.

ยงSide-channels

This implementation does not claim to be resistant against side- channel attacks. In particular, the execution time of this operation may leak information about the returned value, and not just the values of the range bounds. While this implementation tries to avoid operations with particularly data-dependent timing (such as divisions), Rust as a language has no facilities for ensuring data-independent timing, voiding all promises about side-channel- freedom.

ยงExamples

A D20 dice roll:

#![feature(random)]

use std::random::{Distribution, SystemRng};
use std::range::RangeInclusive;

let roll = RangeInclusive::from(1..=20).sample(&mut SystemRng);
assert!(1 <= roll && roll <= 20);
if roll == 20 {
    println!("Wow! You achieve writing a sound linked list.");
} else {
    println!("Miri attacks!");
}
Sourceยง

impl Distribution<i16> for RangeInclusive<i16>

Sourceยง

fn sample(&self, source: &mut (impl Rng + ?Sized)) -> i16

๐Ÿ”ฌThis is a nightly-only experimental API. (random #130703)

Chooses a random number within the range.

Every possible result value is equally likely. In other words, this operation uses unbiased uniform sampling.

ยงPanics

Panics if the range is empty.

ยงSide-channels

This implementation does not claim to be resistant against side- channel attacks. In particular, the execution time of this operation may leak information about the returned value, and not just the values of the range bounds. While this implementation tries to avoid operations with particularly data-dependent timing (such as divisions), Rust as a language has no facilities for ensuring data-independent timing, voiding all promises about side-channel- freedom.

ยงExamples

A D20 dice roll:

#![feature(random)]

use std::random::{Distribution, SystemRng};
use std::range::RangeInclusive;

let roll = RangeInclusive::from(1..=20).sample(&mut SystemRng);
assert!(1 <= roll && roll <= 20);
if roll == 20 {
    println!("Wow! You achieve writing a sound linked list.");
} else {
    println!("Miri attacks!");
}
Sourceยง

impl Distribution<i32> for RangeInclusive<i32>

Sourceยง

fn sample(&self, source: &mut (impl Rng + ?Sized)) -> i32

๐Ÿ”ฌThis is a nightly-only experimental API. (random #130703)

Chooses a random number within the range.

Every possible result value is equally likely. In other words, this operation uses unbiased uniform sampling.

ยงPanics

Panics if the range is empty.

ยงSide-channels

This implementation does not claim to be resistant against side- channel attacks. In particular, the execution time of this operation may leak information about the returned value, and not just the values of the range bounds. While this implementation tries to avoid operations with particularly data-dependent timing (such as divisions), Rust as a language has no facilities for ensuring data-independent timing, voiding all promises about side-channel- freedom.

ยงExamples

A D20 dice roll:

#![feature(random)]

use std::random::{Distribution, SystemRng};
use std::range::RangeInclusive;

let roll = RangeInclusive::from(1..=20).sample(&mut SystemRng);
assert!(1 <= roll && roll <= 20);
if roll == 20 {
    println!("Wow! You achieve writing a sound linked list.");
} else {
    println!("Miri attacks!");
}
Sourceยง

impl Distribution<i64> for RangeInclusive<i64>

Sourceยง

fn sample(&self, source: &mut (impl Rng + ?Sized)) -> i64

๐Ÿ”ฌThis is a nightly-only experimental API. (random #130703)

Chooses a random number within the range.

Every possible result value is equally likely. In other words, this operation uses unbiased uniform sampling.

ยงPanics

Panics if the range is empty.

ยงSide-channels

This implementation does not claim to be resistant against side- channel attacks. In particular, the execution time of this operation may leak information about the returned value, and not just the values of the range bounds. While this implementation tries to avoid operations with particularly data-dependent timing (such as divisions), Rust as a language has no facilities for ensuring data-independent timing, voiding all promises about side-channel- freedom.

ยงExamples

A D20 dice roll:

#![feature(random)]

use std::random::{Distribution, SystemRng};
use std::range::RangeInclusive;

let roll = RangeInclusive::from(1..=20).sample(&mut SystemRng);
assert!(1 <= roll && roll <= 20);
if roll == 20 {
    println!("Wow! You achieve writing a sound linked list.");
} else {
    println!("Miri attacks!");
}
Sourceยง

impl Distribution<i128> for RangeInclusive<i128>

Sourceยง

fn sample(&self, source: &mut (impl Rng + ?Sized)) -> i128

๐Ÿ”ฌThis is a nightly-only experimental API. (random #130703)

Chooses a random number within the range.

Every possible result value is equally likely. In other words, this operation uses unbiased uniform sampling.

ยงPanics

Panics if the range is empty.

ยงSide-channels

This implementation does not claim to be resistant against side- channel attacks. In particular, the execution time of this operation may leak information about the returned value, and not just the values of the range bounds. While this implementation tries to avoid operations with particularly data-dependent timing (such as divisions), Rust as a language has no facilities for ensuring data-independent timing, voiding all promises about side-channel- freedom.

ยงExamples

A D20 dice roll:

#![feature(random)]

use std::random::{Distribution, SystemRng};
use std::range::RangeInclusive;

let roll = RangeInclusive::from(1..=20).sample(&mut SystemRng);
assert!(1 <= roll && roll <= 20);
if roll == 20 {
    println!("Wow! You achieve writing a sound linked list.");
} else {
    println!("Miri attacks!");
}
Sourceยง

impl Distribution<isize> for RangeInclusive<isize>

Sourceยง

fn sample(&self, source: &mut (impl Rng + ?Sized)) -> isize

๐Ÿ”ฌThis is a nightly-only experimental API. (random #130703)

Chooses a random number within the range.

Every possible result value is equally likely. In other words, this operation uses unbiased uniform sampling.

ยงPanics

Panics if the range is empty.

ยงSide-channels

This implementation does not claim to be resistant against side- channel attacks. In particular, the execution time of this operation may leak information about the returned value, and not just the values of the range bounds. While this implementation tries to avoid operations with particularly data-dependent timing (such as divisions), Rust as a language has no facilities for ensuring data-independent timing, voiding all promises about side-channel- freedom.

ยงExamples

A D20 dice roll:

#![feature(random)]

use std::random::{Distribution, SystemRng};
use std::range::RangeInclusive;

let roll = RangeInclusive::from(1..=20).sample(&mut SystemRng);
assert!(1 <= roll && roll <= 20);
if roll == 20 {
    println!("Wow! You achieve writing a sound linked list.");
} else {
    println!("Miri attacks!");
}
Sourceยง

impl Distribution<u8> for RangeInclusive<u8>

Sourceยง

fn sample(&self, source: &mut (impl Rng + ?Sized)) -> u8

๐Ÿ”ฌThis is a nightly-only experimental API. (random #130703)

Chooses a random number within the range.

Every possible result value is equally likely. In other words, this operation uses unbiased uniform sampling.

ยงPanics

Panics if the range is empty.

ยงSide-channels

This implementation does not claim to be resistant against side- channel attacks. In particular, the execution time of this operation may leak information about the returned value, and not just the values of the range bounds. While this implementation tries to avoid operations with particularly data-dependent timing (such as divisions), Rust as a language has no facilities for ensuring data-independent timing, voiding all promises about side-channel- freedom.

ยงExamples

A D20 dice roll:

#![feature(random)]

use std::random::{Distribution, SystemRng};
use std::range::RangeInclusive;

let roll = RangeInclusive::from(1..=20).sample(&mut SystemRng);
assert!(1 <= roll && roll <= 20);
if roll == 20 {
    println!("Wow! You achieve writing a sound linked list.");
} else {
    println!("Miri attacks!");
}
Sourceยง

impl Distribution<u16> for RangeInclusive<u16>

Sourceยง

fn sample(&self, source: &mut (impl Rng + ?Sized)) -> u16

๐Ÿ”ฌThis is a nightly-only experimental API. (random #130703)

Chooses a random number within the range.

Every possible result value is equally likely. In other words, this operation uses unbiased uniform sampling.

ยงPanics

Panics if the range is empty.

ยงSide-channels

This implementation does not claim to be resistant against side- channel attacks. In particular, the execution time of this operation may leak information about the returned value, and not just the values of the range bounds. While this implementation tries to avoid operations with particularly data-dependent timing (such as divisions), Rust as a language has no facilities for ensuring data-independent timing, voiding all promises about side-channel- freedom.

ยงExamples

A D20 dice roll:

#![feature(random)]

use std::random::{Distribution, SystemRng};
use std::range::RangeInclusive;

let roll = RangeInclusive::from(1..=20).sample(&mut SystemRng);
assert!(1 <= roll && roll <= 20);
if roll == 20 {
    println!("Wow! You achieve writing a sound linked list.");
} else {
    println!("Miri attacks!");
}
Sourceยง

impl Distribution<u32> for RangeInclusive<u32>

Sourceยง

fn sample(&self, source: &mut (impl Rng + ?Sized)) -> u32

๐Ÿ”ฌThis is a nightly-only experimental API. (random #130703)

Chooses a random number within the range.

Every possible result value is equally likely. In other words, this operation uses unbiased uniform sampling.

ยงPanics

Panics if the range is empty.

ยงSide-channels

This implementation does not claim to be resistant against side- channel attacks. In particular, the execution time of this operation may leak information about the returned value, and not just the values of the range bounds. While this implementation tries to avoid operations with particularly data-dependent timing (such as divisions), Rust as a language has no facilities for ensuring data-independent timing, voiding all promises about side-channel- freedom.

ยงExamples

A D20 dice roll:

#![feature(random)]

use std::random::{Distribution, SystemRng};
use std::range::RangeInclusive;

let roll = RangeInclusive::from(1..=20).sample(&mut SystemRng);
assert!(1 <= roll && roll <= 20);
if roll == 20 {
    println!("Wow! You achieve writing a sound linked list.");
} else {
    println!("Miri attacks!");
}
Sourceยง

impl Distribution<u64> for RangeInclusive<u64>

Sourceยง

fn sample(&self, source: &mut (impl Rng + ?Sized)) -> u64

๐Ÿ”ฌThis is a nightly-only experimental API. (random #130703)

Chooses a random number within the range.

Every possible result value is equally likely. In other words, this operation uses unbiased uniform sampling.

ยงPanics

Panics if the range is empty.

ยงSide-channels

This implementation does not claim to be resistant against side- channel attacks. In particular, the execution time of this operation may leak information about the returned value, and not just the values of the range bounds. While this implementation tries to avoid operations with particularly data-dependent timing (such as divisions), Rust as a language has no facilities for ensuring data-independent timing, voiding all promises about side-channel- freedom.

ยงExamples

A D20 dice roll:

#![feature(random)]

use std::random::{Distribution, SystemRng};
use std::range::RangeInclusive;

let roll = RangeInclusive::from(1..=20).sample(&mut SystemRng);
assert!(1 <= roll && roll <= 20);
if roll == 20 {
    println!("Wow! You achieve writing a sound linked list.");
} else {
    println!("Miri attacks!");
}
Sourceยง

impl Distribution<u128> for RangeInclusive<u128>

Sourceยง

fn sample(&self, source: &mut (impl Rng + ?Sized)) -> u128

๐Ÿ”ฌThis is a nightly-only experimental API. (random #130703)

Chooses a random number within the range.

Every possible result value is equally likely. In other words, this operation uses unbiased uniform sampling.

ยงPanics

Panics if the range is empty.

ยงSide-channels

This implementation does not claim to be resistant against side- channel attacks. In particular, the execution time of this operation may leak information about the returned value, and not just the values of the range bounds. While this implementation tries to avoid operations with particularly data-dependent timing (such as divisions), Rust as a language has no facilities for ensuring data-independent timing, voiding all promises about side-channel- freedom.

ยงExamples

A D20 dice roll:

#![feature(random)]

use std::random::{Distribution, SystemRng};
use std::range::RangeInclusive;

let roll = RangeInclusive::from(1..=20).sample(&mut SystemRng);
assert!(1 <= roll && roll <= 20);
if roll == 20 {
    println!("Wow! You achieve writing a sound linked list.");
} else {
    println!("Miri attacks!");
}
Sourceยง

impl Distribution<usize> for RangeInclusive<usize>

Sourceยง

fn sample(&self, source: &mut (impl Rng + ?Sized)) -> usize

๐Ÿ”ฌThis is a nightly-only experimental API. (random #130703)

Chooses a random number within the range.

Every possible result value is equally likely. In other words, this operation uses unbiased uniform sampling.

ยงPanics

Panics if the range is empty.

ยงSide-channels

This implementation does not claim to be resistant against side- channel attacks. In particular, the execution time of this operation may leak information about the returned value, and not just the values of the range bounds. While this implementation tries to avoid operations with particularly data-dependent timing (such as divisions), Rust as a language has no facilities for ensuring data-independent timing, voiding all promises about side-channel- freedom.

ยงExamples

A D20 dice roll:

#![feature(random)]

use std::random::{Distribution, SystemRng};
use std::range::RangeInclusive;

let roll = RangeInclusive::from(1..=20).sample(&mut SystemRng);
assert!(1 <= roll && roll <= 20);
if roll == 20 {
    println!("Wow! You achieve writing a sound linked list.");
} else {
    println!("Miri attacks!");
}
1.95.0 ยท Sourceยง

impl<Idx> Eq for RangeInclusive<Idx>
where Idx: Eq,

1.95.0 (const: unstable) ยท Sourceยง

impl<T> From<RangeInclusive<T>> for RangeInclusive<T>

Sourceยง

fn from(value: RangeInclusive<T>) -> RangeInclusive<T> โ“˜

Converts to this type from the input type.
1.95.0 (const: unstable) ยท Sourceยง

impl<T> From<RangeInclusive<T>> for RangeInclusive<T>

Sourceยง

fn from(value: RangeInclusive<T>) -> RangeInclusive<T>

Converts from a legacy range to a non-legacy range, potentially panicking.

ยงPanics

If the legacy range iterator has been exhausted, this function will either panic or return an empty range.

ยงExamples
use core::range::legacy;
use core::range::RangeInclusive;

let single: legacy::RangeInclusive<i32> = 0..=1;
let single = RangeInclusive::from(single);
assert_eq!((single.start, single.last), (0, 1));

let empty: legacy::RangeInclusive<i32> = 0..=0;
let empty = RangeInclusive::from(empty);
assert_eq!((empty.start, empty.last), (0, 0));
use core::range::legacy;
use core::range::RangeInclusive;
use std::panic::catch_unwind;

let mut exhausted: legacy::RangeInclusive<i32> = 0..=0;
exhausted.next();
let result = catch_unwind(|| RangeInclusive::from(exhausted));
// The `from` call either panicked or returned an empty range.
assert!(result.is_err() || result.is_ok_and(|range| range.is_empty()));
Sourceยง

impl GetDisjointMutIndex for RangeInclusive<usize>

Sourceยง

fn is_in_bounds(&self, len: usize) -> bool

๐Ÿ”ฌThis is a nightly-only experimental API. (get_disjoint_mut_helpers)
Returns true if self is in bounds for len slice elements.
Sourceยง

fn is_overlapping(&self, other: &RangeInclusive<usize>) -> bool

๐Ÿ”ฌThis is a nightly-only experimental API. (get_disjoint_mut_helpers)
Returns true if self overlaps with other. Read more
1.95.0 ยท Sourceยง

impl<Idx> Hash for RangeInclusive<Idx>
where Idx: 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
Sourceยง

impl<T> IntoBounds<T> for RangeInclusive<T>

Sourceยง

fn into_bounds(self) -> (Bound<T>, Bound<T>)

๐Ÿ”ฌThis is a nightly-only experimental API. (range_into_bounds #136903)
Convert this range into the start and end bounds. Returns (start_bound, end_bound). Read more
Sourceยง

fn intersect<R>(self, other: R) -> (Bound<T>, Bound<T>)
where Self: Sized, T: Ord, R: IntoBounds<T>,

๐Ÿ”ฌThis is a nightly-only experimental API. (range_into_bounds #136903)
Compute the intersection of self and other. Read more
1.95.0 ยท Sourceยง

impl<A> IntoIterator for RangeInclusive<A>
where A: Step,

Sourceยง

type Item = A

The type of the elements being iterated over.
Sourceยง

type IntoIter = RangeInclusiveIter<A>

Which kind of iterator are we turning this into?
Sourceยง

fn into_iter(self) -> <RangeInclusive<A> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
1.95.0 ยท Sourceยง

impl<Idx> PartialEq for RangeInclusive<Idx>
where Idx: PartialEq,

Sourceยง

fn eq(&self, other: &RangeInclusive<Idx>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) ยท Sourceยง

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

Inequality operator !=. Read more
1.95.0 (const: unstable) ยท Sourceยง

impl<T> RangeBounds<T> for RangeInclusive<T>

Sourceยง

fn start_bound(&self) -> Bound<&T>

Start index bound. Read more
Sourceยง

fn end_bound(&self) -> Bound<&T>

End index bound. Read more
1.35.0 (const: unstable) ยท Sourceยง

fn contains<U>(&self, item: &U) -> bool
where T: PartialOrd<U>, U: PartialOrd<T> + ?Sized,

Returns true if item is contained in the range. Read more
Sourceยง

fn is_empty(&self) -> bool
where T: PartialOrd,

๐Ÿ”ฌThis is a nightly-only experimental API. (range_bounds_is_empty #137300)
Returns true if the range contains no items. One-sided ranges (RangeFrom, etc) always return false. Read more
1.95.0 (const: unstable) ยท Sourceยง

impl<T> RangeBounds<T> for RangeInclusive<&T>

If you need to use this implementation where T is unsized, consider using the RangeBounds impl for a 2-tuple of Bound<&T>, i.e. replace start..=end with (Bound::Included(start), Bound::Included(end)).

Sourceยง

fn start_bound(&self) -> Bound<&T>

Start index bound. Read more
Sourceยง

fn end_bound(&self) -> Bound<&T>

End index bound. Read more
1.35.0 (const: unstable) ยท Sourceยง

fn contains<U>(&self, item: &U) -> bool
where T: PartialOrd<U>, U: PartialOrd<T> + ?Sized,

Returns true if item is contained in the range. Read more
Sourceยง

fn is_empty(&self) -> bool
where T: PartialOrd,

๐Ÿ”ฌThis is a nightly-only experimental API. (range_bounds_is_empty #137300)
Returns true if the range contains no items. One-sided ranges (RangeFrom, etc) always return false. Read more
Sourceยง

impl SliceIndex<ByteStr> for RangeInclusive<usize>

Sourceยง

type Output = ByteStr

The output type returned by methods.
Sourceยง

fn get( self, slice: &ByteStr, ) -> Option<&<RangeInclusive<usize> as SliceIndex<ByteStr>>::Output>

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a shared reference to the output at this location, if in bounds.
Sourceยง

fn get_mut( self, slice: &mut ByteStr, ) -> Option<&mut <RangeInclusive<usize> as SliceIndex<ByteStr>>::Output>

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a mutable reference to the output at this location, if in bounds.
Sourceยง

unsafe fn get_unchecked( self, slice: *const ByteStr, ) -> *const <RangeInclusive<usize> as SliceIndex<ByteStr>>::Output

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a pointer to the output at this location, without performing any bounds checking. Read more
Sourceยง

unsafe fn get_unchecked_mut( self, slice: *mut ByteStr, ) -> *mut <RangeInclusive<usize> as SliceIndex<ByteStr>>::Output

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a mutable pointer to the output at this location, without performing any bounds checking. Read more
Sourceยง

fn index( self, slice: &ByteStr, ) -> &<RangeInclusive<usize> as SliceIndex<ByteStr>>::Output

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a shared reference to the output at this location, panicking if out of bounds.
Sourceยง

fn index_mut( self, slice: &mut ByteStr, ) -> &mut <RangeInclusive<usize> as SliceIndex<ByteStr>>::Output

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a mutable reference to the output at this location, panicking if out of bounds.
1.95.0 (const: unstable) ยท Sourceยง

impl<T> SliceIndex<[T]> for RangeInclusive<usize>

Sourceยง

type Output = [T]

The output type returned by methods.
Sourceยง

fn get(self, slice: &[T]) -> Option<&[T]>

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a shared reference to the output at this location, if in bounds.
Sourceยง

fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a mutable reference to the output at this location, if in bounds.
Sourceยง

unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a pointer to the output at this location, without performing any bounds checking. Read more
Sourceยง

unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a mutable pointer to the output at this location, without performing any bounds checking. Read more
Sourceยง

fn index(self, slice: &[T]) -> &[T]

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a shared reference to the output at this location, panicking if out of bounds.
Sourceยง

fn index_mut(self, slice: &mut [T]) -> &mut [T]

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a mutable reference to the output at this location, panicking if out of bounds.
1.95.0 (const: unstable) ยท Sourceยง

impl SliceIndex<str> for RangeInclusive<usize>

Sourceยง

type Output = str

The output type returned by methods.
Sourceยง

fn get( self, slice: &str, ) -> Option<&<RangeInclusive<usize> as SliceIndex<str>>::Output>

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a shared reference to the output at this location, if in bounds.
Sourceยง

fn get_mut( self, slice: &mut str, ) -> Option<&mut <RangeInclusive<usize> as SliceIndex<str>>::Output>

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a mutable reference to the output at this location, if in bounds.
Sourceยง

unsafe fn get_unchecked( self, slice: *const str, ) -> *const <RangeInclusive<usize> as SliceIndex<str>>::Output

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a pointer to the output at this location, without performing any bounds checking. Read more
Sourceยง

unsafe fn get_unchecked_mut( self, slice: *mut str, ) -> *mut <RangeInclusive<usize> as SliceIndex<str>>::Output

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a mutable pointer to the output at this location, without performing any bounds checking. Read more
Sourceยง

fn index( self, slice: &str, ) -> &<RangeInclusive<usize> as SliceIndex<str>>::Output

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a shared reference to the output at this location, panicking if out of bounds.
Sourceยง

fn index_mut( self, slice: &mut str, ) -> &mut <RangeInclusive<usize> as SliceIndex<str>>::Output

๐Ÿ”ฌThis is a nightly-only experimental API. (slice_index_methods)
Returns a mutable reference to the output at this location, panicking if out of bounds.
1.95.0 ยท Sourceยง

impl<Idx> StructuralPartialEq for RangeInclusive<Idx>
where Idx: PartialEq,

Auto Trait Implementationsยง

ยง

impl<Idx> Freeze for RangeInclusive<Idx>
where Idx: Freeze,

ยง

impl<Idx> RefUnwindSafe for RangeInclusive<Idx>
where Idx: RefUnwindSafe,

ยง

impl<Idx> Send for RangeInclusive<Idx>
where Idx: Send,

ยง

impl<Idx> Sync for RangeInclusive<Idx>
where Idx: Sync,

ยง

impl<Idx> Unpin for RangeInclusive<Idx>
where Idx: Unpin,

ยง

impl<Idx> UnsafeUnpin for RangeInclusive<Idx>
where Idx: UnsafeUnpin,

ยง

impl<Idx> UnwindSafe for RangeInclusive<Idx>
where Idx: 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
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> CloneToUninit for T
where T: Clone,

Sourceยง

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

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

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> 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
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.