Skip to content

Commit

Permalink
pango: Manually implement Language::to_string
Browse files Browse the repository at this point in the history
To avoid an API break for 0.16
  • Loading branch information
bilelmoussaoui committed Dec 4, 2022
1 parent c40aa68 commit 28aa338
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 3 additions & 0 deletions pango/Gir.toml
Expand Up @@ -350,6 +350,9 @@ status = "generate"
nullable = false
[object.function.return]
nullable = false
[[object.function]]
name = "to_string"
manual = true # avoids renaming the function to not cause an API break

[[object]]
name = "Pango.Layout"
Expand Down
10 changes: 0 additions & 10 deletions pango/src/auto/language.rs
Expand Up @@ -48,16 +48,6 @@ impl Language {
}
}

#[doc(alias = "pango_language_to_string")]
#[doc(alias = "to_string")]
pub fn to_str(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::pango_language_to_string(mut_override(
self.to_glib_none().0,
)))
}
}

#[doc(alias = "pango_language_from_string")]
pub fn from_string(language: &str) -> Language {
unsafe { from_glib_none(ffi::pango_language_from_string(language.to_glib_none().0)) }
Expand Down
10 changes: 9 additions & 1 deletion pango/src/language.rs
Expand Up @@ -41,11 +41,19 @@ impl Language {
Self::from_glib_full_as_vec(ptr)
}
}

#[doc(alias = "pango_language_to_string")]
pub fn to_string(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::pango_language_to_string(mut_override(
self.to_glib_none().0,
)))
}
}
}

impl FromStr for Language {
type Err = std::convert::Infallible;

fn from_str(language: &str) -> Result<Self, Self::Err> {
Ok(Self::from_string(language))
}
Expand Down

0 comments on commit 28aa338

Please sign in to comment.