pub struct Range {
pub start: Value,
pub end: Value,
}
Expand description
Type for a range expression start..end
.
§Examples
let range = 0..10;
assert!(!range.contains(-10));
assert!(range.contains(5));
assert!(!range.contains(10));
assert!(!range.contains(20));
assert!(range is std::ops::Range);
Ranges can contain any type:
let range = 'a'..'f';
assert_eq!(range.start, 'a');
range.start = 'b';
assert_eq!(range.start, 'b');
assert_eq!(range.end, 'f');
range.end = 'g';
assert_eq!(range.end, 'g');
Certain ranges can be used as iterators:
let range = 'a'..'e';
assert_eq!(range.iter().collect::<Vec>(), ['a', 'b', 'c', 'd']);
§Examples
use rune::runtime::Range;
let start = rune::to_value(1)?;
let end = rune::to_value(10)?;
let _ = Range::new(start, end);
Fields§
§start: Value
The start value of the range.
end: Value
The to value of the range.
Implementations§
source§impl Range
impl Range
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'..'e';
assert!(range == ('a'..'e'));
assert!(range != ('b'..'e'));
let range = 1.0..2.0;
assert!(range == (1.0..2.0));
assert!(range != (f64::NAN..2.0));
assert!((f64::NAN..2.0) != (f64::NAN..2.0));
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'..'e';
assert!(eq(range, 'a'..'e'));
assert!(!eq(range, 'b'..'e'));
Trait Implementations§
source§impl FromValue for Range
impl FromValue for Range
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 Range
impl InstallWith for Range
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 Range
impl MaybeTypeOf for Range
source§fn maybe_type_of() -> Option<FullTypeOf>
fn maybe_type_of() -> Option<FullTypeOf>
Type information for the given type.
source§impl UnsafeToMut for Range
impl UnsafeToMut for Range
Auto Trait Implementations§
impl !RefUnwindSafe for Range
impl !Send for Range
impl !Sync for Range
impl Unpin for Range
impl !UnwindSafe for Range
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