E0432 Unresolved Import Fix
One use line, one segment that names nothing: a spelling, a module that does not contain the item, a path that starts in the wrong place. This guide separates the shapes that produce E0432 and matches each one to the correction that makes the import resolve: fix the segment, change the module, add the prefix, or link the crate.
Written November 23, 2026 · Tested with Rust 1.99.1 · 27 min read
- The rule underneath: a use path resolves segment by segment, and every segment must name an item in the previous one
- How to read the diagnostic
- The first failure: a misspelled standard library item
- The second failure: an item the module does not contain
Written November 23, 2026
Tested with Rust 1.99.1
What this guide is
Error E0432 is an import that names nothing. The error codes index states it in one line: an import was unresolved. A use declaration creates a local name for an item at a path, and the path is resolved segment by segment - crate, module, item - so E0432 fires at the first segment that names something the target does not contain: a misspelled item, a module segment that is not there, an item that lives in a different module, or a crate that was never linked. The index's own advice covers most of the guide: verify that you did not misspell the import name and that the import exists in the module you tried to import it from.
The forms in this guide each reproduce E0432 with a small, complete program, and each fails at a different segment. A misspelled standard library item. An item name that the module simply does not contain. A misspelled module segment in an otherwise correct path. A module of your own named from inside a nested module without the crate:: prefix. An associated function imported as if a type were a module. An item that exists, but under a different module. A crate that is not linked at all. And an item that a module of your own never defined. In each family the failing program is small, the full compiler output is shown, and the fix corrects the segment that failed: the spelling, the module, the prefix, the kind of thing imported, the dependency, or the missing definition.
Three neighboring results are not E0432 and are worked only in the traps and the decision summary. The same misspelled name written in an expression path, rather than in a use declaration, is E0433 - the subject of the E0433 guide - because the position of the name decides the code. An item that exists and is named by the correct path, but is private, is E0603. And a function called as a value with no import and no definition in scope is E0425.
Build every program in this guide with rustc --edition 2021. In the compiler transcripts below, the file names are the bare names shown on the command line.
The rule underneath: a use path resolves segment by segment, and every segment must name an item in the previous one
The Reference defines a use declaration as creating one or more local name bindings synonymous with some other path - a shortcut, so the shorter name can be used in place of the full path. For that shortcut to exist, the path itself has to resolve. The first segment starts the walk: in Rust 2018 and later, a use path that begins with a crate name starts from that crate, one that begins with the literal crate:: starts at the current crate's root, and self:: and super:: start at the current and parent modules - the error codes index states the same rule, adding that in Rust 2015 paths in use statements were relative to the crate root. Each later segment must then name an item inside what the previous segment resolved to: a module inside a crate, an item inside a module. A segment that names nothing - because the spelling is off, because the item lives elsewhere, or because the module never had it - stops the walk, and that stop is E0432.
The Book's module chapters add the two facts that explain the remaining families. First, a path can take two forms: an absolute path, which starts from a crate root - the crate name for an external crate, the literal crate for the current one - and a relative path, which starts from the current module and uses self, super, or an identifier in the current module. Inside a nested module, a sibling module at the crate root is not an identifier in the current module, so naming it bare starts the walk in the wrong place; crate:: starts it at the root, where the name exists. Second, items are private by default and pub is what makes an item usable from other modules - which is why privacy has its own error, E0603, separate from absence: a private item resolves and is then refused, while an E0432 item is never found at all.
One restriction from the Reference decides the method family. A use path can bind nameable items, enum variants, built-in types, and a few other kinds - it cannot import associated items. A method or associated function such as HashMap::new is an associated item of its type, not an item in a module, so a path that continues past the type, treating the type as a module, has no segment to resolve to. The import that works names the type itself, and the associated function is then called through the type.
How to read the diagnostic
The header names the longest prefix that was being resolved: "unresolved import std::collections::BTreeMapp", "unresolved import std::collection", "unresolved import helpers", "unresolved import serde". Read it for where the walk stopped. When the header names the full path, the last segment is the problem. When it names only an early prefix - std::collection, helpers, serde - the walk stopped there, and everything after that segment was never reached, however correct it looks.
The label under the caret says which kind of stop it was. "no BTreeMapp in collections" and "no farewell in helpers" mean the module resolved and the item does not exist in it. "could not find collection in std" means the module segment itself is missing. "HashMap is a struct, not a module" means the path continued past a type. "use of unresolved module or unlinked crate serde" means the first segment names no linked crate at all. And the helps are unusually direct in this family of errors: "a similar name exists in the module" prints the corrected line when the item is a near miss, "a similar path exists" prints the crate:: form when the start was wrong, and "consider importing this type alias instead" prints the item's real module when it lives somewhere else. When a help prints a complete corrected use line, it has already made the diagnosis - the remaining work is confirming that the printed path is the item the code meant.
The first failure: a misspelled standard library item
BTreeMapp has one letter too many. The module std::collections resolves - its contents include BTreeMap, the sorted map documented in the collections module alongside HashMap - but no item under the spelled name:
use std::collections::BTreeMapp;
fn main() {
let mut m = BTreeMapp::new();
m.insert("a", 1);
println!("{:?}", m.get("a"));
}
$ rustc --edition 2021 fail_misspelled_std.rs -o fail_misspelled_std
error[E0432]: unresolved import `std::collections::BTreeMapp`
--> fail_misspelled_std.rs:1:5
|
1 | use std::collections::BTreeMapp;
| ^^^^^^^^^^^^^^^^^^---------
| |
| no `BTreeMapp` in `collections`
|
help: a similar name exists in the module
|
1 - use std::collections::BTreeMapp;
1 + use std::collections::BTreeMap;
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0432`.
The label states the whole case - no such item in the module - and the help names the near miss and rewrites the line. The fix takes it:
use std::collections::BTreeMap;
fn main() {
let mut m = BTreeMap::new();
m.insert("a", 1);
println!("{:?}", m.get("a"));
}
$ rustc --edition 2021 fix_misspelled_std.rs -o fix_misspelled_std
$ ./fix_misspelled_std
Some(1)
The output is Some(1), the value stored under the key. A similar-name help is a strong sign the failure is a spelling, but read it before accepting it: where two real items sit one letter apart, the compiler offers the nearest name, not necessarily the intended one.
The second failure: an item the module does not contain
LinkedHashMap is spelled exactly as intended - it is a familiar map name from other languages and libraries - but std::collections contains no item by that name at all. There is a LinkedList in the module, and maps named HashMap and BTreeMap; a linked hash map is not among them:
use std::collections::LinkedHashMap;
fn main() {
let m: LinkedHashMap<String, i32> = LinkedHashMap::new();
println!("{}", m.len());
}
$ rustc --edition 2021 fail_no_such_item.rs -o fail_no_such_item
error[E0432]: unresolved import `std::collections::LinkedHashMap`
--> fail_no_such_item.rs:1:5
|
1 | use std::collections::LinkedHashMap;
| ^^^^^^^^^^^^^^^^^^-------------
| |
| no `LinkedHashMap` in `collections`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0432`.
Compare the first family: the label has the same shape, "no LinkedHashMap in collections", but there is no similar-name help, because there is no near miss to offer. That absence is the diagnostic difference between a typo and a wrong assumption about what a module holds. The fix chooses a map the module does contain - here HashMap, with the same key and value types:
use std::collections::HashMap;
fn main() {
let m: HashMap<String, i32> = HashMap::new();
println!("{}", m.len());
}
$ rustc --edition 2021 fix_no_such_item.rs -o fix_no_such_item
$ ./fix_no_such_item
0
The output is 0, the length of the empty map. In real code the replacement is a design choice, not a spelling correction: the item that was wanted may live in an external crate, in which case the fix is to link that crate - the seventh family - or the code has to be written against a type the standard library actually provides, checking the module's item list rather than memory of another language's library.
The third failure: a module segment that is not there
Here the item name is right and the module name is wrong: std::collection, without the final s, is not a module in std. The walk stops one segment earlier than in the first two families, and the header shows it - it names only the prefix that failed, std::collection, not the full path:
use std::collection::HashMap;
fn main() {
let m: HashMap<String, i32> = HashMap::new();
println!("{}", m.len());
}
$ rustc --edition 2021 fail_no_such_module.rs -o fail_no_such_module
error[E0432]: unresolved import `std::collection`
--> fail_no_such_module.rs:1:10
|
1 | use std::collection::HashMap;
| ^^^^^^^^^^ could not find `collection` in `std`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0432`.
The caret sits under the module segment and the label reads "could not find collection in std" - the lookup that failed was for a module inside a crate, not for an item inside a module, and HashMap was never reached. There is no help in this case: for a module segment inside a resolved crate, the compiler does not offer a corrected segment the way it rewrites near-miss item names. (A misspelled first segment is a different shape: use helper::greet; where mod helpers exists gets a "there is a crate or module with a similar name" help printing use helpers::greet;, under the unlinked-crate label.) The fix restores the segment:
use std::collections::HashMap;
fn main() {
let m: HashMap<String, i32> = HashMap::new();
println!("{}", m.len());
}
$ rustc --edition 2021 fix_no_such_module.rs -o fix_no_such_module
$ ./fix_no_such_module
0
The output is 0. The general reading rule follows from the header's shape: when the unresolved import names a strict prefix of the path you wrote, the failing segment is the last one in the header, and the rest of the line is unexamined - fixing the item name at the end of such a line changes nothing until the module segment resolves.
The fourth failure: a local module named without the crate:: prefix, from a nested module
helpers exists, at the crate root, and greet is public inside it. The failing import sits inside mod report, a sibling of helpers - and from inside report, a use path beginning with helpers does not start at the crate root, so the first segment names nothing in the starting scope:
mod helpers {
pub fn greet() -> &'static str { "hello" }
}
mod report {
use helpers::greet;
pub fn show() -> &'static str { greet() }
}
fn main() {
println!("{}", report::show());
println!("{}", helpers::greet());
}
$ rustc --edition 2021 fail_missing_prefix.rs -o fail_missing_prefix
error[E0432]: unresolved import `helpers`
--> fail_missing_prefix.rs:5:9
|
5 | use helpers::greet;
| ^^^^^^^
|
= note: `use` statements changed in Rust 2018; read more at <https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html>
help: a similar path exists
|
5 | use crate::helpers::greet;
| +++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0432`.
The same import written at the crate root would resolve, which is what makes this family confusing: the line is correct in one scope and wrong in another. The note points at the 2018 path change, and the help performs the fix - start the path at the crate root with crate::, the absolute form the Book describes for code in the current crate. A super:: start would also reach the root from a direct child module, naming the parent first; crate:: states the root directly and keeps working if the module is nested deeper later:
mod helpers {
pub fn greet() -> &'static str { "hello" }
}
mod report {
use crate::helpers::greet;
pub fn show() -> &'static str { greet() }
}
fn main() {
println!("{}", report::show());
println!("{}", helpers::greet());
}
$ rustc --edition 2021 fix_missing_prefix.rs -o fix_missing_prefix
$ ./fix_missing_prefix
hello
hello
The output is hello twice - once through report::show, which uses the import, and once through the direct path in main. The separation from the E0433 guide is position, again: the same bare helpers start written in an expression path inside a module is that guide's sibling-module family, under E0433; written in a use declaration, it is this family, under E0432.
The fifth failure: an associated function imported as if the type were a module
new is real, and HashMap is real - but new is an associated function of the HashMap type, not an item in a module named HashMap. A use path can bind items a module contains; it cannot import associated items, so the segment after the type has nothing to resolve to:
use std::collections::HashMap::new;
fn main() {
let m: std::collections::HashMap<String, i32> = new();
println!("{}", m.len());
}
$ rustc --edition 2021 fail_import_method.rs -o fail_import_method
error[E0432]: unresolved import `std::collections::HashMap`
--> fail_import_method.rs:1:23
|
1 | use std::collections::HashMap::new;
| ^^^^^^^ `HashMap` is a struct, not a module
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0432`.
The label is the diagnosis in one clause: "HashMap is a struct, not a module". The header stops at the type, and the failing program's annotation is written as a full path so that the import is the only error in the file - the same program with a bare HashMap annotation would add a second error for the unresolved type. The fix imports the type, and calls the associated function through it, which is the only way associated functions are reached:
use std::collections::HashMap;
fn main() {
let m: HashMap<String, i32> = HashMap::new();
println!("{}", m.len());
}
$ rustc --edition 2021 fix_import_method.rs -o fix_import_method
$ ./fix_import_method
0
The output is 0. The same rule covers methods generally: there is no use line that brings len, insert, or any other method into scope as a bare name. Traits are the one apparent exception, and they follow the rule rather than breaking it - a trait is itself a module item, so it can be imported, and importing it is what makes its methods callable on a type.
The sixth failure: an item that lives in a different module
AtomicBool exists in the standard library - as a boolean type that can be safely shared between threads, documented under std::sync::atomic. It has never been in std::collections, so the import fails exactly as a nonexistent item would, with one difference: the compiler knows where the item does live, and says so:
use std::collections::AtomicBool;
fn main() {
let b = AtomicBool::new(true);
println!("{}", b.load(std::sync::atomic::Ordering::SeqCst));
}
$ rustc --edition 2021 fail_wrong_path.rs -o fail_wrong_path
error[E0432]: unresolved import `std::collections::AtomicBool`
--> fail_wrong_path.rs:1:5
|
1 | use std::collections::AtomicBool;
| ^^^^^^^^^^^^^^^^^^----------
| |
| no `AtomicBool` in `collections`
|
help: consider importing this type alias instead
|
1 - use std::collections::AtomicBool;
1 + use std::sync::atomic::AtomicBool;
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0432`.
The label matches the second family - no such item in this module - and the help separates the two: here it prints the item's real path as a complete replacement line. The fix takes it, and imports Ordering from the same module instead of writing its full path at the call:
use std::sync::atomic::{AtomicBool, Ordering};
fn main() {
let b = AtomicBool::new(true);
println!("{}", b.load(Ordering::SeqCst));
}
$ rustc --edition 2021 fix_wrong_path.rs -o fix_wrong_path
$ ./fix_wrong_path
true
The output is true, the value the atomic was created with. This family is common after a library reorganizes, or when an item is remembered by the company it keeps - atomics grouped mentally with collections of shared state, say - rather than by its module. When the help prints a full alternative path, the item exists and only its address was wrong; when no help appears, as in the second family, the item may not exist in the library at all.
The seventh failure: a crate that was never linked
Every segment after the first in this path may be perfectly correct for the crate it names - it changes nothing, because the first segment names a crate the program does not link. A single file compiled with rustc links the standard library; serde is an external crate, and nothing has linked it:
use serde::Serialize;
fn main() {
println!("ready");
}
$ rustc --edition 2021 fail_no_such_crate.rs -o fail_no_such_crate
error[E0432]: unresolved import `serde`
--> fail_no_such_crate.rs:1:5
|
1 | use serde::Serialize;
| ^^^^^ use of unresolved module or unlinked crate `serde`
|
= help: you might be missing a crate named `serde`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0432`.
The header names only the crate, the label says "unresolved module or unlinked crate", and the help is a statement about the project's dependencies, not about the line. No edit to the use line can fix this family while the path still starts with an unlinked crate: the fix is to link it - in a Cargo project, add the crate as a dependency in Cargo.toml, as the Book's external-package section describes, after which the same import resolves - or, where the import is not actually needed, to remove it. The program below is the second form, the import removed, and it is the form a single rustc file can show:
fn main() {
println!("ready");
}
$ rustc --edition 2021 fix_no_such_crate.rs -o fix_no_such_crate
$ ./fix_no_such_crate
ready
The output is ready. Distinguish this family from a misspelled crate name, which produces the same header shape: if the spelled name is a crate the project intends to use, check the spelling against Cargo.toml first, and the dependency list second - a correct spelling with no dependency entry is this family, and a dependency entry under a different spelling is the first family one segment earlier.
The eighth failure: an item a module of your own does not define
The local counterpart of the second family. helpers resolves - it is declared in the same file - and greet exists inside it, but the import asks for farewell, which the module never defines:
mod helpers {
pub fn greet() -> &'static str { "hello" }
}
use helpers::farewell;
fn main() {
println!("{}", farewell());
println!("{}", helpers::greet());
}
$ rustc --edition 2021 fail_local_no_item.rs -o fail_local_no_item
error[E0432]: unresolved import `helpers::farewell`
--> fail_local_no_item.rs:4:5
|
4 | use helpers::farewell;
| ^^^^^^^^^--------
| |
| no `farewell` in `helpers`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0432`.
The label is the second family's label with a local module in it: "no farewell in helpers". Against your own module there is no documentation page to consult - the module's contents are the file - so the check is direct: either the item was renamed, it was planned and never written, or the import names the wrong module for it. Here it was never written, and the fix defines it, with the same public visibility as the module's other function:
mod helpers {
pub fn greet() -> &'static str { "hello" }
pub fn farewell() -> &'static str { "bye" }
}
use helpers::farewell;
fn main() {
println!("{}", farewell());
println!("{}", helpers::greet());
}
$ rustc --edition 2021 fix_local_no_item.rs -o fix_local_no_item
$ ./fix_local_no_item
bye
hello
The output is bye, then hello. Note what did not happen: making farewell public was never the issue, because a name that does not exist has no visibility to set. If the item does exist in the module and the import still fails, read the label again - an existing private item is refused under a different code, E0603, which is the first trap below.
The fixes in reach order
- The label says "no
XinM" and a help reads "a similar name exists in the module": the last segment is misspelled - take the corrected line the help prints, after confirming the offered name is the item intended. - The label says "no
XinM" with no help: the module holds no such item - check the module's actual item list, choose an item it does contain, or link the crate that provides the one wanted. - The header names only a prefix of your path and the label says "could not find" a module segment: the module segment is wrong - correct it; the segments after it were never examined.
- The import sits inside a nested module, the header names only its first segment, and a help reads "a similar path exists": the path starts in the wrong scope - start it with
crate::(orsuper::where the parent is the intended start). - The label says a name "is a struct, not a module": the path continues past a type into an associated item - import the type itself and call the associated function through it.
- The label says "no
XinM" and a help reads "consider importing this type alias instead", printing a different full path: the item exists in another module - import it from the path the help prints. - The label says "use of unresolved module or unlinked crate": the first segment names no linked crate - add the crate to
Cargo.toml, correct the crate name's spelling, or remove the import. - The module is your own and the label says "no
X" in it: the item is not defined there - define it, correct the name to the item that was defined, or point the import at the module that defines it.
Traps
- The same missing name in an expression path is E0433, not E0432. Move the misspelling out of the
useline and into a call, and the code changes while the underlying absence stays identical:
fn main() {
let m = std::collections::BTreeMapp::new();
println!("{}", m.len());
}
$ rustc --edition 2021 probe_e0433_path.rs -o probe_e0433_path
error[E0433]: cannot find `BTreeMapp` in `collections`
--> probe_e0433_path.rs:2:31
|
2 | let m = std::collections::BTreeMapp::new();
| ^^^^^^^^^ could not find `BTreeMapp` in `collections`
|
help: a struct with a similar name exists
|
2 - let m = std::collections::BTreeMapp::new();
2 + let m = std::collections::BTreeMap::new();
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0433`.
BTreeMapp in collections" and the error codes index defines E0433 as an undeclared crate, module, or type being used. The boundary is position alone: a failing path inside a use declaration is E0432, the same failing path anywhere else is E0433 - which is why the E0433 guide and this one meet at exactly this line, each treating the other position as the trap.
- A private item is E0603, not E0432. Here every segment is spelled right and the item exists - secret is defined in mod a - but it is not pub, so the import is refused rather than unresolved:mod a {
fn secret() -> i32 { 42 }
pub fn open() -> i32 { 1 }
}
use crate::a::secret;
fn main() {
println!("{}", secret());
println!("{}", a::open());
}
$ rustc --edition 2021 probe_private_item.rs -o probe_private_item
error[E0603]: function `secret` is private
--> probe_private_item.rs:5:15
|
5 | use crate::a::secret;
| ^^^^^^ private function
|
note: the function `secret` is defined here
--> probe_private_item.rs:2:5
|
2 | fn secret() -> i32 { 42 }
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0603`.
The header reads "function secret is private" and the error codes index defines E0603 as a private item used outside its scope, fixed by making the item public with pub. The note pointing at the definition is the giveaway that resolution succeeded: E0432 never has a definition to point at. The fix belongs at the definition, not the import - add pub to secret, or call it through a public item such as open.
- A name used as a value, with no import at all, is E0425, not E0432. Nothing here is imported and nothing is defined, so there is no use path to resolve - the call itself names a function that is not in scope:
fn main() {
println!("{}", greet());
}
$ rustc --edition 2021 probe_e0425_value.rs -o probe_e0425_value
error[E0425]: cannot find function `greet` in this scope
--> probe_e0425_value.rs:2:20
|
2 | println!("{}", greet());
| ^^^^^ not found in this scope
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0425`.
The header reads "cannot find function greet in this scope" and the error codes index defines E0425 as an unresolved name being used. The three codes divide by position: in a use declaration, E0432; at the start of a path in an expression, E0433; as a bare value name, E0425. Which one appears is the first fact to read, because each points at a different place to fix - the import line, the path, or the missing definition or import that the bare name needed.
Decision summary
- The header says "unresolved import" under E0432, the label says "no
XinM", and a similar-name help prints a corrected line: a misspelled item - take the spelling. - The header says "unresolved import" under E0432 and the label says "no
XinM", with no help: no such item in that module - pick an item the module contains, or link the crate that has it. - The header names only a prefix of the path under E0432, with "could not find" on a module segment: the module name is wrong - fix that segment before anything after it can be judged.
- The header names only the first segment under E0432, inside a nested module, with a "similar path" help: the start is wrong - begin with
crate::. - The header stops at a type under E0432 and the label says it "is a struct, not a module": an associated item was imported - import the type and call through it.
- The header says "unresolved import" under E0432 and a help prints a different full path for the item: the item lives in another module - import it from there.
- The header names only a crate under E0432, with "unresolved module or unlinked crate": no such dependency - add it to
Cargo.tomlor remove the import. - The header says "cannot find" a name in an expression path (E0433): the same absence outside a
use- fix the path where it is written, per the E0433 guide. - The header says an item "is private" (E0603): the item exists and the path is right - make it
pubat its definition, or reach it through a public item. - The header says "cannot find function" in this scope (E0425): a bare name with no import and no definition - define it, or import it and let any failure there surface as E0432.
Checklist
- The failing segment identified from the header before any edit: the full path in the header means the last segment failed; a prefix means the walk stopped at the header's last segment.
- The label read for its kind: no such item, could not find a module, not a module, or unlinked crate - each kind has a different fix, and the spelling fix applies to only one of them.
- A similar-name or alternative-path help checked against intent before accepting it: the compiler offers the nearest name or the item's real home, and the nearest name is not always the intended one.
- For a local module, the starting scope considered: an import inside a nested module starts there, not at the crate root, until
crate::,self::, orsuper::says otherwise. - An imported name confirmed to be a module item: types, functions, and modules can be imported; methods and associated functions are called through their type, never imported.
- For an external crate, the dependency verified in
Cargo.tomlbefore the import line is edited: an unlinked crate fails identically however the line is spelled. - Absence separated from privacy: no definition anywhere is E0432; a definition the compiler points at, refused as private, is E0603 and is fixed at the definition.
- The position of the failing name checked when the code surprises:
usedeclaration E0432, expression path E0433, bare value E0425. - The fixed program run, and its output checked against what the failing program was trying to compute.
Related guides on this site
- Fix Rust E0599 "no method named" — Import the Trait, Fix the Receiver, or Use the Current Name
- E0107 Wrong Generics Fix
- E0061 Wrong Argument Count Fix
- E0609 No Field Fix
Sources
- Rust, Error codes index: E0432 - the definition of the error: an import was unresolved, with the advice to verify the import name was not misspelled and that the import exists in the module it was imported from, and the rule that in Rust 2018 and later
usepaths are relative to the current module unless they begin with a crate name orcrate::. - The Rust Reference, Use declarations - a
usedeclaration creates local name bindings synonymous with a path, is private to its module by default, can re-export withpub use, and can bind nameable items and enum variants but cannot import associated items. - The Rust Programming Language, Bringing Paths Into Scope with the use Keyword -
usecreates a shortcut valid only in the scope it appears in, the idiomatic full path for structs and other items, renaming withas, re-exporting withpub use, and adding an external crate toCargo.tomlbefore importing from it. - The Rust Programming Language, Paths for Referring to an Item in the Module Tree - absolute paths start from a crate root (
cratefor the current crate, the crate name for an external one), relative paths start from the current module withself,super, or an identifier in it, and items are private by default until markedpub. - Rust std::collections module - the module's actual contents: sequences
Vec,VecDeque,LinkedList; mapsHashMap,BTreeMap; setsHashSet,BTreeSet; andBinaryHeap- the list that separates a misspelling from an item the module never contained. - Rust std::sync::atomic, AtomicBool -
AtomicBoolas a boolean type that can be safely shared between threads, living instd::sync::atomic- the real home of the item the wrong-module family looked up instd::collections. - Rust, Error codes index: E0433 - the neighboring resolution error: an undeclared crate, module, or type was used, covering the same missing name written in an expression path rather than a
usedeclaration. - Rust, Error codes index: E0603 - the neighboring privacy error: a private item was used outside its scope, fixed by making the item public with
pub. - Rust, Error codes index: E0425 - the neighboring scope error: an unresolved name was used, covering a bare function or value name with no import and no definition in scope.
Keep Exploring
The full Rust hub \u2014 ownership, structs and enums, async, and measured comparisons.
Every guide on the site in one list, grouped by topic.
Every browser-only checker and verifier on the site.
The C++, Python, Sysadmin, Rust, Go, and TypeScript hubs.