diff options
author | eri <eri@inventati.org> | 2024-03-08 16:28:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-08 15:28:19 +0000 |
commit | 43f44965cda8751e04195bf4c4f298147907843f (patch) | |
tree | 970527d416716fcd82caf89a5821c050b62a6145 /components/shared/canvas | |
parent | 3a5ca785d3ecc1fd6cb5a519cf1a91ac61e15c8c (diff) | |
download | servo-43f44965cda8751e04195bf4c4f298147907843f.tar.gz servo-43f44965cda8751e04195bf4c4f298147907843f.zip |
clippy: fix warnings in components/shared (#31565)
* clippy: fix some warnings in components/shared
* fix: unit tests
* fix: review comments
Diffstat (limited to 'components/shared/canvas')
-rw-r--r-- | components/shared/canvas/canvas.rs | 51 | ||||
-rw-r--r-- | components/shared/canvas/webgl.rs | 29 |
2 files changed, 31 insertions, 49 deletions
diff --git a/components/shared/canvas/canvas.rs b/components/shared/canvas/canvas.rs index d984dd05ded..f656b5dc92d 100644 --- a/components/shared/canvas/canvas.rs +++ b/components/shared/canvas/canvas.rs @@ -115,11 +115,11 @@ impl LinearGradientStyle { stops: Vec<CanvasGradientStop>, ) -> LinearGradientStyle { LinearGradientStyle { - x0: x0, - y0: y0, - x1: x1, - y1: y1, - stops: stops, + x0, + y0, + x1, + y1, + stops, } } } @@ -146,13 +146,13 @@ impl RadialGradientStyle { stops: Vec<CanvasGradientStop>, ) -> RadialGradientStyle { RadialGradientStyle { - x0: x0, - y0: y0, - r0: r0, - x1: x1, - y1: y1, - r1: r1, - stops: stops, + x0, + y0, + r0, + x1, + y1, + r1, + stops, } } } @@ -402,8 +402,9 @@ impl FromStr for CompositionOrBlending { } } -#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Default, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum TextAlign { + #[default] Start, End, Left, @@ -426,17 +427,12 @@ impl FromStr for TextAlign { } } -impl Default for TextAlign { - fn default() -> TextAlign { - TextAlign::Start - } -} - -#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Default, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum TextBaseline { Top, Hanging, Middle, + #[default] Alphabetic, Ideographic, Bottom, @@ -458,16 +454,11 @@ impl FromStr for TextBaseline { } } -impl Default for TextBaseline { - fn default() -> TextBaseline { - TextBaseline::Alphabetic - } -} - -#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Default, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum Direction { Ltr, Rtl, + #[default] Inherit, } @@ -483,9 +474,3 @@ impl FromStr for Direction { } } } - -impl Default for Direction { - fn default() -> Direction { - Direction::Inherit - } -} diff --git a/components/shared/canvas/webgl.rs b/components/shared/canvas/webgl.rs index 820f3bc7925..31d22bb3f52 100644 --- a/components/shared/canvas/webgl.rs +++ b/components/shared/canvas/webgl.rs @@ -140,10 +140,7 @@ pub struct WebGLMsgSender { impl WebGLMsgSender { pub fn new(id: WebGLContextId, sender: WebGLChan) -> Self { - WebGLMsgSender { - ctx_id: id, - sender: sender, - } + WebGLMsgSender { ctx_id: id, sender } } /// Returns the WebGLContextId associated to this sender @@ -922,7 +919,7 @@ mod gl_ext_constants { pub const COMPRESSED_RGBA_S3TC_DXT5_EXT: GLenum = 0x83F3; pub const COMPRESSED_RGB_ETC1_WEBGL: GLenum = 0x8D64; - pub static COMPRESSIONS: &'static [GLenum] = &[ + pub static COMPRESSIONS: &[GLenum] = &[ COMPRESSED_RGB_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, @@ -1061,18 +1058,18 @@ impl TexFormat { /// Returns whether this format is a known sized or unsized format. pub fn is_sized(&self) -> bool { - match self { + !matches!( + self, TexFormat::DepthComponent | - TexFormat::DepthStencil | - TexFormat::Alpha | - TexFormat::Red | - TexFormat::RG | - TexFormat::RGB | - TexFormat::RGBA | - TexFormat::Luminance | - TexFormat::LuminanceAlpha => false, - _ => true, - } + TexFormat::DepthStencil | + TexFormat::Alpha | + TexFormat::Red | + TexFormat::RG | + TexFormat::RGB | + TexFormat::RGBA | + TexFormat::Luminance | + TexFormat::LuminanceAlpha + ) } pub fn to_unsized(self) -> TexFormat { |