Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unused)]#![warn(unused_must_use)]
- /// Types which implement this can be deserialized in-place from &'bytes mut [u8]
- ///
- ///
- pub
- trait InPlaceDeserialize {}
- impl InPlaceDeserialize for str {}
- pub
- fn deserialize<'bytes, T : ?Sized + 'bytes> (
- bytes: &'bytes mut [u8],
- ) -> &'bytes T
- where
- T : InPlaceDeserialize
- {
- unimplemented!()
- }
- pub
- fn client<'bytes, T> (
- bytes: &'bytes mut [u8],
- ) -> &'bytes mut [u8]
- where
- T : InPlaceDeserialize,
- {
- deserialize::<T>(bytes); // borrowed for an ephemeral lifetime
- bytes
- }
- fn main ()
- {
- let mut s: &'static str = "static";
- let mut bytes = [];
- let short_s = deserialize::<str>(&mut bytes);
- s = short_s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement