Fix fc::Pattern::add_charset
The lifetime constraints didn't do what I thought, and such constraints turn out to be unnecessary anyhow.
This commit is contained in:
parent
28700ed3dc
commit
4b4a187fbd
|
@ -376,9 +376,11 @@ pub mod fc {
|
||||||
|
|
||||||
/// Add charset to the pattern
|
/// Add charset to the pattern
|
||||||
///
|
///
|
||||||
/// The lifetimes here ensure that the charset is alive at least as long
|
/// The referenced charset is copied by fontconfig internally using
|
||||||
/// as the pattern.
|
/// FcValueSave so that no references to application provided memory are
|
||||||
pub fn add_charset<'b, 'a: 'b>(&'b self, charset: &'a CharSetRef) -> bool {
|
/// retained. That is, the CharSet can be safely dropped immediately
|
||||||
|
/// after being added to the pattern.
|
||||||
|
pub unsafe fn add_charset(&self, charset: &CharSetRef) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
FcPatternAddCharSet(
|
FcPatternAddCharSet(
|
||||||
self.as_ptr(),
|
self.as_ptr(),
|
||||||
|
@ -565,6 +567,7 @@ mod tests {
|
||||||
charset.add('💖');
|
charset.add('💖');
|
||||||
let mut pattern = fc::Pattern::new();
|
let mut pattern = fc::Pattern::new();
|
||||||
pattern.add_charset(&charset);
|
pattern.add_charset(&charset);
|
||||||
|
drop(charset);
|
||||||
|
|
||||||
let config = fc::Config::get_current();
|
let config = fc::Config::get_current();
|
||||||
let fonts = fc::font_sort(config, &mut pattern).expect("font_sort");
|
let fonts = fc::font_sort(config, &mut pattern).expect("font_sort");
|
||||||
|
@ -581,4 +584,4 @@ mod tests {
|
||||||
println!("");
|
println!("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue