← Runnable Projects

阅读中文版本

Rust BinaryHeap CLI

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

intermediaterustunverified

Project

rust-priority-queue-cli

Entry point: main.rs

Install

cargo run

Run

cargo run

Test

cargo test

Expected output

Uses BinaryHeap to push and pop items by priority.

Dependencies

  • rust >=1.75

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 BinaryHeap CLI is a self-contained rust command-line program. Uses BinaryHeap to push and pop items by priority.

Install and run

cargo run
cargo run

Project structure

rust-priority-queue-cli/
├── main.rs
└── README snippet above

Key source

// main.rs
use std::collections::BinaryHeap; use std::cmp::Reverse;
fn main() {
    let mut h = BinaryHeap::new();
    for (p, v) in [(3,"a"),(1,"b"),(2,"c")] { h.push(Reverse((p, v))); }
    while let Some(Reverse((_, v))) = h.pop() { print!("{} ", v); }
}

Testing

cargo test

Expected output

When run with the documented command, the program prints:

b c a

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.