Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rust is functional #4077

Closed
wants to merge 1 commit into from
Closed

Conversation

spotlesscoder
Copy link

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

"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
Copy link

ghost commented Oct 25, 2024

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.

Copy link
Contributor

@chriskrycho chriskrycho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, but actually Rust is not strictly functional, "methods" are not strictly limited to object-oriented languages (a method is a function which are associated with a specific data structure, with or without reference to a specific instance), and Rust has both functions and methods!

@spotlesscoder
Copy link
Author

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

@spotlesscoder spotlesscoder deleted the patch-2 branch October 26, 2024 07:30
@chriskrycho
Copy link
Contributor

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
Copy link
Author

spotlesscoder commented Oct 31, 2024

Thanks for the clarification
Today I learned :)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants