Import lazy_static through normal use

This commit is contained in:
Philipp Oppermann
2018-11-13 11:36:40 +01:00
parent 21f3152dc0
commit e7d4012653
9 changed files with 11 additions and 4 deletions

View File

@@ -478,7 +478,6 @@ Let's add the `lazy_static` crate to our project:
```rust
// in src/main.rs
#[macro_use]
extern crate lazy_static;
```
@@ -490,13 +489,15 @@ version = "1.0"
features = ["spin_no_std"]
```
We need the `spin_no_std` feature, since we don't link the standard library. We also need the `#[macro_use]` attribute on the `extern crate` line to import the `lazy_static!` macro.
We need the `spin_no_std` feature, since we don't link the standard library.
With `lazy_static`, we can define our static `WRITER` without problems:
```rust
// in src/vga_buffer.rs
use lazy_static::lazy_static;
lazy_static! {
pub static ref WRITER: Writer = Writer {
column_position: 0,