diff --git a/src/models/proto/cofd.rs b/src/models/proto/cofd.rs index 304561a..fd952c5 100644 --- a/src/models/proto/cofd.rs +++ b/src/models/proto/cofd.rs @@ -14,17 +14,20 @@ pub mod api { //include!(concat!(env!("OUT_DIR"), "/models.proto.cofd.api.rs")); tonic::include_proto!("models.proto.cofd.api"); - /// Trait to extract CharacterIdentifier while avoiding clone. The - /// character identifier is extracted out of the Option, leaving - /// None in its place. + /// Trait to take ownership of CharacterIdentifiers while avoiding + /// clone. The identifier is extracted out of the type, leaving a + /// default value in its place. pub trait DefaultCharacterIdentifier { - /// Extract the CharacterIdentifier from the containing type, - /// leaving behind a default value. - fn or_default(&mut self) -> CharacterIdentifier; + /// Take ownership of a CharacterIdentifier by taking it out + /// of the containing type, leaving behind a default value + /// (None, in the case of Option) in its place. + fn extract(&mut self) -> CharacterIdentifier; } impl DefaultCharacterIdentifier for Option { - fn or_default(&mut self) -> CharacterIdentifier { + /// Extract the identifier, or a default one if the identifier + /// is not specified for some reason. + fn extract(&mut self) -> CharacterIdentifier { self.take().unwrap_or_default() } } diff --git a/src/routes/api/cofd.rs b/src/routes/api/cofd.rs index 89d51b7..4116a1e 100644 --- a/src/routes/api/cofd.rs +++ b/src/routes/api/cofd.rs @@ -44,7 +44,7 @@ pub(super) async fn update_basic_info<'a>( conn: TenebrousDbConn<'_>, logged_in_user: Option<&User>, ) -> Result, Error> { - let id = req.id.or_default(); + let id = req.id.extract(); let mut character = load_character(&conn, logged_in_user, &id.owner, id.character_id).await?; let mut sheet: CofdSheet = character.try_deserialize()?;