Replies: 6 comments 4 replies
-
I agree regarding the callback. It'd be great to find a way to use Perhaps the second point could be solved with a hint in a comment? // HINT: use `write!(buffer, "a fmt string")` to write into a buffer. |
Beta Was this translation helpful? Give feedback.
-
Yes, I either remove the callback or put a comment right by it (probably in both places) pointing out that it's unused in this code. Unless figuring out how to use |
Beta Was this translation helpful? Give feedback.
-
Happy to take a crack at it, yes, but probably not today. |
Beta Was this translation helpful? Give feedback.
-
Likewise, thanks for the course. It's excellent (and I hope you realise the feedback is because I like it and want to improve it). |
Beta Was this translation helpful? Give feedback.
-
So I was just looking at this and wondering what the best way to fix it is. Presumably the callback isn't really right anyway: it's just using So I think I'd be tempted to remove the callback completely and just add a note in the text that here we're only "drawing" a (textual) GUI and that in reality you'd pass a callback to the button. And I'm guessing that callback would actually need to be called with some kind of reference to the window or a widget it was going to write into and cause a refresh? I'll do something brutal and you can see what you think. |
Beta Was this translation helpful? Give feedback.
-
Done. See what you think. |
Beta Was this translation helpful? Give feedback.
-
It took me a little while to understand what we were supposed to do in this exercise. I think a couple of things confused me:
The button had a callback, which made me think we were actually going to implement something you could click and which would use the closure to print "You clicked the button!" But (unless I still haven't understood), there's none of that: it presumably just takes a callback because a real GUI would. But it threw me off.
It wasn't really clear to me at first what I could do with buffer because it wasn't quite similar enough to your example. In the end, I tried
write_all
on it which didn't work, and the compiler suggestedwrite_fmt
, fromstd::format
, so I looked up the documentation for that and figured out that I could usewrite!
(which I actually did) orwriteln!
, which seem to be what you want.Maybe this is all good because not understanding and looking things up is all part of development anyway. And I did get there. But I feel like I got quite lucky by trying
write_all
(andwrite
, in fact), and if I hadn't done that, I don't think I'd have known what to do.Beta Was this translation helpful? Give feedback.
All reactions