Skip to main content

std_mel/ops/vec/
block.rs

1use melodium_core::*;
2use melodium_macro::mel_treatment;
3
4#[mel_treatment(
5    generic T (PartialEquality)
6    input value Block<T>
7    input vec Block<Vec<T>>
8    output contains Block<bool>
9)]
10pub async fn contains() {
11    if let (Ok(value), Ok(Value::Vec(vec))) = (value.recv_one().await, vec.recv_one().await) {
12        let _ = contains
13            .send_one(vec.iter().any(|val| val.partial_equality_eq(&value)).into())
14            .await;
15    }
16}
17
18#[mel_treatment(
19    generic T ()
20    input first Block<Vec<T>>
21    input second Block<Vec<T>>
22    output concatened Block<Vec<T>>
23)]
24pub async fn concat() {
25    if let (Ok(Value::Vec(mut first)), Ok(Value::Vec(mut second))) =
26        (first.recv_one().await, second.recv_one().await)
27    {
28        first.append(&mut second);
29        let _ = concatened.send_one(Value::Vec(first)).await;
30    }
31}