Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "turtle"
version = "1.0.0-rc.4"
version = "1.0.0-dev.2503"
authors = ["Sunjay Varma <varma.sunjay@gmail.com>"]
description = "Learn the Rust language by creating animated drawings!"
homepage = "http://turtle.rs"
Expand Down Expand Up @@ -76,7 +76,7 @@ features = [
# Dependencies used when developing `turtle` directly, but not when using it as
# a library.
[dev-dependencies]
bitvec = "0.22"
bitvec = "1.0"
chrono = "0.4"

# Since the debug performance of turtle isn't all that great, we recommend that
Expand Down
14 changes: 8 additions & 6 deletions examples/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn draw_text(turtle: &mut Turtle, text: &str) {
// need to select the range beginning at `start`, running for
// `byte_count`. Another style of writing this that you might see in
// Rust libraries is `[start ..][.. length]`.
let row: &[u8] = &text.as_bytes()[start .. start + byte_count];
let row: &[u8] = &text.as_bytes()[start..start + byte_count];

// For each byte (`u8`), we use `bitvec` to make a view into its bits.
// `bitvec` provides the `.view_bits::<_>()` method on Rust integers for
Expand Down Expand Up @@ -203,16 +203,18 @@ fn draw_number(turtle: &mut Turtle, number: f32) {
/// going to start on the correct side and be facing the correct way for this
/// drawing to work.
fn draw_row<O, T>(turtle: &mut Turtle, row: &BitSlice<O, T>)
where O: BitOrder, T: BitStore {
where
O: bitvec::store::BitStore,
T: bitvec::order::BitOrder,
{
// `&BitSlice` can iterate over bits. It is just like `&[bool]`, and so it
// produces `&bool` for each loop.
for bit in row.iter().by_val() {
for bit in row.iter().by_vals() {
// This checks if the bit produced by the row is `1` or `0`, and sets
// the pen color to black (`1`) or light grey (`0`)
if bit {
turtle.set_pen_color("black");
}
else {
} else {
turtle.set_pen_color("light grey");
}

Expand All @@ -225,7 +227,7 @@ where O: BitOrder, T: BitStore {
turtle.forward(BIT_MARGIN);
}
// Rewind the turtle
for _ in 0 .. row.len() {
for _ in 0..row.len() {
turtle.backward(BIT_BOX);
}
}
Expand Down
Loading