Skip to content

Modify PyType::name method to return BorrowedValue<str> #3261

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

Merged
merged 4 commits into from
Oct 10, 2021

Conversation

Snowapril
Copy link
Contributor

@Snowapril Snowapril commented Oct 10, 2021

This will close issue #3232

@youknowone youknowone merged commit 7ff974e into RustPython:main Oct 10, 2021
@youknowone
Copy link
Member

Thank you for contributing!

self.name().to_string()
}

pub fn name(&self) -> BorrowedValue<str> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, looked at this too late, but it'd be better to have this be a RwLockReadGuard, since that's the only variant of BorrowedValue the function ever returns. It's kinda like the difference between returning a Box<ConcreteType> and a Box<dyn Trait> - sure, both have more or less the same functionality, but there's some amount of overhead with the type-erased form. (If you just want to hide implementation details you could return an impl Deref<Target=str> + fmt::Display + ...)

@youknowone youknowone added the z-ca-2021 Tag to track contrubution-academy 2021 label Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
z-ca-2021 Tag to track contrubution-academy 2021
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants