Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #158 from sdroege/clone-for-gstring
Browse files Browse the repository at this point in the history
glib: Implement Clone for glib::GString
  • Loading branch information
sdroege authored Nov 19, 2020
2 parents ca08014 + 36c913c commit bdb8866
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions glib/src/gstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ impl GString {
}
}

impl Clone for GString {
fn clone(&self) -> GString {
let cstring = CString::new(self.as_str().to_string()).expect("CString::new failed");

GString(Inner::Native(Some(cstring)))
}
}

impl Drop for GString {
fn drop(&mut self) {
if let GString(Inner::Foreign(ptr, _len)) = self {
Expand Down

0 comments on commit bdb8866

Please # to comment.