Skip to main content

CastFrom

Trait CastFrom 

Source
pub trait CastFrom<S>: Sized {
    // Required method
    fn cast_from(value: S) -> Self;
}
Expand description

Performs a raw numeric cast from type S into Self.

Unlike ConvertTo and ConvertFrom, casts apply standard numeric conversion rules equivalent to an as expression — no audio-aware scaling, rounding, or saturation is applied. This trait is used internally to move values between numeric types for arithmetic or indexing purposes.

For audio-meaningful conversions (e.g. i16f32 in the range [-1.0, 1.0]), use ConvertTo or ConvertFrom instead.

Required Methods§

Source

fn cast_from(value: S) -> Self

Casts a value of type S into Self using raw numeric conversion.

§Arguments

value — the source value to cast.

§Returns

The cast value as Self. No audio-aware scaling is applied.

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 CastFrom<I24> for f32

Source§

fn cast_from(value: I24) -> Self

Source§

impl CastFrom<I24> for f64

Source§

fn cast_from(value: I24) -> Self

Source§

impl CastFrom<I24> for i16

Source§

fn cast_from(value: I24) -> Self

Source§

impl CastFrom<I24> for i32

Source§

fn cast_from(value: I24) -> Self

Source§

impl CastFrom<I24> for u8

Source§

fn cast_from(value: I24) -> Self

Source§

impl CastFrom<f32> for f32

Source§

fn cast_from(value: f32) -> Self

Source§

impl CastFrom<f32> for f64

Source§

fn cast_from(value: f32) -> Self

Source§

impl CastFrom<f32> for i16

Source§

fn cast_from(value: f32) -> Self

Source§

impl CastFrom<f32> for i32

Source§

fn cast_from(value: f32) -> Self

Source§

impl CastFrom<f32> for u8

Source§

fn cast_from(value: f32) -> Self

Source§

impl CastFrom<f64> for f32

Source§

fn cast_from(value: f64) -> Self

Source§

impl CastFrom<f64> for f64

Source§

fn cast_from(value: f64) -> Self

Source§

impl CastFrom<f64> for i16

Source§

fn cast_from(value: f64) -> Self

Source§

impl CastFrom<f64> for i32

Source§

fn cast_from(value: f64) -> Self

Source§

impl CastFrom<f64> for u8

Source§

fn cast_from(value: f64) -> Self

Source§

impl CastFrom<i16> for f32

Source§

fn cast_from(value: i16) -> Self

Source§

impl CastFrom<i16> for f64

Source§

fn cast_from(value: i16) -> Self

Source§

impl CastFrom<i16> for i16

Source§

fn cast_from(value: i16) -> Self

Source§

impl CastFrom<i16> for i32

Source§

fn cast_from(value: i16) -> Self

Source§

impl CastFrom<i16> for u8

Source§

fn cast_from(value: i16) -> Self

Source§

impl CastFrom<i32> for f32

Source§

fn cast_from(value: i32) -> Self

Source§

impl CastFrom<i32> for f64

Source§

fn cast_from(value: i32) -> Self

Source§

impl CastFrom<i32> for i16

Source§

fn cast_from(value: i32) -> Self

Source§

impl CastFrom<i32> for i32

Source§

fn cast_from(value: i32) -> Self

Source§

impl CastFrom<i32> for u8

Source§

fn cast_from(value: i32) -> Self

Source§

impl CastFrom<u8> for f32

Source§

fn cast_from(value: u8) -> Self

Source§

impl CastFrom<u8> for f64

Source§

fn cast_from(value: u8) -> Self

Source§

impl CastFrom<u8> for i16

Source§

fn cast_from(value: u8) -> Self

Source§

impl CastFrom<u8> for i32

Source§

fn cast_from(value: u8) -> Self

Source§

impl CastFrom<u8> for u8

Source§

fn cast_from(value: u8) -> Self

Source§

impl CastFrom<usize> for f32

Source§

fn cast_from(value: usize) -> Self

Source§

impl CastFrom<usize> for f64

Source§

fn cast_from(value: usize) -> Self

Source§

impl CastFrom<usize> for i16

Source§

fn cast_from(value: usize) -> Self

Source§

impl CastFrom<usize> for i32

Source§

fn cast_from(value: usize) -> Self

Source§

impl CastFrom<usize> for u8

Source§

fn cast_from(value: usize) -> Self

Implementors§