Update ring buffer exercise#159
Update ring buffer exercise#159axel-van-abkoude wants to merge 8 commits intotrifectatechfoundation:mainfrom
Conversation
There was a problem hiding this comment.
Looking at this I wonder why we do not return a Result here? Was that not introduced yet in the material?
There was a problem hiding this comment.
Its introduced in 2/3/2-error-handling which is before this file. Although the function does not really return a value.
We could make it a Result<Void,Error>?
There was a problem hiding this comment.
Ah nice, yes in Rust that would be written as Result<(), ()> or more generic Result<(), u8>, returning back the value that was passed in. This is less of a problem for a u8 since it is copied, but important for moved types like String.
There was a problem hiding this comment.
Implemented it as Result<(),&static' str> as it seemed nicer with a description of the error
exercises/2-foundations-of-rust/3-advanced-syntax/4-ring-buffer/src/main.rs
Show resolved
Hide resolved
exercises/2-foundations-of-rust/3-advanced-syntax/4-ring-buffer/src/main.rs
Show resolved
Hide resolved
tdittr
left a comment
There was a problem hiding this comment.
Looks good now :) just run cargo fmt once to straighten out the formatting.
| // 5) EXTRA EXERCISES: | ||
| // - implement the method "has_room" so that "queue.has_room()" is true if and only if writing to the queue will succeed | ||
| // - implement the method "peek" so that "queue.peek()" returns the same thing as "queue.read()", but leaves the element in the queue | ||
| // - eliminate edge cases of the data structure (HINT: what is the behaviour of (n % 0)) |
Additions include: