pub struct VecDecoder;Expand description
Vec Decoder
Implementations§
Source§impl VecDecoder
impl VecDecoder
Sourcepub fn decode(raw: &str, vin: &mut Vec<u8>) -> Result<usize, DecoderError>
pub fn decode(raw: &str, vin: &mut Vec<u8>) -> Result<usize, DecoderError>
Decode and append result into the provided &mut Vec Result Ok() Provides the written bytes
Examples found in repository?
examples/decode_vec.rs (line 7)
3fn main() {
4 let s = "%F0%9F%92%A9";
5
6 let mut v: Vec<u8> = Vec::with_capacity(4);
7 let res = VecDecoder::decode(s, &mut v).unwrap();
8
9 assert_eq!(res, 4);
10 let t = core::str::from_utf8(v.as_slice());
11
12 assert_eq!(t, Ok("💩"));
13
14 println!("{} -> {}", s, t.unwrap());
15}Trait Implementations§
Auto Trait Implementations§
impl Freeze for VecDecoder
impl RefUnwindSafe for VecDecoder
impl Send for VecDecoder
impl Sync for VecDecoder
impl Unpin for VecDecoder
impl UnwindSafe for VecDecoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more