Skip to content

Commit

Permalink
Simplify bound test
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaBluejay committed Sep 3, 2023
1 parent c69e518 commit 7a43eb2
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions tests/test_attributes/test_bound.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
use std::convert::{TryFrom, TryInto};
use std::marker::PhantomData;

use deku::prelude::*;

#[test]
fn test_bound() {
#[derive(PartialEq, Debug, DekuRead, DekuWrite)]
#[deku(bound = "T: DekuRead<'a, ()>, T: DekuWrite<()>")]
struct GenericType<'a, T> {
t: T,
#[deku(skip)]
phantom: PhantomData<&'a ()>,
}
#[deku(bound = "for<'a> T: DekuRead<'a, ()> + DekuWrite<()>")]
struct GenericType<T>(T);

let test_data = [0x01_u8];
let ret_read = <GenericType<u8>>::try_from(&test_data[..]).unwrap();
assert_eq!(
ret_read,
GenericType {
t: 0x01,
phantom: PhantomData
}
);
assert_eq!(ret_read, GenericType(0x01));

let ret_write: Vec<u8> = ret_read.try_into().unwrap();
assert_eq!(ret_write, test_data);
Expand Down

0 comments on commit 7a43eb2

Please sign in to comment.