Fix syntax errors in first construct_buffer() version

This commit is contained in:
Philipp Oppermann
2018-05-04 18:12:08 +02:00
parent ba266f31c5
commit cb1fa395b1

View File

@@ -214,12 +214,15 @@ So how do we create a `Buffer` instance? The naive approach does not work unfort
```rust ```rust
fn construct_buffer() -> Buffer { fn construct_buffer() -> Buffer {
let empty_char = ScreenChar {
ascii_character: b' ',
color_code: ColorCode::new(Color)
}
Buffer { Buffer {
chars: [[Volatile::new(empty_char); BUFFER_WIDTH]; BUFFER_HEIGHT], chars: [[Volatile::new(empty_char()); BUFFER_WIDTH]; BUFFER_HEIGHT],
}
}
fn empty_char() -> ScreenChar {
ScreenChar {
ascii_character: b' ',
color_code: ColorCode::new(Color::Green, Color::Brown),
} }
} }
``` ```
@@ -271,13 +274,6 @@ fn construct_buffer() -> Buffer {
chars: array_init(|_| array_init(|_| Volatile::new(empty_char()))), chars: array_init(|_| array_init(|_| Volatile::new(empty_char()))),
} }
} }
fn empty_char() -> ScreenChar {
ScreenChar {
ascii_character: b' ',
color_code: ColorCode::new(Color::Green, Color::Brown),
}
}
``` ```
See the [documentation of `array_init`][`array_init`] for more information about using that crate. See the [documentation of `array_init`][`array_init`] for more information about using that crate.