#`Vec.concat` method is unavailable

5 messages · Page 1 of 1 (latest)

echo vault
cedar remnant
#

It seems to be only for a Vec of Vecs.

    let v = vec![&env, vec![&env, 1], vec![&env, 2]];
    println!("{:?}",v.concat()) // prints: Vec(Ok(1), Ok(2))
hallow dirge
#

concat concatenates two vectors of the same type, so it makes sense. In rust std you can also do [vec_1, vec_2].concat() but this will not yield a soroban vec, so the sdk needs to rely on their own type for concat() which is in fact a vector

ancient fox
#

what about it's expecting a vec<vec<T>>

#
let vec_of_vecs: Vec<Vec<i32>> = vec![vec![1, 2, 3], vec![4, 5, 6], vec![7, 8, 9]];
let concatenated_vec = vec_of_vecs.concat();
println!("{:?}", concatenated_vec); // Output: [1, 2, 3, 4, 5, 6, 7, 8, 9]