Skip to content

Commit de96942

Browse files
authored
Merge pull request #100 from SlimeYummy/issue/clippy
fix clippy
2 parents d8b7730 + 7cc7b79 commit de96942

18 files changed

+161
-172
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919

2020
steps:
2121
- uses: actions/checkout@v3
22+
- name: Clippy
23+
run: cargo clippy -p ozz-animation-rs -- --no-deps
2224
- name: Build
2325
run: cargo build --release
2426
- name: Run tests

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ozz-animation-rs"
3-
version = "0.10.0"
3+
version = "0.10.1"
44
authors = ["SlimeYummy <zzzcccnnn@outlook.com>"]
55
edition = "2021"
66
rust-version = "1.75"

demo/src/blend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl OzzBlend {
109109

110110
impl OzzExample for OzzBlend {
111111
fn root(&self) -> Mat4 {
112-
return self.models.buf().unwrap()[0];
112+
self.models.buf().unwrap()[0]
113113
}
114114

115115
fn bone_trans(&self) -> &[OzzTransform] {

demo/src/playback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl OzzPlayback {
6969

7070
impl OzzExample for OzzPlayback {
7171
fn root(&self) -> Mat4 {
72-
return self.models.buf().unwrap()[0];
72+
self.models.buf().unwrap()[0]
7373
}
7474

7575
fn bone_trans(&self) -> &[OzzTransform] {

demo/src/two_bone_ik.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl OzzTwoBoneIK {
7070

7171
impl OzzExample for OzzTwoBoneIK {
7272
fn root(&self) -> Mat4 {
73-
return self.models2.buf().unwrap()[0];
73+
self.models2.buf().unwrap()[0]
7474
}
7575

7676
fn bone_trans(&self) -> &[OzzTransform] {

src/animation.rs

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ impl Animation {
403403
archive.read_slice(animation.s_iframe_desc_mut())?;
404404
animation.s_iframe_interval = archive.read()?;
405405
archive.read_slice(animation.scales_mut())?;
406-
407406
Ok(animation)
408407
}
409408

@@ -465,7 +464,7 @@ impl Animation {
465464
}
466465

467466
pub(crate) fn to_raw(&self) -> AnimationRaw {
468-
return AnimationRaw {
467+
AnimationRaw {
469468
duration: self.duration,
470469
num_tracks: self.num_tracks,
471470
name: self.name.clone(),
@@ -491,7 +490,7 @@ impl Animation {
491490
s_iframe_interval: self.s_iframe_interval,
492491
s_iframe_entries: self.s_iframe_entries().to_vec(),
493492
s_iframe_desc: self.s_iframe_desc().to_vec(),
494-
};
493+
}
495494
}
496495

497496
fn new(meta: AnimationMeta) -> Animation {
@@ -652,207 +651,207 @@ impl Animation {
652651
/// Gets the buffer of time points.
653652
#[inline]
654653
pub fn timepoints(&self) -> &[f32] {
655-
return unsafe { slice::from_raw_parts(self.timepoints, self.timepoints_count as usize) };
654+
unsafe { slice::from_raw_parts(self.timepoints, self.timepoints_count as usize) }
656655
}
657656

658657
#[inline]
659658
fn timepoints_mut(&mut self) -> &mut [f32] {
660-
return unsafe { slice::from_raw_parts_mut(self.timepoints, self.timepoints_count as usize) };
659+
unsafe { slice::from_raw_parts_mut(self.timepoints, self.timepoints_count as usize) }
661660
}
662661

663662
/// Gets the buffer of translation keys.
664663
#[inline]
665664
pub fn translations(&self) -> &[Float3Key] {
666-
return unsafe { slice::from_raw_parts(self.translations, self.translations_count as usize) };
665+
unsafe { slice::from_raw_parts(self.translations, self.translations_count as usize) }
667666
}
668667

669668
#[inline]
670669
fn translations_mut(&mut self) -> &mut [Float3Key] {
671-
return unsafe { slice::from_raw_parts_mut(self.translations, self.translations_count as usize) };
670+
unsafe { slice::from_raw_parts_mut(self.translations, self.translations_count as usize) }
672671
}
673672

674673
#[inline]
675674
fn t_ratios(&self) -> &[u16] {
676-
return unsafe { slice::from_raw_parts(self.t_ratios, self.translations_count as usize) };
675+
unsafe { slice::from_raw_parts(self.t_ratios, self.translations_count as usize) }
677676
}
678677

679678
#[inline]
680679
fn t_ratios_mut(&mut self) -> &mut [u16] {
681-
return unsafe { slice::from_raw_parts_mut(self.t_ratios, self.translations_count as usize) };
680+
unsafe { slice::from_raw_parts_mut(self.t_ratios, self.translations_count as usize) }
682681
}
683682

684683
#[inline]
685684
fn t_previouses(&self) -> &[u16] {
686-
return unsafe { slice::from_raw_parts(self.t_previouses, self.translations_count as usize) };
685+
unsafe { slice::from_raw_parts(self.t_previouses, self.translations_count as usize) }
687686
}
688687

689688
#[inline]
690689
fn t_previouses_mut(&mut self) -> &mut [u16] {
691-
return unsafe { slice::from_raw_parts_mut(self.t_previouses, self.translations_count as usize) };
690+
unsafe { slice::from_raw_parts_mut(self.t_previouses, self.translations_count as usize) }
692691
}
693692

694693
#[inline]
695694
fn t_iframe_entries(&self) -> &[u8] {
696-
return unsafe { slice::from_raw_parts(self.t_iframe_entries, self.t_iframe_entries_count as usize) };
695+
unsafe { slice::from_raw_parts(self.t_iframe_entries, self.t_iframe_entries_count as usize) }
697696
}
698697

699698
#[inline]
700699
fn t_iframe_entries_mut(&mut self) -> &mut [u8] {
701-
return unsafe { slice::from_raw_parts_mut(self.t_iframe_entries, self.t_iframe_entries_count as usize) };
700+
unsafe { slice::from_raw_parts_mut(self.t_iframe_entries, self.t_iframe_entries_count as usize) }
702701
}
703702

704703
#[inline]
705704
fn t_iframe_desc(&self) -> &[u32] {
706-
return unsafe { slice::from_raw_parts(self.t_iframe_desc, self.t_iframe_desc_count as usize) };
705+
unsafe { slice::from_raw_parts(self.t_iframe_desc, self.t_iframe_desc_count as usize) }
707706
}
708707

709708
#[inline]
710709
fn t_iframe_desc_mut(&mut self) -> &mut [u32] {
711-
return unsafe { slice::from_raw_parts_mut(self.t_iframe_desc, self.t_iframe_desc_count as usize) };
710+
unsafe { slice::from_raw_parts_mut(self.t_iframe_desc, self.t_iframe_desc_count as usize) }
712711
}
713712

714713
/// Gets the buffer of rotation keys.
715714
#[inline]
716715
pub fn rotations(&self) -> &[QuaternionKey] {
717-
return unsafe { slice::from_raw_parts(self.rotations, self.rotations_count as usize) };
716+
unsafe { slice::from_raw_parts(self.rotations, self.rotations_count as usize) }
718717
}
719718

720719
#[inline]
721720
fn rotations_mut(&mut self) -> &mut [QuaternionKey] {
722-
return unsafe { slice::from_raw_parts_mut(self.rotations, self.rotations_count as usize) };
721+
unsafe { slice::from_raw_parts_mut(self.rotations, self.rotations_count as usize) }
723722
}
724723

725724
#[inline]
726725
fn r_ratios(&self) -> &[u16] {
727-
return unsafe { slice::from_raw_parts(self.r_ratios, self.rotations_count as usize) };
726+
unsafe { slice::from_raw_parts(self.r_ratios, self.rotations_count as usize) }
728727
}
729728

730729
#[inline]
731730
fn r_ratios_mut(&mut self) -> &mut [u16] {
732-
return unsafe { slice::from_raw_parts_mut(self.r_ratios, self.rotations_count as usize) };
731+
unsafe { slice::from_raw_parts_mut(self.r_ratios, self.rotations_count as usize) }
733732
}
734733

735734
#[inline]
736735
fn r_previouses(&self) -> &[u16] {
737-
return unsafe { slice::from_raw_parts(self.r_previouses, self.rotations_count as usize) };
736+
unsafe { slice::from_raw_parts(self.r_previouses, self.rotations_count as usize) }
738737
}
739738

740739
#[inline]
741740
fn r_previouses_mut(&mut self) -> &mut [u16] {
742-
return unsafe { slice::from_raw_parts_mut(self.r_previouses, self.rotations_count as usize) };
741+
unsafe { slice::from_raw_parts_mut(self.r_previouses, self.rotations_count as usize) }
743742
}
744743

745744
#[inline]
746745
fn r_iframe_entries(&self) -> &[u8] {
747-
return unsafe { slice::from_raw_parts(self.r_iframe_entries, self.r_iframe_entries_count as usize) };
746+
unsafe { slice::from_raw_parts(self.r_iframe_entries, self.r_iframe_entries_count as usize) }
748747
}
749748

750749
#[inline]
751750
fn r_iframe_entries_mut(&mut self) -> &mut [u8] {
752-
return unsafe { slice::from_raw_parts_mut(self.r_iframe_entries, self.r_iframe_entries_count as usize) };
751+
unsafe { slice::from_raw_parts_mut(self.r_iframe_entries, self.r_iframe_entries_count as usize) }
753752
}
754753

755754
#[inline]
756755
fn r_iframe_desc(&self) -> &[u32] {
757-
return unsafe { slice::from_raw_parts(self.r_iframe_desc, self.r_iframe_desc_count as usize) };
756+
unsafe { slice::from_raw_parts(self.r_iframe_desc, self.r_iframe_desc_count as usize) }
758757
}
759758

760759
#[inline]
761760
fn r_iframe_desc_mut(&mut self) -> &mut [u32] {
762-
return unsafe { slice::from_raw_parts_mut(self.r_iframe_desc, self.r_iframe_desc_count as usize) };
761+
unsafe { slice::from_raw_parts_mut(self.r_iframe_desc, self.r_iframe_desc_count as usize) }
763762
}
764763

765764
/// Gets the buffer of scale keys.
766765
#[inline]
767766
pub fn scales(&self) -> &[Float3Key] {
768-
return unsafe { slice::from_raw_parts(self.scales, self.scales_count as usize) };
767+
unsafe { slice::from_raw_parts(self.scales, self.scales_count as usize) }
769768
}
770769

771770
#[inline]
772771
fn scales_mut(&mut self) -> &mut [Float3Key] {
773-
return unsafe { slice::from_raw_parts_mut(self.scales, self.scales_count as usize) };
772+
unsafe { slice::from_raw_parts_mut(self.scales, self.scales_count as usize) }
774773
}
775774

776775
#[inline]
777776
fn s_ratios(&self) -> &[u16] {
778-
return unsafe { slice::from_raw_parts(self.s_ratios, self.scales_count as usize) };
777+
unsafe { slice::from_raw_parts(self.s_ratios, self.scales_count as usize) }
779778
}
780779

781780
#[inline]
782781
fn s_ratios_mut(&mut self) -> &mut [u16] {
783-
return unsafe { slice::from_raw_parts_mut(self.s_ratios, self.scales_count as usize) };
782+
unsafe { slice::from_raw_parts_mut(self.s_ratios, self.scales_count as usize) }
784783
}
785784

786785
#[inline]
787786
fn s_previouses(&self) -> &[u16] {
788-
return unsafe { slice::from_raw_parts(self.s_previouses, self.scales_count as usize) };
787+
unsafe { slice::from_raw_parts(self.s_previouses, self.scales_count as usize) }
789788
}
790789

791790
#[inline]
792791
fn s_previouses_mut(&mut self) -> &mut [u16] {
793-
return unsafe { slice::from_raw_parts_mut(self.s_previouses, self.scales_count as usize) };
792+
unsafe { slice::from_raw_parts_mut(self.s_previouses, self.scales_count as usize) }
794793
}
795794

796795
#[inline]
797796
fn s_iframe_entries(&self) -> &[u8] {
798-
return unsafe { slice::from_raw_parts(self.s_iframe_entries, self.s_iframe_entries_count as usize) };
797+
unsafe { slice::from_raw_parts(self.s_iframe_entries, self.s_iframe_entries_count as usize) }
799798
}
800799

801800
#[inline]
802801
fn s_iframe_entries_mut(&mut self) -> &mut [u8] {
803-
return unsafe { slice::from_raw_parts_mut(self.s_iframe_entries, self.s_iframe_entries_count as usize) };
802+
unsafe { slice::from_raw_parts_mut(self.s_iframe_entries, self.s_iframe_entries_count as usize) }
804803
}
805804

806805
#[inline]
807806
fn s_iframe_desc(&self) -> &[u32] {
808-
return unsafe { slice::from_raw_parts(self.s_iframe_desc, self.s_iframe_desc_count as usize) };
807+
unsafe { slice::from_raw_parts(self.s_iframe_desc, self.s_iframe_desc_count as usize) }
809808
}
810809

811810
#[inline]
812811
fn s_iframe_desc_mut(&mut self) -> &mut [u32] {
813-
return unsafe { slice::from_raw_parts_mut(self.s_iframe_desc, self.s_iframe_desc_count as usize) };
812+
unsafe { slice::from_raw_parts_mut(self.s_iframe_desc, self.s_iframe_desc_count as usize) }
814813
}
815814

816815
/// Gets the buffer of translation keys.
817816
#[inline]
818817
pub fn translations_ctrl(&self) -> KeyframesCtrl<'_> {
819-
return unsafe {
818+
unsafe {
820819
KeyframesCtrl {
821820
ratios: slice::from_raw_parts(self.t_ratios, self.translations_count as usize),
822821
previouses: slice::from_raw_parts(self.t_previouses, self.translations_count as usize),
823822
iframe_entries: slice::from_raw_parts(self.t_iframe_entries, self.t_iframe_entries_count as usize),
824823
iframe_desc: slice::from_raw_parts(self.t_iframe_desc, self.t_iframe_desc_count as usize),
825824
iframe_interval: self.t_iframe_interval,
826825
}
827-
};
826+
}
828827
}
829828

830829
/// Gets the buffer of rotation keys.
831830
#[inline]
832831
pub fn rotations_ctrl(&self) -> KeyframesCtrl<'_> {
833-
return unsafe {
832+
unsafe {
834833
KeyframesCtrl {
835834
ratios: slice::from_raw_parts(self.r_ratios, self.rotations_count as usize),
836835
previouses: slice::from_raw_parts(self.r_previouses, self.rotations_count as usize),
837836
iframe_entries: slice::from_raw_parts(self.r_iframe_entries, self.r_iframe_entries_count as usize),
838837
iframe_desc: slice::from_raw_parts(self.r_iframe_desc, self.r_iframe_desc_count as usize),
839838
iframe_interval: self.r_iframe_interval,
840839
}
841-
};
840+
}
842841
}
843842

844843
/// Gets the buffer of scale keys.
845844
#[inline]
846845
pub fn scales_ctrl(&self) -> KeyframesCtrl<'_> {
847-
return unsafe {
846+
unsafe {
848847
KeyframesCtrl {
849848
ratios: slice::from_raw_parts(self.s_ratios, self.scales_count as usize),
850849
previouses: slice::from_raw_parts(self.s_previouses, self.scales_count as usize),
851850
iframe_entries: slice::from_raw_parts(self.s_iframe_entries, self.s_iframe_entries_count as usize),
852851
iframe_desc: slice::from_raw_parts(self.s_iframe_desc, self.s_iframe_desc_count as usize),
853852
iframe_interval: self.s_iframe_interval,
854853
}
855-
};
854+
}
856855
}
857856
}
858857

src/archive.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ impl<R: Read> Archive<R> {
4343

4444
let version = archive.read::<u32>()?;
4545
archive.version = version;
46-
4746
Ok(archive)
4847
}
4948

@@ -105,9 +104,9 @@ impl Archive<Cursor<Vec<u8>>> {
105104
#[cfg(all(feature = "wasm", feature = "nodejs"))]
106105
pub fn from_path(path: &str) -> Result<Archive<Cursor<Vec<u8>>>, OzzError> {
107106
match crate::nodejs::read_file(path) {
108-
Ok(buf) => return Archive::from_vec(buf),
109-
Err(err) => return Err(OzzError::Custom(Box::new(err.as_string().unwrap_or("".into())))),
110-
};
107+
Ok(buf) => Archive::from_vec(buf),
108+
Err(err) => Err(OzzError::Custom(Box::new(err.as_string().unwrap_or("".into())))),
109+
}
111110
}
112111
}
113112

0 commit comments

Comments
 (0)