MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / try_build

Method try_build

atomic-core/src/change/header.rs:389–400  ·  view source on GitHub ↗

Try to build the change header, returning an error if invalid. This is a non-panicking alternative to `build()`.

(self)

Source from the content-addressed store, hash-verified

387 ///
388 /// This is a non-panicking alternative to `build()`.
389 pub fn try_build(self) -> Result<ChangeHeader, &'static str> {
390 if self.message.is_none() || self.message.as_ref().map(|m| m.is_empty()).unwrap_or(true) {
391 return Err("Change message is required");
392 }
393
394 Ok(ChangeHeader {
395 message: self.message.unwrap(),
396 description: self.description,
397 timestamp: self.timestamp.unwrap_or_else(Utc::now),
398 authors: self.authors,
399 })
400 }
401}
402
403#[cfg(test)]

Calls 4

is_noneMethod · 0.80
as_refMethod · 0.80
is_emptyMethod · 0.45
unwrapMethod · 0.45