Closed samueltardieu closed 1 year ago
I'm still on the fence about this elision on whether it's good or not
I've pushed a reformatted version so that cargo format
doesn't complain.
I'm still on the fence about this elision on whether it's good or not
Non-reference patterns have been introduced in Rust 1.26 in an effort to make Rust match
more ergonomic and avoid the explicit use of ref
.
Also note that non-reference patterns are already used in the code, for example at src/decoding.rs:180
(to make b
a &[u8]
):
pub(crate) fn as_bytes(&self) -> &[u8] {
match &self.kind {
DecodingKeyKind::SecretOrDer(b) => b,
DecodingKeyKind::RsaModulusExponent { .. } => unreachable!(),
}
}
or in src/crypto/mod.rs:99
(to make bytes
a &[u8]
, and n
and e
are also auto-references there):
match &key.kind {
DecodingKeyKind::SecretOrDer(bytes) => verify_ring(alg, signature, message, bytes),
DecodingKeyKind::RsaModulusExponent { n, e } => {
rsa::verify_from_components(alg, signature, message, (n, e))
}
}
By using non-reference patterns to match references, the
ref
keyword becomes unnecessary as it is added by the desugaring.