Skip to content
Closed
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
12 changes: 6 additions & 6 deletions src/doc/trpl/ffi.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ pub fn compress(src: &[u8]) -> Vec<u8> {
let psrc = src.as_ptr();

let mut dstlen = snappy_max_compressed_length(srclen);
let mut dst = Vec::with_capacity(dstlen as uint);
let mut dst = Vec::with_capacity(dstlen as usize);
let pdst = dst.as_mut_ptr();

snappy_compress(psrc, srclen, pdst, &mut dstlen);
dst.set_len(dstlen as uint);
dst.set_len(dstlen as usize);
dst
}
}
Expand Down Expand Up @@ -148,11 +148,11 @@ pub fn uncompress(src: &[u8]) -> Option<Vec<u8>> {
let mut dstlen: size_t = 0;
snappy_uncompressed_length(psrc, srclen, &mut dstlen);

let mut dst = Vec::with_capacity(dstlen as uint);
let mut dst = Vec::with_capacity(dstlen as usize);
let pdst = dst.as_mut_ptr();

if snappy_uncompress(psrc, srclen, pdst, &mut dstlen) == 0 {
dst.set_len(dstlen as uint);
dst.set_len(dstlen as usize);
Some(dst)
} else {
None // SNAPPY_INVALID_INPUT
Expand Down Expand Up @@ -420,7 +420,7 @@ Unsafe functions, on the other hand, advertise it to the world. An unsafe functi
this:

~~~~
unsafe fn kaboom(ptr: *const int) -> int { *ptr }
unsafe fn kaboom(ptr: *const isize) -> isize { *ptr }
~~~~

This function can only be called from an `unsafe` block or another `unsafe` function.
Expand All @@ -441,7 +441,7 @@ extern {

fn main() {
println!("You have readline version {} installed.",
rl_readline_version as int);
rl_readline_version as isize);
}
~~~

Expand Down
18 changes: 9 additions & 9 deletions src/doc/trpl/generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ multiple types of arguments. For example, remember our `OptionalInt` type?

```{rust}
enum OptionalInt {
Value(int),
Value(i32),
Missing,
}
```
Expand Down Expand Up @@ -40,26 +40,26 @@ we substitute that type for the same type used in the generic. Here's an
example of using `Option<T>`, with some extra type annotations:

```{rust}
let x: Option<int> = Some(5i);
let x: Option<i32> = Some(5i32);
```

In the type declaration, we say `Option<int>`. Note how similar this looks to
`Option<T>`. So, in this particular `Option`, `T` has the value of `int`. On
the right-hand side of the binding, we do make a `Some(T)`, where `T` is `5i`.
Since that's an `int`, the two sides match, and Rust is happy. If they didn't
In the type declaration, we say `Option<i32>`. Note how similar this looks to
`Option<T>`. So, in this particular `Option`, `T` has the value of `i32`. On
the right-hand side of the binding, we do make a `Some(T)`, where `T` is `5i32`.
Since that's an `i32`, the two sides match, and Rust is happy. If they didn't
match, we'd get an error:

```{rust,ignore}
let x: Option<f64> = Some(5i);
let x: Option<f64> = Some(5i32);
// error: mismatched types: expected `core::option::Option<f64>`
// but found `core::option::Option<int>` (expected f64 but found int)
// but found `core::option::Option<i32>` (expected f64 but found i32)
```

That doesn't mean we can't make `Option<T>`s that hold an `f64`! They just have to
match up:

```{rust}
let x: Option<int> = Some(5i);
let x: Option<i32> = Some(5i32);
let y: Option<f64> = Some(5.0f64);
```

Expand Down
Loading