minor clippy

This commit is contained in:
John Hunter
2023-04-27 14:36:31 +01:00
parent ca9479d2d1
commit 0d11271f41
2 changed files with 34 additions and 29 deletions
+26 -26
View File
@@ -1172,15 +1172,15 @@ struct Subbuffers {
impl PartialEq<InputTypes> for Inputs { impl PartialEq<InputTypes> for Inputs {
fn eq(&self, other: &InputTypes) -> bool { fn eq(&self, other: &InputTypes) -> bool {
match self { match *self {
&Inputs::Variable => true, Inputs::Variable => true,
&Inputs::Float(_) => *other == InputTypes::Float, Inputs::Float(_) => *other == InputTypes::Float,
&Inputs::Vec2(_) => *other == InputTypes::Vec2, Inputs::Vec2(_) => *other == InputTypes::Vec2,
&Inputs::Vec3(_) => *other == InputTypes::Vec3, Inputs::Vec3(_) => *other == InputTypes::Vec3,
&Inputs::Vec4(_) => *other == InputTypes::Vec4, Inputs::Vec4(_) => *other == InputTypes::Vec4,
&Inputs::Mat2(_) => *other == InputTypes::Mat2, Inputs::Mat2(_) => *other == InputTypes::Mat2,
&Inputs::Mat3(_) => *other == InputTypes::Mat3, Inputs::Mat3(_) => *other == InputTypes::Mat3,
&Inputs::Mat4(_) => *other == InputTypes::Mat4, Inputs::Mat4(_) => *other == InputTypes::Mat4,
} }
} }
} }
@@ -1322,8 +1322,8 @@ fn object_size_dependent_setup(
continue 'nextcsg; continue 'nextcsg;
} }
if actual == &Inputs::Variable { if actual == &Inputs::Variable {
match expected { match *expected {
&InputTypes::Float => match runtime_floats.pop() { InputTypes::Float => match runtime_floats.pop() {
Some(u) => { Some(u) => {
if dependencies[u][0] != u8::MAX { if dependencies[u][0] != u8::MAX {
dependencies[u][1] = index as u8 dependencies[u][1] = index as u8
@@ -1336,7 +1336,7 @@ fn object_size_dependent_setup(
continue 'nextcsg; continue 'nextcsg;
} }
}, },
&InputTypes::Vec2 => match runtime_vec2s.pop() { InputTypes::Vec2 => match runtime_vec2s.pop() {
Some(u) => { Some(u) => {
if dependencies[u][0] != u8::MAX { if dependencies[u][0] != u8::MAX {
dependencies[u][1] = index as u8 dependencies[u][1] = index as u8
@@ -1349,7 +1349,7 @@ fn object_size_dependent_setup(
continue 'nextcsg; continue 'nextcsg;
} }
}, },
&InputTypes::Vec3 => match runtime_vec3s.pop() { InputTypes::Vec3 => match runtime_vec3s.pop() {
Some(u) => { Some(u) => {
if u != usize::MAX { if u != usize::MAX {
if dependencies[u][0] != u8::MAX { if dependencies[u][0] != u8::MAX {
@@ -1364,7 +1364,7 @@ fn object_size_dependent_setup(
continue 'nextcsg; continue 'nextcsg;
} }
}, },
&InputTypes::Vec4 => match runtime_vec4s.pop() { InputTypes::Vec4 => match runtime_vec4s.pop() {
Some(u) => { Some(u) => {
if dependencies[u][0] != u8::MAX { if dependencies[u][0] != u8::MAX {
dependencies[u][1] = index as u8 dependencies[u][1] = index as u8
@@ -1377,7 +1377,7 @@ fn object_size_dependent_setup(
continue 'nextcsg; continue 'nextcsg;
} }
}, },
&InputTypes::Mat2 => match runtime_mat2s.pop() { InputTypes::Mat2 => match runtime_mat2s.pop() {
Some(u) => { Some(u) => {
if dependencies[u][0] != u8::MAX { if dependencies[u][0] != u8::MAX {
dependencies[u][1] = index as u8 dependencies[u][1] = index as u8
@@ -1390,7 +1390,7 @@ fn object_size_dependent_setup(
continue 'nextcsg; continue 'nextcsg;
} }
}, },
&InputTypes::Mat3 => match runtime_mat3s.pop() { InputTypes::Mat3 => match runtime_mat3s.pop() {
Some(u) => { Some(u) => {
if dependencies[u][0] != u8::MAX { if dependencies[u][0] != u8::MAX {
dependencies[u][1] = index as u8 dependencies[u][1] = index as u8
@@ -1403,7 +1403,7 @@ fn object_size_dependent_setup(
continue 'nextcsg; continue 'nextcsg;
} }
}, },
&InputTypes::Mat4 => match runtime_mat4s.pop() { InputTypes::Mat4 => match runtime_mat4s.pop() {
Some(u) => { Some(u) => {
if dependencies[u][0] != u8::MAX { if dependencies[u][0] != u8::MAX {
dependencies[u][1] = index as u8 dependencies[u][1] = index as u8
@@ -1418,15 +1418,15 @@ fn object_size_dependent_setup(
}, },
} }
} else { } else {
match actual { match *actual {
&Inputs::Float(f) => floats.push(f as f32), Inputs::Float(f) => floats.push(f as f32),
&Inputs::Vec2(f) => vec2s.push(f.map(|x| x as f32).into()), Inputs::Vec2(f) => vec2s.push(f.map(|x| x as f32).into()),
&Inputs::Vec3(f) => vec4s.push(f.map(|x| x as f32).extend(1.).into()), Inputs::Vec3(f) => vec4s.push(f.map(|x| x as f32).extend(1.).into()),
&Inputs::Vec4(f) => vec4s.push(f.map(|x| x as f32).into()), Inputs::Vec4(f) => vec4s.push(f.map(|x| x as f32).into()),
&Inputs::Mat2(f) => mat2s.push(f64tof32(f.into())), Inputs::Mat2(f) => mat2s.push(f64tof32(f.into())),
&Inputs::Mat3(f) => mat3s.push(f64tof32(f.into())), Inputs::Mat3(f) => mat3s.push(f64tof32(f.into())),
&Inputs::Mat4(f) => mat4s.push(f64tof32(f.into())), Inputs::Mat4(f) => mat4s.push(f64tof32(f.into())),
&Inputs::Variable => unreachable!(), Inputs::Variable => unreachable!(),
} }
} }
} }
+8 -3
View File
@@ -200,7 +200,7 @@ type MCSGObject = HashMap<String, String>;
type MCSGCSG = Vec<MCSGCSGPart>; type MCSGCSG = Vec<MCSGCSGPart>;
type MCSGCSGPart = HashMap<String, String>; type MCSGCSGPart = HashMap<String, String>;
fn matrix3_from_string(input: &String) -> Result<Matrix3<f32>, String> { fn matrix3_from_string(input: &str) -> Result<Matrix3<f32>, String> {
let vec = input let vec = input
.split(' ') .split(' ')
.map(|s| s.parse::<f32>()) .map(|s| s.parse::<f32>())
@@ -211,7 +211,7 @@ fn matrix3_from_string(input: &String) -> Result<Matrix3<f32>, String> {
Ok(*matrix) Ok(*matrix)
} }
fn vector3_from_string(input: &String) -> Result<Vector3<f32>, String> { fn vector3_from_string(input: &str) -> Result<Vector3<f32>, String> {
let vec = input let vec = input
.split(' ') .split(' ')
.map(|s| s.parse::<f32>()) .map(|s| s.parse::<f32>())
@@ -222,7 +222,7 @@ fn vector3_from_string(input: &String) -> Result<Vector3<f32>, String> {
Ok(*vector) Ok(*vector)
} }
fn point3_from_string(input: &String) -> Result<Point3<f32>, String> { fn point3_from_string(input: &str) -> Result<Point3<f32>, String> {
let vec = input let vec = input
.split(' ') .split(' ')
.map(|s| s.parse::<f32>()) .map(|s| s.parse::<f32>())
@@ -242,16 +242,19 @@ fn get_trs(o: &HashMap<String, String>) -> Result<TRS, String> {
Ok(TRS { Ok(TRS {
translation: o translation: o
.get("t") .get("t")
.map(String::as_str)
.map(point3_from_string) .map(point3_from_string)
.transpose()? .transpose()?
.unwrap_or(Point3::origin()), .unwrap_or(Point3::origin()),
rotation: o rotation: o
.get("r") .get("r")
.map(String::as_str)
.map(matrix3_from_string) .map(matrix3_from_string)
.transpose()? .transpose()?
.unwrap_or(Matrix3::identity()), .unwrap_or(Matrix3::identity()),
scale: o scale: o
.get("s") .get("s")
.map(String::as_str)
.map(vector3_from_string) .map(vector3_from_string)
.transpose()? .transpose()?
.unwrap_or(Vector3 { .unwrap_or(Vector3 {
@@ -263,6 +266,7 @@ fn get_trs(o: &HashMap<String, String>) -> Result<TRS, String> {
} }
fn get_color(o: &HashMap<String, String>) -> Result<Vector3<f32>, String> { fn get_color(o: &HashMap<String, String>) -> Result<Vector3<f32>, String> {
Ok(o.get("color") Ok(o.get("color")
.map(String::as_str)
.map(vector3_from_string) .map(vector3_from_string)
.transpose()? .transpose()?
.unwrap_or(Vector3 { .unwrap_or(Vector3 {
@@ -274,6 +278,7 @@ fn get_color(o: &HashMap<String, String>) -> Result<Vector3<f32>, String> {
fn get_rgb(o: &HashMap<String, String>) -> Result<Vector3<f32>, String> { fn get_rgb(o: &HashMap<String, String>) -> Result<Vector3<f32>, String> {
Ok(o.get("rgb") Ok(o.get("rgb")
.map(String::as_str)
.map(vector3_from_string) .map(vector3_from_string)
.transpose()? .transpose()?
.unwrap_or(Vector3 { .unwrap_or(Vector3 {