Skip to content

Commit d074da8

Browse files
Fix 1.75 build failure / add CI (#34)
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai> Signed-off-by: Michael X. Grey <greyxmike@gmail.com> Co-authored-by: Michael X. Grey <greyxmike@gmail.com>
1 parent 85501df commit d074da8

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

.github/workflows/ci_linux.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@ jobs:
3131
run: cargo build --features single_threaded_async
3232
- name: Test single_threaded_async
3333
run: cargo test --features single_threaded_async
34+
35+
# Build and test with 1.75
36+
- name: Install Rust 1.75
37+
run: rustup default 1.75
38+
- name: Build default features with Rust 1.75
39+
run: cargo build
40+
- name: Test default features with Rust 1.75
41+
run: cargo test

src/chain/split.rs

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,12 @@ impl<T: 'static + Send + Sync, const N: usize> Splittable for [T; N] {
532532

533533
fn next(key: &Option<Self::Key>) -> Option<Self::Key> {
534534
// Static arrays have a firm limit of N
535-
SplitAsList::<Self>::next(key).take_if(|key| Self::validate(key))
535+
let mut key = SplitAsList::<Self>::next(key);
536+
if key.map_or(false, |key| Self::validate(&key)) {
537+
key.take()
538+
} else {
539+
None
540+
}
536541
}
537542

538543
fn split(self, dispatcher: SplitDispatcher<'_, Self::Key, Self::Item>) -> OperationResult {
@@ -936,4 +941,49 @@ mod tests {
936941
assert_eq!(result["fib"], input_map["fib"]);
937942
assert_eq!(result["dib"], input_map["dib"]);
938943
}
944+
945+
#[test]
946+
fn test_array_split_limit() {
947+
let mut context = TestingContext::minimal_plugins();
948+
949+
let workflow = context.spawn_io_workflow(|scope, builder| {
950+
scope.input.chain(builder).split(|split| {
951+
let err = split
952+
.next_branch(|_, chain| {
953+
chain.value().connect(scope.terminate);
954+
})
955+
.unwrap()
956+
.next_branch(|_, chain| {
957+
chain.value().connect(scope.terminate);
958+
})
959+
.unwrap()
960+
.next_branch(|_, chain| {
961+
chain.value().connect(scope.terminate);
962+
})
963+
.unwrap()
964+
.next_branch(|_, chain| {
965+
chain.value().connect(scope.terminate);
966+
})
967+
.unwrap()
968+
// This last one should fail because it should exceed the
969+
// array limit
970+
.next_branch(|_, chain| {
971+
chain.value().connect(scope.terminate);
972+
});
973+
974+
assert!(matches!(err, Err(_)));
975+
})
976+
});
977+
978+
let mut promise =
979+
context.command(|commands| commands.request([1, 2, 3, 4], workflow).take_response());
980+
981+
context.run_with_conditions(&mut promise, 1);
982+
assert!(context.no_unhandled_errors());
983+
984+
let result = promise.take().available().unwrap();
985+
// All the values in the array are racing to finish, but the first value
986+
// should finish first since it will naturally get queued first.
987+
assert_eq!(result, 1);
988+
}
939989
}

0 commit comments

Comments
 (0)