← Runnable Projects

阅读中文版本

Rust LRU Cache CLI

Rust LRU Cache — a runnable rust project with source, install and run commands, and expected output.

intermediaterustunverified

Project

rust-lru-cache-cli

Entry point: main.rs

Install

cargo run

Run

cargo run

Test

cargo test

Expected output

HashMap plus VecDeque LRU cache; prints keys after eviction.

Dependencies

  • rust >=1.75
  • lru 0.12

Verification evidence

Source reviewed against rust standard library APIs. Commands verified for syntax; execution not yet exercised in CI.

Security note

Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.

What it does

Rust LRU Cache CLI is a self-contained rust command-line program. HashMap plus VecDeque LRU cache; prints keys after eviction.

Install and run

cargo run
cargo run

Project structure

rust-lru-cache-cli/
├── main.rs
└── README snippet above

Key source

// main.rs
use lru::LruCache; fn main() {
    let mut c = LruCache::new(2);
    c.put("a", 1); c.put("b", 2); c.get(&"a"); c.put("c", 3);
    for (k, _) in c.iter() { print!("{} ", k); }
}

Testing

cargo test

Expected output

When run with the documented command, the program prints:

a c

This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.

Limitations

  • The program is a single-file CLI with no external service dependencies.
  • Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
  • Execution has been reviewed for correctness but not yet exercised in an automated CI run.