Use try_borrow for serializing RefCell

This commit is contained in:
Konrad Borowski
2018-06-01 09:08:16 +02:00
parent dbaf2893e3
commit c3b9ee314b
2 changed files with 12 additions and 1 deletions
+4 -1
View File
@@ -459,7 +459,10 @@ where
where
S: Serializer,
{
self.borrow().serialize(serializer)
match self.try_borrow() {
Ok(value) => value.serialize(serializer),
Err(_) => Err(S::Error::custom("already mutably borrowed")),
}
}
}