rune::runtime

Struct 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

Source

pub fn new(start: Value, end: Value) -> Self

Construct a new range.

Source

pub fn iter(&self) -> VmResult<Value>

Iterate over the range.

§Panics

This panics if the range is not a well-defined range.

§Examples
let range = 'a'..='e';
assert_eq!(range.iter().collect::<Vec>(), ['a', 'b', 'c', 'd', 'e']);

Cannot construct an iterator over floats:

let range = 1.0..=2.0;
range.iter()
Source

pub fn into_iter(&self) -> VmResult<Value>

Iterate over the range.

§Panics

This panics if the range is not a well-defined range.

§Examples
let vec = [];

for value in 'a'..='e' {
    vec.push(value);
}

assert_eq!(vec, ['a', 'b', 'c', 'd', 'e']);

Cannot construct an iterator over floats:

for value in 1.0..=2.0 {
}
Source

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));
Source

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'));
Source

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)));
Source

pub fn cmp(&self, other: &Self) -> VmResult<Ordering>

Test the range for total ordering.

§Examples
use std::ops::cmp;
use std::cmp::Ordering;

assert_eq!(cmp('a'..='e', 'b'..='e'), Ordering::Less);
assert_eq!(cmp('c'..='e', 'b'..='e'), Ordering::Greater);

Trait Implementations§

Source§

impl Any for RangeInclusive

Source§

const ANY_TYPE_INFO: AnyTypeInfo = _

The compile-time type information know for the type.
Source§

impl Clone for RangeInclusive

Source§

fn clone(&self) -> RangeInclusive

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RangeInclusive

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl InstallWith for RangeInclusive

Source§

fn install_with(module: &mut Module) -> Result<(), ContextError>

Hook to install more things into the module.
Source§

impl MaybeTypeOf for RangeInclusive

Source§

fn maybe_type_of() -> Result<DocType>

Type information for the given type.
Source§

impl Named for RangeInclusive

Source§

const ITEM: &'static Item = _

The name item.
Source§

fn full_name(f: &mut Formatter<'_>) -> Result

The exact type name
Source§

fn display() -> impl Display

Return a display wrapper for the named type.
Source§

impl TryClone for RangeInclusive

Source§

fn try_clone(&self) -> Result<Self>

Try to clone the current value, raising an allocation error if it’s unsuccessful.
Source§

fn try_clone_from(&mut self, source: &Self) -> Result<(), Error>

Performs copy-assignment from source. Read more
Source§

impl TypeHash for RangeInclusive

Source§

const HASH: Hash = _

The complete type hash of the type including type parameters which uniquely identifiers a given type. Read more
Source§

impl TypeOf for RangeInclusive

Source§

const PARAMETERS: Hash = _

Type parameters for the type. Read more
Source§

const STATIC_TYPE_INFO: AnyTypeInfo = <Self as crate::Any>::ANY_TYPE_INFO

Access diagnostical type information for the current type. Read more
Source§

fn type_info() -> TypeInfo

Get type info associated with the current type.
Source§

impl UnsafeToMut for RangeInclusive

Source§

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>

Safety Read more
Source§

impl UnsafeToRef for RangeInclusive

Source§

type Guard = RawValueGuard

The raw guard returned. Read more
Source§

unsafe fn unsafe_to_ref<'a>( value: Value, ) -> Result<(&'a Self, Self::Guard), RuntimeError>

Safety Read more
Source§

impl UnsafeToValue for &RangeInclusive

Source§

type Guard = ValueRefGuard

The type used to guard the unsafe value conversion.
Source§

unsafe fn unsafe_to_value(self) -> Result<(Value, Self::Guard), RuntimeError>

Convert into a value. Read more
Source§

impl UnsafeToValue for &mut RangeInclusive

Source§

type Guard = ValueMutGuard

The type used to guard the unsafe value conversion.
Source§

unsafe fn unsafe_to_value(self) -> Result<(Value, Self::Guard), RuntimeError>

Convert into a value. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromValue for T
where T: AnyMarker,

Source§

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToReturn for T
where T: ToValue,

Source§

fn to_return(self) -> VmResult<Value>

Convert something into a return value.
Source§

impl<T> ToValue for T
where T: AnyMarker,

Source§

fn to_value(self) -> Result<Value, RuntimeError>

Convert into a value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TryToOwned for T
where T: TryClone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn try_to_owned(&self) -> Result<T, Error>

Creates owned data from borrowed data, usually by cloning. Read more
Source§

impl<T> UnsafeToValue for T
where T: ToValue,

Source§

type Guard = ()

The type used to guard the unsafe value conversion.
Source§

unsafe fn unsafe_to_value( self, ) -> Result<(Value, <T as UnsafeToValue>::Guard), RuntimeError>

Convert into a value. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T