projects
/
rust-101.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d29f51c
)
make exercise more clear
author
Ralf Jung
<post@ralfj.de>
Sat, 4 Feb 2023 21:06:47 +0000
(22:06 +0100)
committer
Ralf Jung
<post@ralfj.de>
Sat, 4 Feb 2023 21:06:47 +0000
(22:06 +0100)
src/part03.rs
patch
|
blob
|
history
diff --git
a/src/part03.rs
b/src/part03.rs
index 25f9386f4caf5ccd8cc70a49ce611a6ff64f0999..2085d34463c1cfd715d1489fc883d03032369a8f 100644
(file)
--- a/
src/part03.rs
+++ b/
src/part03.rs
@@
-101,7
+101,8
@@
pub fn main() {
// **Exercise 03.1**: Define a trait `Print` to write a generic version of
// `SomethingOrNothing::print`.
// **Exercise 03.1**: Define a trait `Print` to write a generic version of
// `SomethingOrNothing::print`.
-// Implement that trait for `i32`, and change `main` above to use the new generic `print` function.
+// Implement that trait for `i32`, make `print2 use it, and change `main` above to use the new
+// generic `print2` function.
// I will again provide a skeleton for this solution. It also shows how to attach bounds to generic
// implementations (just compare it to the `impl` block from the previous exercise).
// You can read this as "For all types `T` satisfying the `Print` trait, I provide an implementation
// I will again provide a skeleton for this solution. It also shows how to attach bounds to generic
// implementations (just compare it to the `impl` block from the previous exercise).
// You can read this as "For all types `T` satisfying the `Print` trait, I provide an implementation
@@
-114,6
+115,9
@@
pub fn main() {
pub trait Print {
/* Add things here */
}
pub trait Print {
/* Add things here */
}
+impl Print for i32 {
+ /* Add things here */
+}
impl<T: Print> SomethingOrNothing<T> {
fn print2(self) {
unimplemented!()
impl<T: Print> SomethingOrNothing<T> {
fn print2(self) {
unimplemented!()