Problem with unresolved import

I have a small educational project on Rust.
I decided to add performance measurements and ran into a problem - error[E0432]: unresolved import.
Project tree:


extern crate criterion;
pub mod easy;
pub mod benches;

struct Solution;

fn main() {


pub mod benchmarks;


use crate::Solution;
use criterion::{black_box, criterion_group, criterion_main, Criterion};

pub fn criterion_benchmark(c: &mut Criterion) {
    c.bench_function("count_largest_group 9999", |b| b.iter(|| Solution::count_largest_group(black_box(9999))));

criterion_group!(benches, criterion_benchmark);

And after cargo bench i have error:

error[E0432]: unresolved import `crate::Solution`
 --> src/benches/
1 | use crate::Solution;
  |     ^^^^^^^^^^^^^^^ no `Solution` in the root

Why this code working in src\easy\, but didn't working here?

You need to rename to Then, instead of crate::, you should use your_package_name_goes_here::.

1 Like

Thank's for your answer! It's work!
Additionally, I changed the line in => pub struct Solution and move folder benches out from src

You usually wouldn't have benchmarks inside src/. Try moving benches so it's next to src/. You would typically also use snake case for package names.

1 Like

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.