Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
robtfm committed Nov 29, 2024
1 parent 9bbf6cc commit 49db215
Show file tree
Hide file tree
Showing 28 changed files with 78 additions and 93 deletions.
25 changes: 7 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/avatar/src/avatar_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub struct BoothInstance {
#[derive(Resource, Default)]
pub struct LiveBooths(Vec<Arc<Entity>>);

impl<'w, 's> PhotoBooth<'w, 's> {
impl PhotoBooth<'_, '_> {
pub fn spawn_booth(
&mut self,
render_layers: RenderLayers,
Expand Down
2 changes: 1 addition & 1 deletion crates/collectibles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub enum CollectibleError {

const RETAIN_TICKS: u32 = 3;

impl<'w, 's, T: CollectibleType> CollectibleManager<'w, 's, T> {
impl<T: CollectibleType> CollectibleManager<'_, '_, T> {
pub fn get_hash(
&mut self,
urn: impl AsRef<CollectibleUrn<T>>,
Expand Down
6 changes: 3 additions & 3 deletions crates/common/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ pub trait ModifyComponentExt {
) -> &mut Self;
}

impl<'a> ModifyComponentExt for EntityCommands<'a> {
impl ModifyComponentExt for EntityCommands<'_> {
fn modify_component<C: Component, F: FnOnce(&mut C) + Send + Sync + 'static>(
&mut self,
func: F,
Expand Down Expand Up @@ -396,7 +396,7 @@ pub trait ModifyDefaultComponentExt {
) -> &mut Self;
}

impl<'a> ModifyDefaultComponentExt for EntityCommands<'a> {
impl ModifyDefaultComponentExt for EntityCommands<'_> {
fn default_and_modify_component<
C: Component + Default,
F: FnOnce(&mut C) + Send + Sync + 'static,
Expand All @@ -423,7 +423,7 @@ pub struct VolumePanning<'w, 's> {
receiver: Query<'w, 's, &'static GlobalTransform, With<AudioReceiver>>,
}

impl<'w, 's> VolumePanning<'w, 's> {
impl VolumePanning<'_, '_> {
pub fn volume_and_panning(&self, translation: Vec3) -> (f32, f32) {
let Ok(receiver) = self.receiver.get_single() else {
return (1.0, 0.5);
Expand Down
2 changes: 1 addition & 1 deletion crates/comms/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub struct AdapterManager<'w, 's> {
_p: PhantomData<&'s ()>,
}

impl<'w, 's> AdapterManager<'w, 's> {
impl AdapterManager<'_, '_> {
pub fn connect(&mut self, adapter: &str) -> Option<Entity> {
let Some((protocol, address)) = adapter.split_once(':') else {
warn!("unrecognised adapter string: {adapter}");
Expand Down
2 changes: 1 addition & 1 deletion crates/comms/src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct ProfileManager<'w, 's> {

pub struct ProfileMissingError;

impl<'w, 's> ProfileManager<'w, 's> {
impl ProfileManager<'_, '_> {
pub fn get_data(
&mut self,
address: Address,
Expand Down
2 changes: 1 addition & 1 deletion crates/dcl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ deno_webidl = "0.168"
deno_web = "0.199"
deno_websocket = "0.173"

num-derive = "0.3"
num-derive = "0.4.2"
num = "0.4"
num-traits = "0.2"
http = "0.2.9"
Expand Down
56 changes: 26 additions & 30 deletions crates/dcl/src/crdt/lww.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ mod test {

if let Some(data) = data {
assert_eq!(
T::from_reader(&mut DclReader::new(&output_data)).unwrap(),
T::from_reader(&mut DclReader::new(output_data)).unwrap(),
data
);
}
Expand All @@ -215,7 +215,7 @@ mod test {
let buf = data.to_le_bytes();
let mut reader = DclReader::new(&buf);

assert_eq!(state.try_update(entity, timestamp, Some(&mut reader)), true);
assert!(state.try_update(entity, timestamp, Some(&mut reader)));

assert_entry_eq(state, entity, timestamp, Some(data));
}
Expand All @@ -233,11 +233,10 @@ mod test {
let buf = data.to_le_bytes();

let mut reader = DclReader::new(&buf);
assert_eq!(state.try_update(entity, timestamp, Some(&mut reader)), true);
assert!(state.try_update(entity, timestamp, Some(&mut reader)));
let mut reader = DclReader::new(&buf);
assert_eq!(
state.try_update(entity, timestamp, Some(&mut reader)),
false
assert!(
!state.try_update(entity, timestamp, Some(&mut reader))
);

assert_entry_eq(state, entity, timestamp, Some(data));
Expand All @@ -256,13 +255,13 @@ mod test {
let buf = data.to_le_bytes();

let mut reader = DclReader::new(&buf);
assert_eq!(state.try_update(entity, timestamp, Some(&mut reader)), true);
assert!(state.try_update(entity, timestamp, Some(&mut reader)));

let timestamp = SceneCrdtTimestamp(1);
let newer_data = 999u32;
let buf = newer_data.to_le_bytes();
let mut reader = DclReader::new(&buf);
assert_eq!(state.try_update(entity, timestamp, Some(&mut reader)), true);
assert!(state.try_update(entity, timestamp, Some(&mut reader)));

assert_entry_eq(state, entity, timestamp, Some(newer_data));
}
Expand All @@ -280,15 +279,14 @@ mod test {
let buf = data.to_le_bytes();

let mut reader = DclReader::new(&buf);
assert_eq!(state.try_update(entity, timestamp, Some(&mut reader)), true);
assert!(state.try_update(entity, timestamp, Some(&mut reader)));

let older_timestamp = SceneCrdtTimestamp(0);
let newer_data = 999u32;
let buf = newer_data.to_le_bytes();
let mut reader = DclReader::new(&buf);
assert_eq!(
state.try_update(entity, older_timestamp, Some(&mut reader)),
false
assert!(
!state.try_update(entity, older_timestamp, Some(&mut reader))
);

assert_entry_eq(state, entity, timestamp, Some(data));
Expand All @@ -307,12 +305,12 @@ mod test {
let buf = data.to_le_bytes();

let mut reader = DclReader::new(&buf);
assert_eq!(state.try_update(entity, timestamp, Some(&mut reader)), true);
assert!(state.try_update(entity, timestamp, Some(&mut reader)));

let higher_data = 2u32;
let buf = higher_data.to_le_bytes();
let mut reader = DclReader::new(&buf);
assert_eq!(state.try_update(entity, timestamp, Some(&mut reader)), true);
assert!(state.try_update(entity, timestamp, Some(&mut reader)));

assert_entry_eq(state, entity, timestamp, Some(higher_data));
}
Expand All @@ -330,9 +328,9 @@ mod test {
let buf = data.to_le_bytes();

let mut reader = DclReader::new(&buf);
assert_eq!(state.try_update(entity, timestamp, Some(&mut reader)), true);
assert!(state.try_update(entity, timestamp, Some(&mut reader)));

assert_eq!(state.try_update(entity, timestamp, None), false);
assert!(!state.try_update(entity, timestamp, None));

assert_entry_eq(state, entity, timestamp, Some(data));
}
Expand All @@ -350,10 +348,10 @@ mod test {
let buf = data.to_le_bytes();

let mut reader = DclReader::new(&buf);
assert_eq!(state.try_update(entity, timestamp, Some(&mut reader)), true);
assert!(state.try_update(entity, timestamp, Some(&mut reader)));

let newer_timestamp = SceneCrdtTimestamp(2);
assert_eq!(state.try_update(entity, newer_timestamp, None), true);
assert!(state.try_update(entity, newer_timestamp, None));

assert_entry_eq(state, entity, newer_timestamp, Option::<u32>::None);
}
Expand All @@ -371,11 +369,11 @@ mod test {
let buf = data.to_le_bytes();

let mut reader = DclReader::new(&buf);
assert_eq!(state.try_update(entity, timestamp, Some(&mut reader)), true);
assert!(state.try_update(entity, timestamp, Some(&mut reader)));

let newer_timestamp = SceneCrdtTimestamp(2);
assert_eq!(state.try_update(entity, newer_timestamp, None), true);
assert_eq!(state.try_update(entity, newer_timestamp, None), false);
assert!(state.try_update(entity, newer_timestamp, None));
assert!(!state.try_update(entity, newer_timestamp, None));

assert_entry_eq(state, entity, newer_timestamp, Option::<u32>::None);
}
Expand All @@ -393,17 +391,16 @@ mod test {
let buf = data.to_le_bytes();

let mut reader = DclReader::new(&buf);
assert_eq!(state.try_update(entity, timestamp, Some(&mut reader)), true);
assert!(state.try_update(entity, timestamp, Some(&mut reader)));

let newer_timestamp = SceneCrdtTimestamp(2);
assert_eq!(state.try_update(entity, newer_timestamp, None), true);
assert!(state.try_update(entity, newer_timestamp, None));

let data = 3u32;
let buf = data.to_le_bytes();
let mut reader = DclReader::new(&buf);
assert_eq!(
state.try_update(entity, newer_timestamp, Some(&mut reader)),
true
assert!(
state.try_update(entity, newer_timestamp, Some(&mut reader))
);

assert_entry_eq(state, entity, newer_timestamp, Some(data));
Expand All @@ -421,13 +418,12 @@ mod test {
let buf = 1231u32.to_le_bytes();

let mut reader = DclReader::new(&buf);
assert_eq!(state.try_update(entity, timestamp, Some(&mut reader)), true);
assert!(state.try_update(entity, timestamp, Some(&mut reader)));

let newer_timestamp = SceneCrdtTimestamp(2);
let mut reader = DclReader::new(&[]);
assert_eq!(
state.try_update(entity, newer_timestamp, Some(&mut reader)),
true
assert!(
state.try_update(entity, newer_timestamp, Some(&mut reader))
);

assert_entry_eq(state, entity, newer_timestamp, Some(Vec::<u8>::default()));
Expand Down
4 changes: 2 additions & 2 deletions crates/dcl_component/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'a> DclWriter<'a> {
}
}

impl<'a> Deref for DclWriter<'a> {
impl Deref for DclWriter<'_> {
type Target = [u8];

fn deref(&self) -> &Self::Target {
Expand All @@ -73,7 +73,7 @@ pub trait ToDclWriter {
}
}

unsafe impl<'a> prost::bytes::BufMut for DclWriter<'a> {
unsafe impl prost::bytes::BufMut for DclWriter<'_> {
fn remaining_mut(&self) -> usize {
self.buffer.remaining_mut()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/imposters/src/bake_scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ fn pick_imposter_to_bake(
for x in imposter.parcel.x..imposter.parcel.x + size {
for y in imposter.parcel.y..imposter.parcel.y + size {
if let Some(PointerResult::Exists { hash, .. }) =
scene_pointers.get(&IVec2::new(x, y))
scene_pointers.get(IVec2::new(x, y))
{
if live_scenes.0.get(hash).is_some() {
// skip due to live scene
Expand Down
2 changes: 1 addition & 1 deletion crates/imposters/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub struct ImposterLookup<'w, 's> {
asset_server: Res<'w, AssetServer>,
}

impl<'w, 's> ImposterLookup<'w, 's> {
impl ImposterLookup<'_, '_> {
fn imposter_state(
entities: &HashMap<(IVec2, usize, bool), Entity>,
imposters: &Query<(Option<&ImposterMissing>, Option<&Children>)>,
Expand Down
2 changes: 1 addition & 1 deletion crates/input_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub struct InputManager<'w> {
should_accept: Res<'w, AcceptInput>,
}

impl<'w> InputManager<'w> {
impl InputManager<'_> {
pub fn any_just_acted(&self) -> bool {
self.mouse_input.get_just_pressed().len() != 0
|| self.mouse_input.get_just_released().len() != 0
Expand Down
2 changes: 1 addition & 1 deletion crates/ipfs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ pub struct IpfsAssetServer<'w, 's> {
_p: PhantomData<&'s ()>,
}

impl<'w, 's> IpfsAssetServer<'w, 's> {
impl IpfsAssetServer<'_, '_> {
pub fn load_content_file<T: Asset>(
&self,
file_path: &str,
Expand Down
1 change: 1 addition & 0 deletions crates/scene_runner/src/bounds_calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ mod test {
}
}

#[allow(clippy::single_element_loop)]
for test in [vec![
IVec2::new(0, 0),
IVec2::new(1, 1),
Expand Down
Loading

0 comments on commit 49db215

Please sign in to comment.