|
|
|
|
|
by tialaramex
20 days ago
|
|
C++ doesn't have methods/ "member functions" on the primitive types. One reason is that C++ doesn't know where to put them, for user defined class, struct or union types these "member functions" as their name suggests live inside the class/ struct/ union definition but for a primitive where would these live? In Rust they're just impl blocks, for example the method we're discussing here is: impl bool {
pub const fn toggle(&mut self) {
*self = !*self;
}
}
|
|