summaryrefslogtreecommitdiffstats
path: root/openpgp/src/message/mod.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-09-11 16:12:21 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-09-18 13:08:08 +0200
commit446dfdbcb63af00daa3a777958419e1dfb6fc737 (patch)
treea5bbe4244083d9a467ab8d86be762fb67bd0054e /openpgp/src/message/mod.rs
parent130eed7cda9f77502bbb181bfabb45934af46a8d (diff)
openpgp: Make Parse::from_bytes polymorphic over AsRef<[u8]>.
- A drawback of this change is that currently AsRef<[u8]> is not implemented for [u8; _], only for specific lengths. This is a compiler limitation that may be lifted in the future. This limitation required fixing some tests, notably those using include_bytes!. - Fixes #296.
Diffstat (limited to 'openpgp/src/message/mod.rs')
-rw-r--r--openpgp/src/message/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/openpgp/src/message/mod.rs b/openpgp/src/message/mod.rs
index 517c859f..cdf3d1d9 100644
--- a/openpgp/src/message/mod.rs
+++ b/openpgp/src/message/mod.rs
@@ -333,8 +333,8 @@ impl<'a> Parse<'a, Message> for Message {
/// See [`Message::from_packet_pile`] for more details.
///
/// [`Message::from_packet_pile`]: #method.from_packet_pile
- fn from_bytes(buf: &'a [u8]) -> Result<Self> {
- Self::from_packet_pile(PacketPile::from_bytes(buf)?)
+ fn from_bytes<D: AsRef<[u8]> + ?Sized>(data: &'a D) -> Result<Self> {
+ Self::from_packet_pile(PacketPile::from_bytes(data)?)
}
}