mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-11 07:27:27 +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:
@@ -698,7 +698,7 @@ impl std::fmt::Debug for Monster<'_> {
|
||||
}
|
||||
}
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct MonsterT {
|
||||
pub pos: Option<Vec3T>,
|
||||
pub mana: i16,
|
||||
@@ -710,6 +710,21 @@ pub struct MonsterT {
|
||||
pub equipped: EquipmentT,
|
||||
pub path: Option<Vec<Vec3T>>,
|
||||
}
|
||||
impl Default for MonsterT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
pos: None,
|
||||
mana: 150,
|
||||
hp: 100,
|
||||
name: None,
|
||||
inventory: None,
|
||||
color: Color::Blue,
|
||||
weapons: None,
|
||||
equipped: EquipmentT::NONE,
|
||||
path: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl MonsterT {
|
||||
pub fn pack<'b>(
|
||||
&self,
|
||||
@@ -864,11 +879,19 @@ impl std::fmt::Debug for Weapon<'_> {
|
||||
}
|
||||
}
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct WeaponT {
|
||||
pub name: Option<String>,
|
||||
pub damage: i16,
|
||||
}
|
||||
impl Default for WeaponT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: None,
|
||||
damage: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl WeaponT {
|
||||
pub fn pack<'b>(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user