changed match to 'matches!' (#31850)

This commit is contained in:
Aarya Khandelwal 2024-03-25 16:58:12 +05:30 committed by GitHub
parent 9a76dd9325
commit bd39e03eeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 185 additions and 229 deletions

View file

@ -627,17 +627,16 @@ impl WebGLRenderingContext {
}
fn validate_stencil_actions(&self, action: u32) -> bool {
match action {
0 |
constants::KEEP |
constants::REPLACE |
constants::INCR |
constants::DECR |
constants::INVERT |
constants::INCR_WRAP |
constants::DECR_WRAP => true,
_ => false,
}
matches!(
action,
0 | constants::KEEP |
constants::REPLACE |
constants::INCR |
constants::DECR |
constants::INVERT |
constants::INCR_WRAP |
constants::DECR_WRAP
)
}
pub fn get_image_pixels(&self, source: TexImageSource) -> Fallible<Option<TexPixels>> {
@ -3146,23 +3145,20 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
.attachment(attachment)
{
Some(attachment_root) => match attachment_root {
WebGLFramebufferAttachmentRoot::Renderbuffer(_) => match pname {
WebGLFramebufferAttachmentRoot::Renderbuffer(_) => matches!(
pname,
constants::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE |
constants::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME => true,
_ => false,
},
WebGLFramebufferAttachmentRoot::Texture(_) => match pname {
constants::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
),
WebGLFramebufferAttachmentRoot::Texture(_) => matches!(
pname,
constants::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE |
constants::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME |
constants::FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL |
constants::FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE => true,
_ => false,
},
},
_ => match pname {
constants::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE => true,
_ => false,
constants::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME |
constants::FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL |
constants::FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE
),
},
_ => matches!(pname, constants::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE),
};
if !target_matches || !attachment_matches || !pname_matches || !bound_attachment_matches {
@ -3212,18 +3208,18 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://github.com/immersive-web/webxr/issues/862
let target_matches = target == constants::RENDERBUFFER;
let pname_matches = match pname {
let pname_matches = matches!(
pname,
constants::RENDERBUFFER_WIDTH |
constants::RENDERBUFFER_HEIGHT |
constants::RENDERBUFFER_INTERNAL_FORMAT |
constants::RENDERBUFFER_RED_SIZE |
constants::RENDERBUFFER_GREEN_SIZE |
constants::RENDERBUFFER_BLUE_SIZE |
constants::RENDERBUFFER_ALPHA_SIZE |
constants::RENDERBUFFER_DEPTH_SIZE |
constants::RENDERBUFFER_STENCIL_SIZE => true,
_ => false,
};
constants::RENDERBUFFER_HEIGHT |
constants::RENDERBUFFER_INTERNAL_FORMAT |
constants::RENDERBUFFER_RED_SIZE |
constants::RENDERBUFFER_GREEN_SIZE |
constants::RENDERBUFFER_BLUE_SIZE |
constants::RENDERBUFFER_ALPHA_SIZE |
constants::RENDERBUFFER_DEPTH_SIZE |
constants::RENDERBUFFER_STENCIL_SIZE
);
if !target_matches || !pname_matches {
self.webgl_error(InvalidEnum);