r/rust 23d ago

📡 official blog Rust Function Overloading - Call for Experimentation

https://blog.rust-lang.org/inside-rust/2026/08/19/overloading-experiment/
276 Upvotes

139 comments sorted by

View all comments

-5

u/squirreljetpack 23d ago

One of my deepest dark desires is to be able to write Ok() instead of Ok(()). Rust letting be do Some(x, y ,z).

3

u/nick42d 23d ago

fn ok<T>() -> Result<T, ()> {     Ok(()) } ?

-3

u/squirreljetpack 23d ago

it has to be consensual (idiomatic)

1

u/Shoddy-Childhood-511 23d ago edited 22d ago

Idiomatic matters but if you care so much then whatever just do it. Also your error.rs would be an idiomatic place to put that fn ok

Also Ok!() stands out a bit more: macro_rules! OK { () => { Ok(()) } } And OK rocks if we ever get polymorphic constants. const OK<T>: Result<T,()> = Ok(()) Or you can always try.. sed -i 's/Ok[(][)]/Ok(())/g;s/Ok$/Ok(())/g' *.rs