diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2014-09-11 17:07:49 +1200 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2014-09-19 15:11:00 +1200 |
| commit | ce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7 (patch) | |
| tree | 9ea529bfee7d62b85288d37b0e2bbcdd1c866e0d /src/libterm | |
| parent | af3889f6979647b9bd2dc5f5132d80e3e5b405a5 (diff) | |
| download | rust-ce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7.tar.gz rust-ce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7.zip | |
Add enum variants to the type namespace
Change to resolve and update compiler and libs for uses. [breaking-change] Enum variants are now in both the value and type namespaces. This means that if you have a variant with the same name as a type in scope in a module, you will get a name clash and thus an error. The solution is to either rename the type or the variant.
Diffstat (limited to 'src/libterm')
| -rw-r--r-- | src/libterm/terminfo/parm.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index e6fc64cbd3b..93f773f430d 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -41,7 +41,7 @@ enum FormatState { #[allow(missing_doc)] #[deriving(Clone)] pub enum Param { - String(String), + Words(String), Number(int) } @@ -140,8 +140,8 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) '{' => state = IntConstant(0), 'l' => if stack.len() > 0 { match stack.pop().unwrap() { - String(s) => stack.push(Number(s.len() as int)), - _ => return Err("a non-str was used with %l".to_string()) + Words(s) => stack.push(Number(s.len() as int)), + _ => return Err("a non-str was used with %l".to_string()) } } else { return Err("stack is empty".to_string()) }, '+' => if stack.len() > 1 { @@ -543,7 +543,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> { } s } - String(s) => { + Words(s) => { match op { FormatString => { let mut s = Vec::from_slice(s.as_bytes()); @@ -575,7 +575,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> { #[cfg(test)] mod test { - use super::{expand,String,Variables,Number}; + use super::{expand,Words,Variables,Number}; use std::result::Ok; #[test] @@ -611,7 +611,7 @@ mod test { assert!(res.is_err(), "Op {} succeeded incorrectly with 0 stack entries", *cap); let p = if *cap == "%s" || *cap == "%l" { - String("foo".to_string()) + Words("foo".to_string()) } else { Number(97) }; @@ -689,12 +689,12 @@ mod test { let mut varstruct = Variables::new(); let vars = &mut varstruct; assert_eq!(expand(b"%p1%s%p2%2s%p3%2s%p4%.2s", - [String("foo".to_string()), - String("foo".to_string()), - String("f".to_string()), - String("foo".to_string())], vars), + [Words("foo".to_string()), + Words("foo".to_string()), + Words("f".to_string()), + Words("foo".to_string())], vars), Ok("foofoo ffo".bytes().collect())); - assert_eq!(expand(b"%p1%:-4.2s", [String("foo".to_string())], vars), + assert_eq!(expand(b"%p1%:-4.2s", [Words("foo".to_string())], vars), Ok("fo ".bytes().collect())); assert_eq!(expand(b"%p1%d%p1%.3d%p1%5d%p1%:+d", [Number(1)], vars), |
