Struct Range Copy item path 1.6.0 · Source pub struct Range<Idx> {
pub start: Idx,
pub end: Idx,
}
Expand description A (half-open) range bounded inclusively below and exclusively above
(start..end
).
The range start..end
contains all values with start <= x < end
.
It is empty if start >= end
.
§ Examples
The start..end
syntax is a Range
:
assert_eq! ((3 ..5 ), std::ops::Range { start: 3 , end: 5 });
assert_eq! (3 + 4 + 5 , (3 ..6 ).sum());
let arr = [0 , 1 , 2 , 3 , 4 ];
assert_eq! (arr[ .. ], [0 , 1 , 2 , 3 , 4 ]);
assert_eq! (arr[ .. 3 ], [0 , 1 , 2 ]);
assert_eq! (arr[ ..=3 ], [0 , 1 , 2 , 3 ]);
assert_eq! (arr[1 .. ], [ 1 , 2 , 3 , 4 ]);
assert_eq! (arr[1 .. 3 ], [ 1 , 2 ]); assert_eq! (arr[1 ..=3 ], [ 1 , 2 , 3 ]);
The lower bound of the range (inclusive).
The upper bound of the range (exclusive).
🔬 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 1.28.0 · Source § 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::Excluded(end))
.
Returns the argument unchanged.
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From <T> for U
chooses to do.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.