Skip to content

Implement into_static for CowStr and Event in pulldown-cmark - #967

Merged
Martin1887 merged 2 commits into
pulldown-cmark:masterfrom
Atreyagaurav:master
Oct 9, 2024
Merged

Martin1887 merged 2 commits into
pulldown-cmark:masterfrom
Atreyagaurav:master

Conversation

@Atreyagaurav

Copy link
Copy Markdown
Contributor

Fixes: #625

I found that we cannot implement ToOwned, but I found the following code:

impl<'a> BrokenLink<'a> {
    /// Moves the link into version with a static lifetime.
    ///
    /// The `reference` member is cloned to a Boxed or Inline version.
    pub fn into_static(self) -> BrokenLink<'static> {
        BrokenLink {
            span: self.span.clone(),
            link_type: self.link_type,
            reference: self.reference.into_string().into(),
        }
    }
}

So, I added similar implementations for other types with lifetimes so we can use them more freely.

@Atreyagaurav
Atreyagaurav marked this pull request as ready for review October 6, 2024 18:33
@Atreyagaurav

Copy link
Copy Markdown
Contributor Author

Please ignore/let me know if my auto-formatter messed things up in the repo.

@rhysd

rhysd commented Oct 7, 2024 •

Copy link
Copy Markdown
Contributor

I'm not a maintainer but when I contribute to this project I usually try not to apply code formatter in order to avoid unnecessary code changes.

@ollpu

ollpu commented Oct 7, 2024 •

Copy link
Copy Markdown
Collaborator

I think it's long overdue that we enforce rustfmt in CI, but that's something to do separately (and I don't know of other's opinions).

Comment thread pulldown-cmark/src/strings.rs Outdated
@Atreyagaurav

Copy link
Copy Markdown
Contributor Author

Yeah, but I didn't notice the auto-formatter until I commited. This pull request is just adding things, nothing on changing things, so it should not be hard to read, it's just some files. Please forgive me for that :)

@ollpu

ollpu commented Oct 8, 2024 •

Copy link
Copy Markdown
Collaborator

Yeah, but I didn't notice the auto-formatter until I commited.

No worries! If you want to though, you could restore (at least the files that have no other changes) & squash.

git reset --soft upstream/master # or HEAD~2 for two commits
git restore --staged -- pulldown-cmark/src/firstpass.rs pulldown-cmark/src/linklabel.rs pulldown-cmark/src/scanners.rs
git commit
git push --force-with-lease

@Atreyagaurav

Atreyagaurav commented Oct 8, 2024 •

Copy link
Copy Markdown
Contributor Author

I could, but can we leave them be? I think it's good to have them formatted anyway. If it's a blocker for merging. I will do it.

@ollpu

ollpu commented Oct 8, 2024

Copy link
Copy Markdown
Collaborator

Yeah it's fine, we can leave it be.

@Martin1887
Martin1887 merged commit 8bca85e into pulldown-cmark:master Oct 9, 2024
@ollpu

ollpu commented Oct 9, 2024

Copy link
Copy Markdown
Collaborator

Thanks for the PR! This is simple yet quite useful.

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.

returning Events from a function

4 participants