Skip to content

Commit 181ca4e

Browse files
committed
Rename serialize_secret -> into_secret
The `serialize_secret` method is a conversion method. Rust naming conventions for conversion methods that take a reference and returned an owned type that implements `Copy` stipulate that the method should be named `into_`. Rename `serialize_secret` to be `into_secret`.
1 parent 5af56ec commit 181ca4e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/key.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ impl SecretKey {
212212
SecretKey(sk)
213213
}
214214

215-
/// Serializes the secret key as byte value.
215+
/// Gets the secret key as a byte value.
216216
#[inline]
217-
pub fn serialize_secret(&self) -> [u8; constants::SECRET_KEY_SIZE] {
217+
pub fn into_secret(&self) -> [u8; constants::SECRET_KEY_SIZE] {
218218
self.0
219219
}
220220

@@ -809,9 +809,9 @@ impl KeyPair {
809809
KeyPair::new(SECP256K1, rng)
810810
}
811811

812-
/// Serializes the key pair as a secret key byte value.
812+
/// Gets the secret bytes for this key pair.
813813
#[inline]
814-
pub fn serialize_secret(&self) -> [u8; constants::SECRET_KEY_SIZE] {
814+
pub fn into_secret(&self) -> [u8; constants::SECRET_KEY_SIZE] {
815815
*SecretKey::from_keypair(self).as_ref()
816816
}
817817

src/secret.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ macro_rules! impl_display_secret {
3535

3636
hasher.write(DEBUG_HASH_TAG);
3737
hasher.write(DEBUG_HASH_TAG);
38-
hasher.write(&self.serialize_secret());
38+
hasher.write(&self.into_secret());
3939
let hash = hasher.finish();
4040

4141
f.debug_tuple(stringify!($thing))
@@ -55,7 +55,7 @@ macro_rules! impl_display_secret {
5555
let tag_hash = sha256::Hash::hash(tag.as_bytes());
5656
engine.input(&tag_hash[..]);
5757
engine.input(&tag_hash[..]);
58-
engine.input(&self.serialize_secret());
58+
engine.input(&self.into_secret());
5959
let hash = sha256::Hash::from_engine(engine);
6060

6161
f.debug_tuple(stringify!($thing))
@@ -139,7 +139,7 @@ impl SecretKey {
139139
/// ```
140140
#[inline]
141141
pub fn display_secret(&self) -> DisplaySecret {
142-
DisplaySecret { secret: self.serialize_secret() }
142+
DisplaySecret { secret: self.into_secret() }
143143
}
144144
}
145145

@@ -180,6 +180,6 @@ impl KeyPair {
180180
/// ```
181181
#[inline]
182182
pub fn display_secret(&self) -> DisplaySecret {
183-
DisplaySecret { secret: self.serialize_secret() }
183+
DisplaySecret { secret: self.into_secret() }
184184
}
185185
}

0 commit comments

Comments
 (0)