pub trait ConvertInto<S>where
S: Sample,{
// Required method
fn convert_into(self) -> S;
}
Required Methods§
Sourcefn convert_into(self) -> S
fn convert_into(self) -> S
Convert Self
into another Sample
type. This is analogous
to std::convert::Into
, but is intended for preserving the same
represented amplitude between sample types.
This trait has a blanket implementation for all types that implement
ConvertFrom
.
use sampara::{Sample, ConvertInto};
fn main() {
let s: i8 = 0.0f32.convert_into();
assert_eq!(s, 0);
let s: u8 = 0.0f32.convert_into();
assert_eq!(s, 128);
let s: f32 = 255u8.convert_into();
assert_eq!(s, 0.9921875);
}