Move Mnemonic::parse_in above Mnemonic::parse

This commit is contained in:
Steven Roose 2020-09-22 12:36:12 +02:00
parent cb9d5f91d8
commit 077d594aca
No known key found for this signature in database
GPG Key ID: 2F2A88D7F8D68E87
1 changed files with 8 additions and 8 deletions

View File

@ -260,6 +260,14 @@ impl Mnemonic {
Err(Error::AmbiguousWordList(langs))
}
/// Parse a mnemonic in the given language.
pub fn parse_in<'a, S: Into<Cow<'a, str>>>(language: Language, s: S) -> Result<Mnemonic, Error> {
let mut cow = s.into();
Mnemonic::normalize_utf8_cow(&mut cow);
Mnemonic::validate_in(language, cow.as_ref())?;
Ok(Mnemonic(cow.into_owned()))
}
/// Parse a mnemonic and detect the language from the enabled languages.
pub fn parse<'a, S: Into<Cow<'a, str>>>(s: S) -> Result<Mnemonic, Error> {
let mut cow = s.into();
@ -269,14 +277,6 @@ impl Mnemonic {
Ok(Mnemonic(cow.into_owned()))
}
/// Parse a mnemonic in the given language.
pub fn parse_in<'a, S: Into<Cow<'a, str>>>(language: Language, s: S) -> Result<Mnemonic, Error> {
let mut cow = s.into();
Mnemonic::normalize_utf8_cow(&mut cow);
Mnemonic::validate_in(language, cow.as_ref())?;
Ok(Mnemonic(cow.into_owned()))
}
/// Get the mnemonic as a [&str].
pub fn as_str(&self) -> &str {
&self.0