summaryrefslogtreecommitdiffstats
path: root/openpgp/src/serialize/writer
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2019-09-26 11:53:32 +0200
committerNeal H. Walfield <neal@pep.foundation>2019-09-27 22:12:11 +0200
commit424ce126a56660168f8284fa34ae80cb93d74289 (patch)
tree2c0440c1f3b0d557def5e1a496ee4ede22045a9b /openpgp/src/serialize/writer
parenta69ec9f9c5097bb8acd1a4fe2144328c9dc4ade7 (diff)
linting: Clear up bare trait object warnings
Newer Rust compilers requre `dyn` marking trait objects. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'openpgp/src/serialize/writer')
-rw-r--r--openpgp/src/serialize/writer/mod.rs36
-rw-r--r--openpgp/src/serialize/writer/writer_bzip2.rs4
-rw-r--r--openpgp/src/serialize/writer/writer_deflate.rs8
3 files changed, 24 insertions, 24 deletions
diff --git a/openpgp/src/serialize/writer/mod.rs b/openpgp/src/serialize/writer/mod.rs
index d249b631..b751cd3b 100644
--- a/openpgp/src/serialize/writer/mod.rs
+++ b/openpgp/src/serialize/writer/mod.rs
@@ -72,7 +72,7 @@ impl<'a, C> From<Stack<'a, C>> for BoxStack<'a, C> {
}
}
-pub(crate) type BoxStack<'a, C> = Box<'a + Stackable<'a, C>>;
+pub(crate) type BoxStack<'a, C> = Box<dyn Stackable<'a, C> + 'a>;
/// Makes a writer stackable and provides convenience functions.
pub(crate) trait Stackable<'a, C> : io::Write + fmt::Debug {
@@ -99,10 +99,10 @@ pub(crate) trait Stackable<'a, C> : io::Write + fmt::Debug {
///
/// It is a very bad idea to write any data from the inner
/// `Writer`, but it can sometimes be useful to get the cookie.
- fn inner_mut(&mut self) -> Option<&mut Stackable<'a, C>>;
+ fn inner_mut(&mut self) -> Option<&mut dyn Stackable<'a, C>>;
/// Returns a reference to the inner `Writer`.
- fn inner_ref(&self) -> Option<&Stackable<'a, C>>;
+ fn inner_ref(&self) -> Option<&dyn Stackable<'a, C>>;
/// Sets the cookie and returns the old value.
fn cookie_set(&mut self, cookie: C) -> C;
@@ -149,10 +149,10 @@ impl <'a, C> Stackable<'a, C> for BoxStack<'a, C> {
fn mount(&mut self, new: BoxStack<'a, C>) {
self.as_mut().mount(new);
}
- fn inner_mut(&mut self) -> Option<&mut Stackable<'a, C>> {
+ fn inner_mut(&mut self) -> Option<&mut dyn Stackable<'a, C>> {
self.as_mut().inner_mut()
}
- fn inner_ref(&self) -> Option<&Stackable<'a, C>> {
+ fn inner_ref(&self) -> Option<&dyn Stackable<'a, C>> {
self.as_ref().inner_ref()
}
fn cookie_set(&mut self, cookie: C) -> C {
@@ -171,8 +171,8 @@ impl <'a, C> Stackable<'a, C> for BoxStack<'a, C> {
/// Maps a function over the stack of writers.
#[allow(dead_code)]
-pub(crate) fn map<C, F>(head: &Stackable<C>, mut fun: F)
- where F: FnMut(&Stackable<C>) -> bool {
+pub(crate) fn map<C, F>(head: &dyn Stackable<C>, mut fun: F)
+ where F: FnMut(&dyn Stackable<C>) -> bool {
let mut ow = Some(head);
while let Some(w) = ow {
if ! fun(w) {
@@ -184,8 +184,8 @@ pub(crate) fn map<C, F>(head: &Stackable<C>, mut fun: F)
/// Maps a function over the stack of mutable writers.
#[allow(dead_code)]
-pub(crate) fn map_mut<C, F>(head: &mut Stackable<C>, mut fun: F)
- where F: FnMut(&mut Stackable<C>) -> bool {
+pub(crate) fn map_mut<C, F>(head: &mut dyn Stackable<C>, mut fun: F)
+ where F: FnMut(&mut dyn Stackable<C>) -> bool {
let mut ow = Some(head);
while let Some(w) = ow {
if ! fun(w) {
@@ -197,7 +197,7 @@ pub(crate) fn map_mut<C, F>(head: &mut Stackable<C>, mut fun: F)
/// Dumps the writer stack.
#[allow(dead_code)]
-pub(crate) fn dump<C>(head: &Stackable<C>) {
+pub(crate) fn dump<C>(head: &dyn Stackable<C>) {
let mut depth = 0;
map(head, |w| {
eprintln!("{}: {:?}", depth, w);
@@ -257,14 +257,14 @@ impl<'a, C> Stackable<'a, C> for Identity<'a, C> {
fn mount(&mut self, new: BoxStack<'a, C>) {
self.inner = Some(new);
}
- fn inner_ref(&self) -> Option<&Stackable<'a, C>> {
+ fn inner_ref(&self) -> Option<&dyn Stackable<'a, C>> {
if let Some(ref i) = self.inner {
Some(i)
} else {
None
}
}
- fn inner_mut(&mut self) -> Option<&mut Stackable<'a, C>> {
+ fn inner_mut(&mut self) -> Option<&mut dyn Stackable<'a, C>> {
if let Some(ref mut i) = self.inner {
Some(i)
} else {
@@ -342,14 +342,14 @@ impl<'a, W: io::Write, C> Stackable<'a, C> for Generic<W, C> {
/// Sets the inner stackable.
fn mount(&mut self, _new: BoxStack<'a, C>) {
}
- fn inner_mut(&mut self) -> Option<&mut Stackable<'a, C>> {
+ fn inner_mut(&mut self) -> Option<&mut dyn Stackable<'a, C>> {
// If you use Generic to wrap an io::Writer, and you know that
// the io::Writer's inner is also a Stackable, then return a
// reference to the innermost Stackable in your
// implementation. See e.g. writer::ZLIB.
None
}
- fn inner_ref(&self) -> Option<&Stackable<'a, C>> {
+ fn inner_ref(&self) -> Option<&dyn Stackable<'a, C>> {
// If you use Generic to wrap an io::Writer, and you know that
// the io::Writer's inner is also a Stackable, then return a
// reference to the innermost Stackable in your
@@ -419,12 +419,12 @@ impl<'a, C: 'a> Stackable<'a, C> for Encryptor<'a, C> {
fn mount(&mut self, _new: BoxStack<'a, C>) {
unreachable!("Only implemented by Signer")
}
- fn inner_mut(&mut self) -> Option<&mut Stackable<'a, C>> {
+ fn inner_mut(&mut self) -> Option<&mut dyn Stackable<'a, C>> {
// XXX: Unfortunately, this doesn't work due to a lifetime mismatch:
// self.inner.inner.get_mut().map(|r| r.as_mut())
None
}
- fn inner_ref(&self) -> Option<&Stackable<'a, C>> {
+ fn inner_ref(&self) -> Option<&dyn Stackable<'a, C>> {
self.inner.inner.get_ref().map(|r| r.as_ref())
}
fn cookie_set(&mut self, cookie: C) -> C {
@@ -492,12 +492,12 @@ impl<'a, C: 'a> Stackable<'a, C> for AEADEncryptor<'a, C> {
fn mount(&mut self, _new: BoxStack<'a, C>) {
unreachable!("Only implemented by Signer")
}
- fn inner_mut(&mut self) -> Option<&mut Stackable<'a, C>> {
+ fn inner_mut(&mut self) -> Option<&mut dyn Stackable<'a, C>> {
// XXX: Unfortunately, this doesn't work due to a lifetime mismatch:
// self.inner.inner.get_mut().map(|r| r.as_mut())
None
}
- fn inner_ref(&self) -> Option<&Stackable<'a, C>> {
+ fn inner_ref(&self) -> Option<&dyn Stackable<'a, C>> {
self.inner.inner.get_ref().map(|r| r.as_ref())
}
fn cookie_set(&mut self, cookie: C) -> C {
diff --git a/openpgp/src/serialize/writer/writer_bzip2.rs b/openpgp/src/serialize/writer/writer_bzip2.rs
index e8f70233..62affd0c 100644
--- a/openpgp/src/serialize/writer/writer_bzip2.rs
+++ b/openpgp/src/serialize/writer/writer_bzip2.rs
@@ -53,10 +53,10 @@ impl<'a, C: 'a> Stackable<'a, C> for BZ<'a, C> {
fn mount(&mut self, _new: BoxStack<'a, C>) {
unreachable!("Only implemented by Signer")
}
- fn inner_mut(&mut self) -> Option<&mut Stackable<'a, C>> {
+ fn inner_mut(&mut self) -> Option<&mut dyn Stackable<'a, C>> {
Some(self.inner.inner.get_mut())
}
- fn inner_ref(&self) -> Option<&Stackable<'a, C>> {
+ fn inner_ref(&self) -> Option<&dyn Stackable<'a, C>> {
Some(self.inner.inner.get_ref())
}
fn cookie_set(&mut self, cookie: C) -> C {
diff --git a/openpgp/src/serialize/writer/writer_deflate.rs b/openpgp/src/serialize/writer/writer_deflate.rs
index 1120e4a1..387b3f2c 100644
--- a/openpgp/src/serialize/writer/writer_deflate.rs
+++ b/openpgp/src/serialize/writer/writer_deflate.rs
@@ -53,10 +53,10 @@ impl<'a, C: 'a> Stackable<'a, C> for ZIP<'a, C> {
fn mount(&mut self, _new: BoxStack<'a, C>) {
unreachable!("Only implemented by Signer")
}
- fn inner_mut(&mut self) -> Option<&mut Stackable<'a, C>> {
+ fn inner_mut(&mut self) -> Option<&mut dyn Stackable<'a, C>> {
Some(self.inner.inner.get_mut())
}
- fn inner_ref(&self) -> Option<&Stackable<'a, C>> {
+ fn inner_ref(&self) -> Option<&dyn Stackable<'a, C>> {
Some(self.inner.inner.get_ref())
}
fn cookie_set(&mut self, cookie: C) -> C {
@@ -121,10 +121,10 @@ impl<'a, C: 'a> Stackable<'a, C> for ZLIB<'a, C> {
fn mount(&mut self, _new: BoxStack<'a, C>) {
unreachable!("Only implemented by Signer")
}
- fn inner_mut(&mut self) -> Option<&mut Stackable<'a, C>> {
+ fn inner_mut(&mut self) -> Option<&mut dyn Stackable<'a, C>> {
Some(self.inner.inner.get_mut())
}
- fn inner_ref(&self) -> Option<&Stackable<'a, C>> {
+ fn inner_ref(&self) -> Option<&dyn Stackable<'a, C>> {
Some(self.inner.inner.get_ref())
}
fn cookie_set(&mut self, cookie: C) -> C {