Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
=========

# v1.0.1

- Add static `Mnemonic::language_of` method.
- Add `Mnemonic::language` getter method.

# v1.0.0

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bip39"
version = "1.0.0"
version = "1.0.1"
authors = ["Steven Roose <steven@stevenroose.org>"]
license = "CC0-1.0"
homepage = "https://github.com/rust-bitcoin/rust-bip39/"
Expand Down
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,20 @@ impl Mnemonic {
/// word lists. In the extremely unlikely case that a word list can be
/// interpreted in multiple languages, an [Error::AmbiguousLanguages] is
/// returned, containing the possible languages.
fn language_of<S: AsRef<str>>(mnemonic: S) -> Result<Language, Error> {
pub fn language_of<S: AsRef<str>>(mnemonic: S) -> Result<Language, Error> {
Mnemonic::language_of_iter(mnemonic.as_ref().split_whitespace())
}

/// Get this mnemonic's language.
///
/// Some word lists don't guarantee that their words don't occur in other
/// word lists. In the extremely unlikely case that a word list can be
/// interpreted in multiple languages, an [Error::AmbiguousLanguages] is
/// returned, containing the possible languages.
pub fn language(&self) -> Result<Language, Error> {
Mnemonic::language_of_iter(self.word_iter())
}

/// Parse a mnemonic in normalized UTF8 in the given language.
pub fn parse_in_normalized(language: Language, s: &str) -> Result<Mnemonic, Error> {
let nb_words = s.split_whitespace().count();
Expand Down