From 21f20e2f93895fae364a2a208282169cc1a20b6b Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Fri, 2 Feb 2018 21:23:11 -0500 Subject: [PATCH] Return a PathBuf instead of a String This is just better. --- core-text/src/font_descriptor.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core-text/src/font_descriptor.rs b/core-text/src/font_descriptor.rs index 9ae9680..e396e3b 100644 --- a/core-text/src/font_descriptor.rs +++ b/core-text/src/font_descriptor.rs @@ -20,6 +20,7 @@ use core_graphics::base::CGFloat; use libc::c_void; use std::mem; +use std::path::PathBuf; /* * CTFontTraits.h @@ -240,7 +241,7 @@ impl CTFontDescriptor { } } - pub fn font_path(&self) -> Option { + pub fn font_path(&self) -> Option { unsafe { let value = CTFontDescriptorCopyAttribute(self.0, kCTFontURLAttribute); if value.is_null() { @@ -250,11 +251,7 @@ impl CTFontDescriptor { let value = CFType::wrap_under_create_rule(value); assert!(value.instance_of::()); let url = CFURL::wrap_under_get_rule(mem::transmute(value.as_CFTypeRef())); - let path = CFString::wrap_under_create_rule(CFURLCopyFileSystemPath( - url.as_concrete_TypeRef(), - kCFURLPOSIXPathStyle, - )).to_string(); - Some(path) + url.to_path() } }