From 428c20c79ff413e48c06af38dcb4509278b44a09 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 5 Jul 2021 21:48:10 +0000 Subject: [PATCH] borsh: add bool type (#18429) (cherry picked from commit e7b36c84841e7a3e8d635bec2e7c0ee18150f212) Co-authored-by: Michael Vines --- sdk/program/src/borsh.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/program/src/borsh.rs b/sdk/program/src/borsh.rs index 0137de6f2a..fdc0e2daf1 100644 --- a/sdk/program/src/borsh.rs +++ b/sdk/program/src/borsh.rs @@ -44,7 +44,7 @@ fn get_declaration_packed_len( .map(|element| get_declaration_packed_len(element, definitions)) .sum(), None => match declaration { - "u8" | "i8" => 1, + "bool" | "u8" | "i8" => 1, "u16" | "i16" => 2, "u32" | "i32" => 4, "u64" | "i64" => 8, @@ -143,6 +143,7 @@ mod tests { pub number_u32: u32, pub tuple: (u8, u16), pub enumeration: TestEnum, + pub r#bool: bool, } #[derive(Debug, PartialEq, BorshSerialize, BorshDeserialize, BorshSchema)] @@ -192,6 +193,7 @@ mod tests { assert_eq!( get_packed_len::(), size_of::() * 16 + + size_of::() + size_of::() + size_of::() + size_of::()