by aeurielesn · 2y ago · 0 comments
Not even one tubo-fish. No multiple lines of `where` clauses. No (dyn) trait impl. Not even a lambda!
On top of that Rust's syntax is full of noise. Curly braces, semicolons, ugly angel brackets, `::` instead of points for namespaces, etc.
Rust is a quite good language on the technical level. But the surface syntax is really ugly.
https://www.youtube.com/watch?t=1529&v=WiPp9YEBV0Q&feature=y...
The return type of that get_or_create_inode() function is:
Result<Either<ARef<INode<T>>, inode::New<T>>>
I'd say that's a pretty good example for 'hideous'. It looks like some of the worst C++ code I've seen and then quickly tried to forget. If stuff like this ends up in the Linux kernel I would be pissed too as a Linux kernel greybeard.If you never seen such types before it may look intimidating. But if you ever seen any ML style language the type of said function looks actually very ordinary. It does not use any really more complex concepts, it's just regular nested generic types. Pretty standard stuff.
In Rust you could also have things like:
fn foo<'a, T, U, V, W>(a: &'a T, b: U, c: V, d: W)
where
T: MyTrait<U> + Debug + 'a,
U: Debug + Hash,
V: SomeOtherTrait<V> + Debug + std::marker::Copy,
W: Box<dyn Fn(V) -> U> + Debug,
{
todo!("Just a demo");
}
That's indeed much more involved, even it doesn't use any deeply nested wrapper types.But I think nobody would force such complex signatures on API end-users.
(Even there is of course also no magic going on. It's just the quite quite expressive type language in Rust).
enum ReceivedINode<T> {
Existing(ARef<INode<T>)
New(inode::New<T>)
}
fn get(..) -> Result<ReceivedINode<T>>
Calm down with the bikeshedding. It’s just a complex C API and they wanted to convey the semantics concisely.