rust-embedded / heapless

Heapless, `static` friendly data structures
Apache License 2.0
1.52k stars 181 forks source link

LinearMap: add `LinearMapView`, similar to `VecView` #479

Closed sosthene-nitrokey closed 3 months ago

sosthene-nitrokey commented 3 months ago

While implementing I realized that &mut LinearMap does not implement IntoIter. Should I add it ? 

I currently did not add it to LinearMapView either for symmetry, but that can lead to confusion. For example, the following doesn't compile:

use heapless::{LinearMap, LinearMapView};

let mut map: LinearMap<_, _, 8> = LinearMap::new();
let map_view: &mut LinearMapView<_, _> = &mut map;

for (key, val) in map_view {
    println!("key: {} val: {}", key, val);
}

The fix is to use instead

for (key, val) in &*map_view {
sosthene-nitrokey commented 3 months ago

replaced by #491