Skip to content

Commit 895d45e

Browse files
committed
---
yaml --- r: 148431 b: refs/heads/try2 c: 290c29c h: refs/heads/master i: 148429: d695783 148427: f77c791 148423: 5246432 148415: 257ad4d v: v3
1 parent a70a973 commit 895d45e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1035
-565
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: e0ea31f56c4e97d0cac367c1bc1e222393713822
8+
refs/heads/try2: 290c29c24cee74b3ffbd6a9d330b09d9d330d508
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/tutorial.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,10 +1020,15 @@ being destroyed along with the owner. Since the `list` variable above is
10201020
immutable, the whole list is immutable. The memory allocation itself is the
10211021
box, while the owner holds onto a pointer to it:
10221022

1023-
Cons cell Cons cell Cons cell
1024-
+-----------+ +-----+-----+ +-----+-----+
1025-
| 1 | ~ | -> | 2 | ~ | -> | 3 | ~ | -> Nil
1026-
+-----------+ +-----+-----+ +-----+-----+
1023+
List box List box List box List box
1024+
+--------------+ +--------------+ +--------------+ +--------------+
1025+
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
1026+
+--------------+ +--------------+ +--------------+ +--------------+
1027+
1028+
> Note: the above diagram shows the logical contents of the enum. The actual
1029+
> memory layout of the enum may vary. For example, for the `List` enum shown
1030+
> above, Rust guarantees that there will be no enum tag field in the actual
1031+
> structure. See the language reference for more details.
10271032
10281033
An owned box is a common example of a type with a destructor. The allocated
10291034
memory is cleaned up when the box is destroyed.

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: Patrick Walton <pcwalton@mozilla.com>
44
" Maintainer: Ben Blum <bblum@cs.cmu.edu>
55
" Maintainer: Chris Morgan <me@chrismorgan.info>
6-
" Last Change: 2013 Dec 10
6+
" Last Change: 2014 Jan 4
77

88
if version < 600
99
syntax clear
@@ -147,8 +147,8 @@ syn match rustMacro '#\w\(\w\)*' contains=rustAssert,rustFail
147147
syn match rustSpecialError display contained /\\./
148148
syn match rustSpecial display contained /\\\([nrt0\\'"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)/
149149
syn match rustStringContinuation display contained /\\\n\s*/
150-
syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustSpecial,rustSpecialError,rustStringContinuation
151-
syn region rustString start='r\z(#*\)"' end='"\z1'
150+
syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustSpecial,rustSpecialError,rustStringContinuation,@Spell
151+
syn region rustString start='r\z(#*\)"' end='"\z1' contains=@Spell
152152

153153
syn region rustAttribute start="#\[" end="\]" contains=rustString,rustDeriving
154154
syn region rustDeriving start="deriving(" end=")" contained contains=rustTrait
@@ -179,10 +179,10 @@ syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit
179179
syn match rustCharacter /'\([^'\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'/ contains=rustSpecial,rustSpecialError
180180

181181
syn cluster rustComment contains=rustCommentLine,rustCommentLineDoc,rustCommentBlock,rustCommentBlockDoc
182-
syn region rustCommentLine start="//" end="$" contains=rustTodo
183-
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo
184-
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,@rustComment keepend extend
185-
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,@rustComment keepend extend
182+
syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell
183+
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell
184+
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,@rustComment,@Spell keepend extend
185+
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,@rustComment,@Spell keepend extend
186186
" FIXME: this is a really ugly and not fully correct implementation. Most
187187
" importantly, a case like ``/* */*`` should have the final ``*`` not being in
188188
" a comment, but in practice at present it leaves comments open two levels

branches/try2/src/libextra/base64.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ impl<'a> FromBase64 for &'a str {
237237
}
238238

239239
for (idx, byte) in it {
240-
if (byte as char) != '=' {
241-
return Err(InvalidBase64Character(self.char_at(idx), idx));
240+
match byte as char {
241+
'='|'\r'|'\n' => continue,
242+
_ => return Err(InvalidBase64Character(self.char_at(idx), idx)),
242243
}
243244
}
244245

@@ -310,6 +311,8 @@ mod test {
310311
fn test_from_base64_newlines() {
311312
assert_eq!("Zm9v\r\nYmFy".from_base64().unwrap(),
312313
"foobar".as_bytes().to_owned());
314+
assert_eq!("Zm9vYg==\r\n".from_base64().unwrap(),
315+
"foob".as_bytes().to_owned());
313316
}
314317

315318
#[test]

branches/try2/src/libextra/bitv.rs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,23 @@ impl Bitv {
269269

270270
impl Bitv {
271271
pub fn new(nbits: uint, init: bool) -> Bitv {
272-
let rep = if nbits <= uint::bits {
272+
let rep = if nbits < uint::bits {
273+
Small(SmallBitv::new(if init {(1<<nbits)-1} else {0}))
274+
} else if nbits == uint::bits {
273275
Small(SmallBitv::new(if init {!0} else {0}))
274-
}
275-
else {
276-
let nelems = nbits/uint::bits +
277-
if nbits % uint::bits == 0 {0} else {1};
278-
let elem = if init {!0u} else {0u};
279-
let s = vec::from_elem(nelems, elem);
276+
} else {
277+
let exact = nbits % uint::bits == 0;
278+
let nelems = nbits/uint::bits + if exact {0} else {1};
279+
let s =
280+
if init {
281+
if exact {
282+
vec::from_elem(nelems, !0u)
283+
} else {
284+
let mut v = vec::from_elem(nelems-1, !0u);
285+
v.push((1<<nbits % uint::bits)-1);
286+
v
287+
}
288+
} else { vec::from_elem(nelems, 0u)};
280289
Big(BigBitv::new(s))
281290
};
282291
Bitv {rep: rep, nbits: nbits}
@@ -1329,6 +1338,20 @@ mod tests {
13291338
assert_eq!(idxs, ~[0, 2, 3]);
13301339
}
13311340
1341+
#[test]
1342+
fn test_bitv_set_frombitv_init() {
1343+
let bools = [true, false];
1344+
let lengths = [10, 64, 100];
1345+
for &b in bools.iter() {
1346+
for &l in lengths.iter() {
1347+
let bitset = BitvSet::from_bitv(Bitv::new(l, b));
1348+
assert_eq!(bitset.contains(&1u), b)
1349+
assert_eq!(bitset.contains(&(l-1u)), b)
1350+
assert!(!bitset.contains(&l))
1351+
}
1352+
}
1353+
}
1354+
13321355
#[test]
13331356
fn test_small_difference() {
13341357
let mut b1 = Bitv::new(3, false);

branches/try2/src/libextra/c_vec.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,19 @@ impl <T> Container for CVec<T> {
160160

161161
#[cfg(test)]
162162
mod tests {
163-
164163
use super::*;
165164

166165
use std::libc::*;
167166
use std::libc;
168167
use std::ptr;
168+
use std::rt::global_heap::malloc_raw;
169169

170170
fn malloc(n: uint) -> CVec<u8> {
171171
unsafe {
172-
let mem = libc::malloc(n as size_t);
173-
174-
assert!(mem as int != 0);
172+
let mem = malloc_raw(n);
175173

176174
CVec::new_with_dtor(mem as *mut u8, n,
177-
proc() { libc::free(mem); })
175+
proc() { libc::free(mem as *c_void); })
178176
}
179177
}
180178

0 commit comments

Comments
 (0)