Skip to content

Commit 096ccf4

Browse files
committed
Fix formatting
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
1 parent ca7a226 commit 096ccf4

File tree

11 files changed

+529
-444
lines changed

11 files changed

+529
-444
lines changed

src/buffer/any_buffer.rs

Lines changed: 187 additions & 174 deletions
Large diffs are not rendered by default.

src/buffer/buffer_map.rs

Lines changed: 43 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
*
1616
*/
1717

18-
use std::{
19-
any::TypeId,
20-
borrow::Cow,
21-
collections::HashMap,
22-
};
18+
use std::{any::TypeId, borrow::Cow, collections::HashMap};
2319

2420
use thiserror::Error as ThisError;
2521

@@ -28,9 +24,9 @@ use smallvec::SmallVec;
2824
use bevy_ecs::prelude::{Entity, World};
2925

3026
use crate::{
31-
AnyBuffer, AddOperation, Chain, OperationError, OperationResult, OperationRoster, Buffered, Gate,
32-
Join, Joined, Accessed, BufferKeyBuilder, AnyBufferKey, Builder, Output, UnusedTarget, GateState,
33-
add_listener_to_source,
27+
add_listener_to_source, Accessed, AddOperation, AnyBuffer, AnyBufferKey, BufferKeyBuilder,
28+
Buffered, Builder, Chain, Gate, GateState, Join, Joined, OperationError, OperationResult,
29+
OperationRoster, Output, UnusedTarget,
3430
};
3531

