From b49ed146c07df628bb5f5fb58ba5019128e16b7c Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Mon, 29 Jul 2024 23:12:56 +0400 Subject: [PATCH] doc fixes --- crates/five8_const/README.md | 2 +- crates/five8_const/src/lib.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/five8_const/README.md b/crates/five8_const/README.md index 86f3aa0..8e7e898 100644 --- a/crates/five8_const/README.md +++ b/crates/five8_const/README.md @@ -12,7 +12,7 @@ While the first two functions return `Result` types, the `_unwrap` functions are more useful for declaring constants: ```rust -const EXAMPLE: [u8; 32] = decode_32_const_unwrap("JEKNVnkbo3jma5nREBBJCDoXFVeKkD56V3xKrvRmWxFF"); +const EXAMPLE: [u8; 32] = five8_const::decode_32_const_unwrap("JEKNVnkbo3jma5nREBBJCDoXFVeKkD56V3xKrvRmWxFF"); ``` If you want to base58 encoding or decoding at runtime, diff --git a/crates/five8_const/src/lib.rs b/crates/five8_const/src/lib.rs index 47e8ad5..caf1149 100644 --- a/crates/five8_const/src/lib.rs +++ b/crates/five8_const/src/lib.rs @@ -1,3 +1,4 @@ +#![doc = include_str!("../README.md")] use five8_core::{ DecodeError, BASE58_ENCODED_32_MAX_LEN, BASE58_ENCODED_64_MAX_LEN, BASE58_INVALID_CHAR, BASE58_INVERSE, BASE58_INVERSE_TABLE_OFFSET, BASE58_INVERSE_TABLE_SENTINEL, BINARY_SZ_32, @@ -192,6 +193,7 @@ const fn decode_const_unwrap< } } +/// Try decode into a 32-byte array. pub const fn decode_32_const(encoded: &str) -> Result<[u8; N_32], DecodeError> { decode_const::( encoded, @@ -199,6 +201,7 @@ pub const fn decode_32_const(encoded: &str) -> Result<[u8; N_32], DecodeError> { ) } +/// Decode into a 32-byte array. Panic on error. pub const fn decode_32_const_unwrap(encoded: &str) -> [u8; N_32] { decode_const_unwrap::< N_32, @@ -209,6 +212,7 @@ pub const fn decode_32_const_unwrap(encoded: &str) -> [u8; N_32] { >(encoded, &DEC_TABLE_32) } +/// Try decode into a 64-byte array. pub const fn decode_64_const(encoded: &str) -> Result<[u8; N_64], DecodeError> { decode_const::( encoded, @@ -216,6 +220,7 @@ pub const fn decode_64_const(encoded: &str) -> Result<[u8; N_64], DecodeError> { ) } +/// Decode into a 64-byte array. Panic on error. pub const fn decode_64_const_unwrap(encoded: &str) -> [u8; N_64] { decode_const_unwrap::< N_64,