std.range.ExclusiveRange
Valuetype pub copy ExclusiveRange
An exclusive range of integers.
Static methods
new
Show source codeHide source code
fn pub inline static new(start: Int, end: Int) -> ExclusiveRange {
ExclusiveRange(start: start, end: end)
}
fn pub inline static new(start: Int, end: Int) -> ExclusiveRange
Returns a new ExclusiveRange
over the given values.
Instance methods
!=
Show source codeHide source code
fn pub !=(other: ref Self) -> Bool {
(self == other).false?
}
fn pub !=(other: ref Self) -> Bool
Returns true
if self
and the given object are not equal to each other.
==
Show source codeHide source code
fn pub inline ==(other: ref ExclusiveRange) -> Bool {
@start == other.start and @end == other.end
}
fn pub inline ==(other: ExclusiveRange) -> Bool
Returns true
if self
and other
are identical.
Examples
Comparing two identical ranges:
1.until(10) == 1.until(10) # => true
Comparing two different ranges:
1.until(10) == 1.until(5) # => false
clone
Show source codeHide source code
fn pub inline clone -> ExclusiveRange {
ExclusiveRange(start: @start, end: @end)
}
fn pub inline clone -> ExclusiveRange
Creates a clone of self
.
The returned value is an owned value that is the same type as the receiver
of this method. For example, cloning a ref Array[Int]
results in a
Array[Int]
, not another ref Array[Int]
.
contains?
Show source codeHide source code
fn pub inline contains?(value: Int) -> Bool {
@start <= value and value < @end
}
fn pub inline contains?(value: Int) -> Bool
Returns true
if the given argument resides in the range of self
.
Examples
1.to(10).contains?(5) # => true
1.to(10).contains?(10) # => true
end
Show source codeHide source code
fn pub inline end -> Int {
@end
}
fn pub inline end -> Int
Returns the last value in the range.
fmt
Show source codeHide source code
fn pub fmt(formatter: mut Formatter) {
formatter.write('[')
@start.fmt(formatter)
formatter.write(' until ')
@end.fmt(formatter)
formatter.write(']')
}
fn pub fmt(formatter: mut Formatter)
Formats self
in a human-readable format for debugging purposes.
hash
Show source codeHide source code
fn pub hash[H: mut + Hasher](hasher: mut H) {
@start.hash(hasher)
@end.hash(hasher)
}
fn pub hash[H: mut + Hasher](hasher: mut H: mut)
Writes the hash for self
into the given Hasher
.
inclusive?
Show source codeHide source code
fn pub inline inclusive? -> Bool {
false
}
fn pub inline inclusive? -> Bool
Returns true
if the range is an inclusive range.
into_iter
Show source codeHide source code
fn pub move into_iter -> Stream[Int] {
iter
}
fn pub move into_iter -> Stream[Int]
Moves self
into an iterator.
iter
Show source codeHide source code
fn pub iter -> Stream[Int] {
let mut current = @start
let end = @end
Stream.new(fn move {
if current < end {
Option.Some(current := current + 1)
} else {
Option.None
}
})
}
fn pub iter -> Stream[Int]
Returns an iterator over the values in self
.
size
Show source codeHide source code
fn pub inline size -> Int {
if @end >= @start { @end - @start } else { 0 }
}
fn pub inline size -> Int
Returns the number of values in this range.
start
Show source codeHide source code
fn pub inline start -> Int {
@start
}
fn pub inline start -> Int
Returns the first value in the range.
Implemented traits
Clone
impl Clone for ExclusiveRange
Equal
impl Equal for ExclusiveRange
Format
impl Format for ExclusiveRange
Hash
impl Hash for ExclusiveRange
Range
impl Range for ExclusiveRange