Fixed the example and tests to use the new Converter trait.
Transmutable was changed to Converter. This needed to be reflected in the example and tests. Also, fixed some comments in the new transmutable module.
This commit is contained in:
@ -3,21 +3,18 @@
|
||||
extern crate alchemy;
|
||||
|
||||
|
||||
use std::f32;
|
||||
|
||||
use alchemy::{PlatformEndian, Transmutable};
|
||||
use alchemy::{Converter, PlatformEndian};
|
||||
|
||||
|
||||
|
||||
pub fn main()
|
||||
{
|
||||
let num: f32;
|
||||
let mut final_num: f32;
|
||||
let final_num: f32;
|
||||
let mut buffer: [u8; 4];
|
||||
|
||||
// Initialize the variables.
|
||||
num = 6.291985f32;
|
||||
final_num = f32::NAN;
|
||||
buffer = [0u8; 4];
|
||||
|
||||
println!("Converting the value {} into and out of an array of bytes.", num);
|
||||
|
@ -6,7 +6,9 @@ use ::endian::{BigEndian, LittleEndian, PlatformEndian, Endianess};
|
||||
|
||||
|
||||
|
||||
/// Handles the repetative
|
||||
/// Handles the repetative endianess matching
|
||||
/// for the primitive number types when converting
|
||||
/// a number to bytes.
|
||||
macro_rules! handle_endianess_to_bytes
|
||||
{
|
||||
($buffer: ident, $val: ident, $endianess: ident, $func: ident) =>
|
||||
@ -36,6 +38,9 @@ macro_rules! handle_endianess_to_bytes
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles the repetative endianess matching
|
||||
/// for the primitive number types when converting
|
||||
/// a number from bytes.
|
||||
macro_rules! handle_endianess_from_bytes
|
||||
{
|
||||
($buffer: ident, $endianess: ident, $func: ident) =>
|
||||
@ -358,3 +363,5 @@ impl Transmutable for f64
|
||||
handle_endianess_from_bytes!(buffer, endianess, bytes_to_f64)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ macro_rules! full_check_impl
|
||||
{
|
||||
use rand::ThreadRng;
|
||||
use rand::distributions::{IndependentSample, Range};
|
||||
use alchemy::{BigEndian, LittleEndian, Transmutable};
|
||||
use alchemy::{Converter, BigEndian, LittleEndian};
|
||||
|
||||
let range: Range<$T>;
|
||||
let mut rng: ThreadRng;
|
||||
@ -115,7 +115,7 @@ macro_rules! overflow_impl
|
||||
{
|
||||
use std::num::Zero;
|
||||
|
||||
use alchemy::{BigEndian, LittleEndian, Transmutable};
|
||||
use alchemy::{Converter, BigEndian, LittleEndian};
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user