Make users type method syntax themselves in structs3#2296
Open
senekor wants to merge 1 commit intorust-lang:mainfrom
Open
Make users type method syntax themselves in structs3#2296senekor wants to merge 1 commit intorust-lang:mainfrom
structs3#2296senekor wants to merge 1 commit intorust-lang:mainfrom
Conversation
7c15c95 to
5eb1cee
Compare
mo8it
requested changes
Apr 5, 2026
| fn get_fees(&self, cents_per_gram: u32) { | ||
| // TODO: Calculate the package's fees. | ||
| // TODO: Turn this function into a method on `Fireworks`. | ||
| fn start(fireworks: Fireworks) -> String { |
Contributor
There was a problem hiding this comment.
Why take ownership here? I really like the concept of the exercise which lets users write their own methods. But we need to find a better story where moving actually makes sense, also type wise. The struct should contain some field that isn't Copy.
Contributor
Author
There was a problem hiding this comment.
Why take ownership here?
You can't start the fireworks twice, so it must be consumed.
The struct should contain some field that isn't
Copy.
Why? There is no #[derive(Copy)]. Are you concerned users will cheat themselves?
0e91eed to
4fd2c89
Compare
4fd2c89 to
7c1d8eb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #2286