pub struct RationalNumbersLib;Expand description
The library that installs the numbers/rational domain: its literal class
and shapes, the Rational value class, the reduced arithmetic ops, and the
promotion rules to and from the integer and f64 domains.
§Examples
use std::sync::Arc;
use sim_kernel::{Cx, DefaultFactory, NoopEvalPolicy};
use sim_lib_numbers_rational::{RationalNumbersLib, number_domain};
let mut cx = Cx::new(Arc::new(NoopEvalPolicy), Arc::new(DefaultFactory));
cx.load_lib(&RationalNumbersLib::new()).unwrap();
// Rational literals parse into the domain even before any base scalar lib
// is loaded; arithmetic over them additionally needs the integer libs.
let value = cx
.factory()
.number_literal(number_domain(), "1/2".to_owned())
.unwrap();
let number = cx.number_value_ref(value).unwrap().unwrap();
assert_eq!(number.domain, number_domain());Implementations§
Trait Implementations§
Source§impl Default for RationalNumbersLib
impl Default for RationalNumbersLib
Auto Trait Implementations§
impl Freeze for RationalNumbersLib
impl RefUnwindSafe for RationalNumbersLib
impl Send for RationalNumbersLib
impl Sync for RationalNumbersLib
impl Unpin for RationalNumbersLib
impl UnsafeUnpin for RationalNumbersLib
impl UnwindSafe for RationalNumbersLib
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