Skip to content

Commit e6b43dc

Browse files
authored
Merge pull request #1669 from sdroege/intern-string
glib: Add bindings for `g_intern_string()` and `g_intern_static_string()` to `GStr`
2 parents 9ce31b9 + 84824fd commit e6b43dc

File tree

3 files changed

+72
-36
lines changed

3 files changed

+72
-36
lines changed

Cargo.lock

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glib/src/gstring.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,39 @@ impl GStr {
289289
}
290290
}
291291
pub const NONE: Option<&'static GStr> = None;
292+
293+
// rustdoc-stripper-ignore-next
294+
/// Interns the string and returns the canonical representation.
295+
#[inline]
296+
#[doc(alias = "g_intern_string")]
297+
pub fn intern(&self) -> &'static GStr {
298+
unsafe {
299+
let s = ffi::g_intern_string(self.to_glib_none().0);
300+
GStr::from_ptr(s)
301+
}
302+
}
303+
304+
// rustdoc-stripper-ignore-next
305+
/// Interns the `'static` string and returns the canonical representation.
306+
#[inline]
307+
#[doc(alias = "g_intern_static_string")]
308+
pub fn intern_static(&'static self) -> &'static GStr {
309+
unsafe {
310+
let s = ffi::g_intern_static_string(self.to_glib_none().0);
311+
GStr::from_ptr(s)
312+
}
313+
}
314+
315+
// rustdoc-stripper-ignore-next
316+
/// Interns the string and returns the canonical representation.
317+
#[inline]
318+
#[doc(alias = "g_intern_string")]
319+
pub fn intern_from_str(s: impl AsRef<str>) -> &'static GStr {
320+
unsafe {
321+
let s = ffi::g_intern_string(s.as_ref().to_glib_none().0);
322+
GStr::from_ptr(s)
323+
}
324+
}
292325
}
293326

294327
// rustdoc-stripper-ignore-next

graphene/src/matrix.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ impl ops::MulAssign<Matrix> for Matrix {
246246
impl ops::Mul<Vec4> for Matrix {
247247
type Output = Vec4;
248248

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

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

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

0 commit comments

Comments
 (0)