Add an unsafe method to convert CFDictionary to CFMutableDictionary

This commit is contained in:
Jeff Muizelaar
2019-03-28 17:31:50 -04:00
parent 44c7a29fc5
commit 87bd8a4d1a
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ name = "core-foundation"
description = "Bindings to Core Foundation for macOS"
homepage = "https://github.com/servo/core-foundation-rs"
repository = "https://github.com/servo/core-foundation-rs"
version = "0.6.3"
version = "0.6.4"
authors = ["The Servo Project Developers"]
license = "MIT / Apache-2.0"
categories = ["os::macos-apis"]
+7
View File
@@ -58,6 +58,13 @@ impl<K, V> CFDictionary<K, V> {
unsafe { CFDictionary::wrap_under_get_rule(self.0) }
}
/// Returns a `CFMutableDictionary` pointing to the same underlying dictionary as this immutable one.
/// This should only be used when the underlying dictionary is mutable.
#[inline]
pub unsafe fn to_mutable(&self) -> CFMutableDictionary<K, V> {
CFMutableDictionary::wrap_under_get_rule(self.0 as CFMutableDictionaryRef)
}
/// Returns the same dictionary, but with the types reset to void pointers.
/// Equal to `to_untyped`, but is faster since it does not increment the retain count.
#[inline]