book
book copied to clipboard
Fix #3761 false about C
There are not any methods in C
While true, you can use the ->
modifier in C to access members in a struct on a pointer.
The arrow is just syntactic sugar. You could always write (*struct).member
instead of struct->member
While true, you can use the
->
modifier in C to access members in a struct on a pointer. The arrow is just syntactic sugar. You could always write(*struct).member
instead ofstruct->member
Yes, but you can't call method in C anyway. Maybe better to rewrite all about ->
?
Yes, but you can't call method in C anyway. Maybe better to rewrite all about
->
?
Yeah, I completely agree - talking about methods while mentioning C is wrong. I think C should be mentioned in the paragraph though and it should be rewritten imo.
While it is technically true that C does not have methods, you can absolutely store a function pointer on a struct in C and then call it using ->
access. (There is a reason for C++’s use of that exact syntax. 😉) Closing this as the point here is not pedantic precision about C and C++ but rather getting the point across about how Rust differs from them. Thanks, though!
@chriskrycho Calling functions methods is still wrong at that point though.