Skip to content

Add enum variants to the type namespace #17338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2014
Merged
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
6 changes: 3 additions & 3 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ mod tests {

use {Mutable, MutableSeq};
use str;
use str::{Str, StrSlice, Owned, Slice};
use str::{Str, StrSlice, Owned};
use super::String;
use vec::Vec;

Expand All @@ -898,10 +898,10 @@ mod tests {
#[test]
fn test_from_utf8_lossy() {
let xs = b"hello";
assert_eq!(String::from_utf8_lossy(xs), Slice("hello"));
assert_eq!(String::from_utf8_lossy(xs), str::Slice("hello"));

let xs = "ศไทย中华Việt Nam".as_bytes();
assert_eq!(String::from_utf8_lossy(xs), Slice("ศไทย中华Việt Nam"));
assert_eq!(String::from_utf8_lossy(xs), str::Slice("ศไทย中华Việt Nam"));

let xs = b"Hello\xC2 There\xFF Goodbye";
assert_eq!(String::from_utf8_lossy(xs),
Expand Down
37 changes: 19 additions & 18 deletions src/libfmt_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use std::char;
use std::str;
use std::string;

/// A piece is a portion of the format string which represents the next part
/// to emit. These are emitted as a stream by the `Parser` class.
Expand All @@ -32,7 +33,7 @@ pub enum Piece<'a> {
String(&'a str),
/// This describes that formatting should process the next argument (as
/// specified inside) for emission.
Argument(Argument<'a>),
NextArgument(Argument<'a>),
}

/// Representation of an argument specification.
Expand Down Expand Up @@ -129,7 +130,7 @@ pub struct Parser<'a> {
input: &'a str,
cur: str::CharOffsets<'a>,
/// Error messages accumulated during parsing
pub errors: Vec<String>,
pub errors: Vec<string::String>,
}

impl<'a> Iterator<Piece<'a>> for Parser<'a> {
Expand All @@ -140,7 +141,7 @@ impl<'a> Iterator<Piece<'a>> for Parser<'a> {
if self.consume('{') {
Some(String(self.string(pos + 1)))
} else {
let ret = Some(Argument(self.argument()));
let ret = Some(NextArgument(self.argument()));
self.must_consume('}');
ret
}
Expand Down Expand Up @@ -469,28 +470,28 @@ mod tests {

#[test]
fn format_nothing() {
same("{}", [Argument(Argument {
same("{}", [NextArgument(Argument {
position: ArgumentNext,
format: fmtdflt(),
})]);
}
#[test]
fn format_position() {
same("{3}", [Argument(Argument {
same("{3}", [NextArgument(Argument {
position: ArgumentIs(3),
format: fmtdflt(),
})]);
}
#[test]
fn format_position_nothing_else() {
same("{3:}", [Argument(Argument {
same("{3:}", [NextArgument(Argument {
position: ArgumentIs(3),
format: fmtdflt(),
})]);
}
#[test]
fn format_type() {
same("{3:a}", [Argument(Argument {
same("{3:a}", [NextArgument(Argument {
position: ArgumentIs(3),
format: FormatSpec {
fill: None,
Expand All @@ -504,7 +505,7 @@ mod tests {
}
#[test]
fn format_align_fill() {
same("{3:>}", [Argument(Argument {
same("{3:>}", [NextArgument(Argument {
position: ArgumentIs(3),
format: FormatSpec {
fill: None,
Expand All @@ -515,7 +516,7 @@ mod tests {
ty: "",
},
})]);
same("{3:0<}", [Argument(Argument {
same("{3:0<}", [NextArgument(Argument {
position: ArgumentIs(3),
format: FormatSpec {
fill: Some('0'),
Expand All @@ -526,7 +527,7 @@ mod tests {
ty: "",
},
})]);
same("{3:*<abcd}", [Argument(Argument {
same("{3:*<abcd}", [NextArgument(Argument {
position: ArgumentIs(3),
format: FormatSpec {
fill: Some('*'),
Expand All @@ -540,7 +541,7 @@ mod tests {
}
#[test]
fn format_counts() {
same("{:10s}", [Argument(Argument {
same("{:10s}", [NextArgument(Argument {
position: ArgumentNext,
format: FormatSpec {
fill: None,
Expand All @@ -551,7 +552,7 @@ mod tests {
ty: "s",
},
})]);
same("{:10$.10s}", [Argument(Argument {
same("{:10$.10s}", [NextArgument(Argument {
position: ArgumentNext,
format: FormatSpec {
fill: None,
Expand All @@ -562,7 +563,7 @@ mod tests {
ty: "s",
},
})]);
same("{:.*s}", [Argument(Argument {
same("{:.*s}", [NextArgument(Argument {
position: ArgumentNext,
format: FormatSpec {
fill: None,
Expand All @@ -573,7 +574,7 @@ mod tests {
ty: "s",
},
})]);
same("{:.10$s}", [Argument(Argument {
same("{:.10$s}", [NextArgument(Argument {
position: ArgumentNext,
format: FormatSpec {
fill: None,
Expand All @@ -584,7 +585,7 @@ mod tests {
ty: "s",
},
})]);
same("{:a$.b$s}", [Argument(Argument {
same("{:a$.b$s}", [NextArgument(Argument {
position: ArgumentNext,
format: FormatSpec {
fill: None,
Expand All @@ -598,7 +599,7 @@ mod tests {
}
#[test]
fn format_flags() {
same("{:-}", [Argument(Argument {
same("{:-}", [NextArgument(Argument {
position: ArgumentNext,
format: FormatSpec {
fill: None,
Expand All @@ -609,7 +610,7 @@ mod tests {
ty: "",
},
})]);
same("{:+#}", [Argument(Argument {
same("{:+#}", [NextArgument(Argument {
position: ArgumentNext,
format: FormatSpec {
fill: None,
Expand All @@ -623,7 +624,7 @@ mod tests {
}
#[test]
fn format_mixture() {
same("abcd {3:a} efg", [String("abcd "), Argument(Argument {
same("abcd {3:a} efg", [String("abcd "), NextArgument(Argument {
position: ArgumentIs(3),
format: FormatSpec {
fill: None,
Expand Down
8 changes: 4 additions & 4 deletions src/libnative/io/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn ntohs(u: u16) -> u16 {
}

enum InAddr {
InAddr(libc::in_addr),
In4Addr(libc::in_addr),
In6Addr(libc::in6_addr),
}

Expand All @@ -48,7 +48,7 @@ fn ip_to_inaddr(ip: rtio::IpAddr) -> InAddr {
(b as u32 << 16) |
(c as u32 << 8) |
(d as u32 << 0);
InAddr(libc::in_addr {
In4Addr(libc::in_addr {
s_addr: Int::from_be(ip)
})
}
Expand All @@ -74,7 +74,7 @@ fn addr_to_sockaddr(addr: rtio::SocketAddr,
-> libc::socklen_t {
unsafe {
let len = match ip_to_inaddr(addr.ip) {
InAddr(inaddr) => {
In4Addr(inaddr) => {
let storage = storage as *mut _ as *mut libc::sockaddr_in;
(*storage).sin_family = libc::AF_INET as libc::sa_family_t;
(*storage).sin_port = htons(addr.port);
Expand Down Expand Up @@ -723,7 +723,7 @@ impl UdpSocket {
pub fn set_membership(&mut self, addr: rtio::IpAddr,
opt: libc::c_int) -> IoResult<()> {
match ip_to_inaddr(addr) {
InAddr(addr) => {
In4Addr(addr) => {
let mreq = libc::ip_mreq {
imr_multiaddr: addr,
// interface == INADDR_ANY
Expand Down
Loading