Skip to content

Commit

Permalink
Merge pull request #10
Browse files Browse the repository at this point in the history
v1.0.2RC
  • Loading branch information
cubicle-jockey authored Aug 10, 2024
2 parents d1163cb + 48c83b3 commit 4cf9a71
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cj_common"
version = "1.0.1"
version = "1.0.2"
edition = "2021"
keywords = ["hex", "base64", "range", "bit", "inset"]
categories = ["encoding", "parsing"]
Expand Down
18 changes: 9 additions & 9 deletions src/cj_binary/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const HEX_TABLE_LOWER: [&str; 256] = [
///
/// assert_eq!(u8_to_hex_str(&0xD1), "D1");
/// ```
#[inline]
#[inline(always)]
pub const fn u8_to_hex_str(value: &u8) -> &'static str {
HEX_TABLE[*value as usize]
}
Expand All @@ -77,7 +77,7 @@ pub const fn u8_to_hex_str(value: &u8) -> &'static str {
///
/// assert_eq!(u8_to_hex_low_str(&0xD1), "d1");
/// ```
#[inline]
#[inline(always)]
pub const fn u8_to_hex_low_str(value: &u8) -> &'static str {
HEX_TABLE_LOWER[*value as usize]
}
Expand All @@ -88,7 +88,7 @@ pub const fn u8_to_hex_low_str(value: &u8) -> &'static str {
///
/// assert_eq!(u8_to_hex(&0xD1), "D1".to_string());
/// ```
#[inline]
#[inline(always)]
pub fn u8_to_hex(value: &u8) -> String {
HEX_TABLE[*value as usize].to_string()
}
Expand All @@ -99,7 +99,7 @@ pub fn u8_to_hex(value: &u8) -> String {
///
/// assert_eq!(u8_to_hex_low(&0xD1), "d1".to_string());
/// ```
#[inline]
#[inline(always)]
pub fn u8_to_hex_low(value: &u8) -> String {
HEX_TABLE_LOWER[*value as usize].to_string()
}
Expand All @@ -111,7 +111,7 @@ pub fn u8_to_hex_low(value: &u8) -> String {
/// let array = [0xA0,0xA1,0xA2];
/// assert_eq!(u8_array_to_hex(&array),"A0A1A2");
/// ```
#[inline]
#[inline(always)]
pub fn u8_array_to_hex(value: &[u8]) -> String {
let mut rslt = String::with_capacity(value.len() * 2);
value.iter().for_each(|f| rslt.push_str(u8_to_hex_str(f)));
Expand All @@ -126,7 +126,7 @@ pub fn u8_array_to_hex(value: &[u8]) -> String {
/// let array = [0xA0,0xA1,0xA2];
/// assert_eq!(u8_array_to_hex_low(&array),"a0a1a2");
/// ```
#[inline]
#[inline(always)]
pub fn u8_array_to_hex_low(value: &[u8]) -> String {
let mut rslt = String::with_capacity(value.len() * 2);
value
Expand All @@ -143,7 +143,7 @@ pub fn u8_array_to_hex_low(value: &[u8]) -> String {
/// assert_eq!(hex_char_to_u8(&'A'),Some(0x0A));
/// assert_eq!(hex_char_to_u8(&'G'),None);
/// ```
#[inline]
#[inline(always)]
pub const fn hex_char_to_u8(hex1: &char) -> Option<u8> {
let r = match hex1 {
'0' => 0u8,
Expand Down Expand Up @@ -177,7 +177,7 @@ pub const fn hex_char_to_u8(hex1: &char) -> Option<u8> {
/// assert_eq!(hex_str_to_u8("AB"),Some(0xAB));
/// assert_eq!(hex_str_to_u8("G"),None);
/// ```
#[inline]
#[inline(always)]
pub fn hex_str_to_u8(hex2: &str) -> Option<u8> {
if hex2.len() > 0 {
let mut r: u8;
Expand Down Expand Up @@ -407,7 +407,7 @@ pub type HexArray = [char; 2];
/// assert_eq!(hex_chars_to_u8(&['A','B']),Some(0xAB));
/// assert_eq!(hex_chars_to_u8(&['N','O']),None);
/// ```
#[inline]
#[inline(always)]
pub fn hex_chars_to_u8(hex2: &HexArray) -> Option<u8> {
let mut r: u8;
if let Some(x) = hex_char_to_u8(&hex2[0]) {
Expand Down

0 comments on commit 4cf9a71

Please sign in to comment.