Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Arlie Davis committed Jun 17, 2024
1 parent 768b91e commit 8246bcf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ where
{
fn First(&self) -> windows_core::Result<IIterator<T>> {
use windows_core::IUnknownImpl;
Ok(windows_core::ComObject::new(StockIterator {
owner: self.to_object(),
current: 0.into(),
})
.into_interface())
Ok(windows_core::ComObject::new(StockIterator { owner: self.to_object(), current: 0.into() }).into_interface())
}
}

Expand Down Expand Up @@ -62,8 +58,7 @@ where
let current = self.current.load(std::sync::atomic::Ordering::Relaxed);

if current < owner.values.len() {
self.current
.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
self.current.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
}

Ok(owner.values.len() > current + 1)
Expand All @@ -76,8 +71,7 @@ where
let actual = std::cmp::min(owner.values.len() - current, values.len());
let (values, _) = values.split_at_mut(actual);
values.clone_from_slice(&owner.values[current..current + actual]);
self.current
.fetch_add(actual, std::sync::atomic::Ordering::Relaxed);
self.current.fetch_add(actual, std::sync::atomic::Ordering::Relaxed);
Ok(actual as u32)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ where
fn First(&self) -> windows_core::Result<IIterator<IKeyValuePair<K, V>>> {
use windows_core::IUnknownImpl;

Ok(windows_core::ComObject::new(StockMapViewIterator::<K, V> {
_owner: self.to_object(),
current: std::sync::RwLock::new(self.map.iter()),
})
.into_interface())
Ok(windows_core::ComObject::new(StockMapViewIterator::<K, V> { _owner: self.to_object(), current: std::sync::RwLock::new(self.map.iter()) }).into_interface())
}
}

Expand All @@ -37,10 +33,7 @@ where
V::Default: Clone,
{
fn Lookup(&self, key: &K::Default) -> windows_core::Result<V> {
let value = self
.map
.get(key)
.ok_or_else(|| windows_core::Error::from(windows_core::imp::E_BOUNDS))?;
let value = self.map.get(key).ok_or_else(|| windows_core::Error::from(windows_core::imp::E_BOUNDS))?;
V::from_default(value)
}
fn Size(&self) -> windows_core::Result<u32> {
Expand All @@ -49,11 +42,7 @@ where
fn HasKey(&self, key: &K::Default) -> windows_core::Result<bool> {
Ok(self.map.contains_key(key))
}
fn Split(
&self,
first: &mut Option<IMapView<K, V>>,
second: &mut Option<IMapView<K, V>>,
) -> windows_core::Result<()> {
fn Split(&self, first: &mut Option<IMapView<K, V>>, second: &mut Option<IMapView<K, V>>) -> windows_core::Result<()> {
*first = None;
*second = None;
Ok(())
Expand Down Expand Up @@ -83,11 +72,7 @@ where
let mut current = self.current.read().unwrap().clone().peekable();

if let Some((key, value)) = current.peek() {
Ok(windows_core::ComObject::new(StockKeyValuePair {
key: (*key).clone(),
value: (*value).clone(),
})
.into_interface())
Ok(windows_core::ComObject::new(StockKeyValuePair { key: (*key).clone(), value: (*value).clone() }).into_interface())
} else {
Err(windows_core::Error::from(windows_core::imp::E_BOUNDS))
}
Expand All @@ -112,13 +97,7 @@ where

for pair in pairs {
if let Some((key, value)) = current.next() {
*pair = Some(
windows_core::ComObject::new(StockKeyValuePair {
key: (*key).clone(),
value: (*value).clone(),
})
.into_interface(),
);
*pair = Some(windows_core::ComObject::new(StockKeyValuePair { key: (*key).clone(), value: (*value).clone() }).into_interface());
actual += 1;
} else {
break;
Expand Down Expand Up @@ -164,9 +143,7 @@ where
V::Default: Clone,
{
type Error = windows_core::Error;
fn try_from(
map: std::collections::BTreeMap<K::Default, V::Default>,
) -> windows_core::Result<Self> {
fn try_from(map: std::collections::BTreeMap<K::Default, V::Default>) -> windows_core::Result<Self> {
// TODO: should provide a fallible try_into or more explicit allocator
Ok(StockMapView { map }.into())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::Foundation::Collections::{IIterator, IIterator_Impl, IIterable, IIterable_Impl, IVectorView, IVectorView_Impl};
use crate::Foundation::Collections::{IIterable, IIterable_Impl, IIterator, IIterator_Impl, IVectorView, IVectorView_Impl};

#[windows_core::implement(IVectorView<T>, IIterable<T>)]
struct StockVectorView<T>
Expand All @@ -17,11 +17,7 @@ where
fn First(&self) -> windows_core::Result<IIterator<T>> {
use windows_core::IUnknownImpl;

Ok(windows_core::ComObject::new(StockVectorViewIterator {
owner: self.to_object(),
current: 0.into(),
})
.into_interface())
Ok(windows_core::ComObject::new(StockVectorViewIterator { owner: self.to_object(), current: 0.into() }).into_interface())
}
}

Expand All @@ -31,10 +27,7 @@ where
T::Default: Clone + PartialEq,
{
fn GetAt(&self, index: u32) -> windows_core::Result<T> {
let item = self
.values
.get(index as usize)
.ok_or_else(|| windows_core::Error::from(windows_core::imp::E_BOUNDS))?;
let item = self.values.get(index as usize).ok_or_else(|| windows_core::Error::from(windows_core::imp::E_BOUNDS))?;
T::from_default(item)
}
fn Size(&self) -> windows_core::Result<u32> {
Expand Down Expand Up @@ -95,8 +88,7 @@ where
let current = self.current.load(std::sync::atomic::Ordering::Relaxed);

if current < self.owner.values.len() {
self.current
.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
self.current.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
}

Ok(self.owner.values.len() > current + 1)
Expand All @@ -108,8 +100,7 @@ where
let actual = std::cmp::min(self.owner.values.len() - current, values.len());
let (values, _) = values.split_at_mut(actual);
values.clone_from_slice(&self.owner.values[current..current + actual]);
self.current
.fetch_add(actual, std::sync::atomic::Ordering::Relaxed);
self.current.fetch_add(actual, std::sync::atomic::Ordering::Relaxed);
Ok(actual as u32)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::Win32::Foundation::{VARIANT_BOOL, VARIANT_TRUE, VARIANT_FALSE};
use crate::Win32::Foundation::{VARIANT_BOOL, VARIANT_FALSE, VARIANT_TRUE};

impl VARIANT_BOOL {
#[inline]
Expand Down

0 comments on commit 8246bcf

Please sign in to comment.