Skip to content

Commit d1413c6

Browse files
committed
refactor: Use explicit return to avoid surprises for developers coming from other languages
1 parent feda5d8 commit d1413c6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn panic_if_null<T>(pointer: *const T) {
3434
/// Convert type to raw pointer.
3535
#[inline]
3636
pub fn raw<T>(data: T) -> *mut T {
37-
Box::into_raw(Box::new(data))
37+
return Box::into_raw(Box::new(data));
3838
}
3939

4040
/// Free pointer to type.
@@ -65,7 +65,7 @@ pub unsafe fn own_back<T>(pointer: *mut T) -> T {
6565
panic_if_null(pointer);
6666
// CAUTION: this is unsafe
6767
let boxed = Box::from_raw(pointer);
68-
*boxed
68+
return *boxed;
6969
}
7070

7171
/// Convert raw pointer to type to type reference.
@@ -77,7 +77,7 @@ pub unsafe fn own_back<T>(pointer: *mut T) -> T {
7777
pub unsafe fn object<'a, T>(pointer: *const T) -> &'a T {
7878
panic_if_null(pointer);
7979
// CAUTION: this is unsafe
80-
&*pointer
80+
return &*pointer;
8181
}
8282

8383
/// Convert raw pointer to type into type mutable reference.
@@ -89,5 +89,5 @@ pub unsafe fn object<'a, T>(pointer: *const T) -> &'a T {
8989
pub unsafe fn mut_object<'a, T>(pointer: *mut T) -> &'a mut T {
9090
panic_if_null(pointer);
9191
// CAUTION: this is unsafe
92-
&mut *pointer
92+
return &mut *pointer;
9393
}

0 commit comments

Comments
 (0)