Implement pretty-printing of ..
and update tests.
Update tests to change all `&expr[]` to `&expr[..]` to make sure pretty printing passes.
This commit is contained in:
parent
75239142a8
commit
7d527fa96b
13 changed files with 23 additions and 28 deletions
|
@ -1813,9 +1813,7 @@ impl<'a> State<'a> {
|
||||||
if let &Some(ref e) = start {
|
if let &Some(ref e) = start {
|
||||||
try!(self.print_expr(&**e));
|
try!(self.print_expr(&**e));
|
||||||
}
|
}
|
||||||
if start.is_some() || end.is_some() {
|
try!(word(&mut self.s, ".."));
|
||||||
try!(word(&mut self.s, ".."));
|
|
||||||
}
|
|
||||||
if let &Some(ref e) = end {
|
if let &Some(ref e) = end {
|
||||||
try!(self.print_expr(&**e));
|
try!(self.print_expr(&**e));
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,7 @@ impl<'a, W: Writer> RandomFasta<'a, W> {
|
||||||
|
|
||||||
fn nextc(&mut self) -> u8 {
|
fn nextc(&mut self) -> u8 {
|
||||||
let r = self.rng(1.0);
|
let r = self.rng(1.0);
|
||||||
for a in &self.lookup[] {
|
for a in &self.lookup[..] {
|
||||||
if a.p >= r {
|
if a.p >= r {
|
||||||
return a.c;
|
return a.c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,6 @@ fn main() {
|
||||||
let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
|
let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
|
||||||
unsafe {
|
unsafe {
|
||||||
let oof: Oof<[u8; 5], i32> = mem::transmute(foo);
|
let oof: Oof<[u8; 5], i32> = mem::transmute(foo);
|
||||||
println!("{:?} {:?}", &oof.rab[], oof.zab);
|
println!("{:?} {:?}", &oof.rab[..], oof.zab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ fn test_rbml<'a, 'b, A:
|
||||||
let mut rbml_w = EBwriter::Encoder::new(&mut wr);
|
let mut rbml_w = EBwriter::Encoder::new(&mut wr);
|
||||||
a1.encode(&mut rbml_w);
|
a1.encode(&mut rbml_w);
|
||||||
|
|
||||||
let d: serialize::rbml::Doc<'a> = EBDoc::new(&wr[]);
|
let d: serialize::rbml::Doc<'a> = EBDoc::new(&wr);
|
||||||
let mut decoder: EBReader::Decoder<'a> = EBreader::Decoder::new(d);
|
let mut decoder: EBReader::Decoder<'a> = EBreader::Decoder::new(d);
|
||||||
let a2: A = Decodable::decode(&mut decoder);
|
let a2: A = Decodable::decode(&mut decoder);
|
||||||
assert!(*a1 == a2);
|
assert!(*a1 == a2);
|
||||||
|
|
|
@ -47,11 +47,11 @@ fn use_slice(_: &[u8]) {}
|
||||||
fn use_slice_mut(_: &mut [u8]) {}
|
fn use_slice_mut(_: &mut [u8]) {}
|
||||||
|
|
||||||
fn use_vec(mut v: Vec<u8>) {
|
fn use_vec(mut v: Vec<u8>) {
|
||||||
use_slice_mut(&mut v[]); // what you have to write today
|
use_slice_mut(&mut v[..]); // what you have to write today
|
||||||
use_slice_mut(&mut v); // what you'd be able to write
|
use_slice_mut(&mut v); // what you'd be able to write
|
||||||
use_slice_mut(&mut &mut &mut v);
|
use_slice_mut(&mut &mut &mut v);
|
||||||
|
|
||||||
use_slice(&v[]); // what you have to write today
|
use_slice(&v[..]); // what you have to write today
|
||||||
use_slice(&v); // what you'd be able to write
|
use_slice(&v); // what you'd be able to write
|
||||||
use_slice(&&&&&&v);
|
use_slice(&&&&&&v);
|
||||||
use_slice(&mut &&&&&v);
|
use_slice(&mut &&&&&v);
|
||||||
|
@ -59,7 +59,7 @@ fn use_vec(mut v: Vec<u8>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn use_vec_ref(v: &Vec<u8>) {
|
fn use_vec_ref(v: &Vec<u8>) {
|
||||||
use_slice(&v[]); // what you have to write today
|
use_slice(&v[..]); // what you have to write today
|
||||||
use_slice(v); // what you'd be able to write
|
use_slice(v); // what you'd be able to write
|
||||||
use_slice(&&&&&&v);
|
use_slice(&&&&&&v);
|
||||||
use_slice(&mut &&&&&v);
|
use_slice(&mut &&&&&v);
|
||||||
|
|
|
@ -59,7 +59,7 @@ fn roundtrip<'a, T: Rand + Eq + Encodable<Encoder<'a>> +
|
||||||
let mut w = Vec::new();
|
let mut w = Vec::new();
|
||||||
let mut e = Encoder::new(&mut w);
|
let mut e = Encoder::new(&mut w);
|
||||||
obj.encode(&mut e);
|
obj.encode(&mut e);
|
||||||
let doc = rbml::Doc::new(&w[]);
|
let doc = rbml::Doc::new(&w);
|
||||||
let mut dec = Decoder::new(doc);
|
let mut dec = Decoder::new(doc);
|
||||||
let obj2 = Decodable::decode(&mut dec);
|
let obj2 = Decodable::decode(&mut dec);
|
||||||
assert!(obj == obj2);
|
assert!(obj == obj2);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x = [1; 100];
|
let x = [1; 100];
|
||||||
let mut y = 0;
|
let mut y = 0;
|
||||||
for i in &x[] {
|
for i in &x[..] {
|
||||||
if y > 10 {
|
if y > 10 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ pub fn main() {
|
||||||
let y = [2; 100];
|
let y = [2; 100];
|
||||||
let mut p = 0;
|
let mut p = 0;
|
||||||
let mut q = 0;
|
let mut q = 0;
|
||||||
for i in &x[] {
|
for i in &x[..] {
|
||||||
for j in &y[] {
|
for j in &y[..] {
|
||||||
p += *j;
|
p += *j;
|
||||||
}
|
}
|
||||||
q += *i + p;
|
q += *i + p;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x = [1; 100];
|
let x = [1; 100];
|
||||||
let mut y = 0;
|
let mut y = 0;
|
||||||
for i in &x[] {
|
for i in &x[..] {
|
||||||
y += *i
|
y += *i
|
||||||
}
|
}
|
||||||
assert!(y == 100);
|
assert!(y == 100);
|
||||||
|
|
|
@ -18,9 +18,9 @@ pub fn main() {
|
||||||
let x = [(), ()];
|
let x = [(), ()];
|
||||||
let slice = &x[..1];
|
let slice = &x[..1];
|
||||||
|
|
||||||
assert_repr_eq(&abc[], "[1, 2, 3]".to_string());
|
assert_repr_eq(&abc[..], "[1, 2, 3]".to_string());
|
||||||
assert_repr_eq(&tf[], "[true, false]".to_string());
|
assert_repr_eq(&tf[..], "[true, false]".to_string());
|
||||||
assert_repr_eq(&x[], "[(), ()]".to_string());
|
assert_repr_eq(&x[..], "[(), ()]".to_string());
|
||||||
assert_repr_eq(slice, "[()]".to_string());
|
assert_repr_eq(slice, "[()]".to_string());
|
||||||
assert_repr_eq(&x[], "[(), ()]".to_string());
|
assert_repr_eq(&x[..], "[(), ()]".to_string());
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ pub fn main() {
|
||||||
let y = [ 0; 1 ];
|
let y = [ 0; 1 ];
|
||||||
|
|
||||||
print!("[");
|
print!("[");
|
||||||
for xi in &x[] {
|
for xi in &x[..] {
|
||||||
print!("{:?}, ", &xi[]);
|
print!("{:?}, ", &xi[..]);
|
||||||
}
|
}
|
||||||
println!("]");
|
println!("]");
|
||||||
println!("{:?}", &y[]);
|
println!("{:?}", &y[..]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: &[int] = &[1, 2, 3, 4, 5];
|
let x: &[int] = &[1, 2, 3, 4, 5];
|
||||||
let cmp: &[int] = &[1, 2, 3, 4, 5];
|
let cmp: &[int] = &[1, 2, 3, 4, 5];
|
||||||
assert!(&x[] == cmp);
|
|
||||||
assert!(&x[..] == cmp);
|
assert!(&x[..] == cmp);
|
||||||
let cmp: &[int] = &[3, 4, 5];
|
let cmp: &[int] = &[3, 4, 5];
|
||||||
assert!(&x[2..] == cmp);
|
assert!(&x[2..] == cmp);
|
||||||
|
@ -24,7 +23,7 @@ fn main() {
|
||||||
|
|
||||||
let x: Vec<int> = vec![1, 2, 3, 4, 5];
|
let x: Vec<int> = vec![1, 2, 3, 4, 5];
|
||||||
let cmp: &[int] = &[1, 2, 3, 4, 5];
|
let cmp: &[int] = &[1, 2, 3, 4, 5];
|
||||||
assert!(&x[] == cmp);
|
assert!(&x[..] == cmp);
|
||||||
let cmp: &[int] = &[3, 4, 5];
|
let cmp: &[int] = &[3, 4, 5];
|
||||||
assert!(&x[2..] == cmp);
|
assert!(&x[2..] == cmp);
|
||||||
let cmp: &[int] = &[1, 2, 3];
|
let cmp: &[int] = &[1, 2, 3];
|
||||||
|
@ -35,7 +34,6 @@ fn main() {
|
||||||
let x: &mut [int] = &mut [1, 2, 3, 4, 5];
|
let x: &mut [int] = &mut [1, 2, 3, 4, 5];
|
||||||
{
|
{
|
||||||
let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
|
let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
|
||||||
assert!(&mut x[] == cmp);
|
|
||||||
assert!(&mut x[..] == cmp);
|
assert!(&mut x[..] == cmp);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -54,7 +52,6 @@ fn main() {
|
||||||
let mut x: Vec<int> = vec![1, 2, 3, 4, 5];
|
let mut x: Vec<int> = vec![1, 2, 3, 4, 5];
|
||||||
{
|
{
|
||||||
let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
|
let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
|
||||||
assert!(&mut x[] == cmp);
|
|
||||||
assert!(&mut x[..] == cmp);
|
assert!(&mut x[..] == cmp);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,11 +80,11 @@ impl IndexMut<RangeFull> for Foo {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut x = Foo;
|
let mut x = Foo;
|
||||||
&x[];
|
&x[..];
|
||||||
&x[Foo..];
|
&x[Foo..];
|
||||||
&x[..Foo];
|
&x[..Foo];
|
||||||
&x[Foo..Foo];
|
&x[Foo..Foo];
|
||||||
&mut x[];
|
&mut x[..];
|
||||||
&mut x[Foo..];
|
&mut x[Foo..];
|
||||||
&mut x[..Foo];
|
&mut x[..Foo];
|
||||||
&mut x[Foo..Foo];
|
&mut x[Foo..Foo];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue