Skip to content

Commit c15a222

Browse files
committed
unwrap where error is impossible
1 parent 292913b commit c15a222

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

keypair/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,9 @@ pub fn keypair_from_seed(seed: &[u8]) -> Result<Keypair, Box<dyn error::Error>>
262262
if seed.len() < ed25519_dalek::SECRET_KEY_LENGTH {
263263
return Err("Seed is too short".into());
264264
}
265-
let secret_key = ed25519_dalek::SecretKey::try_from(&seed[..ed25519_dalek::SECRET_KEY_LENGTH])
266-
.map_err(|e| e.to_string())?;
265+
// this won't fail as we've already checked the length
266+
let secret_key =
267+
ed25519_dalek::SecretKey::try_from(&seed[..ed25519_dalek::SECRET_KEY_LENGTH]).unwrap();
267268
Ok(Keypair(ed25519_dalek::SigningKey::from(secret_key)))
268269
}
269270

0 commit comments

Comments
 (0)