Fill BtreeSet with range corresponding to Vec len

How can I do this:

let v=vec![0,1,2,3];
let mut s=BTreeSet::new();
//here I want to fill btreeset with indexes of vec
//I've tried, but no luck
s.extend([..v.len()]);

Thank you

You do it like this:

let v = vec![0, 1, 2, 3];
let mut s = BTreeSet::new();
s.extend(0..v.len());

playground

1 Like

Almost... :wink:
Thanks