Skip to content

Commit

Permalink
Add ObjectArgument::num_objects
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Jan 13, 2023
1 parent e04f42b commit 6b201ff
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/fj-kernel/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pub trait ObjectArgument<T>: IntoIterator<Item = T> {
/// A return value that has one more element thatn the argument
type SizePlusOne<R>;

/// Return the number of objects
fn num_objects(&self) -> usize;

/// Create a return value by mapping the implementing type
fn map<F, R>(self, f: F) -> Self::SameSize<R>
where
Expand All @@ -62,6 +65,10 @@ impl<T> ObjectArgument<T> for Vec<T> {
type SameSize<R> = Vec<R>;
type SizePlusOne<R> = Vec<R>;

fn num_objects(&self) -> usize {
self.len()
}

fn map<F, R>(self, mut f: F) -> Self::SameSize<R>
where
F: FnMut(T) -> R,
Expand Down Expand Up @@ -96,6 +103,10 @@ macro_rules! impl_object_argument_for_arrays {
type SameSize<R> = [R; $len];
type SizePlusOne<R> = [R; $len_plus_one];

fn num_objects(&self) -> usize {
self.len()
}

fn map<F, R>(self, f: F) -> Self::SameSize<R>
where
F: FnMut(T) -> R,
Expand Down

0 comments on commit 6b201ff

Please sign in to comment.