re: Benefits of Rust VIEW POST

re: Generics. This might not be something I use myself, but because of generics, it's possible for the standard library to add slightly higher function...

You seem to be undervaluing Rust's type system. Generics aside, one of the biggest complaints I see Rust users having when they try Go is how there's no middle-ground between using exact types and using interface{}.

Go has interfaces beyond interface{}, and you should use them exactly for that. They allow you to refer to things based on what functions they provide instead of what someone wrote in an inherits or similar.

package main

import "fmt"

type Fooer interface {

type Bar struct {

func (b Bar) foo() {

func useFooer(f Fooer) {

func main() {

Good point. That was a big phrasing mistake on my part. A better expression of what I was thinking would be "insufficient middle-ground".

I'm sure at least some of it is that we've been spoiled by Rust's excellent support for using sum types (enums containing data... A.K.A. compiler-verified tagged unions) to extend the compiler's ability to catch mistakes in variably-typed fields.

(The name "sum type" refers to the set of possible combinations. A tagged union is the sum of the possible combinations of its values. A struct is an example of a product type because its possible combinations are the set product of the possible combinations of its members.)

...but then the Rust community are overachievers that way. They've been working hard to design a viable system of Pi/Dependent types. (Types where, as in Ada, you can say that type Rating is "Type u8 where the value is in the range '1 through 5'" and get various kinds of compile-time goodness from it.)

Code of Conduct Report abuse