From f200f792ff13995c58c58f37be8e2effdc8db593 Mon Sep 17 00:00:00 2001 From: Narukara Date: Wed, 18 Jan 2023 04:02:19 +0800 Subject: [PATCH] remove extern crate statements --- src/collections/index.md | 9 ++++----- src/interoperability/c-with-rust.md | 2 -- src/peripherals/singletons.md | 3 +-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/collections/index.md b/src/collections/index.md index 7319a397..aa03666a 100644 --- a/src/collections/index.md +++ b/src/collections/index.md @@ -49,9 +49,8 @@ in your program instead of this allocator. ``` rust,ignore // Bump pointer allocator implementation -extern crate cortex_m; - -use core::alloc::GlobalAlloc; +use core::alloc::{GlobalAlloc, Layout}; +use core::cell::UnsafeCell; use core::ptr; use cortex_m::interrupt; @@ -144,8 +143,7 @@ as they are exact same implementation. allocator. Just `use` its collections and proceed to instantiate them: ```rust,ignore -extern crate heapless; // v0.4.x - +// heapless version: v0.4.x use heapless::Vec; use heapless::consts::*; @@ -155,6 +153,7 @@ fn main() -> ! { xs.push(42).unwrap(); assert_eq!(xs.pop(), Some(42)); + loop {} } ``` diff --git a/src/interoperability/c-with-rust.md b/src/interoperability/c-with-rust.md index d5d8db39..6bec3bd8 100644 --- a/src/interoperability/c-with-rust.md +++ b/src/interoperability/c-with-rust.md @@ -125,8 +125,6 @@ For projects with limited dependencies or complexity, or for projects where it i In the simplest case of compiling a single C file as a dependency to a static library, an example `build.rs` script using the [`cc` crate] would look like this: ```rust,ignore -extern crate cc; - fn main() { cc::Build::new() .file("foo.c") diff --git a/src/peripherals/singletons.md b/src/peripherals/singletons.md index 3f04aa17..1f3a556e 100644 --- a/src/peripherals/singletons.md +++ b/src/peripherals/singletons.md @@ -61,8 +61,7 @@ This has a small runtime overhead because we must wrap the `SerialPort` structur Although we created our own `Peripherals` structure above, it is not necessary to do this for your code. the `cortex_m` crate contains a macro called `singleton!()` that will perform this action for you. ```rust,ignore -#[macro_use(singleton)] -extern crate cortex_m; +use cortex_m::singleton; fn main() { // OK if `main` is executed only once