--- start quote ---
Trait methods can also take self by reference or mutable reference:
impl std::clone::Clone for Number { fn clone(&self) -> Self { Self { ..*self } } }
What? What does this even mean? What is <asterisk>self, and why?
Too many questions, not nearly enough answers.
T { ..t }
Inside the trait "Self" is an alias for "Number".
"&self" is shorthand for "self: &Number", i.e., a reference to Number.
To dereference a reference, prefix with
*
self
and
*self
Thus,
Self { ..*self }
Disclaimer! everything I know about rust I learned 2 days ago from this blog post, so I might be wrong :-)
--- start quote ---
Trait methods can also take self by reference or mutable reference:
--- end quote ---What? What does this even mean? What is <asterisk>self, and why?
Too many questions, not nearly enough answers.