Skip to content

Use cargo run in more places #16732

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

Closed
wants to merge 16 commits into from
Closed
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
46 changes: 20 additions & 26 deletions src/doc/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ Try it out:

```{notrust,ignore}
$ cargo run
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
Running `target/guessing_game`
Hello, world!
$
Expand Down Expand Up @@ -1957,18 +1957,12 @@ fn main() {
}
```

... and then recompile:
Try running our new program a few times:

```{notrust,ignore}
$ cargo build
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
$
```

Excellent! Try running our new program a few times:

```{notrust,ignore}
$ ./target/guessing_game
$ cargo run
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
Running `target/guessing_game`
Guess the number!
The secret number is: 7
Please input your guess.
Expand Down Expand Up @@ -2019,9 +2013,9 @@ fn main() {
And trying it out:

```{notrust,ignore}
$ cargo build
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
$ ./target/guessing_game
$ cargo run
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
Running `target/guessing_game`
Guess the number!
The secret number is: 57
Please input your guess.
Expand Down Expand Up @@ -2290,9 +2284,9 @@ We use a `match` to either give us the `uint` inside of the `Option`, or we
print an error message and return. Let's give this a shot:

```{notrust,ignore}
$ cargo build
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
$ ./target/guessing_game
$ cargo run
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
Running `target/guessing_game`
Guess the number!
The secret number is: 17
Please input your guess.
Expand Down Expand Up @@ -2356,9 +2350,9 @@ fn cmp(a: uint, b: uint) -> Ordering {
Let's try it!

```{notrust,ignore}
$ cargo build
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
$ ./target/guessing_game
$ cargo run
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
Running `target/guessing_game`
Guess the number!
The secret number is: 58
Please input your guess.
Expand Down Expand Up @@ -2434,9 +2428,9 @@ And try it out. But wait, didn't we just add an infinite loop? Yup. Remember
that `return`? If we give a non-number answer, we'll `return` and quit. Observe:

```{notrust,ignore}
$ cargo build
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
$ ./target/guessing_game
$ cargo run
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
Running `target/guessing_game`
Guess the number!
The secret number is: 59
Please input your guess.
Expand Down Expand Up @@ -2567,9 +2561,9 @@ fn cmp(a: uint, b: uint) -> Ordering {
Now we should be good! Let's try:

```{rust,ignore}
$ cargo build
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
$ ./target/guessing_game
$ cargo run
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
Running `target/guessing_game`
Guess the number!
The secret number is: 61
Please input your guess.
Expand Down
2 changes: 1 addition & 1 deletion src/libfmt_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl<'a> Parser<'a> {
self.cur.next();
}
Some((_, other)) => {
self.err(format!("expected `{}` but found `{}`",
self.err(format!("expected `{}`, found `{}`",
c,
other).as_slice());
}
Expand Down
39 changes: 39 additions & 0 deletions src/libnative/io/c_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ pub static ENABLE_INSERT_MODE: libc::DWORD = 0x20;
pub static ENABLE_LINE_INPUT: libc::DWORD = 0x2;
pub static ENABLE_PROCESSED_INPUT: libc::DWORD = 0x1;
pub static ENABLE_QUICK_EDIT_MODE: libc::DWORD = 0x40;
pub static WSA_INVALID_EVENT: WSAEVENT = 0 as WSAEVENT;

pub static FD_ACCEPT: libc::c_long = 0x08;
pub static FD_MAX_EVENTS: uint = 10;
pub static WSA_INFINITE: libc::DWORD = libc::INFINITE;
pub static WSA_WAIT_TIMEOUT: libc::DWORD = libc::consts::os::extra::WAIT_TIMEOUT;
pub static WSA_WAIT_EVENT_0: libc::DWORD = libc::consts::os::extra::WAIT_OBJECT_0;
pub static WSA_WAIT_FAILED: libc::DWORD = libc::consts::os::extra::WAIT_FAILED;

#[repr(C)]
#[cfg(target_arch = "x86")]
Expand All @@ -52,6 +60,16 @@ pub struct WSADATA {

pub type LPWSADATA = *mut WSADATA;

#[repr(C)]
pub struct WSANETWORKEVENTS {
pub lNetworkEvents: libc::c_long,
pub iErrorCode: [libc::c_int, ..FD_MAX_EVENTS],
}

pub type LPWSANETWORKEVENTS = *mut WSANETWORKEVENTS;

pub type WSAEVENT = libc::HANDLE;

#[repr(C)]
pub struct fd_set {
fd_count: libc::c_uint,
Expand All @@ -68,6 +86,21 @@ extern "system" {
pub fn WSAStartup(wVersionRequested: libc::WORD,
lpWSAData: LPWSADATA) -> libc::c_int;
pub fn WSAGetLastError() -> libc::c_int;
pub fn WSACloseEvent(hEvent: WSAEVENT) -> libc::BOOL;
pub fn WSACreateEvent() -> WSAEVENT;
pub fn WSAEventSelect(s: libc::SOCKET,
hEventObject: WSAEVENT,
lNetworkEvents: libc::c_long) -> libc::c_int;
pub fn WSASetEvent(hEvent: WSAEVENT) -> libc::BOOL;
pub fn WSAWaitForMultipleEvents(cEvents: libc::DWORD,
lphEvents: *const WSAEVENT,
fWaitAll: libc::BOOL,
dwTimeout: libc::DWORD,
fAltertable: libc::BOOL) -> libc::DWORD;
pub fn WSAEnumNetworkEvents(s: libc::SOCKET,
hEventObject: WSAEVENT,
lpNetworkEvents: LPWSANETWORKEVENTS)
-> libc::c_int;

pub fn ioctlsocket(s: libc::SOCKET, cmd: libc::c_long,
argp: *mut libc::c_ulong) -> libc::c_int;
Expand All @@ -82,6 +115,12 @@ extern "system" {
optval: *mut libc::c_char,
optlen: *mut libc::c_int) -> libc::c_int;

pub fn SetEvent(hEvent: libc::HANDLE) -> libc::BOOL;
pub fn WaitForMultipleObjects(nCount: libc::DWORD,
lpHandles: *const libc::HANDLE,
bWaitAll: libc::BOOL,
dwMilliseconds: libc::DWORD) -> libc::DWORD;

pub fn CancelIo(hFile: libc::HANDLE) -> libc::BOOL;
pub fn CancelIoEx(hFile: libc::HANDLE,
lpOverlapped: libc::LPOVERLAPPED) -> libc::BOOL;
Expand Down
Loading