Skip to content

Commit

Permalink
Run cargo fmt on the entire source tree (#58)
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Robinson <[email protected]>
  • Loading branch information
mrobinson authored Oct 8, 2024
1 parent 18f10eb commit 5a9070f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
8 changes: 3 additions & 5 deletions src/font_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use winapi::um::dwrite::IDWriteFontCollectionLoader;
use winapi::um::dwrite::{IDWriteFont, IDWriteFontCollection, IDWriteFontFamily};
use wio::com::ComPtr;

use crate::helpers::*;
use super::{DWriteFactory, Font, FontDescriptor, FontFace, FontFamily};
use crate::helpers::*;

static NEXT_ID: AtomicUsize = AtomicUsize::new(0);

Expand Down Expand Up @@ -48,10 +48,8 @@ impl FontCollection {
pub fn get_system(update: bool) -> FontCollection {
unsafe {
let mut native: *mut IDWriteFontCollection = ptr::null_mut();
let hr = (*DWriteFactory()).GetSystemFontCollection(
&mut native,
if update { TRUE } else { FALSE },
);
let hr = (*DWriteFactory())
.GetSystemFontCollection(&mut native, if update { TRUE } else { FALSE });
assert!(hr == 0);

FontCollection {
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ include!("types.rs");

use std::ffi::CString;
use std::ptr;
use winapi::Interface;
use winapi::shared::guiddef::REFIID;
use winapi::shared::winerror::S_OK;
use winapi::um::dwrite::DWRITE_FACTORY_TYPE;
use winapi::um::dwrite::DWRITE_FACTORY_TYPE_SHARED;
use winapi::um::dwrite::IDWriteFactory;
use winapi::um::dwrite::IDWriteRenderingParams;
use winapi::um::dwrite::DWRITE_FACTORY_TYPE;
use winapi::um::dwrite::DWRITE_FACTORY_TYPE_SHARED;
use winapi::um::unknwnbase::IUnknown;
use winapi::um::winnt::LPCSTR;
use winapi::Interface;

pub use winapi::um::winnt::HRESULT;

Expand Down
16 changes: 11 additions & 5 deletions src/text_analysis_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::com_helpers::Com;

pub struct TextAnalysisSource<'a> {
native: ComPtr<IDWriteTextAnalysisSource>,
phantom: PhantomData<CustomTextAnalysisSourceImpl<'a>>
phantom: PhantomData<CustomTextAnalysisSourceImpl<'a>>,
}

impl<'a> TextAnalysisSource<'a> {
Expand All @@ -28,10 +28,13 @@ impl<'a> TextAnalysisSource<'a> {
) -> TextAnalysisSource<'a> {
let native = unsafe {
ComPtr::from_raw(
CustomTextAnalysisSourceImpl::from_text_native(inner, text).into_interface()
CustomTextAnalysisSourceImpl::from_text_native(inner, text).into_interface(),
)
};
TextAnalysisSource { native, phantom: PhantomData }
TextAnalysisSource {
native,
phantom: PhantomData,
}
}

/// Create a new custom TextAnalysisSource for the given text and a trait
Expand All @@ -51,10 +54,13 @@ impl<'a> TextAnalysisSource<'a> {
text,
number_subst,
)
.into_interface()
.into_interface(),
)
};
TextAnalysisSource { native, phantom: PhantomData }
TextAnalysisSource {
native,
phantom: PhantomData,
}
}

pub fn as_ptr(&self) -> *mut IDWriteTextAnalysisSource {
Expand Down
12 changes: 8 additions & 4 deletions src/text_analysis_source_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,15 @@ unsafe extern "system" fn CustomTextAnalysisSourceImpl_GetLocaleName(
let (locale, text_len) = this.inner.get_locale_name(text_position);

// Copy the locale data into the buffer
for (i, c) in OsStr::new(&*locale).encode_wide().chain(Some(0)).enumerate() {
for (i, c) in OsStr::new(&*locale)
.encode_wide()
.chain(Some(0))
.enumerate()
{
// -1 here is deliberate: it ensures that we never write to the last character in
// this.locale_buf, so that the buffer is always null-terminated.
if i >= this.locale_buf.len() - 1 {
break
break;
}

*this.locale_buf.get_unchecked_mut(i) = c;
Expand Down Expand Up @@ -169,8 +173,8 @@ unsafe extern "system" fn CustomTextAnalysisSourceImpl_GetNumberSubstitution(
let com_ptr = &number_subst.native;
com_ptr.AddRef();
com_ptr.as_raw()
},
None => std::ptr::null_mut()
}
None => std::ptr::null_mut(),
};

S_OK
Expand Down

0 comments on commit 5a9070f

Please sign in to comment.