default: Better usage of the default Trait

This commit is contained in:
Clement RENAULT 2017-06-13 10:25:21 +02:00
parent 1becc239e4
commit eda92188c9
2 changed files with 9 additions and 3 deletions

View File

@ -112,3 +112,9 @@ pub fn verify(signature: &str, signing_input: &str, key: &[u8], algorithm: Algor
Algorithm::RS512 => verify_rsa(&signature::RSA_PKCS1_2048_8192_SHA512, signature, signing_input, key),
}
}
impl Default for Algorithm {
fn default() -> Self {
Algorithm::HS256
}
}

View File

@ -56,8 +56,8 @@ impl Header {
}
impl Default for Header {
/// Returns a JWT header using HS256
fn default() -> Header {
Header::new(Algorithm::HS256)
/// Returns a JWT header using the default Algorithm, HS256
fn default() -> Self {
Header::new(Algorithm::default())
}
}