Skip to content

Commit 1f43e5d

Browse files
committed
Revert "can: Make new_unchecked() safe"
This reverts commit b2d00d1 and 31eabd5. Mark the constructor as unsafe again to prevent UB in safe code that assumes the CAN IDs to contain valid data. This is in line with functions like `from_utf8_unchecked()` from the std library.
1 parent 31eabd5 commit 1f43e5d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/can/id.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl StandardId {
2525

2626
/// Creates a new `StandardId` without checking if it is inside the valid range.
2727
#[inline]
28-
pub const fn new_unchecked(raw: u16) -> Self {
28+
pub const unsafe fn new_unchecked(raw: u16) -> Self {
2929
Self(raw)
3030
}
3131

@@ -61,7 +61,7 @@ impl ExtendedId {
6161

6262
/// Creates a new `ExtendedId` without checking if it is inside the valid range.
6363
#[inline]
64-
pub const fn new_unchecked(raw: u32) -> Self {
64+
pub const unsafe fn new_unchecked(raw: u32) -> Self {
6565
Self(raw)
6666
}
6767

0 commit comments

Comments
 (0)