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

feat: Handle getters and setters in documentation template assist #12274

Merged
merged 1 commit into from
May 16, 2022
Merged

feat: Handle getters and setters in documentation template assist #12274

merged 1 commit into from
May 16, 2022

Conversation

jonas-schievink
Copy link
Contributor

The assist can now turn this:

pub struct S;
impl S {
    pub fn data_mut$0(&mut self) -> &mut [u8] { &mut [] }
}

into

pub struct S;
impl S {
    /// Returns a mutable reference to the data.
    ///
    /// # Examples
    ///
    /// ```
    /// use test::S;
    ///
    /// let mut s = ;
    /// assert_eq!(s.data_mut(), );
    /// assert_eq!(s, );
    /// ```
    pub fn data_mut(&mut self) -> &mut [u8] { &mut [] }
}

And similarly for by-value or immutable getters, and for setters. Previously the intro line would be empty.

This PR also removes the documentation generation function from the "Generate getter/setter" assist, since that is better handled by applying the 2 assists in sequence. cc #12273

@jonas-schievink
Copy link
Contributor Author

@bors r+

@bors
Copy link
Contributor

bors commented May 16, 2022

📌 Commit f1b6e45 has been approved by jonas-schievink

@bors
Copy link
Contributor

bors commented May 16, 2022

⌛ Testing commit f1b6e45 with merge da503b6...

@bors
Copy link
Contributor

bors commented May 16, 2022

☀️ Test successful - checks-actions
Approved by: jonas-schievink
Pushing da503b6 to master...

@bors bors merged commit da503b6 into rust-lang:master May 16, 2022
@jonas-schievink jonas-schievink deleted the move-getter-docs-generation branch May 16, 2022 17:24
@jonas-schievink
Copy link
Contributor Author

Oh I forgot generate_setter is in a different file

bors added a commit that referenced this pull request May 16, 2022
…-schievink

fix: Don't generate documentation in `generate_setter`

Followup to #12274
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