pub struct CommitReference {
pub commit: String,
pub named_by: String,
pub covers: Option<String>,
}Expand description
One commit the layer itself names, and the record that named it.
The pair is the fact, not the commit alone. One commit named by three records is three
references, because each record is a separate claim about what that commit was for, and
folding them would lose the attribution — which is the only reason to carry a commit here
at all. So named_by ends the ordering key, and two references to one commit both
survive.
use majordomus_cli::devcontext::CommitReference;
use majordomus_cli::order::canonical;
use serde_json::json;
let by = |commit: &str, record: &str| -> CommitReference {
serde_json::from_value(json!({"commit": commit, "named_by": record})).unwrap()
};
let mut commits = vec![
by("cd04012", "majordomus://session/b"),
by("cd04012", "majordomus://session/a"),
by("5e31dd4", "majordomus://issue/I0301"),
];
canonical(&mut commits);
// filed under the commit, which is what a reader looks for
let order: Vec<&str> = commits.iter().map(|c| c.commit.as_str()).collect();
assert_eq!(order, ["5e31dd4", "cd04012", "cd04012"]);
// and the record ends the key, so one commit named twice stays two facts
assert_eq!(commits[1].named_by, "majordomus://session/a");
assert_eq!(commits[2].named_by, "majordomus://session/b");
// `covers` is what the record said the commit was for, when it said
let with_reason = by("cd04012", "majordomus://session/a");
assert!(with_reason.covers.is_none(), "absent rather than an empty sentence");Fields§
§commit: StringThe commit as the record wrote it.
named_by: StringThe entry that named it.
covers: Option<String>What the record says the commit was for.
Trait Implementations§
Source§impl Clone for CommitReference
impl Clone for CommitReference
Source§fn clone(&self) -> CommitReference
fn clone(&self) -> CommitReference
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CommitReference
impl Debug for CommitReference
Source§impl<'de> Deserialize<'de> for CommitReference
impl<'de> Deserialize<'de> for CommitReference
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for CommitReference
Source§impl JsonSchema for CommitReference
impl JsonSchema for CommitReference
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl Ord for CommitReference
impl Ord for CommitReference
Source§fn cmp(&self, other: &CommitReference) -> Ordering
fn cmp(&self, other: &CommitReference) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl Ordered for CommitReference
The commit is what a reader looks for; the entry that named it ends the key, because one
commit is named by several records and each of those is a separate fact.
impl Ordered for CommitReference
The commit is what a reader looks for; the entry that named it ends the key, because one commit is named by several records and each of those is a separate fact.
Source§impl PartialEq for CommitReference
impl PartialEq for CommitReference
Source§fn eq(&self, other: &CommitReference) -> bool
fn eq(&self, other: &CommitReference) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for CommitReference
impl PartialOrd for CommitReference
Source§impl Serialize for CommitReference
impl Serialize for CommitReference
impl StructuralPartialEq for CommitReference
Auto Trait Implementations§
impl Freeze for CommitReference
impl RefUnwindSafe for CommitReference
impl Send for CommitReference
impl Sync for CommitReference
impl Unpin for CommitReference
impl UnsafeUnpin for CommitReference
impl UnwindSafe for CommitReference
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.