pub struct RangeFrom {
pub start: Value,
}
Expand description
Type for a from range expression start..
.
§Examples
let range = 0..;
assert!(!range.contains(-10));
assert!(range.contains(5));
assert!(range.contains(10));
assert!(range.contains(20));
assert!(range is std::ops::RangeFrom);
Ranges can contain any type:
let range = 'a'..;
assert_eq!(range.start, 'a');
range.start = 'b';
assert_eq!(range.start, 'b');
Certain ranges can be used as iterators:
let range = 'a'..;
assert_eq!(range.iter().take(5).collect::<Vec>(), ['a', 'b', 'c', 'd', 'e']);
§Rust examples
use rune::runtime::RangeFrom;
let start = rune::to_value(1)?;
let _ = RangeFrom::new(start);
Fields§
§start: Value
The start value of the range.
Implementations§
source§impl RangeFrom
impl RangeFrom
sourcepub fn into_iter(&self) -> VmResult<Iterator>
pub fn into_iter(&self) -> VmResult<Iterator>
Build an iterator over the range.
§Panics
This panics if the range is not a well-defined range.
§Examples
let vec = [];
for value in 'a'.. {
vec.push(value);
if value == 'e' {
break;
}
}
assert_eq!(vec, ['a', 'b', 'c', 'd', 'e']);
Cannot construct an iterator over floats:
let range = 1.0..;
for value in 1.0 .. {
}
sourcepub fn partial_eq(&self, other: &Self) -> VmResult<bool>
pub fn partial_eq(&self, other: &Self) -> VmResult<bool>
Test the range for partial equality.
§Examples
let range = 'a'..;
assert!(range == ('a'..));
assert!(range != ('b'..));
let range = 1.0..;
assert!(range == (1.0..));
assert!(range != (f64::NAN..));
assert!((f64::NAN..) != (f64::NAN..));
sourcepub fn eq(&self, other: &Self) -> VmResult<bool>
pub fn eq(&self, other: &Self) -> VmResult<bool>
Test the range for total equality.
§Examples
use std::ops::eq;
let range = 'a'..;
assert!(eq(range, 'a'..));
assert!(!eq(range, 'b'..));
Trait Implementations§
source§impl FromValue for RangeFrom
impl FromValue for RangeFrom
source§fn from_value(value: Value) -> VmResult<Self>
fn from_value(value: Value) -> VmResult<Self>
Try to convert to the given type, from the given value.
source§impl InstallWith for RangeFrom
impl InstallWith for RangeFrom
source§fn install_with(module: &mut Module) -> Result<(), ContextError>
fn install_with(module: &mut Module) -> Result<(), ContextError>
Hook to install more things into the module.
source§impl MaybeTypeOf for RangeFrom
impl MaybeTypeOf for RangeFrom
source§fn maybe_type_of() -> Option<FullTypeOf>
fn maybe_type_of() -> Option<FullTypeOf>
Type information for the given type.
source§impl UnsafeToMut for RangeFrom
impl UnsafeToMut for RangeFrom
Auto Trait Implementations§
impl !RefUnwindSafe for RangeFrom
impl !Send for RangeFrom
impl !Sync for RangeFrom
impl Unpin for RangeFrom
impl !UnwindSafe for RangeFrom
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more