rust-lang / book

The Rust Programming Language
https://doc.rust-lang.org/book/
Other
15.28k stars 3.44k forks source link

fix: rust is functional #4077

Closed spotlesscoder closed 1 month ago

spotlesscoder commented 1 month ago

"method" is a term that usually refers to functions provided by a class in OOP as Rust is functional, rather use the term function

ghost commented 1 month ago

In my research, the group of functions wrapping_* are indeed methods. A method is a function associated with a type: so associated that the first parameter is 'self'. Note that in C++, structs can also have methods.

spotlesscoder commented 1 month ago

OK - but what's the difference between a method and a function in Rust?

chriskrycho commented 4 weeks ago

A method is a function which is attached to a data type (a struct or an enum). It appears in an impl block for that type. So all methods are functions, but not all functions are methods!

spotlesscoder commented 4 weeks ago

Thanks for the clarification Today I learned :)

Things you don't learn at university when they only teach OO bullshit patterns