Skip to main content

TryConvertFromRawReal

Trait TryConvertFromRawReal 

Source
pub trait TryConvertFromRawReal<RawRealIn: RawRealTrait>: RawRealTrait {
    // Required method
    fn try_convert_from_raw_real(
        value_in: RawRealIn,
        precision_out: u32,
    ) -> Result<Self, RawRealConversionError<RawRealIn, Self>>;
}
Expand description

Conversion contract from one raw real type to another.

This trait is the low-level engine behind RawRealTrait::try_convert. Implementors define how to convert from RawRealIn into Self, including precision handling and exact representability guarantees.

§Design

  • RawRealIn is the input raw real type.
  • Self is the output raw real type.
  • precision_out is always interpreted by the output type (Self).

§Error Semantics

Implementations should map failures to RawRealConversionError:

  • input validation failures -> InputValidation
  • output validation failures -> OutputValidation
  • invalid requested precision for fixed-precision targets -> InvalidOutputPrecision
  • exactness loss after conversion -> NonRepresentableExactly

Required Methods§

Source

fn try_convert_from_raw_real( value_in: RawRealIn, precision_out: u32, ) -> Result<Self, RawRealConversionError<RawRealIn, Self>>

Performs raw-real conversion with explicit output precision.

§Parameters
  • value_in: input raw value to be converted.
  • precision_out: requested output precision interpreted by Self.
§Returns
  • Ok(Self) when conversion is valid and exact under the trait contract.
  • Err(RawRealConversionError<RawRealIn, Self>) otherwise.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl TryConvertFromRawReal<Float> for Float

Available on crate feature rug only.
Source§

fn try_convert_from_raw_real( value_in: Float, precision_out: u32, ) -> Result<Self, RawRealConversionError<Float, Self>>

Source§

impl TryConvertFromRawReal<Float> for f32

Source§

fn try_convert_from_raw_real( value_in: Float, precision_out: u32, ) -> Result<Self, RawRealConversionError<Float, Self>>

Source§

impl TryConvertFromRawReal<Float> for f64

Source§

fn try_convert_from_raw_real( value_in: Float, precision_out: u32, ) -> Result<Self, RawRealConversionError<Float, Self>>

Source§

impl TryConvertFromRawReal<f32> for Float

Source§

fn try_convert_from_raw_real( value_in: f32, precision_out: u32, ) -> Result<Self, RawRealConversionError<f32, Self>>

Source§

impl TryConvertFromRawReal<f32> for f64

Source§

fn try_convert_from_raw_real( value_in: f32, precision_out: u32, ) -> Result<Self, RawRealConversionError<f32, f64>>

Source§

impl TryConvertFromRawReal<f64> for Float

Source§

fn try_convert_from_raw_real( value_in: f64, precision_out: u32, ) -> Result<Self, RawRealConversionError<f64, Self>>

Source§

impl TryConvertFromRawReal<f64> for f32

Source§

fn try_convert_from_raw_real( value_in: f64, precision_out: u32, ) -> Result<Self, RawRealConversionError<f64, f32>>

Implementors§

Source§

impl<T: NativeReal> TryConvertFromRawReal<T> for T