| Crates.io | ext-rs |
| lib.rs | ext-rs |
| version | 0.1.0 |
| created_at | 2025-11-30 02:21:37.315011+00 |
| updated_at | 2025-11-30 02:21:37.315011+00 |
| description | A Rust crate that brings C++-style extensions to Rust. Because why not? |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1957753 |
| size | 8,535 |
This is a joke crate. It's what happens when you doesn't have a job.
If you use this in production code, your pull request will be rejected, your colleagues will judge you, and rightfully so.
You know what Rust is really missing? The C++ stream extraction operator (>>). Sure, Rust has:
Read traits with explicit error typesparse() methods that don't panicBut where's the fun in that? Where's the mysterious operator overloading? Where's the silent panic when parsing fails? Where's the chaos?
This crate brings the "magic" ✨ of C++'s std::cin >> value to Rust by abusing the right-shift operator because, apparently, that's what we're doing with our lives now.
[dependencies]
ext-rs = "0.1.0"
use std::io::BufReader;
use extract_rs::*;
let data = b"42 Hello 3.14";
let mut reader = ExtReader(BufReader::new(&data[..]));
let mut int_value: i32 = 0;
let mut string_value = String::new();
let mut float_value: f64 = 0.0;
// The cursed syntax:
reader >> &mut int_value >> &mut string_value >> &mut float_value;
// Or if you prefer your bad decisions to be more explicit:
reader.extract(&mut int_value)
.extract(&mut string_value)
.extract(&mut float_value);
assert_eq!(int_value, 42);
assert_eq!(string_value, "Hello");
assert_eq!(float_value, 3.14);
If you want to parse stdin directly:
use std::io::BufReader;
use extract_rs::*;
let stdin = std::io::stdin();
let mut reader = ExtReader(BufReader::new(stdin.lock()));
let mut int_value: i32 = 0;
reader >> &mut int_value;
// Curiously, the linter mark this as unused, but, who cares?
.unwrap() never caused any problems, RIP CloudflareBecause.
Q: Should I use this?
A: No.
Q: But what if—
A: No.
Q: Can I contribute?
A: I mean, technically yes, but also... why?
Q: Does this follow Rust best practices?
A: It follows the best practice of showing you what NOT to do.
This crate:
reader >> &mut value; // What could go wrong? 🔥
Actual Rust:
let value: i32 = line
.trim()
.parse()
.expect("Please enter a valid number");
One of these is maintainable.
std::io::BufRead for readingstr::parse() for parsingResult for error handlingMIT (because even jokes deserve proper licensing)
This crate is meant for educational purposes only—specifically, to educate you on what not to do. If you find yourself actually wanting to use this, please take a step back, have a cup of coffee, and reconsider your life choices.
Remember: Just because you can doesn't mean you should.
Made with ❤️ and poor judgment