Title: Hands-on Rust: map_idx causes error E0425(page 81)

Thanks for finding that! I’ve added the issues into the issue tracker and will have them resolved for the next beta.

Does the version in the downloadable code folder compile ok for you? It builds correctly on my system. I suspect that the book needs to be more explicit about where the map_idx function goes. It isn’t part of the Map implementation - it is a free function. From the map.rs file:

#[derive(Copy, Clone, PartialEq)]
pub enum TileType {
    Wall,
    Floor,
}

pub fn map_idx(x: i32, y: i32) -> usize {
    ((y * SCREEN_WIDTH) + x) as usize
}

pub struct Map {
    pub tiles: Vec<TileType>,
}

impl Map {
    pub fn new() -> Self {
    // etc.

Thanks again. The errata I’m receiving are great, and are really helping the book shape up.

1 Like