Struct rune::runtime::RangeInclusive
source · pub struct RangeInclusive {
pub start: Value,
pub end: Value,
}
Expand description
Type for an inclusive 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::RangeInclusive);
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', 'e']);
§Rust Examples
use rune::runtime::RangeInclusive;
let start = rune::to_value(1)?;
let end = rune::to_value(10)?;
let _ = RangeInclusive::new(start, end);
Fields§
§start: Value
The start value of the range.
end: Value
The end value of the range.
Implementations§
source§impl RangeInclusive
impl RangeInclusive
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'));
sourcepub fn partial_cmp(&self, other: &Self) -> VmResult<Option<Ordering>>
pub fn partial_cmp(&self, other: &Self) -> VmResult<Option<Ordering>>
Test the range for partial ordering.
§Examples
assert!(('a'..='e') < ('b'..='e'));
assert!(('c'..='e') > ('b'..='e'));
assert!(!((f64::NAN..=2.0) > (f64::INFINITY..=2.0)));
assert!(!((f64::NAN..=2.0) < (f64::INFINITY..=2.0)));
Trait Implementations§
source§impl Clone for RangeInclusive
impl Clone for RangeInclusive
source§fn clone(&self) -> RangeInclusive
fn clone(&self) -> RangeInclusive
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RangeInclusive
impl Debug for RangeInclusive
source§impl FromValue for RangeInclusive
impl FromValue for RangeInclusive
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 RangeInclusive
impl InstallWith for RangeInclusive
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 RangeInclusive
impl MaybeTypeOf for RangeInclusive
source§fn maybe_type_of() -> Option<FullTypeOf>
fn maybe_type_of() -> Option<FullTypeOf>
Type information for the given type.
source§impl Named for RangeInclusive
impl Named for RangeInclusive
source§impl ToValue for RangeInclusive
impl ToValue for RangeInclusive
source§impl TryFrom<RangeInclusive> for Value
impl TryFrom<RangeInclusive> for Value
source§impl TypeOf for RangeInclusive
impl TypeOf for RangeInclusive
source§impl UnsafeToMut for RangeInclusive
impl UnsafeToMut for RangeInclusive
Auto Trait Implementations§
impl !RefUnwindSafe for RangeInclusive
impl !Send for RangeInclusive
impl !Sync for RangeInclusive
impl Unpin for RangeInclusive
impl !UnwindSafe for RangeInclusive
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