Skip to content

Commit

Permalink
glib: Implement From<&GStr> and From<GString> for Cow<GStr>
Browse files Browse the repository at this point in the history
  • Loading branch information
sdroege committed Dec 12, 2022
1 parent d593895 commit d31771e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion glib/src/gstring.rs
Expand Up @@ -2,7 +2,7 @@

use crate::translate::*;
use crate::types::{StaticType, Type};
use std::borrow::Borrow;
use std::borrow::{Borrow, Cow};
use std::cmp::Ordering;
use std::ffi::{CStr, CString, OsStr};
use std::fmt;
Expand Down Expand Up @@ -740,6 +740,18 @@ impl From<&CStr> for GString {
}
}

impl<'a> From<GString> for Cow<'a, GStr> {
fn from(v: GString) -> Self {
Cow::Owned(v)
}
}

impl<'a> From<&'a GStr> for Cow<'a, GStr> {
fn from(v: &'a GStr) -> Self {
Cow::Borrowed(v)
}
}

#[doc(hidden)]
impl FromGlibPtrFull<*mut u8> for GString {
#[inline]
Expand Down

0 comments on commit d31771e

Please sign in to comment.