Skip to content

Commit

Permalink
Merge pull request #1669 from sdroege/intern-string
Browse files Browse the repository at this point in the history
glib: Add bindings for `g_intern_string()` and `g_intern_static_string()` to `GStr`
  • Loading branch information
sdroege authored Mar 3, 2025
2 parents 9ce31b9 + 84824fd commit e6b43dc
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 36 deletions.
72 changes: 36 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions glib/src/gstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,39 @@ impl GStr {
}
}
pub const NONE: Option<&'static GStr> = None;

// rustdoc-stripper-ignore-next
/// Interns the string and returns the canonical representation.
#[inline]
#[doc(alias = "g_intern_string")]
pub fn intern(&self) -> &'static GStr {
unsafe {
let s = ffi::g_intern_string(self.to_glib_none().0);
GStr::from_ptr(s)
}
}

// rustdoc-stripper-ignore-next
/// Interns the `'static` string and returns the canonical representation.
#[inline]
#[doc(alias = "g_intern_static_string")]
pub fn intern_static(&'static self) -> &'static GStr {
unsafe {
let s = ffi::g_intern_static_string(self.to_glib_none().0);
GStr::from_ptr(s)
}
}

// rustdoc-stripper-ignore-next
/// Interns the string and returns the canonical representation.
#[inline]
#[doc(alias = "g_intern_string")]
pub fn intern_from_str(s: impl AsRef<str>) -> &'static GStr {
unsafe {
let s = ffi::g_intern_string(s.as_ref().to_glib_none().0);
GStr::from_ptr(s)
}
}
}

// rustdoc-stripper-ignore-next
Expand Down
3 changes: 3 additions & 0 deletions graphene/src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ impl ops::MulAssign<Matrix> for Matrix {
impl ops::Mul<Vec4> for Matrix {
type Output = Vec4;

// rustdoc-stripper-ignore-next
/// Transforms this `Vec4` using the provided matrix.
/// See [Matrix::transform_vec4].
fn mul(self, rhs: Vec4) -> Self::Output {
Expand All @@ -256,6 +257,7 @@ impl ops::Mul<Vec4> for Matrix {
impl ops::Mul<Vec3> for Matrix {
type Output = Vec3;

// rustdoc-stripper-ignore-next
/// Transforms this `Vec3` using the provided matrix.
/// See [Matrix::transform_vec3].
fn mul(self, rhs: Vec3) -> Self::Output {
Expand All @@ -274,6 +276,7 @@ impl ops::Mul<Point> for Matrix {
impl ops::Mul<Point3D> for Matrix {
type Output = Point3D;

// rustdoc-stripper-ignore-next
/// Transforms this point using the provided matrix.
/// See [Matrix::transform_point3d].
fn mul(self, rhs: Point3D) -> Self::Output {
Expand Down

0 comments on commit e6b43dc

Please sign in to comment.