This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::fs::File; | |
| use std::io::{self, Seek, SeekFrom}; | |
| use std::time::Duration; | |
| use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; | |
| use mio; | |
| use mio::unix::{EventedFd, UnixReady}; | |
| use nix::poll::{self, PollFd, EventFlags}; | |
| use libc::c_int; | |
| use super::*; | |
| use inotify; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern crate mio; | |
| use mio::unix::EventedFd; | |
| use mio::{Token, PollOpt, Ready, Poll, Events}; | |
| use std::io::ErrorKind; | |
| use std::time::Duration; | |
| fn main() { | |
| const IN: Token = Token(0); | |
| let fd0_e = EventedFd(&0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern crate nix; | |
| use std::io; | |
| use std::io::BufRead; | |
| /// switch stdin to key input | |
| fn ttyin() -> io::Result<()> { | |
| use std::fs::File; | |
| use nix::unistd; | |
| use std::os::unix::io::AsRawFd; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::marker::PhantomData; | |
| use std::mem; | |
| // Unit-like struct | |
| struct U; | |
| // Empty tuple struct | |
| struct T(); | |
| // Empty struct | |
| struct E {} | |
| // Empty tuple member struct |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env sh | |
| # Usage: | |
| # | |
| # $ rustinstant 'println!("hello world!")' | |
| # => hello world | |
| # | |
| # or | |
| # | |
| # $ cat << EOF | rustinstant |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env sh | |
| # $ ./rust-temporary-exec.sh 'println!("hello world!")' | |
| # => hello world! | |
| set -eu | |
| echo "fn main() { $1 }" | rustc - && ./rust_out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![feature(test)] | |
| extern crate test; | |
| #[cfg(test)] | |
| mod tests { | |
| use super::*; | |
| use std::str; | |
| use test::Bencher; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait Foo { | |
| fn method(&self) -> String; | |
| } | |
| impl Foo for u8 { | |
| fn method(&self) -> String { | |
| format!("u8: {}", *self) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[derive(Clone, Debug)] | |
| struct AnyOption { | |
| a: bool, | |
| b: bool, | |
| } | |
| struct AnyBuilder { | |
| option: AnyOption, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io; | |
| use std::fs::File; | |
| fn main() { | |
| let r = io::stdin(); | |
| let mut reader = r.lock(); | |
| let mut writer = File::create("temp_copy.txt").unwrap(); | |
| let _ = io::copy(&mut reader, &mut writer); |