use super::Value;
use indexmap::IndexMap;
mod bignum;
mod fixnum;
mod instance;
mod object;
mod rb_string;
mod rb_struct;
mod sym;
mod symbol;
mod userdata;
pub use bignum::{Bignum, BignumRef};
pub use fixnum::Fixnum;
pub use instance::Instance;
pub use object::Object;
pub use rb_string::RbString;
pub use rb_struct::RbStruct;
pub use sym::Sym;
pub use symbol::Symbol;
pub use userdata::Userdata;
pub type RbArray = Vec<Value>;
pub type RbHash = IndexMap<Value, Value>;
pub type RbFields = IndexMap<Symbol, Value>;
fn get_canonical_le_bytes_info(is_negative: bool, le_bytes: &[u8]) -> (bool, usize) {
if let Some((i, _)) = le_bytes.iter().enumerate().rfind(|(_, byte)| **byte != 0) {
(is_negative, i + 1)
} else {
(false, 0)
}
}
fn canonicalize_le_bytes_ref(is_negative: bool, le_bytes: &[u8]) -> (bool, &[u8]) {
let (is_negative, le_bytes_size) = get_canonical_le_bytes_info(is_negative, le_bytes);
(is_negative, &le_bytes[..le_bytes_size])
}
fn canonicalize_le_bytes_vec(is_negative: bool, mut le_bytes: Vec<u8>) -> (bool, Vec<u8>) {
let (is_negative, le_bytes_size) = get_canonical_le_bytes_info(is_negative, &le_bytes);
le_bytes.truncate(le_bytes_size);
(is_negative, le_bytes)
}
fn to_array_with_default<const N: usize>(slice: &[u8]) -> [u8; N] {
let mut bytes = [0u8; N];
let copy_size = N.min(slice.len());
bytes[..copy_size].copy_from_slice(&slice[..copy_size]);
bytes
}