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

Miscellaneous minor improvements #2370

Merged
merged 12 commits into from
Sep 20, 2024
Merged

Miscellaneous minor improvements #2370

merged 12 commits into from
Sep 20, 2024

Conversation

randomPoison
Copy link
Collaborator

Various little changes that I've wanted when going through classes. Let me know if any of these seem problematic, I can pretty easily remove any commits that would be better to discuss separately.

@@ -19,7 +19,7 @@ fn pick<T>(n: i32, even: T, odd: T) -> T {
fn main() {
println!("picked a number: {:?}", pick(97, 222, 333));
println!("picked a tuple: {:?}", pick(28, ("dog", 1), ("cat", 2)));
println!("picked a tuple: {:?}", pick(28, "dog", "cat"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

These aren't tuples anymore. I guess that would be "picked a string". But the idea here was to show that T doesn't just have to be a named type like String or i32, but can be any type.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, I would add this as an additional example so the students see two "simple" types as well as a compound type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hrm, I get what you're saying about demonstrating that generic types can also be compound types, though I don't think it's all that important to emphasize. I think students can generalize from "integers and strings" to "any type". But saying it explicitly to students might be good, so would it be good enough to add a speaker note about it?

src/methods-and-traits/exercise.rs Show resolved Hide resolved
@randomPoison randomPoison merged commit 2f9babd into main Sep 20, 2024
37 checks passed
@randomPoison randomPoison deleted the legare/misc-fixes branch September 20, 2024 21:19
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.

4 participants