Skip to content

Commit a50d77c

Browse files
Fix some lints
1 parent 84788c9 commit a50d77c

10 files changed

+95
-101
lines changed

src/graphics/canvas.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl CanvasBuilder {
7474
/// # Errors
7575
///
7676
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
77-
/// graphics API encounters an error.
77+
/// graphics API encounters an error.
7878
pub fn build(&self, ctx: &mut Context) -> Result<Canvas> {
7979
let attachments = ctx.device.new_canvas(
8080
self.width,
@@ -139,7 +139,7 @@ impl Canvas {
139139
/// # Errors
140140
///
141141
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
142-
/// graphics API encounters an error.
142+
/// graphics API encounters an error.
143143
pub fn new(ctx: &mut Context, width: i32, height: i32) -> Result<Canvas> {
144144
CanvasBuilder::new(width, height).build(ctx)
145145
}
@@ -213,8 +213,8 @@ impl Canvas {
213213
/// # Errors
214214
///
215215
/// * [`TetraError::NotEnoughData`](crate::TetraError::NotEnoughData) will be returned
216-
/// if not enough data is provided to fill the target rectangle. This is to prevent
217-
/// the graphics API from trying to read uninitialized memory.
216+
/// if not enough data is provided to fill the target rectangle. This is to prevent
217+
/// the graphics API from trying to read uninitialized memory.
218218
///
219219
/// # Panics
220220
///
@@ -246,8 +246,8 @@ impl Canvas {
246246
/// # Errors
247247
///
248248
/// * [`TetraError::NotEnoughData`](crate::TetraError::NotEnoughData) will be returned
249-
/// if not enough data is provided to fill the target rectangle. This is to prevent
250-
/// the graphics API from trying to read uninitialized memory.
249+
/// if not enough data is provided to fill the target rectangle. This is to prevent
250+
/// the graphics API from trying to read uninitialized memory.
251251
pub fn replace_data(&self, ctx: &mut Context, data: &[u8]) -> Result {
252252
self.texture.replace_data(ctx, data)
253253
}

src/graphics/color.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ use crate::math::Vec4;
2222
/// can be enabled via the `serde` feature.
2323
#[repr(C)]
2424
#[derive(Debug, Default, Copy, Clone, PartialEq)]
25-
#[cfg_attr(
26-
feature = "serde",
27-
derive(serde::Serialize, serde::Deserialize)
28-
)]
25+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2926
pub struct Color {
3027
/// The red component of the color.
3128
pub r: f32,
@@ -188,7 +185,7 @@ impl Color {
188185
}
189186

190187
fn clamp_f32(val: f32) -> f32 {
191-
f32::min(f32::max(0.0, val), 1.0)
188+
val.clamp(0.0, 1.0)
192189
}
193190

194191
impl From<Color> for Vec4<f32> {
@@ -544,9 +541,9 @@ mod tests {
544541
}
545542

546543
fn same_color(a: Color, b: Color) -> bool {
547-
(a.r - b.r).abs() < std::f32::EPSILON
548-
&& (a.g - b.g).abs() < std::f32::EPSILON
549-
&& (a.b - b.b).abs() < std::f32::EPSILON
550-
&& (a.a - b.a).abs() < std::f32::EPSILON
544+
(a.r - b.r).abs() < f32::EPSILON
545+
&& (a.g - b.g).abs() < f32::EPSILON
546+
&& (a.b - b.b).abs() < f32::EPSILON
547+
&& (a.a - b.a).abs() < f32::EPSILON
551548
}
552549
}

src/graphics/image_data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl ImageData {
7777
/// # Errors
7878
///
7979
/// * [`TetraError::NotEnoughData`] will be returned if not enough data is provided to fill
80-
/// the image.
80+
/// the image.
8181
pub fn from_data<D>(
8282
width: i32,
8383
height: i32,

src/graphics/mesh.rs

+24-24
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl VertexBuffer {
128128
/// # Errors
129129
///
130130
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
131-
/// graphics API encounters an error.
131+
/// graphics API encounters an error.
132132
pub fn new(ctx: &mut Context, vertices: &[Vertex]) -> Result<VertexBuffer> {
133133
VertexBuffer::with_usage(ctx, vertices, BufferUsage::Dynamic)
134134
}
@@ -140,7 +140,7 @@ impl VertexBuffer {
140140
/// # Errors
141141
///
142142
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
143-
/// graphics API encounters an error.
143+
/// graphics API encounters an error.
144144
pub fn with_usage(
145145
ctx: &mut Context,
146146
vertices: &[Vertex],
@@ -210,7 +210,7 @@ impl IndexBuffer {
210210
/// # Errors
211211
///
212212
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
213-
/// graphics API encounters an error.
213+
/// graphics API encounters an error.
214214
pub fn new(ctx: &mut Context, indices: &[u32]) -> Result<IndexBuffer> {
215215
IndexBuffer::with_usage(ctx, indices, BufferUsage::Dynamic)
216216
}
@@ -222,7 +222,7 @@ impl IndexBuffer {
222222
/// # Errors
223223
///
224224
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
225-
/// graphics API encounters an error.
225+
/// graphics API encounters an error.
226226
pub fn with_usage(
227227
ctx: &mut Context,
228228
indices: &[u32],
@@ -512,9 +512,9 @@ impl Mesh {
512512
/// # Errors
513513
///
514514
/// * [`TetraError::TessellationError`](crate::TetraError::TessellationError) will be returned if the shape
515-
/// could not be turned into vertex data.
515+
/// could not be turned into vertex data.
516516
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
517-
/// graphics API encounters an error.
517+
/// graphics API encounters an error.
518518
pub fn rectangle(ctx: &mut Context, style: ShapeStyle, rectangle: Rectangle) -> Result<Mesh> {
519519
GeometryBuilder::new()
520520
.rectangle(style, rectangle)?
@@ -529,9 +529,9 @@ impl Mesh {
529529
/// # Errors
530530
///
531531
/// * [`TetraError::TessellationError`](crate::TetraError::TessellationError) will be returned if the shape
532-
/// could not be turned into vertex data.
532+
/// could not be turned into vertex data.
533533
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
534-
/// graphics API encounters an error.
534+
/// graphics API encounters an error.
535535
pub fn rounded_rectangle(
536536
ctx: &mut Context,
537537
style: ShapeStyle,
@@ -551,9 +551,9 @@ impl Mesh {
551551
/// # Errors
552552
///
553553
/// * [`TetraError::TessellationError`](crate::TetraError::TessellationError) will be returned if the shape
554-
/// could not be turned into vertex data.
554+
/// could not be turned into vertex data.
555555
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
556-
/// graphics API encounters an error.
556+
/// graphics API encounters an error.
557557
pub fn circle(
558558
ctx: &mut Context,
559559
style: ShapeStyle,
@@ -573,9 +573,9 @@ impl Mesh {
573573
/// # Errors
574574
///
575575
/// * [`TetraError::TessellationError`](crate::TetraError::TessellationError) will be returned if the shape
576-
/// could not be turned into vertex data.
576+
/// could not be turned into vertex data.
577577
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
578-
/// graphics API encounters an error.
578+
/// graphics API encounters an error.
579579
pub fn ellipse(
580580
ctx: &mut Context,
581581
style: ShapeStyle,
@@ -595,9 +595,9 @@ impl Mesh {
595595
/// # Errors
596596
///
597597
/// * [`TetraError::TessellationError`](crate::TetraError::TessellationError) will be returned if the shape
598-
/// could not be turned into vertex data.
598+
/// could not be turned into vertex data.
599599
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
600-
/// graphics API encounters an error.
600+
/// graphics API encounters an error.
601601
pub fn polygon(ctx: &mut Context, style: ShapeStyle, points: &[Vec2<f32>]) -> Result<Mesh> {
602602
GeometryBuilder::new()
603603
.polygon(style, points)?
@@ -612,9 +612,9 @@ impl Mesh {
612612
/// # Errors
613613
///
614614
/// * [`TetraError::TessellationError`](crate::TetraError::TessellationError) will be returned if the shape
615-
/// could not be turned into vertex data.
615+
/// could not be turned into vertex data.
616616
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
617-
/// graphics API encounters an error.
617+
/// graphics API encounters an error.
618618
pub fn polyline(ctx: &mut Context, stroke_width: f32, points: &[Vec2<f32>]) -> Result<Mesh> {
619619
GeometryBuilder::new()
620620
.polyline(stroke_width, points)?
@@ -690,7 +690,7 @@ impl GeometryBuilder {
690690
/// # Errors
691691
///
692692
/// * [`TetraError::TessellationError`](crate::TetraError::TessellationError) will be returned if the shape
693-
/// could not be turned into vertex data.
693+
/// could not be turned into vertex data.
694694
pub fn rectangle(
695695
&mut self,
696696
style: ShapeStyle,
@@ -724,7 +724,7 @@ impl GeometryBuilder {
724724
/// # Errors
725725
///
726726
/// * [`TetraError::TessellationError`](crate::TetraError::TessellationError) will be returned if the shape
727-
/// could not be turned into vertex data.
727+
/// could not be turned into vertex data.
728728
pub fn rounded_rectangle(
729729
&mut self,
730730
style: ShapeStyle,
@@ -759,7 +759,7 @@ impl GeometryBuilder {
759759
/// # Errors
760760
///
761761
/// * [`TetraError::TessellationError`](crate::TetraError::TessellationError) will be returned if the shape
762-
/// could not be turned into vertex data.
762+
/// could not be turned into vertex data.
763763
pub fn circle(
764764
&mut self,
765765
style: ShapeStyle,
@@ -806,7 +806,7 @@ impl GeometryBuilder {
806806
/// # Errors
807807
///
808808
/// * [`TetraError::TessellationError`](crate::TetraError::TessellationError) will be returned if the shape
809-
/// could not be turned into vertex data.
809+
/// could not be turned into vertex data.
810810
pub fn ellipse(
811811
&mut self,
812812
style: ShapeStyle,
@@ -857,7 +857,7 @@ impl GeometryBuilder {
857857
/// # Errors
858858
///
859859
/// * [`TetraError::TessellationError`](crate::TetraError::TessellationError) will be returned if the shape
860-
/// could not be turned into vertex data.
860+
/// could not be turned into vertex data.
861861
pub fn polygon(
862862
&mut self,
863863
style: ShapeStyle,
@@ -903,7 +903,7 @@ impl GeometryBuilder {
903903
/// # Errors
904904
///
905905
/// * [`TetraError::TessellationError`](crate::TetraError::TessellationError) will be returned if the shape
906-
/// could not be turned into vertex data.
906+
/// could not be turned into vertex data.
907907
pub fn polyline(
908908
&mut self,
909909
stroke_width: f32,
@@ -971,7 +971,7 @@ impl GeometryBuilder {
971971
/// # Errors
972972
///
973973
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
974-
/// graphics API encounters an error.
974+
/// graphics API encounters an error.
975975
pub fn build_buffers(&self, ctx: &mut Context) -> Result<(VertexBuffer, IndexBuffer)> {
976976
Ok((
977977
VertexBuffer::new(ctx, &self.data.vertices)?,
@@ -986,7 +986,7 @@ impl GeometryBuilder {
986986
/// # Errors
987987
///
988988
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the underlying
989-
/// graphics API encounters an error.
989+
/// graphics API encounters an error.
990990
pub fn build_mesh(&self, ctx: &mut Context) -> Result<Mesh> {
991991
let (vertex_buffer, index_buffer) = self.build_buffers(ctx)?;
992992

src/graphics/shader.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ impl Shader {
107107
/// # Errors
108108
///
109109
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the
110-
/// underlying graphics API encounters an error.
110+
/// underlying graphics API encounters an error.
111111
/// * [`TetraError::FailedToLoadAsset`](crate::TetraError::FailedToLoadAsset) will be returned
112-
/// if the files could not be loaded.
112+
/// if the files could not be loaded.
113113
/// * [`TetraError::InvalidShader`](crate::TetraError::InvalidShader) will be returned if the
114-
/// shader could not be compiled.
114+
/// shader could not be compiled.
115115
pub fn new<P>(ctx: &mut Context, vertex_path: P, fragment_path: P) -> Result<Shader>
116116
where
117117
P: AsRef<Path>,
@@ -130,11 +130,11 @@ impl Shader {
130130
/// # Errors
131131
///
132132
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the
133-
/// underlying graphics API encounters an error.
133+
/// underlying graphics API encounters an error.
134134
/// * [`TetraError::FailedToLoadAsset`](crate::TetraError::FailedToLoadAsset) will be returned
135-
/// if the file could not be loaded.
135+
/// if the file could not be loaded.
136136
/// * [`TetraError::InvalidShader`](crate::TetraError::InvalidShader) will be returned if the
137-
/// shader could not be compiled.
137+
/// shader could not be compiled.
138138
pub fn from_vertex_file<P>(ctx: &mut Context, path: P) -> Result<Shader>
139139
where
140140
P: AsRef<Path>,
@@ -153,11 +153,11 @@ impl Shader {
153153
/// # Errors
154154
///
155155
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the
156-
/// underlying graphics API encounters an error.
156+
/// underlying graphics API encounters an error.
157157
/// * [`TetraError::FailedToLoadAsset`](crate::TetraError::FailedToLoadAsset) will be returned
158-
/// if the file could not be loaded.
158+
/// if the file could not be loaded.
159159
/// * [`TetraError::InvalidShader`](crate::TetraError::InvalidShader) will be returned if the
160-
/// shader could not be compiled.
160+
/// shader could not be compiled.
161161
pub fn from_fragment_file<P>(ctx: &mut Context, path: P) -> Result<Shader>
162162
where
163163
P: AsRef<Path>,
@@ -174,9 +174,9 @@ impl Shader {
174174
/// # Errors
175175
///
176176
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the
177-
/// underlying graphics API encounters an error.
177+
/// underlying graphics API encounters an error.
178178
/// * [`TetraError::InvalidShader`](crate::TetraError::InvalidShader) will be returned if the
179-
/// shader could not be compiled.
179+
/// shader could not be compiled.
180180
pub fn from_string(
181181
ctx: &mut Context,
182182
vertex_shader: &str,
@@ -192,9 +192,9 @@ impl Shader {
192192
/// # Errors
193193
///
194194
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the
195-
/// underlying graphics API encounters an error.
195+
/// underlying graphics API encounters an error.
196196
/// * [`TetraError::InvalidShader`](crate::TetraError::InvalidShader) will be returned if the
197-
/// shader could not be compiled.
197+
/// shader could not be compiled.
198198
pub fn from_vertex_string(ctx: &mut Context, shader: &str) -> Result<Shader> {
199199
Shader::with_device(&mut ctx.device, shader, DEFAULT_FRAGMENT_SHADER)
200200
}
@@ -206,9 +206,9 @@ impl Shader {
206206
/// # Errors
207207
///
208208
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the
209-
/// underlying graphics API encounters an error.
209+
/// underlying graphics API encounters an error.
210210
/// * [`TetraError::InvalidShader`](crate::TetraError::InvalidShader) will be returned if the
211-
/// shader could not be compiled.
211+
/// shader could not be compiled.
212212
pub fn from_fragment_string(ctx: &mut Context, shader: &str) -> Result<Shader> {
213213
Shader::with_device(&mut ctx.device, DEFAULT_VERTEX_SHADER, shader)
214214
}

src/graphics/text.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ impl Font {
7272
/// # Errors
7373
///
7474
/// * [`TetraError::FailedToLoadAsset`](crate::TetraError::FailedToLoadAsset) will be returned
75-
/// if the file could not be loaded.
75+
/// if the file could not be loaded.
7676
/// * [`TetraError::InvalidFont`](crate::TetraError::InvalidFont) will be returned if the font
77-
/// data was invalid.
77+
/// data was invalid.
7878
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the GPU cache for the font
7979
/// could not be created.
8080
#[cfg(feature = "font_ttf")]
@@ -98,9 +98,9 @@ impl Font {
9898
/// # Errors
9999
///
100100
/// * [`TetraError::InvalidFont`](crate::TetraError::InvalidFont) will be returned if the font
101-
/// data was invalid.
101+
/// data was invalid.
102102
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the GPU cache for the font
103-
/// could not be created.
103+
/// could not be created.
104104
#[cfg(feature = "font_ttf")]
105105
pub fn from_vector_file_data(
106106
ctx: &mut Context,
@@ -137,11 +137,11 @@ impl Font {
137137
/// # Errors
138138
///
139139
/// * [`TetraError::FailedToLoadAsset`](crate::TetraError::FailedToLoadAsset) will be returned
140-
/// if the font or the associated images could not be loaded.
140+
/// if the font or the associated images could not be loaded.
141141
/// * [`TetraError::InvalidFont`](crate::TetraError::InvalidFont) will be returned if the font
142-
/// data was invalid.
142+
/// data was invalid.
143143
/// * [`TetraError::PlatformError`](crate::TetraError::PlatformError) will be returned if the GPU cache for the font
144-
/// could not be created.
144+
/// could not be created.
145145
pub fn bmfont<P>(ctx: &mut Context, path: P) -> Result<Font>
146146
where
147147
P: AsRef<Path>,

0 commit comments

Comments
 (0)