| |
|
| |
match change.action {
|
| |
Action::Comment { comment } => {
|
| - |
match self.comments.get(&id) {
|
| - |
Some(Redactable::Present(_)) => {
|
| - |
// Do nothing, the action was already processed,
|
| - |
// since a change with the same content-id as this
|
| - |
// one exists already.
|
| - |
}
|
| - |
Some(Redactable::Redacted) => {
|
| - |
// Do nothing, the action was redacted.
|
| + |
let present = Redactable::Present(comment);
|
| + |
|
| + |
match self.comments.entry(id) {
|
| + |
Entry::Vacant(e) => {
|
| + |
e.insert(present);
|
| |
}
|
| - |
None => {
|
| - |
self.comments.insert(id, Redactable::Present(comment));
|
| + |
Entry::Occupied(mut e) => {
|
| + |
e.get_mut().merge(present);
|
| |
}
|
| |
}
|
| |
}
|
| |
Action::Redact { id } => {
|
| - |
self.comments.insert(id, Redactable::Redacted);
|
| + |
self.comments
|
| + |
.entry(id)
|
| + |
.and_modify(|e| e.merge(Redactable::Redacted))
|
| + |
.or_insert(Redactable::Redacted);
|
| |
}
|
| |
Action::Tag { tag } => {
|
| |
self.tags
|