Search results

There are no results.

std.range.ExclusiveRange

Value
type pub copy ExclusiveRange

An exclusive range of integers.

Static methods

new

Show source code
Hide 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 code
Hide source code
fn pub !=(other: T) -> Bool {
  (self == other).false?
}
fn pub !=(other: T) -> Bool

Returns true if self and the given object are not equal to each other.

==

Show source code
Hide 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 code
Hide source code
fn pub inline clone -> ExclusiveRange {
  ExclusiveRange(start: @start, end: @end)
}
fn pub inline clone -> ExclusiveRange

Creates a clone of self.

contains?

Show source code
Hide source code
fn pub inline contains?(value: ref 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

Checking if a Range covers a value:

1.until(10).cover?(5)  # => true
1.until(10).cover?(15) # => false

end

Show source code
Hide source code
fn pub inline end -> Int {
  @end
}
fn pub inline end -> Int

Returns the last value in the range.

fmt

Show source code
Hide source code
fn pub fmt(formatter: mut Formatter) {
  @start.fmt(formatter)
  formatter.write(' until ')
  @end.fmt(formatter)
}
fn pub fmt(formatter: mut Formatter)

Formats self in a human-readable format for debugging purposes.

hash

Show source code
Hide 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 code
Hide source code
fn pub inline inclusive? -> Bool {
  false
}
fn pub inline inclusive? -> Bool

Returns true if the range is an inclusive range.

iter

Show source code
Hide 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 code
Hide 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 code
Hide source code
fn pub inline start -> Int {
  @start
}
fn pub inline start -> Int

Returns the first value in the range.

Implemented traits

std.clone.

Clone

impl Clone[ExclusiveRange] for ExclusiveRange
std.cmp.

Contains

impl Contains[Int] for ExclusiveRange
std.cmp.

Equal

impl Equal[ExclusiveRange] for ExclusiveRange
std.fmt.

Format

impl Format for ExclusiveRange
std.hash.

Hash

impl Hash for ExclusiveRange
std.range.

Range

impl Range for ExclusiveRange