Commit db972be2 authored by jean-airoldie's avatar jean-airoldie Committed by Robert Winslow

[rust] Ran rustfmt against library code (#5389)

parent e304f8c1
This diff is collapsed.
...@@ -34,7 +34,7 @@ pub trait EndianScalar: Sized + PartialEq + Copy + Clone { ...@@ -34,7 +34,7 @@ pub trait EndianScalar: Sized + PartialEq + Copy + Clone {
/// Macro for implementing a no-op endian conversion. This is used for types /// Macro for implementing a no-op endian conversion. This is used for types
/// that are one byte wide. /// that are one byte wide.
macro_rules! impl_endian_scalar_noop { macro_rules! impl_endian_scalar_noop {
($ty:ident) => ( ($ty:ident) => {
impl EndianScalar for $ty { impl EndianScalar for $ty {
#[inline] #[inline]
fn to_little_endian(self) -> Self { fn to_little_endian(self) -> Self {
...@@ -45,7 +45,7 @@ macro_rules! impl_endian_scalar_noop { ...@@ -45,7 +45,7 @@ macro_rules! impl_endian_scalar_noop {
self self
} }
} }
) };
} }
/// Macro for implementing an endian conversion using the stdlib `to_le` and /// Macro for implementing an endian conversion using the stdlib `to_le` and
...@@ -53,7 +53,7 @@ macro_rules! impl_endian_scalar_noop { ...@@ -53,7 +53,7 @@ macro_rules! impl_endian_scalar_noop {
/// floats, because the `to_le` and `from_le` are not implemented for them in /// floats, because the `to_le` and `from_le` are not implemented for them in
/// the stdlib. /// the stdlib.
macro_rules! impl_endian_scalar_stdlib_le_conversion { macro_rules! impl_endian_scalar_stdlib_le_conversion {
($ty:ident) => ( ($ty:ident) => {
impl EndianScalar for $ty { impl EndianScalar for $ty {
#[inline] #[inline]
fn to_little_endian(self) -> Self { fn to_little_endian(self) -> Self {
...@@ -64,7 +64,7 @@ macro_rules! impl_endian_scalar_stdlib_le_conversion { ...@@ -64,7 +64,7 @@ macro_rules! impl_endian_scalar_stdlib_le_conversion {
Self::from_le(self) Self::from_le(self)
} }
} }
) };
} }
impl_endian_scalar_noop!(bool); impl_endian_scalar_noop!(bool);
...@@ -177,4 +177,3 @@ pub fn read_scalar<T: EndianScalar>(s: &[u8]) -> T { ...@@ -177,4 +177,3 @@ pub fn read_scalar<T: EndianScalar>(s: &[u8]) -> T {
x.from_little_endian() x.from_little_endian()
} }
...@@ -39,12 +39,14 @@ mod vtable; ...@@ -39,12 +39,14 @@ mod vtable;
mod vtable_writer; mod vtable_writer;
pub use builder::FlatBufferBuilder; pub use builder::FlatBufferBuilder;
pub use endian_scalar::{EndianScalar, emplace_scalar, read_scalar, read_scalar_at, byte_swap_f32, byte_swap_f64}; pub use endian_scalar::{
byte_swap_f32, byte_swap_f64, emplace_scalar, read_scalar, read_scalar_at, EndianScalar,
};
pub use follow::{Follow, FollowStart}; pub use follow::{Follow, FollowStart};
pub use primitives::*; pub use primitives::*;
pub use push::Push; pub use push::Push;
pub use table::{Table, buffer_has_identifier, get_root, get_size_prefixed_root}; pub use table::{buffer_has_identifier, get_root, get_size_prefixed_root, Table};
pub use vector::{SafeSliceAccess, Vector, follow_cast_ref}; pub use vector::{follow_cast_ref, SafeSliceAccess, Vector};
pub use vtable::field_index_to_field_offset; pub use vtable::field_index_to_field_offset;
// TODO(rw): Unify `create_vector` and `create_vector_direct` by using // TODO(rw): Unify `create_vector` and `create_vector_direct` by using
......
...@@ -274,7 +274,7 @@ impl<'a, T: Follow<'a> + 'a> Follow<'a> for SkipFileIdentifier<T> { ...@@ -274,7 +274,7 @@ impl<'a, T: Follow<'a> + 'a> Follow<'a> for SkipFileIdentifier<T> {
/// EndianScalar, but implementing Follow that way causes a conflict with /// EndianScalar, but implementing Follow that way causes a conflict with
/// other impls. /// other impls.
macro_rules! impl_follow_for_endian_scalar { macro_rules! impl_follow_for_endian_scalar {
($ty:ident) => ( ($ty:ident) => {
impl<'a> Follow<'a> for $ty { impl<'a> Follow<'a> for $ty {
type Inner = $ty; type Inner = $ty;
#[inline(always)] #[inline(always)]
...@@ -282,7 +282,7 @@ macro_rules! impl_follow_for_endian_scalar { ...@@ -282,7 +282,7 @@ macro_rules! impl_follow_for_endian_scalar {
read_scalar_at::<$ty>(buf, loc) read_scalar_at::<$ty>(buf, loc)
} }
} }
) };
} }
impl_follow_for_endian_scalar!(bool); impl_follow_for_endian_scalar!(bool);
......
...@@ -55,7 +55,7 @@ impl PushAlignment { ...@@ -55,7 +55,7 @@ impl PushAlignment {
/// Macro to implement Push for EndianScalar types. /// Macro to implement Push for EndianScalar types.
macro_rules! impl_push_for_endian_scalar { macro_rules! impl_push_for_endian_scalar {
($ty:ident) => ( ($ty:ident) => {
impl Push for $ty { impl Push for $ty {
type Output = $ty; type Output = $ty;
...@@ -63,9 +63,8 @@ macro_rules! impl_push_for_endian_scalar { ...@@ -63,9 +63,8 @@ macro_rules! impl_push_for_endian_scalar {
fn push(&self, dst: &mut [u8], _rest: &[u8]) { fn push(&self, dst: &mut [u8], _rest: &[u8]) {
emplace_scalar::<$ty>(dst, *self); emplace_scalar::<$ty>(dst, *self);
} }
} }
) };
} }
impl_push_for_endian_scalar!(bool); impl_push_for_endian_scalar!(bool);
......
...@@ -134,4 +134,3 @@ impl<'a, T: Follow<'a> + 'a> Follow<'a> for Vector<'a, T> { ...@@ -134,4 +134,3 @@ impl<'a, T: Follow<'a> + 'a> Follow<'a> for Vector<'a, T> {
Vector::new(buf, loc) Vector::new(buf, loc)
} }
} }
...@@ -34,10 +34,7 @@ impl<'a> PartialEq for VTable<'a> { ...@@ -34,10 +34,7 @@ impl<'a> PartialEq for VTable<'a> {
impl<'a> VTable<'a> { impl<'a> VTable<'a> {
pub fn init(buf: &'a [u8], loc: usize) -> Self { pub fn init(buf: &'a [u8], loc: usize) -> Self {
VTable { VTable { buf: buf, loc: loc }
buf: buf,
loc: loc,
}
} }
pub fn num_fields(&self) -> usize { pub fn num_fields(&self) -> usize {
(self.num_bytes() / SIZE_VOFFSET) - 2 (self.num_bytes() / SIZE_VOFFSET) - 2
...@@ -72,7 +69,6 @@ impl<'a> VTable<'a> { ...@@ -72,7 +69,6 @@ impl<'a> VTable<'a> {
} }
} }
#[allow(dead_code)] #[allow(dead_code)]
pub fn field_index_to_field_offset(field_id: VOffsetT) -> VOffsetT { pub fn field_index_to_field_offset(field_id: VOffsetT) -> VOffsetT {
// Should correspond to what end_table() below builds up. // Should correspond to what end_table() below builds up.
......
...@@ -82,4 +82,3 @@ impl<'a> VTableWriter<'a> { ...@@ -82,4 +82,3 @@ impl<'a> VTableWriter<'a> {
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment