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 Any for RangeInclusive
impl Any for RangeInclusive
Source§const ANY_TYPE_INFO: AnyTypeInfo = _
const ANY_TYPE_INFO: AnyTypeInfo = _
The compile-time type information know for the type.
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 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() -> Result<DocType>
fn maybe_type_of() -> Result<DocType>
Type information for the given type.
Source§impl Named for RangeInclusive
impl Named for RangeInclusive
Source§impl TryClone for RangeInclusive
impl TryClone for RangeInclusive
Source§impl TypeHash for RangeInclusive
impl TypeHash for RangeInclusive
Source§impl TypeOf for RangeInclusive
impl TypeOf for RangeInclusive
Source§const PARAMETERS: Hash = _
const PARAMETERS: Hash = _
Type parameters for the type. Read more
Source§const STATIC_TYPE_INFO: AnyTypeInfo = <Self as crate::Any>::ANY_TYPE_INFO
const STATIC_TYPE_INFO: AnyTypeInfo = <Self as crate::Any>::ANY_TYPE_INFO
Access diagnostical type information for the current type. Read more
Source§impl UnsafeToMut for RangeInclusive
impl UnsafeToMut for RangeInclusive
Source§type Guard = RawValueGuard
type Guard = RawValueGuard
The raw guard returned. Read more
Source§unsafe fn unsafe_to_mut<'a>(
value: Value,
) -> Result<(&'a mut Self, Self::Guard), RuntimeError>
unsafe fn unsafe_to_mut<'a>( value: Value, ) -> Result<(&'a mut Self, Self::Guard), RuntimeError>
Safety Read more
Source§impl UnsafeToRef for RangeInclusive
impl UnsafeToRef for RangeInclusive
Source§type Guard = RawValueGuard
type Guard = RawValueGuard
The raw guard returned. Read more
Source§unsafe fn unsafe_to_ref<'a>(
value: Value,
) -> Result<(&'a Self, Self::Guard), RuntimeError>
unsafe fn unsafe_to_ref<'a>( value: Value, ) -> Result<(&'a Self, Self::Guard), RuntimeError>
Safety Read more
Source§impl UnsafeToValue for &RangeInclusive
impl UnsafeToValue for &RangeInclusive
Source§type Guard = ValueRefGuard
type Guard = ValueRefGuard
The type used to guard the unsafe value conversion.
Source§unsafe fn unsafe_to_value(self) -> Result<(Value, Self::Guard), RuntimeError>
unsafe fn unsafe_to_value(self) -> Result<(Value, Self::Guard), RuntimeError>
Convert into a value. Read more
Source§impl UnsafeToValue for &mut RangeInclusive
impl UnsafeToValue for &mut RangeInclusive
Source§type Guard = ValueMutGuard
type Guard = ValueMutGuard
The type used to guard the unsafe value conversion.
Source§unsafe fn unsafe_to_value(self) -> Result<(Value, Self::Guard), RuntimeError>
unsafe fn unsafe_to_value(self) -> Result<(Value, Self::Guard), RuntimeError>
Convert into a value. Read more
Auto Trait Implementations§
impl Freeze for RangeInclusive
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromValue for Twhere
T: AnyMarker,
impl<T> FromValue for Twhere
T: AnyMarker,
Source§fn from_value(value: Value) -> Result<T, RuntimeError>
fn from_value(value: Value) -> Result<T, RuntimeError>
Try to convert to the given type, from the given value.
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> TryToOwned for Twhere
T: TryClone,
impl<T> TryToOwned for Twhere
T: TryClone,
Source§impl<T> UnsafeToValue for Twhere
T: ToValue,
impl<T> UnsafeToValue for Twhere
T: ToValue,
Source§unsafe fn unsafe_to_value(
self,
) -> Result<(Value, <T as UnsafeToValue>::Guard), RuntimeError>
unsafe fn unsafe_to_value( self, ) -> Result<(Value, <T as UnsafeToValue>::Guard), RuntimeError>
Convert into a value. Read more