Undo temporary edits before performing rename or canceling it

Also, wire up remote renames.
This commit is contained in:
Antonio Scandurra
2022-02-18 11:41:47 +01:00
parent 514d69e83d
commit f9723ae16b
9 changed files with 331 additions and 60 deletions
+34 -1
View File
@@ -3,8 +3,9 @@ pub mod test;
use futures::Future;
use std::{
borrow::{Borrow, BorrowMut},
cmp::Ordering,
ops::AddAssign,
ops::{AddAssign, Deref, DerefMut},
pin::Pin,
task::{Context, Poll},
};
@@ -123,6 +124,38 @@ where
}
}
pub enum CowMut<'a, T: ?Sized + ToOwned> {
Borrowed(&'a mut T),
Owned(T::Owned),
}
impl<'a, T> Deref for CowMut<'a, T>
where
T: ?Sized + ToOwned,
{
type Target = T;
fn deref(&self) -> &Self::Target {
match self {
CowMut::Borrowed(value) => value,
CowMut::Owned(value) => value.borrow(),
}
}
}
impl<'a, T> DerefMut for CowMut<'a, T>
where
T: ?Sized + ToOwned,
T::Owned: BorrowMut<T>,
{
fn deref_mut(&mut self) -> &mut Self::Target {
match self {
CowMut::Borrowed(value) => value,
CowMut::Owned(value) => value.borrow_mut(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;