Skip to content

Commit 57ea4d1

Browse files
committed
Add a comment to justify implementing scary things
With the zerocopy feature activated we implement some zerocopy traits containing an `only_derive_is_allowed_to_implement_this_trait` function. That is fine as long as we know what we are doing.
1 parent b67dbea commit 57ea4d1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,10 @@ mod impl_zerocopy {
10821082
T::Numeric: Immutable,
10831083
T::Numeric: FromZeros,
10841084
{
1085+
// We are actually allowed to implement this trait. The scary name is just meant
1086+
// to convey that "this is dangerous and you'd better know what you're doing and
1087+
// be sure that you need to do this and can't just use the derives". (https://github.com/google/zerocopy/issues/287)
1088+
// We can not use the derives for this, because they dont support validation.
10851089
fn only_derive_is_allowed_to_implement_this_trait() {}
10861090
}
10871091

@@ -1091,6 +1095,10 @@ mod impl_zerocopy {
10911095
T: BitFlag,
10921096
T::Numeric: Unaligned,
10931097
{
1098+
// We are actually allowed to implement this trait. The scary name is just meant
1099+
// to convey that "this is dangerous and you'd better know what you're doing and
1100+
// be sure that you need to do this and can't just use the derives". (https://github.com/google/zerocopy/issues/287)
1101+
// We can not use the derives for this, because they dont support validation.
10941102
fn only_derive_is_allowed_to_implement_this_trait() {}
10951103
}
10961104

@@ -1101,6 +1109,10 @@ mod impl_zerocopy {
11011109
T::Numeric: Immutable,
11021110
T::Numeric: TryFromBytes,
11031111
{
1112+
// We are actually allowed to implement this trait. The scary name is just meant
1113+
// to convey that "this is dangerous and you'd better know what you're doing and
1114+
// be sure that you need to do this and can't just use the derives". (https://github.com/google/zerocopy/issues/287)
1115+
// We can not use the derives for this, because they dont support validation.
11041116
fn only_derive_is_allowed_to_implement_this_trait()
11051117
where
11061118
Self: Sized,

0 commit comments

Comments
 (0)