Skip to content

Commit 9385c6d

Browse files
committed
Use Self more.
1 parent 1c36465 commit 9385c6d

File tree

16 files changed

+43
-43
lines changed

16 files changed

+43
-43
lines changed

src/aead.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<A: AsRef<[u8]>> Aad<A> {
7474
/// Construct the `Aad` from the given bytes.
7575
#[inline]
7676
pub fn from(aad: A) -> Self {
77-
Aad(aad)
77+
Self(aad)
7878
}
7979
}
8080

src/aead/chacha20_poly1305_openssh.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ pub struct SealingKey {
4545

4646
impl SealingKey {
4747
/// Constructs a new `SealingKey`.
48-
pub fn new(key_material: &[u8; KEY_LEN]) -> SealingKey {
49-
SealingKey {
48+
pub fn new(key_material: &[u8; KEY_LEN]) -> Self {
49+
Self {
5050
key: Key::new(key_material, cpu::features()),
5151
}
5252
}
@@ -92,8 +92,8 @@ pub struct OpeningKey {
9292

9393
impl OpeningKey {
9494
/// Constructs a new `OpeningKey`.
95-
pub fn new(key_material: &[u8; KEY_LEN]) -> OpeningKey {
96-
OpeningKey {
95+
pub fn new(key_material: &[u8; KEY_LEN]) -> Self {
96+
Self {
9797
key: Key::new(key_material, cpu::features()),
9898
}
9999
}
@@ -153,10 +153,10 @@ struct Key {
153153
}
154154

155155
impl Key {
156-
fn new(key_material: &[u8; KEY_LEN], cpu_features: cpu::Features) -> Key {
156+
fn new(key_material: &[u8; KEY_LEN], cpu_features: cpu::Features) -> Self {
157157
// The first half becomes K_2 and the second half becomes K_1.
158158
let &[k_2, k_1]: &[[u8; chacha::KEY_LEN]; 2] = key_material.chunks_fixed();
159-
Key {
159+
Self {
160160
k_1: k_1.into(),
161161
k_2: k_2.into(),
162162
cpu_features,

src/aead/gcm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub struct Context {
8686

8787
impl Context {
8888
pub(crate) fn new(key: &Key, aad: Aad<&[u8]>, cpu_features: cpu::Features) -> Self {
89-
let mut ctx = Context {
89+
let mut ctx = Self {
9090
inner: ContextInner {
9191
Xi: Xi(Block::zero()),
9292
_unused: Block::zero(),

src/agreement.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ derive_debug_via_field!(Algorithm, curve);
8181

8282
impl Eq for Algorithm {}
8383
impl PartialEq for Algorithm {
84-
fn eq(&self, other: &Algorithm) -> bool {
84+
fn eq(&self, other: &Self) -> bool {
8585
self.curve.id == other.curve.id
8686
}
8787
}

src/arithmetic/bigint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ impl<M> Elem<M, Unencoded> {
432432
input: untrusted::Input,
433433
m: &Modulus<M>,
434434
) -> Result<Self, error::Unspecified> {
435-
Ok(Elem {
435+
Ok(Self {
436436
limbs: BoxedLimbs::from_be_bytes_padded_less_than(input, m)?,
437437
encoding: PhantomData,
438438
})

src/bits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ impl BitLength {
5757

5858
#[cfg(feature = "alloc")]
5959
#[inline]
60-
pub fn try_sub_1(self) -> Result<BitLength, error::Unspecified> {
60+
pub fn try_sub_1(self) -> Result<Self, error::Unspecified> {
6161
let sum = self.0.checked_sub(1).ok_or(error::Unspecified)?;
62-
Ok(BitLength(sum))
62+
Ok(Self(sum))
6363
}
6464
}

src/digest/sha2.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,17 @@ const MAX_ROUNDS: usize = 80;
178178
pub(super) const CHAINING_WORDS: usize = 8;
179179

180180
impl Word for Wrapping<u32> {
181-
const ZERO: Self = Wrapping(0);
181+
const ZERO: Self = Self(0);
182182
type InputBytes = [u8; 4];
183183

184184
#[inline(always)]
185185
fn from_be_bytes(input: Self::InputBytes) -> Self {
186-
Wrapping(u32::from_be_bytes(input))
186+
Self(u32::from_be_bytes(input))
187187
}
188188

189189
#[inline(always)]
190190
fn rotr(self, count: u32) -> Self {
191-
Wrapping(self.0.rotate_right(count))
191+
Self(self.0.rotate_right(count))
192192
}
193193
}
194194

@@ -270,17 +270,17 @@ impl Sha2 for Wrapping<u32> {
270270
}
271271

272272
impl Word for Wrapping<u64> {
273-
const ZERO: Self = Wrapping(0);
273+
const ZERO: Self = Self(0);
274274
type InputBytes = [u8; 8];
275275

276276
#[inline(always)]
277277
fn from_be_bytes(input: Self::InputBytes) -> Self {
278-
Wrapping(u64::from_be_bytes(input))
278+
Self(u64::from_be_bytes(input))
279279
}
280280

281281
#[inline(always)]
282282
fn rotr(self, count: u32) -> Self {
283-
Wrapping(self.0.rotate_right(count))
283+
Self(self.0.rotate_right(count))
284284
}
285285
}
286286

src/ec/keys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl Seed {
4545
curve: &'static Curve,
4646
bytes: untrusted::Input,
4747
cpu_features: cpu::Features,
48-
) -> Result<Seed, error::Unspecified> {
48+
) -> Result<Self, error::Unspecified> {
4949
let bytes = bytes.as_slice_less_safe();
5050
if curve.elem_scalar_seed_len != bytes.len() {
5151
return Err(error::Unspecified);

src/ec/suite_b/ecdsa/signing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl NonceRandomKey {
358358
let mut ctx = digest::Context::new(alg.digest_alg);
359359
ctx.update(rand);
360360
ctx.update(seed.bytes_less_safe());
361-
Ok(NonceRandomKey(ctx.finish()))
361+
Ok(Self(ctx.finish()))
362362
}
363363
}
364364

src/ec/suite_b/ops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ pub struct Point {
4343
}
4444

4545
impl Point {
46-
pub fn new_at_infinity() -> Point {
47-
Point {
46+
pub fn new_at_infinity() -> Self {
47+
Self {
4848
xyz: [0; 3 * MAX_LIMBS],
4949
}
5050
}

0 commit comments

Comments
 (0)