Skip to content

Commit ca2f840

Browse files
committed
Make from_char_unchecked public
The `from_char_unchecked` function is useful outside for users of the crate, make it public and document the panic case. Add rustdocs to `from_char` and `from_char_unchecked`, and make `from_char_unchecked` public.
1 parent b7767ee commit ca2f840

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/primitives/gf32.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ impl Fe32 {
177177
}
178178

179179
/// Creates a field element from a single bech32 character.
180+
///
181+
/// # Errors
182+
///
183+
/// If the input char is not part of the bech32 alphabet.
180184
#[inline]
181185
pub fn from_char(c: char) -> Result<Fe32, FromCharError> {
182186
use FromCharError::*;
@@ -191,7 +195,12 @@ impl Fe32 {
191195
Ok(Fe32(u5))
192196
}
193197

194-
pub(crate) fn from_char_unchecked(c: u8) -> Fe32 { Fe32(CHARS_INV[usize::from(c)] as u8) }
198+
/// Creates a field element from a single bech32 character.
199+
///
200+
/// # Panics
201+
///
202+
/// If the input character is not part of the bech32 alphabet.
203+
pub fn from_char_unchecked(c: u8) -> Fe32 { Fe32(CHARS_INV[usize::from(c)] as u8) }
195204

196205
/// Converts the field element to a lowercase bech32 character.
197206
#[inline]

0 commit comments

Comments
 (0)