mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-21 22:32:23 +00:00
c9e1ae1373
* Remove where clause from derived TransparentWrapper impls. * Add test for TransparentWrapper trait bound regression.
52 lines
1.1 KiB
Rust
52 lines
1.1 KiB
Rust
#![cfg(feature = "derive")]
|
|
#![allow(dead_code)]
|
|
|
|
use bytemuck::{ByteEq, ByteHash, Pod, TransparentWrapper, Zeroable};
|
|
|
|
#[derive(Copy, Clone, Pod, Zeroable, ByteEq, ByteHash)]
|
|
#[repr(C)]
|
|
struct Test {
|
|
a: u16,
|
|
b: u16,
|
|
}
|
|
|
|
#[derive(TransparentWrapper)]
|
|
#[repr(transparent)]
|
|
struct TransparentSingle {
|
|
a: u16,
|
|
}
|
|
|
|
#[derive(TransparentWrapper)]
|
|
#[repr(transparent)]
|
|
#[transparent(u16)]
|
|
struct TransparentWithZeroSized {
|
|
a: u16,
|
|
b: (),
|
|
}
|
|
|
|
#[derive(TransparentWrapper)]
|
|
#[repr(transparent)]
|
|
struct TransparentWithGeneric<T> {
|
|
a: T,
|
|
}
|
|
|
|
/// Ensuring that no additional bounds are emitted.
|
|
/// See https://github.com/Lokathor/bytemuck/issues/145
|
|
fn test_generic<T>(x: T) -> TransparentWithGeneric<T> {
|
|
TransparentWithGeneric::wrap(x)
|
|
}
|
|
|
|
#[derive(TransparentWrapper)]
|
|
#[repr(transparent)]
|
|
#[transparent(T)]
|
|
struct TransparentWithGenericAndZeroSized<T> {
|
|
a: T,
|
|
b: ()
|
|
}
|
|
|
|
/// Ensuring that no additional bounds are emitted.
|
|
/// See https://github.com/Lokathor/bytemuck/issues/145
|
|
fn test_generic_with_zst<T>(x: T) -> TransparentWithGenericAndZeroSized<T> {
|
|
TransparentWithGenericAndZeroSized::wrap(x)
|
|
}
|