Skip to content

Commit

Permalink
doc: Use raw pointer instead of raw object
Browse files Browse the repository at this point in the history
  • Loading branch information
henkkuli committed Nov 10, 2023
1 parent e6303ec commit dee34f0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ impl<'a> Blob<'a> {
pub fn len(&self) -> usize {
(unsafe { sys::hb_blob_get_length(self.0) }) as usize
}
}

/// Converts the blob into raw [`sys::hb_blob_t`] object.
impl<'a> Blob<'a> {
/// Converts the blob into raw [`sys::hb_blob_t`] pointer.
///
/// This method transfers the ownership of the blob to the caller. It is up to the caller to call
/// [`sys::hb_blob_destroy`] to free the object, or call [`Self::from_raw`] to convert it back into [`Blob`].
/// [`sys::hb_blob_destroy`] to free the pointer, or call [`Self::from_raw`] to convert it back into [`Blob`].
pub fn into_raw(self) -> *mut sys::hb_blob_t {
let ptr = self.0;
std::mem::forget(self);
Expand All @@ -80,7 +82,7 @@ impl<'a> Blob<'a> {
self.0
}

/// Constructs a blob from raw [`sys::hb_blob_t`] object.
/// Constructs a blob from raw [`sys::hb_blob_t`] pointer.
///
/// # Safety
/// The given `blob` pointer must either be constructed by some Harfbuzz function, or be returned from
Expand Down
8 changes: 5 additions & 3 deletions src/font_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ impl<'a> FontFace<'a> {
unsafe { sys::hb_face_collect_unicodes(self.as_raw(), set.as_raw()) };
Ok(set)
}
}

/// Converts the font face into raw [`sys::hb_face_t`] object.
impl<'a> FontFace<'a> {
/// Converts the font face into raw [`sys::hb_face_t`] pointer.
///
/// This method transfers the ownership of the font face to the caller. It is up to the caller to call
/// [`sys::hb_face_destroy`] to free the object, or call [`Self::from_raw`] to convert it back into [`FontFace`].
/// [`sys::hb_face_destroy`] to free the pointer, or call [`Self::from_raw`] to convert it back into [`FontFace`].
pub fn into_raw(self) -> *mut sys::hb_face_t {
let ptr = self.0;
std::mem::forget(self);
Expand All @@ -74,7 +76,7 @@ impl<'a> FontFace<'a> {
self.0
}

/// Constructs a font face from raw [`sys::hb_face_t`] object.
/// Constructs a font face from raw [`sys::hb_face_t`] pointer.
///
/// # Safety
/// The given `font_face` pointer must either be constructed by some Harfbuzz function, or be returned from
Expand Down
6 changes: 3 additions & 3 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ where
}

impl<'a, T> Set<'a, T> {
/// Converts the set into raw [`sys::hb_set_t`] object.
/// Converts the set into raw [`sys::hb_set_t`] pointer.
///
/// This method transfers the ownership of the set to the caller. It is up to the caller to call
/// [`sys::hb_set_destroy`] to free the object, or call [`Self::from_raw`] to convert it back into [`Set`].
/// [`sys::hb_set_destroy`] to free the pointer, or call [`Self::from_raw`] to convert it back into [`Set`].
pub fn into_raw(self) -> *mut sys::hb_set_t {
let ptr = self.0 .0;
std::mem::forget(self);
Expand All @@ -227,7 +227,7 @@ impl<'a, T> Set<'a, T> {
self.0 .0
}

/// Constructs a set from raw [`sys::hb_set_t`] object.
/// Constructs a set from raw [`sys::hb_set_t`] pointer.
///
/// # Safety
/// The given `set` pointer must either be constructed by some Harfbuzz function, or be returned from
Expand Down
8 changes: 5 additions & 3 deletions src/subset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,13 @@ impl SubsetInput {
}
Ok(unsafe { FontFace::from_raw(face) })
}
}

/// Converts the subset input into raw [`sys::hb_subset_input_t`] object.
impl SubsetInput {
/// Converts the subset input into raw [`sys::hb_subset_input_t`] pointer.
///
/// This method transfers the ownership of the subset input to the caller. It is up to the caller to call
/// [`sys::hb_blob_destroy`] to free the object, or call [`Self::from_raw`] to convert it back into [`SubsetInput`].
/// [`sys::hb_blob_destroy`] to free the pointer, or call [`Self::from_raw`] to convert it back into [`SubsetInput`].
pub fn into_raw(self) -> *mut sys::hb_subset_input_t {
let ptr = self.0;
std::mem::forget(self);
Expand All @@ -200,7 +202,7 @@ impl SubsetInput {
self.0
}

/// Constructs a subset input from raw [`sys::hb_subset_input_t`] object.
/// Constructs a subset input from raw [`sys::hb_subset_input_t`] pointer.
///
/// # Safety
/// The given `subset` pointer must either be constructed by some Harfbuzz function, or be returned from
Expand Down

0 comments on commit dee34f0

Please sign in to comment.