Skip to content

Commit 766b53a

Browse files
committed
fix: modified the points pointed out in review
1 parent 321915a commit 766b53a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Diff for: src/errs.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ impl Err {
3535
R: fmt::Debug + Send + Sync + 'static,
3636
{
3737
let boxed = Box::new(ReasonContainer::<R>::new(reason));
38-
let ptr: ptr::NonNull<ReasonContainer> =
39-
unsafe { ptr::NonNull::new_unchecked(Box::into_raw(boxed)).cast::<ReasonContainer>() };
38+
let ptr = ptr::NonNull::from(Box::leak(boxed)).cast::<ReasonContainer>();
4039
Self {
4140
reason_container: ptr,
4241
source: None,
@@ -65,8 +64,7 @@ impl Err {
6564
E: error::Error + Send + Sync + 'static,
6665
{
6766
let boxed = Box::new(ReasonContainer::<R>::new(reason));
68-
let ptr: ptr::NonNull<ReasonContainer> =
69-
unsafe { ptr::NonNull::new_unchecked(Box::into_raw(boxed)).cast::<ReasonContainer>() };
67+
let ptr = ptr::NonNull::from(Box::leak(boxed)).cast::<ReasonContainer>();
7068
Self {
7169
reason_container: ptr,
7270
source: Some(Box::new(source)),

0 commit comments

Comments
 (0)