Skip to content

Commit 02d1bcb

Browse files
committed
doc: Add errors section to ref doc of functions returning a result
1 parent 8aaf192 commit 02d1bcb

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
@@ -54,6 +54,10 @@ pub unsafe fn free<T>(pointer: *mut T) {
5454

5555
/// Opposite of [`raw<T>()`], to use Rust's ownership as usually.
5656
///
57+
/// # Errors
58+
///
59+
/// The pointer must be not null as it is an obvious invalid pointer.
60+
///
5761
/// # Safety
5862
///
5963
/// The pointer must be a valid reference and never call it twice or behavior is undefined.
@@ -74,6 +78,10 @@ pub unsafe fn own_back<T>(pointer: *mut T) -> Result<T, crate::error::PointerErr
7478
/// That's the difference with [`own_back<T>()`], you must
7579
/// use [`own_back<T>()`] to own it again and it will be dropped.
7680
///
81+
/// # Errors
82+
///
83+
/// The pointer must be not null as it is an obvious invalid pointer.
84+
///
7785
/// # Safety
7886
///
7987
/// Invalid pointer or call it twice could cause an undefined behavior or heap error and a crash.
@@ -89,6 +97,10 @@ pub unsafe fn object<'a, T>(pointer: *const T) -> Result<&'a T, crate::error::Po
8997
/// That's the difference with [`own_back<T>()`], you must
9098
/// use [`own_back<T>()`] to own it again and it will be dropped.
9199
///
100+
/// # Errors
101+
///
102+
/// The pointer must be not null as it is an obvious invalid pointer.
103+
///
92104
/// # Safety
93105
///
94106
/// Invalid pointer or call it twice could cause an undefined behavior or heap error and a crash.

0 commit comments

Comments
 (0)