pub trait Translate<T>: Sized {
// Required method
fn translate(value: T) -> Self;
}Expand description
Trait used for translating one sample type to another.
This performs infallible translations where any loss in precision is expected and is not supported between types which cannot be universally translated in this manner such as translations from a higher to a lower precision format.
§Examples
use audio::Translate;
assert_eq!(i16::translate(-1.0f32), i16::MIN);
assert_eq!(i16::translate(0.0f32), 0);
assert_eq!(u16::translate(-1.0f32), u16::MIN);
assert_eq!(u16::translate(0.0f32), 32768);Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.