Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Jan 10, 2024
1 parent 7d039d2 commit a8234d3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
4 changes: 2 additions & 2 deletions crates/libs/core/src/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Default for PROPVARIANT {

impl Clone for VARIANT {
fn clone(&self) -> Self {
unsafe {
unsafe {
let mut value = Self::new();
imp::VariantCopy(&mut value.0, &self.0);
value
Expand All @@ -30,7 +30,7 @@ impl Clone for VARIANT {

impl Clone for PROPVARIANT {
fn clone(&self) -> Self {
unsafe {
unsafe {
let mut value = Self::new();
imp::PropVariantCopy(&mut value.0, &self.0);
value
Expand Down
12 changes: 10 additions & 2 deletions crates/libs/metadata/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,19 @@ impl Reader {
}

pub fn remap_types(&self) -> impl Iterator<Item = &(TypeName, TypeName)> + '_ {
if self.sys { [].iter() } else { REMAP_TYPES.iter() }
if self.sys {
[].iter()
} else {
REMAP_TYPES.iter()
}
}

pub fn core_types(&self) -> impl Iterator<Item = &(TypeName, Type)> + '_ {
if self.sys { SYS_CORE_TYPES.iter() } else { CORE_TYPES.iter() }
if self.sys {
SYS_CORE_TYPES.iter()
} else {
CORE_TYPES.iter()
}
}

pub fn type_from_ref(&self, code: TypeDefOrRef, enclosing: Option<TypeDef>, generics: &[Type]) -> Type {
Expand Down
5 changes: 1 addition & 4 deletions crates/tests/implement/tests/properties.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#![allow(non_snake_case)]

use windows::{
core::*, Win32::System::Com::*,
Win32::UI::Shell::PropertiesSystem::*,
};
use windows::{core::*, Win32::System::Com::*, Win32::UI::Shell::PropertiesSystem::*};

#[implement(IInitializeWithStream, IPropertyStore, IPropertyStoreCapabilities)]
struct Object(std::sync::RwLock<PROPVARIANT>);
Expand Down
33 changes: 25 additions & 8 deletions crates/tests/variant/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ fn test_variant() -> Result<()> {

let v = VARIANT::from(BSTR::from("hello"));
assert_eq!(BSTR::try_from(&v)?, "hello");
assert_eq!(VARIANT::from(BSTR::from("hello")), VARIANT::from(BSTR::from("hello")));
assert_ne!(VARIANT::from(BSTR::from("hello")), VARIANT::from(BSTR::from("goodbye")));
assert_eq!(
VARIANT::from(BSTR::from("hello")),
VARIANT::from(BSTR::from("hello"))
);
assert_ne!(
VARIANT::from(BSTR::from("hello")),
VARIANT::from(BSTR::from("goodbye"))
);

let v = VARIANT::from(3.5f64);
assert_eq!(BSTR::try_from(&v)?, "3.5");
Expand All @@ -87,7 +93,6 @@ fn test_variant() -> Result<()> {
Ok(())
}


#[test]
fn test_propvariant() -> Result<()> {
let empty: PROPVARIANT = PROPVARIANT::new();
Expand Down Expand Up @@ -139,12 +144,18 @@ fn test_propvariant() -> Result<()> {

let v = PROPVARIANT::from(5294967295u64);
assert_eq!(u64::try_from(&v)?, 5294967295u64);
assert_eq!(PROPVARIANT::from(5294967295u64), PROPVARIANT::from(5294967295u64));
assert_eq!(
PROPVARIANT::from(5294967295u64),
PROPVARIANT::from(5294967295u64)
);
assert_ne!(PROPVARIANT::from(5294967295u64), PROPVARIANT::from(0u64));

let v = PROPVARIANT::from(-5294967295i64);
assert_eq!(i64::try_from(&v)?, -5294967295i64);
assert_eq!(PROPVARIANT::from(-5294967295i64), PROPVARIANT::from(-5294967295i64));
assert_eq!(
PROPVARIANT::from(-5294967295i64),
PROPVARIANT::from(-5294967295i64)
);
assert_ne!(PROPVARIANT::from(-5294967295i64), PROPVARIANT::from(0i64));

let v = PROPVARIANT::from(3.5f32);
Expand All @@ -159,8 +170,14 @@ fn test_propvariant() -> Result<()> {

let v = PROPVARIANT::from(BSTR::from("hello"));
assert_eq!(BSTR::try_from(&v)?, "hello");
assert_eq!(PROPVARIANT::from(BSTR::from("hello")), PROPVARIANT::from(BSTR::from("hello")));
assert_ne!(PROPVARIANT::from(BSTR::from("hello")), PROPVARIANT::from(BSTR::from("goodbye")));
assert_eq!(
PROPVARIANT::from(BSTR::from("hello")),
PROPVARIANT::from(BSTR::from("hello"))
);
assert_ne!(
PROPVARIANT::from(BSTR::from("hello")),
PROPVARIANT::from(BSTR::from("goodbye"))
);

let v = PROPVARIANT::from(3.5f64);
assert_eq!(BSTR::try_from(&v)?, "3.5");
Expand All @@ -173,4 +190,4 @@ fn test_propvariant() -> Result<()> {
assert_ne!(v, PROPVARIANT::from(true));

Ok(())
}
}

0 comments on commit a8234d3

Please sign in to comment.