Skip to main content

TryPrimedFrom

Trait TryPrimedFrom 

Source
pub trait TryPrimedFrom<N>
where Self: Sized,
{ type Error; // Required method fn try_primed_from<P>(p: P, n: N) -> Result<Self, Self::Error> where P: Into<Prime>; }
Expand description

Can attempt to create from N with the given Prime

Required Associated Types§

Source

type Error

The type returned in the event of a conversion error

Required Methods§

Source

fn try_primed_from<P>(p: P, n: N) -> Result<Self, Self::Error>
where P: Into<Prime>,

Convert from N to Self with Prime p

assert_eq!(Ok("123._5"), UAdic::try_primed_from(5, 38).map(|a| a.to_string()).as_deref());
assert_eq!(Ok("(4)23._5"), EAdic::try_primed_from(5, -12).map(|a| a.to_string()).as_deref());
let n = Rational32::new(1, 24);
assert_eq!(Ok("(34)4._5"), EAdic::try_primed_from(5, n).map(|a| a.to_string()).as_deref());
let n = Rational32::new(1, 5);
assert_eq!(Err(AdicError::DivideByPrime), EAdic::try_primed_from(5, n));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§