mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-11 23:40:57 +00:00
Implement Rust object API defaults (#6444)
* Implment Rust object API defaults * satisfy return analysis * git clang format Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
@@ -763,7 +763,7 @@ impl std::fmt::Debug for ScalarStuff<'_> {
|
||||
}
|
||||
}
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct ScalarStuffT {
|
||||
pub just_i8: i8,
|
||||
pub maybe_i8: Option<i8>,
|
||||
@@ -802,6 +802,48 @@ pub struct ScalarStuffT {
|
||||
pub maybe_enum: Option<OptionalByte>,
|
||||
pub default_enum: OptionalByte,
|
||||
}
|
||||
impl Default for ScalarStuffT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
just_i8: 0,
|
||||
maybe_i8: None,
|
||||
default_i8: 42,
|
||||
just_u8: 0,
|
||||
maybe_u8: None,
|
||||
default_u8: 42,
|
||||
just_i16: 0,
|
||||
maybe_i16: None,
|
||||
default_i16: 42,
|
||||
just_u16: 0,
|
||||
maybe_u16: None,
|
||||
default_u16: 42,
|
||||
just_i32: 0,
|
||||
maybe_i32: None,
|
||||
default_i32: 42,
|
||||
just_u32: 0,
|
||||
maybe_u32: None,
|
||||
default_u32: 42,
|
||||
just_i64: 0,
|
||||
maybe_i64: None,
|
||||
default_i64: 42,
|
||||
just_u64: 0,
|
||||
maybe_u64: None,
|
||||
default_u64: 42,
|
||||
just_f32: 0.0,
|
||||
maybe_f32: None,
|
||||
default_f32: 42.0,
|
||||
just_f64: 0.0,
|
||||
maybe_f64: None,
|
||||
default_f64: 42.0,
|
||||
just_bool: false,
|
||||
maybe_bool: None,
|
||||
default_bool: true,
|
||||
just_enum: OptionalByte::None,
|
||||
maybe_enum: None,
|
||||
default_enum: OptionalByte::One,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ScalarStuffT {
|
||||
pub fn pack<'b>(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user