diff --git a/blog/content/second-edition/posts/03-vga-text-buffer/index.md b/blog/content/second-edition/posts/03-vga-text-buffer/index.md index c16606ae..b6395148 100644 --- a/blog/content/second-edition/posts/03-vga-text-buffer/index.md +++ b/blog/content/second-edition/posts/03-vga-text-buffer/index.md @@ -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, diff --git a/blog/content/second-edition/posts/05-integration-tests/index.md b/blog/content/second-edition/posts/05-integration-tests/index.md index b0b5125a..7b2a6232 100644 --- a/blog/content/second-edition/posts/05-integration-tests/index.md +++ b/blog/content/second-edition/posts/05-integration-tests/index.md @@ -85,6 +85,7 @@ mod serial; use uart_16550::SerialPort; use spin::Mutex; +use lazy_static::lazy_static; lazy_static! { pub static ref SERIAL1: Mutex = { @@ -375,7 +376,6 @@ Cargo supports hybrid projects that are both a library and a binary. We only nee extern crate bootloader; extern crate spin; extern crate volatile; -#[macro_use] extern crate lazy_static; extern crate uart_16550; extern crate x86_64; diff --git a/blog/content/second-edition/posts/06-cpu-exceptions/index.md b/blog/content/second-edition/posts/06-cpu-exceptions/index.md index 6be16753..c6acc5cf 100644 --- a/blog/content/second-edition/posts/06-cpu-exceptions/index.md +++ b/blog/content/second-edition/posts/06-cpu-exceptions/index.md @@ -382,6 +382,8 @@ We already imported the `lazy_static` crate when we [created an abstraction for ```rust // in src/interrupts.rs +use lazy_static::lazy_static; + lazy_static! { static ref IDT: InterruptDescriptorTable = { let mut idt = InterruptDescriptorTable::new(); diff --git a/blog/content/second-edition/posts/07-double-faults/index.md b/blog/content/second-edition/posts/07-double-faults/index.md index fc451acd..41c588a3 100644 --- a/blog/content/second-edition/posts/07-double-faults/index.md +++ b/blog/content/second-edition/posts/07-double-faults/index.md @@ -235,6 +235,7 @@ pub mod gdt; use x86_64::VirtAddr; use x86_64::structures::tss::TaskStateSegment; +use lazy_static::lazy_static; pub const DOUBLE_FAULT_IST_INDEX: u16 = 0; diff --git a/src/gdt.rs b/src/gdt.rs index be448606..b394d154 100644 --- a/src/gdt.rs +++ b/src/gdt.rs @@ -1,6 +1,7 @@ use x86_64::structures::gdt::{Descriptor, GlobalDescriptorTable, SegmentSelector}; use x86_64::structures::tss::TaskStateSegment; use x86_64::VirtAddr; +use lazy_static::lazy_static; pub const DOUBLE_FAULT_IST_INDEX: u16 = 0; diff --git a/src/interrupts.rs b/src/interrupts.rs index b1cdf323..1c978ada 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -8,6 +8,7 @@ use gdt; use pic8259_simple::ChainedPics; use spin; use x86_64::structures::idt::{ExceptionStackFrame, InterruptDescriptorTable}; +use lazy_static::lazy_static; pub const PIC_1_OFFSET: u8 = 32; pub const PIC_2_OFFSET: u8 = PIC_1_OFFSET + 8; diff --git a/src/lib.rs b/src/lib.rs index 4c859466..accd97a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,6 @@ extern crate bootloader; extern crate spin; extern crate volatile; -#[macro_use] extern crate lazy_static; extern crate pic8259_simple; extern crate uart_16550; diff --git a/src/serial.rs b/src/serial.rs index 830bf2f5..494273c9 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -1,5 +1,6 @@ use spin::Mutex; use uart_16550::SerialPort; +use lazy_static::lazy_static; lazy_static! { pub static ref SERIAL1: Mutex = { diff --git a/src/vga_buffer.rs b/src/vga_buffer.rs index f3d9a58c..9c245190 100644 --- a/src/vga_buffer.rs +++ b/src/vga_buffer.rs @@ -1,6 +1,7 @@ use core::fmt; use spin::Mutex; use volatile::Volatile; +use lazy_static::lazy_static; lazy_static! { /// A global `Writer` instance that can be used for printing to the VGA text buffer.