Skip to content

Commit

Permalink
made clippy happy
Browse files Browse the repository at this point in the history
- just disabled `clippy::excessive_precision` lint for `validate_cornell`test
  • Loading branch information
renpenguin committed Jan 17, 2024
1 parent 2772049 commit 80743a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
7 changes: 3 additions & 4 deletions examples/print_mesh.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
fn main() {
let obj_file = std::env::args()
.skip(1)
.next()
.nth(1)
.expect("A .obj file to print is required");

let (models, materials) =
tobj::load_obj(&obj_file, &tobj::LoadOptions::default()).expect("Failed to OBJ load file");
tobj::load_obj(obj_file, &tobj::LoadOptions::default()).expect("Failed to OBJ load file");

// Note: If you don't mind missing the materials, you can generate a default.
let materials = materials.expect("Failed to load MTL file");
Expand All @@ -15,7 +14,7 @@ fn main() {

for (i, m) in models.iter().enumerate() {
let mesh = &m.mesh;
println!("");
println!();
println!("model[{}].name = \'{}\'", i, m.name);
println!("model[{}].mesh.material_id = {:?}", i, mesh.material_id);

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ fn export_faces(
}
Face::Polygon(ref indices) => {
if load_options.triangulate {
let a = indices.get(0).ok_or(LoadError::InvalidPolygon)?;
let a = indices.first().ok_or(LoadError::InvalidPolygon)?;
let mut b = indices.get(1).ok_or(LoadError::InvalidPolygon)?;
for c in indices.iter().skip(2) {
add_vertex(&mut mesh, &mut index_map, a, pos, v_color, texcoord, normal)?;
Expand Down Expand Up @@ -1327,7 +1327,7 @@ fn export_faces_multi_index(
}
Face::Polygon(ref indices) => {
if load_options.triangulate {
let a = indices.get(0).ok_or(LoadError::InvalidPolygon)?;
let a = indices.first().ok_or(LoadError::InvalidPolygon)?;
let mut b = indices.get(1).ok_or(LoadError::InvalidPolygon)?;
for c in indices.iter().skip(2) {
add_vertex_multi_index(
Expand Down
7 changes: 4 additions & 3 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::{

use crate as tobj;

const CORNELL_BOX_OBJ: &'static str = include_str!("../obj/cornell_box.obj");
const CORNELL_BOX_MTL1: &'static str = include_str!("../obj/cornell_box.mtl");
const CORNELL_BOX_MTL2: &'static str = include_str!("../obj/cornell_box2.mtl");
const CORNELL_BOX_OBJ: &str = include_str!("../obj/cornell_box.obj");
const CORNELL_BOX_MTL1: &str = include_str!("../obj/cornell_box.mtl");
const CORNELL_BOX_MTL2: &str = include_str!("../obj/cornell_box2.mtl");

// Set the tolerance for float comparison
use crate::Float;
Expand Down Expand Up @@ -271,6 +271,7 @@ fn multiple_face_formats() {
assert!(tri.texcoords.is_empty());
}

#[allow(clippy::excessive_precision)]
fn validate_cornell(models: Vec<tobj::Model>, mats: Vec<tobj::Material>) {
// Verify the floor loaded properly
assert_eq!(models[0].name, "floor");
Expand Down

0 comments on commit 80743a4

Please sign in to comment.