Skip to content

Commit

Permalink
doc: perform some 80-chars wrappings
Browse files Browse the repository at this point in the history
  • Loading branch information
adrientetar committed Apr 27, 2014
1 parent 5371146 commit b7dba33
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/doc/rust.md
Expand Up @@ -471,7 +471,7 @@ Two examples of paths with type arguments:
# fn f() {
# fn id<T>(t: T) -> T { t }
type T = HashMap<int,~str>; // Type arguments used in a type expression
let x = id::<int>(10); // Type arguments used in a call expression
let x = id::<int>(10); // Type arguments used in a call expression
# }
~~~~

Expand Down
22 changes: 13 additions & 9 deletions src/doc/tutorial.md
Expand Up @@ -982,7 +982,8 @@ The obvious approach is to define `Cons` as containing an element in the list
along with the next `List` node. However, this will generate a compiler error.

~~~ {.ignore}
// error: illegal recursive enum type; wrap the inner value in a box to make it representable
// error: illegal recursive enum type; wrap the inner value in a box to make it
// representable
enum List {
Cons(u32, List), // an element (`u32`) and the next node in the list
Nil
Expand Down Expand Up @@ -1054,10 +1055,10 @@ immutable, the whole list is immutable. The memory allocation itself is the
box, while the owner holds onto a pointer to it:

~~~ {.notrust}
List box List box List box List box
+--------------+ +--------------+ +--------------+ +--------------+
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
+--------------+ +--------------+ +--------------+ +--------------+
List box List box List box List box
+--------------+ +--------------+ +--------------+ +----------+
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
+--------------+ +--------------+ +--------------+ +----------+
~~~

> *Note:* the above diagram shows the logical contents of the enum. The actual
Expand Down Expand Up @@ -1197,7 +1198,8 @@ fn eq(xs: &List, ys: &List) -> bool {
// If we have reached the end of both lists, they are equal.
(&Nil, &Nil) => true,
// If the current element in both lists is equal, keep going.
(&Cons(x, ~ref next_xs), &Cons(y, ~ref next_ys)) if x == y => eq(next_xs, next_ys),
(&Cons(x, ~ref next_xs), &Cons(y, ~ref next_ys))
if x == y => eq(next_xs, next_ys),
// If the current elements are not equal, the lists are not equal.
_ => false
}
Expand Down Expand Up @@ -1256,7 +1258,7 @@ Using the generic `List<T>` works much like before, thanks to type inference:
# Cons(value, ~xs)
# }
let mut xs = Nil; // Unknown type! This is a `List<T>`, but `T` can be anything.
xs = prepend(xs, 10); // The compiler infers the type of `xs` as `List<int>` from this.
xs = prepend(xs, 10); // Here the compiler infers `xs`'s type as `List<int>`.
xs = prepend(xs, 15);
xs = prepend(xs, 20);
~~~
Expand Down Expand Up @@ -1303,7 +1305,8 @@ fn eq<T: Eq>(xs: &List<T>, ys: &List<T>) -> bool {
// If we have reached the end of both lists, they are equal.
(&Nil, &Nil) => true,
// If the current element in both lists is equal, keep going.
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys)) if x == y => eq(next_xs, next_ys),
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys))
if x == y => eq(next_xs, next_ys),
// If the current elements are not equal, the lists are not equal.
_ => false
}
Expand Down Expand Up @@ -1331,7 +1334,8 @@ impl<T: Eq> Eq for List<T> {
// If we have reached the end of both lists, they are equal.
(&Nil, &Nil) => true,
// If the current element in both lists is equal, keep going.
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys)) if x == y => next_xs == next_ys,
(&Cons(ref x, ~ref next_xs), &Cons(ref y, ~ref next_ys))
if x == y => next_xs == next_ys,
// If the current elements are not equal, the lists are not equal.
_ => false
}
Expand Down

0 comments on commit b7dba33

Please sign in to comment.