From 2a266fb0917f003b6ee368f3f57b954d597ae19e Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 28 Aug 2022 21:31:07 -0700 Subject: [PATCH] Change rustfmt settings --- examples/combat.rs | 6 +++--- examples/conway.rs | 6 +++--- examples/cow_sphere.rs | 6 +++--- examples/raycast.rs | 6 +++--- examples/terrain.rs | 8 ++++---- rustfmt.toml | 1 - src/lib.rs | 6 +++--- src/protocol_inner/var_int.rs | 2 +- src/slab.rs | 8 ++++---- valence_nbt/src/binary/ser/map.rs | 10 +++++----- valence_nbt/src/binary/ser/payload.rs | 8 ++++---- valence_nbt/src/binary/ser/root.rs | 8 ++++---- valence_nbt/src/binary/ser/seq.rs | 2 +- valence_nbt/src/binary/ser/structs.rs | 2 +- valence_nbt/src/value.rs | 14 +++++++------- 15 files changed, 46 insertions(+), 47 deletions(-) diff --git a/examples/combat.rs b/examples/combat.rs index 93080fd..cdc4888 100644 --- a/examples/combat.rs +++ b/examples/combat.rs @@ -55,12 +55,12 @@ const SPAWN_POS: BlockPos = BlockPos::new(0, 20, 0); #[async_trait] impl Config for Game { - type ChunkState = (); + type ServerState = Option; type ClientState = ClientState; type EntityState = EntityState; - type PlayerListState = (); - type ServerState = Option; type WorldState = (); + type ChunkState = (); + type PlayerListState = (); fn max_connections(&self) -> usize { // We want status pings to be successful even if the server is full. diff --git a/examples/conway.rs b/examples/conway.rs index eed5ade..ff0a29e 100644 --- a/examples/conway.rs +++ b/examples/conway.rs @@ -53,12 +53,12 @@ const BOARD_Y: i32 = 50; #[async_trait] impl Config for Game { - type ChunkState = (); + type ServerState = ServerState; type ClientState = EntityId; type EntityState = (); - type PlayerListState = (); - type ServerState = ServerState; type WorldState = (); + type ChunkState = (); + type PlayerListState = (); fn max_connections(&self) -> usize { // We want status pings to be successful even if the server is full. diff --git a/examples/cow_sphere.rs b/examples/cow_sphere.rs index 5304e09..6bab5c1 100644 --- a/examples/cow_sphere.rs +++ b/examples/cow_sphere.rs @@ -48,12 +48,12 @@ const SPAWN_POS: BlockPos = BlockPos::new(0, 100, -25); #[async_trait] impl Config for Game { - type ChunkState = (); + type ServerState = ServerState; type ClientState = EntityId; type EntityState = (); - type PlayerListState = (); - type ServerState = ServerState; type WorldState = (); + type ChunkState = (); + type PlayerListState = (); fn max_connections(&self) -> usize { // We want status pings to be successful even if the server is full. diff --git a/examples/raycast.rs b/examples/raycast.rs index 6510e52..cfc08e9 100644 --- a/examples/raycast.rs +++ b/examples/raycast.rs @@ -42,13 +42,13 @@ const PLAYER_EYE_HEIGHT: f64 = 1.6; #[async_trait] impl Config for Game { - type ChunkState = (); + type ServerState = Option; type ClientState = EntityId; /// `true` for entities that have been intersected with. type EntityState = bool; - type PlayerListState = (); - type ServerState = Option; type WorldState = (); + type ChunkState = (); + type PlayerListState = (); fn max_connections(&self) -> usize { // We want status pings to be successful even if the server is full. diff --git a/examples/terrain.rs b/examples/terrain.rs index 7c9eda5..7a36653 100644 --- a/examples/terrain.rs +++ b/examples/terrain.rs @@ -52,13 +52,13 @@ const MAX_PLAYERS: usize = 10; #[async_trait] impl Config for Game { - /// If the chunk should stay loaded at the end of the tick. - type ChunkState = bool; + type ServerState = Option; type ClientState = EntityId; type EntityState = (); - type PlayerListState = (); - type ServerState = Option; type WorldState = (); + /// If the chunk should stay loaded at the end of the tick. + type ChunkState = bool; + type PlayerListState = (); fn max_connections(&self) -> usize { // We want status pings to be successful even if the server is full. diff --git a/rustfmt.toml b/rustfmt.toml index 4d0985a..7788221 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -2,7 +2,6 @@ edition = "2021" unstable_features = true wrap_comments = true imports_granularity = "Module" -reorder_impl_items = true group_imports = "StdExternalCrate" format_code_in_doc_comments = true format_macro_matchers = true diff --git a/src/lib.rs b/src/lib.rs index c374616..17b00e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,11 +58,11 @@ //! struct Game; //! //! impl Config for Game { -//! type ChunkState = (); +//! type ServerState = (); //! type ClientState = (); //! type EntityState = (); -//! type ServerState = (); //! type WorldState = (); +//! type ChunkState = (); //! //! fn max_connections(&self) -> usize { //! 256 @@ -128,7 +128,7 @@ pub use async_trait::async_trait; #[doc(inline)] pub use server::start_server; #[doc(inline)] -pub use {nbt, uuid, vek}; +pub use {uuid, vek}; pub mod biome; pub mod block; diff --git a/src/protocol_inner/var_int.rs b/src/protocol_inner/var_int.rs index 95005c5..5c2aaa4 100644 --- a/src/protocol_inner/var_int.rs +++ b/src/protocol_inner/var_int.rs @@ -96,7 +96,7 @@ mod tests { { buf.clear(); n.encode(&mut buf).unwrap(); - assert!(buf.len() == n.written_size()); + assert_eq!(buf.len(), n.written_size()); } } diff --git a/src/slab.rs b/src/slab.rs index aacb3ab..1471956 100644 --- a/src/slab.rs +++ b/src/slab.rs @@ -149,8 +149,8 @@ impl Slab { } impl<'a, T> IntoIterator for &'a Slab { - type IntoIter = Iter<'a, T>; type Item = (usize, &'a T); + type IntoIter = Iter<'a, T>; fn into_iter(self) -> Self::IntoIter { self.iter() @@ -158,8 +158,8 @@ impl<'a, T> IntoIterator for &'a Slab { } impl<'a, T> IntoIterator for &'a mut Slab { - type IntoIter = IterMut<'a, T>; type Item = (usize, &'a mut T); + type IntoIter = IterMut<'a, T>; fn into_iter(self) -> Self::IntoIter { self.iter_mut() @@ -167,8 +167,8 @@ impl<'a, T> IntoIterator for &'a mut Slab { } impl<'a, T: Sync> IntoParallelIterator for &'a Slab { - type Item = (usize, &'a T); type Iter = ParIter<'a, T>; + type Item = (usize, &'a T); fn into_par_iter(self) -> Self::Iter { ParIter { slab: self } @@ -176,8 +176,8 @@ impl<'a, T: Sync> IntoParallelIterator for &'a Slab { } impl<'a, T: Send + Sync> IntoParallelIterator for &'a mut Slab { - type Item = (usize, &'a mut T); type Iter = ParIterMut<'a, T>; + type Item = (usize, &'a mut T); fn into_par_iter(self) -> Self::Iter { ParIterMut { slab: self } diff --git a/valence_nbt/src/binary/ser/map.rs b/valence_nbt/src/binary/ser/map.rs index 18656d4..b5084f1 100644 --- a/valence_nbt/src/binary/ser/map.rs +++ b/valence_nbt/src/binary/ser/map.rs @@ -13,8 +13,8 @@ pub struct SerializeMap<'w, W: ?Sized> { } impl<'w, W: Write + ?Sized> ser::SerializeMap for SerializeMap<'w, W> { - type Error = Error; type Ok = (); + type Error = Error; fn serialize_key(&mut self, _key: &T) -> Result<(), Error> where @@ -62,15 +62,15 @@ fn key_not_a_string(typ: &str) -> Result { } impl Serializer for MapEntrySerializer<'_, '_, W, V> { - type Error = Error; type Ok = (); - type SerializeMap = Impossible; + type Error = Error; type SerializeSeq = Impossible; - type SerializeStruct = Impossible; - type SerializeStructVariant = Impossible; type SerializeTuple = Impossible; type SerializeTupleStruct = Impossible; type SerializeTupleVariant = Impossible; + type SerializeMap = Impossible; + type SerializeStruct = Impossible; + type SerializeStructVariant = Impossible; fn serialize_bool(self, _v: bool) -> Result { key_not_a_string("bool") diff --git a/valence_nbt/src/binary/ser/payload.rs b/valence_nbt/src/binary/ser/payload.rs index 84e08d6..bd68b23 100644 --- a/valence_nbt/src/binary/ser/payload.rs +++ b/valence_nbt/src/binary/ser/payload.rs @@ -99,15 +99,15 @@ fn unsupported(typ: &str) -> Result { } impl<'a, W: Write + ?Sized> Serializer for &'a mut PayloadSerializer<'_, '_, W> { - type Error = Error; type Ok = (); - type SerializeMap = SerializeMap<'a, W>; + type Error = Error; type SerializeSeq = SerializeSeq<'a, W>; - type SerializeStruct = SerializeStruct<'a, W>; - type SerializeStructVariant = Impossible; type SerializeTuple = Impossible; type SerializeTupleStruct = Impossible; type SerializeTupleVariant = Impossible; + type SerializeMap = SerializeMap<'a, W>; + type SerializeStruct = SerializeStruct<'a, W>; + type SerializeStructVariant = Impossible; fn serialize_bool(self, v: bool) -> Result { self.check_state(Tag::Byte)?; diff --git a/valence_nbt/src/binary/ser/root.rs b/valence_nbt/src/binary/ser/root.rs index fc2aeda..5e613e7 100644 --- a/valence_nbt/src/binary/ser/root.rs +++ b/valence_nbt/src/binary/ser/root.rs @@ -33,15 +33,15 @@ fn not_compound(typ: &str) -> Result { } impl<'a, W: Write> Serializer for &'a mut RootSerializer<'_, W> { - type Error = Error; type Ok = (); - type SerializeMap = SerializeMap<'a, W>; + type Error = Error; type SerializeSeq = Impossible; - type SerializeStruct = SerializeStruct<'a, W>; - type SerializeStructVariant = Impossible; type SerializeTuple = Impossible; type SerializeTupleStruct = Impossible; type SerializeTupleVariant = Impossible; + type SerializeMap = SerializeMap<'a, W>; + type SerializeStruct = SerializeStruct<'a, W>; + type SerializeStructVariant = Impossible; fn serialize_bool(self, _v: bool) -> Result { not_compound("bool") diff --git a/valence_nbt/src/binary/ser/seq.rs b/valence_nbt/src/binary/ser/seq.rs index b00cdf9..77a3492 100644 --- a/valence_nbt/src/binary/ser/seq.rs +++ b/valence_nbt/src/binary/ser/seq.rs @@ -50,8 +50,8 @@ impl<'w, W: Write + ?Sized> SerializeSeq<'w, W> { } impl ser::SerializeSeq for SerializeSeq<'_, W> { - type Error = Error; type Ok = (); + type Error = Error; fn serialize_element(&mut self, value: &T) -> Result<(), Self::Error> where diff --git a/valence_nbt/src/binary/ser/structs.rs b/valence_nbt/src/binary/ser/structs.rs index c8587a5..117a71e 100644 --- a/valence_nbt/src/binary/ser/structs.rs +++ b/valence_nbt/src/binary/ser/structs.rs @@ -11,8 +11,8 @@ pub struct SerializeStruct<'w, W: ?Sized> { } impl ser::SerializeStruct for SerializeStruct<'_, W> { - type Error = Error; type Ok = (); + type Error = Error; fn serialize_field( &mut self, diff --git a/valence_nbt/src/value.rs b/valence_nbt/src/value.rs index ba1bd00..930315c 100644 --- a/valence_nbt/src/value.rs +++ b/valence_nbt/src/value.rs @@ -488,13 +488,6 @@ impl<'de, 'a> Visitor<'de> for DeserializeListElement<'a> { visit!(self, Double, v, E) } - fn visit_string(self, v: String) -> Result - where - E: Error, - { - visit!(self, String, v, E) - } - fn visit_str(self, v: &str) -> Result where E: Error, @@ -502,6 +495,13 @@ impl<'de, 'a> Visitor<'de> for DeserializeListElement<'a> { visit!(self, String, v.to_owned(), E) } + fn visit_string(self, v: String) -> Result + where + E: Error, + { + visit!(self, String, v, E) + } + fn visit_seq(self, seq: A) -> Result where A: SeqAccess<'de>,