diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /third_party/rust/scroll/examples | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | third_party/rust/scroll/examples/data_ctx.rs | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/third_party/rust/scroll/examples/data_ctx.rs b/third_party/rust/scroll/examples/data_ctx.rs deleted file mode 100644 index 667f4b18f0..0000000000 --- a/third_party/rust/scroll/examples/data_ctx.rs +++ /dev/null @@ -1,24 +0,0 @@ -use scroll::{ctx, Endian, Pread, BE}; - -#[derive(Debug)] -struct Data<'a> { - name: &'a str, - id: u32, -} - -impl<'a> ctx::TryFromCtx<'a, Endian> for Data<'a> { - type Error = scroll::Error; - fn try_from_ctx(src: &'a [u8], endian: Endian) -> Result<(Self, usize), Self::Error> { - let name = src.pread::<&'a str>(0)?; - let id = src.pread_with(name.len() + 1, endian)?; - Ok((Data { name: name, id: id }, name.len() + 4)) - } -} - -fn main() { - let bytes = b"UserName\x00\x01\x02\x03\x04"; - let data = bytes.pread_with::<Data>(0, BE).unwrap(); - assert_eq!(data.id, 0x01020304); - assert_eq!(data.name.to_string(), "UserName".to_string()); - println!("Data: {:?}", &data); -} |