Use alloc::collections::LinkedList;

use alloc::collections::LinkedList;

How do I make the above line compile ?

rustc gives error of:

3 | use alloc::collections::LinkedList;
  |     ^^^^^ use of undeclared crate or module `alloc`

however, IntelliJ can jump to it with no problem via:

stdlib-1.51.0/alloc/src/collections/linked_list.rs

You still need extern crate here.

extern crate alloc;
use alloc::collections::LinkedList;
1 Like

Realistically, you’ll just want to use std::collections::LinkedList (which is actually internally a re-export of the type from alloc). Unless you’re developing with #![no_std].

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.