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

Chapter 17.3: Listing 17-17: Unnecessary &self used in function call #2037

Closed
UnHumbleBen opened this issue Jul 23, 2019 · 0 comments · Fixed by #2038
Closed

Chapter 17.3: Listing 17-17: Unnecessary &self used in function call #2037

UnHumbleBen opened this issue Jul 23, 2019 · 0 comments · Fixed by #2038

Comments

@UnHumbleBen
Copy link
Contributor

In the implementation of the content() method for the Post struct,

    pub fn content(&self) -> &str {
        self.state.as_ref().unwrap().content(&self)
    }

can be replaced with

    pub fn content(&self) -> &str {
        self.state.as_ref().unwrap().content(self)
    }

removing the "&" inside of the arguments for the call to the content() method.
I believe this clarifies the code because self is already a reference, so it is awkward to use deref coercion here.

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 a pull request may close this issue.

1 participant