]> git.lizzy.rs Git - rust.git/commitdiff
serialize: Convert statics to constants
authorAlex Crichton <alex@alexcrichton.com>
Mon, 6 Oct 2014 23:33:56 +0000 (16:33 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 9 Oct 2014 16:44:51 +0000 (09:44 -0700)
src/libserialize/json.rs

index a9ac5ec3ab4f675001b439515001867efc02eba8..5d9211caac1b102254a1632b348e547dd07fc157 100644 (file)
@@ -360,18 +360,16 @@ fn escape_char(writer: &mut io::Writer, v: char) -> Result<(), io::IoError> {
 }
 
 fn spaces(wr: &mut io::Writer, mut n: uint) -> Result<(), io::IoError> {
-    #[allow(non_uppercase_statics)]
-    static len: uint = 16;
-    #[allow(non_uppercase_statics)]
-    static buf: [u8, ..len] = [b' ', ..len];
+    const LEN: uint = 16;
+    static BUF: [u8, ..LEN] = [b' ', ..LEN];
 
-    while n >= len {
-        try!(wr.write(buf));
-        n -= len;
+    while n >= LEN {
+        try!(wr.write(BUF));
+        n -= LEN;
     }
 
     if n > 0 {
-        wr.write(buf[..n])
+        wr.write(BUF[..n])
     } else {
         Ok(())
     }