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

Add the MapOwned trait and the Once<T> userdata type #693

Merged
merged 1 commit into from Feb 23, 2021
Merged

Add the MapOwned trait and the Once<T> userdata type #693

merged 1 commit into from Feb 23, 2021

Conversation

ghost
Copy link

@ghost ghost commented Feb 5, 2021

This adds support for exporting methods that take ownership of self. Once<T> is a userdata wrapper that uses atomic compare-exchange to allow taking ownership safely once.

@ghost ghost added the feature Adds functionality to the library label Feb 5, 2021
Copy link
Member

@halzy halzy left a comment

Choose a reason for hiding this comment

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

Nice improvements! The comments are minor, fix if you want.

bors try

impl Display for ValueTaken {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "this object can only be used once")
Copy link
Member

Choose a reason for hiding this comment

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

Capitalize the first char for consistency with the other Display impls in the file. Also, the text alludes to the object having been used already. Perhaps be more direct? "This object has already been used once."

Copy link
Author

Choose a reason for hiding this comment

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

Changed to this object has already been used once. According to the Rust API Guidelines, error messages should actually be lower case without trailing punctuation: https://rust-lang.github.io/api-guidelines/interoperability.html#error-types-are-meaningful-and-well-behaved-c-good-err

We can change the other Display impls in another PR.

}

ok
}
Copy link
Member

Choose a reason for hiding this comment

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

Tests! <3

bors bot added a commit that referenced this pull request Feb 5, 2021
@bors
Copy link
Contributor

bors bot commented Feb 5, 2021

try

Build succeeded:

This adds support for exporting methods that take ownership of `self`.
`Once<T>` is a userdata wrapper that uses atomic compare-exchange to allow
taking ownership safely once.
@ghost
Copy link
Author

ghost commented Feb 23, 2021

Updated and should be ready!

bors r+

bors bot added a commit that referenced this pull request Feb 23, 2021
693: Add the MapOwned trait and the `Once<T>` userdata type r=toasteater a=toasteater

This adds support for exporting methods that take ownership of `self`. `Once<T>` is a userdata wrapper that uses atomic compare-exchange to allow taking ownership safely once.

Co-authored-by: toasteater <48371905+toasteater@users.noreply.github.com>
@bors
Copy link
Contributor

bors bot commented Feb 23, 2021

Build failed:

@ghost
Copy link
Author

ghost commented Feb 23, 2021

Failed due to new clippy lints fixed in #703

bors retry

@bors
Copy link
Contributor

bors bot commented Feb 23, 2021

Build succeeded:

@bors bors bot merged commit f2b4080 into godot-rust:master Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adds functionality to the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant