Remove unused keyword "mut" where not needed
This commit is contained in:
parent
ae5255c7c7
commit
ac804bd839
9 changed files with 26 additions and 23 deletions
|
@ -147,12 +147,12 @@ fn create_with_content_and_header(rt: &Runtime,
|
|||
.map_dbg_err(|e| format!("Error in Store::create(): {:?}", e))
|
||||
.map(|mut element| {
|
||||
{
|
||||
let mut e_content = element.get_content_mut();
|
||||
let e_content = element.get_content_mut();
|
||||
*e_content = content;
|
||||
debug!("New content set");
|
||||
}
|
||||
{
|
||||
let mut e_header = element.get_header_mut();
|
||||
let e_header = element.get_header_mut();
|
||||
*e_header = header;
|
||||
debug!("New header set");
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ pub fn update(rt: &Runtime) {
|
|||
rt.store()
|
||||
.retrieve(path)
|
||||
.map(|mut locked_e| {
|
||||
let mut e = locked_e.deref_mut();
|
||||
let e = locked_e.deref_mut();
|
||||
|
||||
scmd.value_of("content")
|
||||
.map(|new_content| {
|
||||
|
|
|
@ -80,7 +80,7 @@ impl FileAbstractionInstance for InMemoryFileAbstractionInstance {
|
|||
match *self {
|
||||
InMemoryFileAbstractionInstance { ref absent_path, .. } => {
|
||||
let mut mtx = self.fs_abstraction.lock().expect("Locking Mutex failed");
|
||||
let mut backend = mtx.get_mut();
|
||||
let backend = mtx.get_mut();
|
||||
let _ = backend.insert(absent_path.clone(), buf.clone());
|
||||
return Ok(());
|
||||
},
|
||||
|
@ -130,7 +130,7 @@ impl FileAbstraction for InMemoryFileAbstraction {
|
|||
fn copy(&self, from: &PathBuf, to: &PathBuf) -> Result<(), SE> {
|
||||
debug!("Copying : {:?} -> {:?}", from, to);
|
||||
let mut mtx = self.backend().lock().expect("Locking Mutex failed");
|
||||
let mut backend = mtx.get_mut();
|
||||
let backend = mtx.get_mut();
|
||||
|
||||
let a = try!(backend.get(from).cloned().ok_or(SEK::FileNotFound.into_error()));
|
||||
backend.insert(to.clone(), a);
|
||||
|
@ -141,7 +141,7 @@ impl FileAbstraction for InMemoryFileAbstraction {
|
|||
fn rename(&self, from: &PathBuf, to: &PathBuf) -> Result<(), SE> {
|
||||
debug!("Renaming: {:?} -> {:?}", from, to);
|
||||
let mut mtx = self.backend().lock().expect("Locking Mutex failed");
|
||||
let mut backend = mtx.get_mut();
|
||||
let backend = mtx.get_mut();
|
||||
|
||||
let a = try!(backend.get(from).cloned().ok_or(SEK::FileNotFound.into_error()));
|
||||
backend.insert(to.clone(), a);
|
||||
|
@ -164,7 +164,7 @@ impl FileAbstraction for InMemoryFileAbstraction {
|
|||
fn fill<'a>(&'a mut self, mut d: Drain) -> Result<(), SE> {
|
||||
debug!("Draining into : {:?}", self);
|
||||
let mut mtx = try!(self.backend().lock().map_err(|_| SEK::LockError.into_error()));
|
||||
let mut backend = mtx.get_mut();
|
||||
let backend = mtx.get_mut();
|
||||
|
||||
for (path, element) in d.iter() {
|
||||
debug!("Drain into {:?}: {:?}", self, path);
|
||||
|
|
|
@ -143,7 +143,7 @@ impl<W: Write, M: Mapper> FileAbstraction for StdoutFileAbstraction<W, M> {
|
|||
fn fill(&mut self, mut d: Drain) -> Result<(), SE> {
|
||||
debug!("Draining into : {:?}", self);
|
||||
let mut mtx = try!(self.backend().lock().map_err(|_| SEK::IoError.into_error()));
|
||||
let mut backend = mtx.get_mut();
|
||||
let backend = mtx.get_mut();
|
||||
|
||||
for (path, element) in d.iter() {
|
||||
debug!("Drain into {:?}: {:?}", self, path);
|
||||
|
|
|
@ -452,7 +452,7 @@ impl Store {
|
|||
.map_err(|_| SE::new(SEK::LockPoisoned, None))
|
||||
.and_then(|mut es| {
|
||||
let new_se = try!(StoreEntry::new(id.clone(), &self.backend));
|
||||
let mut se = es.entry(id.clone()).or_insert(new_se);
|
||||
let se = es.entry(id.clone()).or_insert(new_se);
|
||||
let entry = se.get_entry();
|
||||
se.status = StoreEntryStatus::Borrowed;
|
||||
entry
|
||||
|
@ -564,7 +564,7 @@ impl Store {
|
|||
Ok(e) => e,
|
||||
};
|
||||
|
||||
let mut se = try!(hsmap.get_mut(&entry.location).ok_or(SE::new(SEK::IdNotFound, None)));
|
||||
let se = try!(hsmap.get_mut(&entry.location).ok_or(SE::new(SEK::IdNotFound, None)));
|
||||
|
||||
assert!(se.is_borrowed(), "Tried to update a non borrowed entry.");
|
||||
|
||||
|
|
|
@ -75,8 +75,8 @@ impl<'a> Counter<'a> {
|
|||
let mut lockentry = try!(store.create(id).map_err_into(CEK::StoreWriteError));
|
||||
|
||||
{
|
||||
let mut entry = lockentry.deref_mut();
|
||||
let mut header = entry.get_header_mut();
|
||||
let entry = lockentry.deref_mut();
|
||||
let header = entry.get_header_mut();
|
||||
let setres = header.set(&String::from("counter"), Value::Table(BTreeMap::new()));
|
||||
if setres.is_err() {
|
||||
return Err(CEK::StoreWriteError.into_error());
|
||||
|
@ -103,7 +103,7 @@ impl<'a> Counter<'a> {
|
|||
self.unit = unit;
|
||||
|
||||
if let Some(u) = self.unit.clone() {
|
||||
let mut header = self.fle.deref_mut().get_header_mut();
|
||||
let header = self.fle.deref_mut().get_header_mut();
|
||||
let setres = header.set(&String::from("counter.unit"), Value::String(u.0));
|
||||
if setres.is_err() {
|
||||
self.unit = None;
|
||||
|
@ -114,7 +114,7 @@ impl<'a> Counter<'a> {
|
|||
}
|
||||
|
||||
pub fn inc(&mut self) -> Result<()> {
|
||||
let mut header = self.fle.deref_mut().get_header_mut();
|
||||
let header = self.fle.deref_mut().get_header_mut();
|
||||
let query = String::from("counter.value");
|
||||
match try!(header.read(&query).map_err_into(CEK::StoreReadError)) {
|
||||
Some(&Value::Integer(i)) => {
|
||||
|
@ -127,7 +127,7 @@ impl<'a> Counter<'a> {
|
|||
}
|
||||
|
||||
pub fn dec(&mut self) -> Result<()> {
|
||||
let mut header = self.fle.deref_mut().get_header_mut();
|
||||
let header = self.fle.deref_mut().get_header_mut();
|
||||
let query = String::from("counter.value");
|
||||
match try!(header.read(&query).map_err_into(CEK::StoreReadError)) {
|
||||
Some(&Value::Integer(i)) => {
|
||||
|
@ -144,8 +144,10 @@ impl<'a> Counter<'a> {
|
|||
}
|
||||
|
||||
pub fn set(&mut self, v: i64) -> Result<()> {
|
||||
let mut header = self.fle.deref_mut().get_header_mut();
|
||||
header.set(&String::from("counter.value"), Value::Integer(v))
|
||||
self.fle
|
||||
.deref_mut()
|
||||
.get_header_mut()
|
||||
.set(&String::from("counter.value"), Value::Integer(v))
|
||||
.map_err_into(CEK::StoreWriteError)
|
||||
.map(|_| ())
|
||||
}
|
||||
|
|
|
@ -58,10 +58,10 @@ impl<'a> Note<'a> {
|
|||
.map_err_into(NEK::StoreWriteError));
|
||||
|
||||
{
|
||||
let mut entry = lockentry.deref_mut();
|
||||
let entry = lockentry.deref_mut();
|
||||
|
||||
{
|
||||
let mut header = entry.get_header_mut();
|
||||
let header = entry.get_header_mut();
|
||||
let setres = header.set("note", Value::Table(BTreeMap::new()));
|
||||
if setres.is_err() {
|
||||
let kind = NEK::StoreWriteError;
|
||||
|
@ -85,8 +85,9 @@ impl<'a> Note<'a> {
|
|||
}
|
||||
|
||||
pub fn set_name(&mut self, n: String) -> Result<()> {
|
||||
let mut header = self.entry.get_header_mut();
|
||||
header.set("note.name", Value::String(n))
|
||||
self.entry
|
||||
.get_header_mut()
|
||||
.set("note.name", Value::String(n))
|
||||
.map_err(|e| NE::new(NEK::StoreWriteError, Some(Box::new(e))))
|
||||
.map(|_| ())
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ impl<'a> IntoTask<'a> for TTask {
|
|||
.map_err_into(TEK::StoreError)
|
||||
.and_then(|mut fle| {
|
||||
{
|
||||
let mut hdr = fle.get_header_mut();
|
||||
let hdr = fle.get_header_mut();
|
||||
if try!(hdr.read("todo").map_err_into(TEK::StoreError)).is_none() {
|
||||
try!(hdr
|
||||
.set("todo", Value::Table(BTreeMap::new()))
|
||||
|
|
|
@ -350,7 +350,7 @@ impl ExternalLinker for Entry {
|
|||
|
||||
debug!("Generating header content!");
|
||||
{
|
||||
let mut hdr = file.deref_mut().get_header_mut();
|
||||
let hdr = file.deref_mut().get_header_mut();
|
||||
|
||||
let mut table = match hdr.read("imag.content") {
|
||||
Ok(Some(&Value::Table(ref table))) => table.clone(),
|
||||
|
|
Loading…
Reference in a new issue