Skip to content

Make users type method syntax themselves in structs3#2296

Open
senekor wants to merge 1 commit intorust-lang:mainfrom
senekor:senekor/nqmzmklxswoz
Open

Make users type method syntax themselves in structs3#2296
senekor wants to merge 1 commit intorust-lang:mainfrom
senekor:senekor/nqmzmklxswoz

Conversation

@senekor
Copy link
Copy Markdown
Contributor

@senekor senekor commented Sep 25, 2025

closes #2286

@senekor senekor force-pushed the senekor/nqmzmklxswoz branch 2 times, most recently from 7c15c95 to 5eb1cee Compare February 26, 2026 16:59
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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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?

@rust-lang rust-lang deleted a comment from senekor Apr 5, 2026
@senekor senekor force-pushed the senekor/nqmzmklxswoz branch 2 times, most recently from 0e91eed to 4fd2c89 Compare April 5, 2026 20:22
@senekor senekor force-pushed the senekor/nqmzmklxswoz branch from 4fd2c89 to 7c1d8eb Compare April 5, 2026 20:23
@senekor senekor requested a review from mo8it April 5, 2026 20:33
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.

structs3 doesn't actually practice method syntax

2 participants