Rust

Share Rust code online.

Share Rust snippets, ownership patterns, or trait implementations: highlighted and encrypted without needing a GitHub account.

textdrop.sh/xk4mR2
1use std::collections::HashMap;23fn word_freq(text: &str) -> HashMap<&str, usize> {4    let mut counts = HashMap::new();5    for word in text.split_whitespace() {6        *counts.entry(word).or_insert(0) += 1;7    }8    counts9}1011fn top_n<'a>(12    counts: &'a HashMap<&str, usize>,13    n: usize,14) -> Vec<(&&'a str, &'a usize)> {15    let mut pairs: Vec<_> = counts.iter().collect();16    pairs.sort_unstable_by(|a, b| b.1.cmp(a.1));17    pairs.into_iter().take(n).collect()18}1920fn main() {21    let text = "the quick brown fox jumps over the lazy dog the fox";22    let counts = word_freq(text);23    for (word, count) in top_n(&counts, 3) {24        println!("{word}: {count}");25    }26}
Every paste includes

Rust syntax highlighting

Paste Rust code and get a shareable link with full syntax highlighting, server-side rendered with no JavaScript overhead.

Burn after read

Deleted on first open. Can't be viewed twice.

Password protection

Add a password for end-to-end encryption with no raw key stored.

Configurable expiry

Set pastes to expire after 1 hour, 1 day, 7 days, or up to 30 days. Gone when you say so.

No account needed

No sign-up, no email, no ads. Paste and share in seconds.

How it works
Plain Text
Markdown
Code
DB_HOST=db-01.prod.internal
DB_USER=api_svc
DB_PASS=xK9$mP2!qR7nLw2
REDIS_URL=redis://:abc@cache:6379
delete after setup — expires 1hr
7 days
Share
textdrop.sh/
7 days · plain text
Use cases
  • 01Share ownership and borrowing examples
  • 02Send trait implementation patterns
  • 03Distribute iterator chain snippets
  • 04Share async Tokio code for review
  • 05Send error handling with thiserror/anyhow
FAQ
Does the Rust highlighter support macros?+

Yes. The Shiki Rust grammar handles macro_rules!, procedural macros, and attribute macros.

Can I share Cargo.toml config files?+

Yes: use the TOML language option for Cargo.toml files.

Is there a size limit?+

Pastes up to 5 MB are supported.

Other languages
Drop your code