diff --git a/src/instance.rs b/src/instance.rs index 911211d7685d7ae00df269cbb5580ade88776bcb..d64f91541805d716ca075c4145d536a1cae42a88 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -20,7 +20,7 @@ crate::define_string_newtype! { //////////////////////////////////////////////////////////////////////////////// /// Serializable struct representing a member of the raft group. -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)] pub struct Instance { /// Instances are identified by name. pub instance_id: InstanceId, @@ -59,20 +59,6 @@ impl Instance { pub fn is_reincarnated(&self) -> bool { self.current_grade.incarnation < self.target_grade.incarnation } - - /// Only used for testing. - pub(crate) fn default() -> Self { - Self { - instance_id: Default::default(), - instance_uuid: Default::default(), - raft_id: Default::default(), - replicaset_id: Default::default(), - replicaset_uuid: Default::default(), - current_grade: Default::default(), - target_grade: Default::default(), - failure_domain: Default::default(), - } - } } impl std::fmt::Display for Instance { diff --git a/src/instance/grade.rs b/src/instance/grade.rs index 6780f3200d2f1235938352049cb664279b1ba96e..497eed0c51c69b21ce2d72cd31f396fa35d4b356 100644 --- a/src/instance/grade.rs +++ b/src/instance/grade.rs @@ -144,11 +144,10 @@ impl From<TargetGrade> for CurrentGrade { /// Check if instance's current and target grades match the specified pattern. /// # Examples: -/// ```no_run +/// ``` /// # use picodata::{has_grades, instance::Instance}; -/// # let instance: Instance = unsafe { -/// # std::mem::MaybeUninit::uninit().assume_init() -/// # }; +/// # let instance = Instance::default(); +/// # /// // Check if current_grade == `Offline`, target_grade == `Online` /// has_grades!(instance, Offline -> Online); ///