Pybites Logo Rust Platform

Use and Paths

Medium +3 pts

🎯 In Python, you bring names into scope with import and from ... import:

import math
from collections import Counter, defaultdict
from os.path import join as path_join

Rust's use statement works the same way — it brings items from other modules into the current scope so you don't have to write full paths everywhere.

Path types

Rust has three ways to reference items in the module tree:

crate:: — absolute path from the crate root (like Python's absolute imports):

use crate::utils::helpers::format_name;

super:: — relative path to the parent module …

Login to see the full exercise.