3632
#[derive(Clone, Default)]
@@ -40,11 +36,7 @@ pub struct BufferMap {
4036

4137
impl BufferMap {
4238
/// Insert a named buffer into the map.
43-
pub fn insert(
44-
&mut self,
45-
name: Cow<'static, str>,
46-
buffer: impl Into<AnyBuffer>,
47-
) {
39+
pub fn insert(&mut self, name: Cow<'static, str>, buffer: impl Into<AnyBuffer>) {
4840
self.inner.insert(name, buffer.into());
4941
}
5042

@@ -67,11 +59,7 @@ pub struct IncompatibleLayout {
6759

6860
impl IncompatibleLayout {
6961
/// Check whether a named buffer is compatible with a specific type.
70-
pub fn require_buffer<T: 'static>(
71-
&mut self,
72-
expected_name: &str,
73-
buffers: &BufferMap,
74-
) {
62+
pub fn require_buffer<T: 'static>(&mut self, expected_name: &str, buffers: &BufferMap) {
7563
if let Some((name, buffer)) = buffers.inner.get_key_value(expected_name) {
7664
if buffer.message_type_id() != TypeId::of::<T>() {
7765
self.incompatible_buffers.push(BufferIncompatibility {
@@ -81,7 +69,8 @@ impl IncompatibleLayout {
8169
});
8270
}
8371
} else {
84-
self.missing_buffers.push(Cow::Owned(expected_name.to_owned()));
72+
self.missing_buffers
73+
.push(Cow::Owned(expected_name.to_owned()));
8574
}
8675
}
8776

@@ -124,11 +113,7 @@ pub trait BufferMapLayout: Sized {
124113
world: &mut World,
125114
) -> OperationResult;
126115

127-
fn add_listener(
128-
buffers: &BufferMap,
129-
listener: Entity,
130-
world: &mut World,
131-
) -> OperationResult {
116+
fn add_listener(buffers: &BufferMap, listener: Entity, world: &mut World) -> OperationResult {
132117
for buffer in buffers.inner.values() {
133118
add_listener_to_source(buffer.id(), listener, world)?;
134119
}
@@ -157,7 +142,7 @@ pub trait BufferMapLayout: Sized {
157142
}
158143
}
159144

160-
pub trait JoinedValue: 'static + BufferMapLayout + Send + Sync{
145+
pub trait JoinedValue: 'static + BufferMapLayout + Send + Sync {
161146
/// This associated type must represent a buffer map layout that is
162147
/// guaranteed to be compatible for this JoinedValue. Failure to implement
163148
/// this trait accordingly will result in panics.
@@ -198,11 +183,7 @@ pub trait JoinedValue: 'static + BufferMapLayout + Send + Sync{
198183

199184
/// Trait to describe a layout of buffer keys
200185
pub trait BufferKeyMap: BufferMapLayout + Clone {
201-
fn add_accessor(
202-
buffers: &BufferMap,
203-
accessor: Entity,
204-
world: &mut World,
205-
) -> OperationResult;
186+
fn add_accessor(buffers: &BufferMap, accessor: Entity, world: &mut World) -> OperationResult;
206187

207188
fn create_key(buffers: &BufferMap, builder: &BufferKeyBuilder) -> Self;
208189

@@ -219,13 +200,19 @@ struct BufferedMap<K> {
219200
impl<K: BufferMapLayout> BufferedMap<K> {
220201
fn new(map: BufferMap) -> Result<Self, IncompatibleLayout> {
221202
K::is_compatible(&map)?;
222-
Ok(Self { map, _ignore: Default::default() })
203+
Ok(Self {
204+
map,
205+
_ignore: Default::default(),
206+
})
223207
}
224208
}
225209

226210
impl<K> Clone for BufferedMap<K> {
227211
fn clone(&self) -> Self {
228-
Self { map: self.map.clone(), _ignore: Default::default() }
212+
Self {
213+
map: self.map.clone(),
214+
_ignore: Default::default(),
215+
}
229216
}
230217
}
231218

@@ -322,11 +309,7 @@ impl BufferMapLayout for AnyBufferKeyMap {
322309
Ok(min_count.unwrap_or(0))
323310
}
324311

325-
fn add_listener(
326-
buffers: &BufferMap,
327-
listener: Entity,
328-
world: &mut World,
329-
) -> OperationResult {
312+
fn add_listener(buffers: &BufferMap, listener: Entity, world: &mut World) -> OperationResult {
330313
for buffer in buffers.inner.values() {
331314
buffer.add_listener(listener, world)?;
332315
}
@@ -377,9 +360,8 @@ mod tests {
377360
use std::borrow::Cow;
378361

379362
use crate::{
380-
prelude::*,
381-
testing::*,
382-
OperationResult, OperationError, OrBroken, InspectBuffer, ManageBuffer, BufferMap,
363+
prelude::*, testing::*, BufferMap, InspectBuffer, ManageBuffer, OperationError,
364+
OperationResult, OrBroken,
383365
};
384366

385367
use bevy_ecs::prelude::World;
@@ -420,17 +402,11 @@ mod tests {
420402
.or_broken()?
421403
.buffered_count::<String>(session)?;
422404

423-
Ok(
424-
[
425-
integer_count,
426-
float_count,
427-
string_count,
428-
]
405+
Ok([integer_count, float_count, string_count]
429406
.iter()
430407
.min()
431408
.copied()
432-
.unwrap_or(0)
433-
)
409+
.unwrap_or(0))
434410
}
435411

436412
fn ensure_active_session(
@@ -480,7 +456,11 @@ mod tests {
480456
.or_broken()?
481457
.pull_from_buffer::<String>(session)?;
482458

483-
Ok(Self { integer, float, string })
459+
Ok(Self {
460+
integer,
461+
float,
462+
string,
463+
})
484464
}
485465
}
486466

@@ -514,25 +494,23 @@ mod tests {
514494
buffers.insert(Cow::Borrowed("float"), buffer_f64);
515495
buffers.insert(Cow::Borrowed("string"), buffer_string);
516496

517-
scope
518-
.input
519-
.chain(builder)
520-
.fork_unzip((
521-
|chain: Chain<_>| chain.connect(buffer_i64.input_slot()),
522-
|chain: Chain<_>| chain.connect(buffer_f64.input_slot()),
523-
|chain: Chain<_>| chain.connect(buffer_string.input_slot()),
524-
));
497+
scope.input.chain(builder).fork_unzip((
498+
|chain: Chain<_>| chain.connect(buffer_i64.input_slot()),
499+
|chain: Chain<_>| chain.connect(buffer_f64.input_slot()),
500+
|chain: Chain<_>| chain.connect(buffer_string.input_slot()),
501+
));
525502

526-
builder.try_join_into(buffers).unwrap().connect(scope.terminate);
503+
builder
504+
.try_join_into(buffers)
505+
.unwrap()
506+
.connect(scope.terminate);
527507
});
528508

529-
let mut promise = context.command(
530-
|commands| commands.request(
531-
(5_i64, 3.14_f64, "hello".to_string()),
532-
workflow,
533-
)
534-
.take_response()
535-
);
509+
let mut promise = context.command(|commands| {
510+
commands
511+
.request((5_i64, 3.14_f64, "hello".to_string()), workflow)
512+
.take_response()
513+
});
536514

537515
context.run_with_conditions(&mut promise, Duration::from_secs(2));
538516
let value: TestJoinedValue = promise.take().available().unwrap();

src/buffer/buffer_storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub(crate) struct BufferStorage<T> {
4444
}
4545

4646
impl<T> BufferStorage<T> {
47-
pub(crate) fn count(&self, session: Entity) -> usize {
47+
pub(crate) fn count(&self, session: Entity) -> usize {
4848
self.reverse_queues
4949
.get(&session)
5050
.map(|q| q.len())

src/buffer/bufferable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use smallvec::SmallVec;
2020

2121
use crate::{
2222
Accessed, AddOperation, Buffer, BufferSettings, Buffered, Builder, Chain,
23-
CleanupWorkflowConditions, CloneFromBuffer, Join, Joined, Listen, Output, Scope,
24-
ScopeSettings, UnusedTarget,
23+
CleanupWorkflowConditions, CloneFromBuffer, Join, Joined, Listen, Output, Scope, ScopeSettings,
24+
UnusedTarget,
2525
};
2626

2727
pub type BufferKeys<B> = <<B as Bufferable>::BufferType as Accessed>::Key;

src/buffer/buffered.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,7 @@ pub(crate) fn add_listener_to_source(
540540
listener: Entity,
541541
world: &mut World,
542542
) -> OperationResult {
543-
let mut targets = world
544-
.get_mut::<ForkTargetStorage>(source)
545-
.or_broken()?;
543+
let mut targets = world.get_mut::<ForkTargetStorage>(source).or_broken()?;
546544
if !targets.0.contains(&listener) {
547545
targets.0.push(listener);
548546
}

0 commit comments

Comments
 (0)