Skip to content

Commit

Permalink
feat: implement ToKey trait for bool and add corresponding test case
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-herlemont committed Jan 11, 2025
1 parent 8abc106 commit 821e264
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/db_type/key/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,16 @@ impl_inner_key_value_for_primitive!(i128);
impl_inner_key_value_for_primitive!(f32);
impl_inner_key_value_for_primitive!(f64);

impl ToKey for bool {
fn to_key(&self) -> Key {
Key::new(vec![*self as u8])
}

fn key_names() -> Vec<String> {
vec!["bool".to_string()]
}
}

impl RedbValue for Key {
type SelfType<'a> = Key;
type AsBytes<'a> = &'a [u8] where Self: 'a;
Expand Down
2 changes: 2 additions & 0 deletions tests/check_type/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,5 @@ create_test!(
u128,
1u128
);

create_test!(test_bool_bool, bool, true, bool, true, u8, 1u8);

0 comments on commit 821e264

Please sign in to comment.