244
I love Rust (lemmy.blahaj.zone)
you are viewing a single comment's thread
view the rest of the comments
[-] akkajdh999@programming.dev 17 points 22 hours ago

In Go "==" operator works for everything by default, I like it more:

type A struct {
	Name string
	Quality int
}
func main() {
	var x A
	var y A
	fmt.Printf("%v", x == y)
}

(if all you want is to compare all corresponding fields which you usually want)

[-] Ephera@lemmy.ml 2 points 2 hours ago

Yeah, I came to Rust from Scala and Kotlin, where equality is default-implemented (for case class and data class respectively, which is basically all we ever used), so this meme surprised me a bit.

I do actually like that you can decide a type cannot be compared, because sometimes it really just doesn't make sense. How would you compare two HTTP clients, for example? But yeah, it certainly is a choice one can disagree with.

this post was submitted on 15 Nov 2024
244 points (93.0% liked)

Programmer Humor

32476 readers
889 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS