commit
stringlengths
40
40
old_file
stringlengths
4
236
new_file
stringlengths
4
236
old_contents
stringlengths
1
3.26k
new_contents
stringlengths
16
4.43k
subject
stringlengths
16
624
message
stringlengths
17
3.29k
lang
stringclasses
5 values
license
stringclasses
13 values
repos
stringlengths
5
91.5k
8069ae01fef6efd5ed0961232a0c2bd8f8983ec6
src/lib.rs
src/lib.rs
extern crate hyper; extern crate json; mod request; mod response; pub use request::Request; pub use response::Response; pub type Result = hyper::Result<Response>; pub type Error = hyper::error::Error; pub fn get(url: &str) -> Result { Request::default().get(url) } pub fn post(url: &str) -> Result { Reques...
extern crate hyper; extern crate json; mod request; mod response; pub use request::Request; pub use response::Response; pub use response::Codes; pub type Result = hyper::Result<Response>; pub type Error = hyper::error::Error; pub fn get(url: &str) -> Result { Request::default().get(url) } pub fn post(url: &str...
Prepare for upcoming public Codes enum
Prepare for upcoming public Codes enum
Rust
mit
imp/requests-rs
4aa7803951baede7eaf2460be48ae9690c19bba2
src/main.rs
src/main.rs
extern crate rand; use std::io::Read; use std::fs::File; use rand::Rng; const DICT_FILE: &'static str = "/usr/share/dict/words"; fn main() { let mut dict = File::open(DICT_FILE).unwrap(); // Not ideal, but whatever. let mut buf = String::new(); dict.read_to_string(&mut buf); let mut lines: Vec<_...
extern crate rand; use std::io::Read; use std::fs::File; use rand::Rng; const DICT_FILE: &'static str = "/usr/share/dict/words"; fn main() { let mut dict = File::open(DICT_FILE).unwrap(); // Not ideal, but whatever. let mut buf = String::new(); dict.read_to_string(&mut buf); let mut lines: Vec<_...
Print a newline after the words
Print a newline after the words
Rust
mit
richo/pwrs
7fb87279069c4cfc241837bb6ae7ea77d38b1322
src/main.rs
src/main.rs
extern crate editorconfig; extern crate argparse; use editorconfig::*; use argparse::{ArgumentParser, Store, List, Print}; use std::path::Path; fn main() { let mut conf_filename = ".editorconfig".to_string(); let mut version = "".to_string(); let mut targets: Vec<String> = vec![]; { let mut ap...
extern crate editorconfig; extern crate argparse; use editorconfig::*; use argparse::{ArgumentParser, Store, List, Print}; use std::path::Path; fn main() { let mut conf_filename = ".editorconfig".to_string(); let mut version = "".to_string(); let mut targets: Vec<String> = vec![]; { let mut ap...
Add workaround for backwards compatibility test
Add workaround for backwards compatibility test This is probably not a good way to do this, but I am fairly confident nobody has ever actually depended on backwards compatibility.
Rust
mit
mrandri19/rust-editorconfig
b86941d8a159466c8d4c953ad4a0f4f5130aacca
src/main.rs
src/main.rs
#![allow(unknown_lints)] #![allow(while_let_on_iterator)] // For a performance boost on Linux // #![feature(alloc_system)] // extern crate alloc_system; extern crate fnv; extern crate glob; extern crate liner; extern crate smallvec; extern crate smallstring; #[cfg(all(unix, not(target_os = "redox")))] extern crate u...
#![allow(unknown_lints)] #![allow(while_let_on_iterator)] // For a performance boost on Linux // #![feature(alloc_system)] // extern crate alloc_system; extern crate fnv; extern crate glob; extern crate liner; extern crate smallvec; extern crate smallstring; #[cfg(all(unix, not(target_os = "redox")))] extern crate u...
Fix loading the history file for liner
Fix loading the history file for liner
Rust
mit
redox-os/ion,jwbowen/ion,bheesham/ion,bheesham/ion,redox-os/ion,redox-os/ion,jwbowen/ion
888111da2690bebe5eb2d3bcc21533aa284153ca
libogg/build.rs
libogg/build.rs
extern crate gcc; fn main() { let root = Path::new(std::os::getenv("CARGO_MANIFEST_DIR").unwrap()) .join("libogg"); let config = gcc::Config { include_directories: vec![ root.join("include"), ], definitions: vec![ ("_USRDLL".to_string(), None), ...
extern crate gcc; fn main() { let root = Path::new(std::os::getenv("CARGO_MANIFEST_DIR").unwrap()) .join("libogg"); let config = gcc::Config { include_directories: vec![ root.join("include"), ], definitions: vec![ ("_USRDLL".to_string(), None), ...
Fix paths to pass to gcc-rs
Fix paths to pass to gcc-rs
Rust
bsd-3-clause
tomaka/ogg-sys,tomaka/ogg-sys
4f86ac5af5ab3b6341c0de3e48155752fc95b1c7
benches/new_game.rs
benches/new_game.rs
#![feature(test)] #[cfg(test)] extern crate congalife; extern crate test; use congalife::Game; use test::Bencher; #[bench] fn bench_new_game_64(b: &mut Bencher) { b.iter(|| Game::new(64, 0.2)); } #[bench] fn bench_new_game_128(b: &mut Bencher) { b.iter(|| Game::new(128, 0.2)); } #[bench] fn bench_new_game_...
#![feature(test)] #[cfg(test)] extern crate congalife; extern crate test; use congalife::Game; use test::Bencher; #[bench] fn bench_new_game_64(b: &mut Bencher) { b.iter(|| Game::new(64, 0.2)); } #[bench] fn bench_new_game_128(b: &mut Bencher) { b.iter(|| Game::new(128, 0.2)); } #[bench] fn bench_new_game_...
Fix typo and add larger new game benchmark
Fix typo and add larger new game benchmark
Rust
mit
apostrophest/rust-congalife
b813b76983308fa7897e51a2d5359cc13500030e
spaceapi_server/src/datastore/hash_map_store.rs
spaceapi_server/src/datastore/hash_map_store.rs
use super::{DataStore, DataStoreError}; use std::collections::HashMap; pub type HashMapStore = HashMap<String,String>; /// Implement the DataStore methods for HashMap impl DataStore for HashMapStore { fn store(&mut self, key: &str, value: &str) -> Result<(), DataStoreError> { self.insert(key.into(), valu...
use super::{DataStore, DataStoreError}; use std::collections::HashMap; pub type HashMapStore = HashMap<String,String>; /// Implement the DataStore methods for HashMap impl DataStore for HashMapStore { fn store(&mut self, key: &str, value: &str) -> Result<(), DataStoreError> { self.insert(key.into(), valu...
Add unit tests for HashMapStore
server: Add unit tests for HashMapStore
Rust
mit
coredump-ch/spaceapi
ac9ca231b5f4c85064569d67361ff7a2b98947c6
src/behavioral_bitvec.rs
src/behavioral_bitvec.rs
use primal_bit::BitVec; pub struct BehavioralBitvec { bitvec: BitVec, bitpos: usize, } impl BehavioralBitvec { pub fn new(n: usize) -> Self { BehavioralBitvec { bitvec: BitVec::from_elem(n, false), bitpos: 0, } } #[inline] pub fn push(&mut self, output:...
use primal_bit::BitVec; use hamming; pub struct BehavioralBitvec { bitvec: BitVec, bitpos: usize, } impl BehavioralBitvec { pub fn new(n: usize) -> Self { BehavioralBitvec { bitvec: BitVec::from_elem(n, false), bitpos: 0, } } pub fn hamming_distance(&self, ...
Add hamming distance and test cases
Add hamming distance and test cases
Rust
mit
mneumann/hypernsga,mneumann/hypernsga
0da5095e5f5990409bf5aac41cc37515c6ed6c4f
src/main.rs
src/main.rs
use std::env; use tougou_bot::commands::{ pic::PicCommand, ping::PingCommand, status::StatusCommand }; use tougou_bot::discord_client::*; fn main() { let token: String = env::var("DISCORD_TOKEN").expect("Must set the environment variable `DISCORD_TOKEN`"); let client = serenity_discord_client::Serenit...
use std::env; use std::sync::{ Condvar, Mutex }; use tougou_bot::commands::{ pic::PicCommand, ping::PingCommand, status::StatusCommand }; use tougou_bot::discord_client::*; fn main() { let token: String = env::var("DISCORD_TOKEN").expect("Must set the environment variable `DISCORD_TOKEN`"); let client...
Change process keep alive mechanism
Change process keep alive mechanism
Rust
mit
Hammatt/tougou_bot
034ccad64b35b849e471e85a15ebf1dbd981e95a
pdfutil/src/main.rs
pdfutil/src/main.rs
extern crate lopdf; use lopdf::{Document}; #[macro_use] extern crate clap; use clap::{App, Arg}; fn main() { let arguments = App::new("PDF utility program using lopdf library") .version(crate_version!()) .author(crate_authors!()) .arg(Arg::with_name("input") .short("i") .long("input") .value_name("inp...
extern crate lopdf; use lopdf::Document; #[macro_use] extern crate clap; use clap::{App, Arg, SubCommand}; fn main() { let app = App::new("PDF utility program using lopdf library") .version(crate_version!()) .author(crate_authors!()) .arg(Arg::with_name("input") .short("i") .long("input") .value_name(...
Add compress/decompress subcommands to pdfutil
Add compress/decompress subcommands to pdfutil
Rust
mit
J-F-Liu/lopdf
806620a53c78b44326dca6f53f0adc81d748629f
src/environment.rs
src/environment.rs
use tool::*; /// /// Represents a tooling environment, which enables tools to be retrieved by name. /// /// Environments make it possible to use tools without needing to know where the /// precise implementation is located. Environments also provide a way to perform /// dependency injection in other tools. /// pub tra...
use std::error::Error; use tool::*; /// /// Represents a tooling environment, which enables tools to be retrieved by name. /// /// Environments make it possible to use tools without needing to know where the /// precise implementation is located. Environments also provide a way to perform /// dependency injection in o...
Fix compiler errors for Error
Fix compiler errors for Error Not sure about returning a reference here but we will for the moment
Rust
apache-2.0
Logicalshift/gossyp,Logicalshift/gossyp
ed88340b0b356b177dcad9d388fa7cbe54e29c06
src/engine/world.rs
src/engine/world.rs
use std::vec::Vec; use engine::{Actor, Map}; use engine::builders::MapFromString; use util::units::{Direction, Point}; pub struct World { pub player: Actor, pub actors: Vec<Actor>, pub map: Map, } impl World { pub fn new() -> World { World { player: Actor::new("Player".to_string(...
use std::vec::Vec; use engine::{Actor, Map}; use engine::builders::MapFromString; use util::units::{Direction, Point}; pub struct World { pub player: Actor, pub actors: Vec<Actor>, pub map: Map, } impl World { pub fn new() -> World { World { player: Actor::new("Player".to_string(...
Add a small 5x5 test map
Add a small 5x5 test map
Rust
bsd-3-clause
jgilchrist/rslike
0d514703cbc31e0c043a8254db7fdcb807ab588a
components/core/src/util/sys.rs
components/core/src/util/sys.rs
use crate::error::{Error, Result}; pub use crate::os::system::{uname, Uname}; use std::net::{IpAddr, UdpSocket}; static GOOGLE_DNS: &str = "8.8.8.8:53"; pub fn ip() -> Result<IpAddr> { let socket = UdpSocket::bind("0.0.0.0:0").map_err(Error::IpLookupFa...
use crate::error::{Error, Result}; pub use crate::os::system::{uname, Uname}; use std::{io, net::{IpAddr, Ipv4Addr, ToSocketAddrs, UdpSocket}}; const UNSPECIFIED_SOCKET_ADDR: (Ipv4Addr, u16) = (Ipv4Addr::UNSPECIFIE...
Make ip lookup more testable
Make ip lookup more testable Signed-off-by: David McNeil <e57c3c663692ef9cceb57f3c25154b8f67832195@gmail.com>
Rust
apache-2.0
habitat-sh/habitat,habitat-sh/habitat,rsertelon/habitat,rsertelon/habitat,habitat-sh/habitat,rsertelon/habitat,rsertelon/habitat,habitat-sh/habitat,habitat-sh/habitat,habitat-sh/habitat,habitat-sh/habitat,rsertelon/habitat,rsertelon/habitat,rsertelon/habitat,habitat-sh/habitat
74a020d6c6e072aad73963f5d0f3e331ec723421
rust/scrabble-score/src/lib.rs
rust/scrabble-score/src/lib.rs
pub fn score(string: &str) -> usize { string .chars() .map(|c| match c { 'A' | 'E' | 'I' | 'O' | 'U' | 'L' | 'N' | 'R' | 'S' | 'T' => 1, 'a' | 'e' | 'i' | 'o' | 'u' | 'l' | 'n' | 'r' | 's' | 't' => 1, 'D' | 'G' => 2, 'd' | 'g' => 2, 'B' | '...
#![feature(ascii_ctype)] use std::ascii::AsciiExt; const SCORETABLE: [usize; 26] = [ // a, b, c, d, e, f, g, h, i, j, k, l, m 1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, // n, o, p, q, r, s, t, u, v, w, x, y, z 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10, ]; pub fn score...
Use lookup table to simplify code
Use lookup table to simplify code And also it is effeicent now
Rust
bsd-2-clause
gyn/exercism,gyn/exercism,gyn/exercism,gyn/exercism
08a92a0e643e942911799c9ee8becaae1b30d7e9
build.rs
build.rs
#[allow(dead_code)] fn add_xcode_private_framework_path() { // PrivateFramework dir: // `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/PrivateFrameworks/ let xcode_dir = std::process::Command::new("xcode-select") .arg("-p") .output() .expect("Fai...
#[allow(dead_code)] fn add_xcode_private_framework_path() { // PrivateFramework dir: // `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/PrivateFrameworks/ let xcode_dir = std::process::Command::new("xcode-select") .arg("-p") .output() .expect("Fai...
Add alternative search path for private frameworks
Add alternative search path for private frameworks
Rust
apache-2.0
mrmekon/rubrail-rs
27c3d7c71dfd7c2926ca174d3cb88805ad44be22
beer-song/src/lib.rs
beer-song/src/lib.rs
pub fn sing(start: u32, end: u32) -> String { let mut song = String::new(); for i in (end..start+1).rev() { song.push_str(&verse(i)); song.push_str("\n"); } song.pop(); song } pub fn verse(n: u32) -> String { if n == 0 { "No more bottles of beer on the wall, no more bott...
pub fn sing(start: u32, end: u32) -> String { (end..start+1).rev().map(|x| verse(x)).collect::<Vec<_>>().join("\n") } pub fn verse(n: u32) -> String { match n { 0 => "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n".to...
Make beer-song much more idiomatic
Make beer-song much more idiomatic
Rust
mit
ragnese/exercism-rust
e56805598e906d18ac3c4ef5b083453cebb15aa7
src/test_utils/mod.rs
src/test_utils/mod.rs
#![cfg(test)] use std::cell::RefCell; use std::rc::Rc; use alloc::AllocBox; use js_types::js_obj::JsObjStruct; use js_types::js_str::JsStrStruct; use js_types::js_var::{JsKey, JsPtrEnum, JsType, JsVar}; use js_types::binding::Binding; pub fn make_str(s: &str) -> (JsVar, JsPtrEnum, Binding) { let var = JsVar::new(...
#![cfg(test)] use std::cell::RefCell; use std::rc::Rc; use alloc::AllocBox; use js_types::js_obj::JsObjStruct; use js_types::js_str::JsStrStruct; use js_types::js_var::{JsKey, JsPtrEnum, JsPtrTag, JsType, JsVar}; use js_types::binding::Binding; pub fn make_str(s: &str) -> (JsVar, JsPtrEnum, Binding) { let var = J...
Update test_utils to use new JsPtrTag type
Update test_utils to use new JsPtrTag type
Rust
mit
rustoscript/french-press
cef275fd8f099348060d00b6022cc2b15b853f71
src/datastore.rs
src/datastore.rs
use std::io; use std::fs; use std::io::Write; use std::io::BufReader; use std::io::BufRead; pub fn store_event(name: String, details: Vec<String>) -> io::Result<()> { let mut f = try!(fs::File::create("/tmp/data.csv")); let mut row_data = details.to_vec(); row_data.insert(0, name); let row_string = row...
use std::io; use std::fs; use std::fs::OpenOptions; use std::io::Write; use std::io::BufReader; use std::io::BufRead; pub fn store_event(name: String, details: Vec<String>) -> io::Result<()> { let mut f = OpenOptions::new() .read(true) .write(true) .create(true) ...
Append to data file instead of truncating
Append to data file instead of truncating
Rust
agpl-3.0
joecannatti/soji
b884243cbca9cced860abb132220385c995d32ee
bip_peer/src/lib.rs
bip_peer/src/lib.rs
extern crate bip_handshake; extern crate bip_metainfo; extern crate bip_util; extern crate rotor; extern crate rotor_stream; #[macro_use] extern crate nom; mod disk; mod message; mod piece; mod protocol; mod registration; mod token;
extern crate bip_handshake; extern crate bip_metainfo; extern crate bip_util; extern crate rotor; extern crate rotor_stream; #[macro_use] extern crate nom; //mod disk; //mod message; //mod piece; //mod protocol; //mod registration; //mod token;
Disable bip_peer For bip_handshake Migration
Disable bip_peer For bip_handshake Migration
Rust
apache-2.0
GGist/redox-rs
f526d04cbcc96a0b536355c8093763a78faec6c2
src/interface/mod.rs
src/interface/mod.rs
mod terminal; mod ansi; use std::io::Write; use self::terminal::{Terminal, Event, Key}; pub struct Interface { choices: Vec<String>, terminal: Terminal } impl Interface { /// Creates a new Interface with the provided input choices. pub fn with_choices(choices: Vec<String>) -> Interface { let ...
mod terminal; mod ansi; use std::io::{self, Write}; use self::terminal::{Terminal, Event, Key}; use self::ansi::{clear, cursor}; pub struct Interface { choices: Vec<String>, search: String, terminal: Terminal } impl Interface { /// Creates a new Interface with the provided input choices. pub fn w...
Add search query, split out render method
Add search query, split out render method
Rust
mit
stewart/rff,stewart/rff
741d109265e773e0d25a2759ac1a94ef0d69334f
indentexlib/src/preprocessing.rs
indentexlib/src/preprocessing.rs
use std::io::{BufRead, Error}; pub fn read_and_trim_lines<T: BufRead>(buffered_reader: T) -> Result<Vec<String>, Error> { buffered_reader .lines() .map(|r| Ok(crate::utils::trim_end_inplace(r?))) .collect() }
use std::io::{BufRead, Error}; pub fn read_and_trim_lines<T: BufRead>(buffered_reader: T) -> Result<Vec<String>, Error> { buffered_reader .lines() .map(|r| Ok(crate::utils::trim_end_inplace(r?))) .collect() } // LCOV_EXCL_START #[cfg(test)] mod tests { #[cfg(test)] mod read_and_tri...
Implement unit tests for the trim lines fn
Implement unit tests for the trim lines fn
Rust
mit
mp4096/indentex
7c8fa41625fd17c73876420e300e7c787cb056f6
src/wiz/extraction.rs
src/wiz/extraction.rs
extern crate tar; extern crate flate2; use std::fs::File; use std::io::{BufReader, Read, Write}; use std::path::Path; use self::tar::Archive; use self::flate2::read::GzDecoder; fn extract_tar(input: &Path, output: &Path) { let file = File::open(input).unwrap(); let mut archive = Archive::new(file); archi...
extern crate tar; extern crate flate2; use std::fs::File; use std::io::{BufReader, Read, Write}; use std::path::Path; use self::tar::Archive; use self::flate2::read::GzDecoder; fn extract_tar(input: &Path, output: &Path) { let file = match File::open(input) { Ok(x) => x, Err(why) => panic!("A...
Use match instead of unwrap
Use match instead of unwrap
Rust
bsd-3-clause
hch12907/wiz
296262a74eea6a228c37ef45fe043b4917f290d8
imap-proto/src/parser/rfc5161.rs
imap-proto/src/parser/rfc5161.rs
//! //! https://tools.ietf.org/html/rfc5161 //! //! The IMAP ENABLE Extension //! // rustfmt doesn't do a very good job on nom parser invocations. #![cfg_attr(rustfmt, rustfmt_skip)] #![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure))] use crate::types::*; use crate::parser::core::atom; // The EN...
//! //! https://tools.ietf.org/html/rfc5161 //! //! The IMAP ENABLE Extension //! // rustfmt doesn't do a very good job on nom parser invocations. #![cfg_attr(rustfmt, rustfmt_skip)] use crate::types::*; use crate::parser::core::atom; // The ENABLED response lists capabilities that were enabled in response // to a E...
Remove usage of redundant closures
Remove usage of redundant closures
Rust
apache-2.0
djc/tokio-imap
6757d9086ba4165f9422215a091d28ecbad7641b
main.rs
main.rs
#![no_std] #![allow(ctypes)] enum Color { Black = 0, Blue = 1, Green = 2, Cyan = 3, Red = 4, Pink = 5, Brown = 6, LightGray = 7, DarkGray = 8, LightBlue = 9, LightGreen = 10, LightCyan = 11, LightRed = 12, LightPink ...
#![no_std] #![allow(ctypes)] enum Color { Black = 0, Blue = 1, Green = 2, Cyan = 3, Red = 4, Pink = 5, Brown = 6, LightGray = 7, DarkGray = 8, LightBlue = 9, LightGreen = 10, LightCyan = 11, LightRed = 12, LightPink ...
Remove range since 0.11 doesn't like it.
Remove range since 0.11 doesn't like it.
Rust
mit
smkell/rustboot,smkell/rustboot
a1cece752b62ffa2218766d82107031accd40dcc
src/lib/protobuf.rs
src/lib/protobuf.rs
#[link(name = "protobuf", vers = "0.1.0")]; #[crate_type = "lib"]; #[feature(globs)]; #[feature(managed_boxes)]; #[desc = "protobuf implementation for rust"]; #[license = "BSD"]; #[author = "Stepan Koltsov"]; pub use core::*; mod core; pub mod descriptor; pub mod codegen; pub mod rt; mod misc; mod zigzag; mod hex; ...
#[link(name = "protobuf", vers = "0.1.0")]; #[crate_type = "lib"]; #[feature(globs)]; #[feature(managed_boxes)]; #[desc = "protobuf implementation for rust"]; #[license = "BSD"]; pub use core::*; mod core; pub mod descriptor; pub mod codegen; pub mod rt; mod misc; mod zigzag; mod hex; #[cfg(test)] mod shrug; #[cfg(...
Remove author annotation to mute rustc complains
Remove author annotation to mute rustc complains
Rust
bsd-2-clause
thijsc/rust-protobuf,Blei/rust-protobuf,jamwt/rust-protobuf,jamwt/rust-protobuf,Blei/rust-protobuf,Stebalien/rust-protobuf,jimmycuadra/rust-protobuf,filsmick/rust-protobuf,frew/rust-protobuf,thijsc/rust-protobuf,Stebalien/rust-protobuf,filsmick/rust-protobuf,jimmycuadra/rust-protobuf,danburkert/rust-protobuf,plietar/ru...
a76b24e274a30694004f919372698e707cfb9dff
beacon_node/beacon_chain/test_harness/src/lib.rs
beacon_node/beacon_chain/test_harness/src/lib.rs
//! Provides a testing environment for the `BeaconChain`, `Attester` and `BlockProposer` objects. //! //! This environment bypasses networking and client run-times and connects the `Attester` and `Proposer` //! directly to the `BeaconChain` via an `Arc`. //! //! The `BeaconChainHarness` contains a single `BeaconChain` ...
//! Provides a testing environment for the `BeaconChain`, `Attester` and `BlockProposer` objects. //! //! This environment bypasses networking and client run-times and connects the `Attester` and `Proposer` //! directly to the `BeaconChain` via an `Arc`. //! //! The `BeaconChainHarness` contains a single `BeaconChain` ...
Disable running docs example for test harness
Disable running docs example for test harness
Rust
apache-2.0
sigp/lighthouse,sigp/lighthouse,sigp/lighthouse,sigp/lighthouse
4398b553158e5785e91ff49fe1d0b9614315102e
benches/generate.rs
benches/generate.rs
extern crate identicon; extern crate openssl; extern crate test; use openssl::crypto::hash::{Hasher, HashType}; use test::Bencher; use identicon::Identicon; #[bench] fn generate(x: &mut Bencher) { let source = String::from_str("42"); let input = source.as_bytes(); x.iter(|| { let mut hash = Hash...
extern crate identicon; extern crate openssl; extern crate test; use openssl::crypto::hash::{hash, Type}; use test::Bencher; use identicon::Identicon; #[bench] fn generate(x: &mut Bencher) { let source = String::from_str("42"); let input = source.as_bytes(); x.iter(|| { let bytes = hash(Type::MD...
Use hash function to consume all input at once.
Use hash function to consume all input at once.
Rust
mit
dgraham/identicon
bc1abed08e33e9cef56f37e1318e37ab8f186526
code/07/pointers.rs
code/07/pointers.rs
fn plus_one(x: &int) -> int { *x + 1 } fn main() { let x = @10; let y = ~10; println(plus_one(x).to_str()); println(plus_one(y).to_str()); }
use std::gc::Gc; fn plus_one(x: &int) -> int { *x + 1 } fn main() { let x = Gc::new(10); let y = ~10; println(plus_one(x.borrow()).to_str()); println(plus_one(y).to_str()); }
Fix for usage of managed boxes
Fix for usage of managed boxes As per, https://github.com/mozilla/rust/wiki/Doc-detailed-release-notes#09-january-2014 @ is deprecated.
Rust
agpl-3.0
dskecse/rust_for_rubyists,dskecse/rust_for_rubyists,dskecse/rust_for_rubyists,steveklabnik/rust_for_rubyists,gpbonillas/rust_for_rubyists,steveklabnik/rust_for_rubyists,gpbonillas/rust_for_rubyists,steveklabnik/rust_for_rubyists,gpbonillas/rust_for_rubyists
e4d6556664aad6efadbe8942e49a56490112bfc9
cli/src/main.rs
cli/src/main.rs
#[macro_use] extern crate clap; extern crate names; use names::{Generator, Name}; fn main() { let (naming, amount) = { let app = clap_app!(names => (version: &crate_version!()[..]) (author: "\nAuthor: Fletcher Nichol <fnichol@nichol.ca>\n") (about: "A random...
#[macro_use] extern crate clap; extern crate names; use clap::{AppSettings, Arg}; use names::{Generator, Name}; fn main() { let (naming, amount) = parse_cli_args(); let mut generator = Generator::with_naming(naming); for _ in 0..amount { println!("{}", generator.next().unwrap()); } } fn pars...
Update clap code to use `app_from_crate!` macro.
[cli] Update clap code to use `app_from_crate!` macro. Signed-off-by: Fletcher Nichol <77a0fd9e8048bbacd11af4e957bc6ff03b549f49@nichol.ca>
Rust
mit
fnichol/names
5a7493fa636e1892b13083e46aeb9971c2e23b30
frameworks/Rust/hyper/src/main.rs
frameworks/Rust/hyper/src/main.rs
extern crate hyper; use hyper::server::{Server, Request, Response}; use hyper::uri::RequestUri; use hyper::header::ContentType; use hyper::header; const HELLO_WORLD: &'static [u8; 13] = b"Hello, World!"; fn main() { Server::http("0.0.0.0:8080").unwrap().handle(handler).unwrap(); } fn handler(req: Request, mut r...
extern crate hyper; use hyper::server::{Server, Request, Response}; use hyper::uri::RequestUri; use hyper::header::ContentType; use hyper::header; const HELLO_WORLD: &'static [u8; 13] = b"Hello, World!"; fn main() { Server::http("0.0.0.0:8080").unwrap().handle(handler).unwrap(); } fn handler(req: Request, mut r...
Fix hyper warning wrt content type
Fix hyper warning wrt content type Hyper's convenience method produces an extra parameter that the benchmark doesn't require, so let's build our own without it.
Rust
bsd-3-clause
Eyepea/FrameworkBenchmarks,circlespainter/FrameworkBenchmarks,steveklabnik/FrameworkBenchmarks,methane/FrameworkBenchmarks,Dith3r/FrameworkBenchmarks,jetty-project/FrameworkBenchmarks,zloster/FrameworkBenchmarks,jeevatkm/FrameworkBenchmarks,Jesterovskiy/FrameworkBenchmarks,herloct/FrameworkBenchmarks,kostya-sh/Framewor...
18ec06fc6ac92edb33212a778b435ba845b08495
src/pretty/string_utils.rs
src/pretty/string_utils.rs
fn replicate<A:Clone>(x:A, l:uint) -> Vec<A> { let i = 0u; let mut res = Vec::new(); for _ in range(i,l) { res.push(x.clone()); } res } fn pad_right(c:char, l:uint, str:String) -> String { let str_len = str.len(); if l > str_len { let padding = replicate(String::from_chars([...
use std::iter::Repeat; fn replicate<A:Clone>(x:A, l:uint) -> Vec<A> { FromIterator::from_iter(Repeat::new(x).take(l)) } fn pad_right(c:char, l:uint, str:String) -> String { let str_len = str.len(); if l > str_len { let padding = replicate(String::from_chars([c]), l - str_len).concat(); let...
Use iterator to repeat elem
Use iterator to repeat elem
Rust
mit
epsilonz/pretty.rs,Marwes/pretty.rs,Marwes/pretty.rs
8173aec34eb458d351c43207783e775a1c44e8f2
yes.rs
yes.rs
use std::env; #[allow(while_true)] fn main() { let args: Vec<String> = env::args().collect(); match args.len() { 1 => { while true { println!("y"); } }, _ => { while true { println!("{}", args[1]); } ...
use std::env; fn main() { let args: Vec<String> = env::args().collect(); let args = &args[1..]; let output = if args.is_empty() { "y".to_string() } else { args.join(" ") }; loop { println!("{}", output) } }
Simplify solution, use `loop` for endless loop
Rust: Simplify solution, use `loop` for endless loop
Rust
mit
mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes,mubaris/yes
0beee76601f94c5601357c239e5e850266a47c2a
base.rs
base.rs
use geom::size::Size2D; pub trait ShareContext { // Creates a new context for GL object sharing. static fn new(size: Size2D<int>) -> Self; // Flushes the context. fn flush(&self); // Returns the platform-specific ID that can be passed to other processes to access the shared // resources. ...
use geom::size::Size2D; pub trait ShareContext { // Creates a new context for GL object sharing. static fn new(size: Size2D<int>) -> Self; // Flushes the context. fn flush(&self); // Returns the platform-specific ID that can be passed to other processes to access the shared // resources. ...
Update tests for language changes
Update tests for language changes
Rust
apache-2.0
servo/sharegl
3a04a1f5dca54b99afe9fdcb83b46b3e3d6b568c
src/lib.rs
src/lib.rs
#![crate_type = "lib"] #![warn(missing_docs)] //! Synchronization primitives based on spinning #![cfg_attr(feature = "const_fn", feature(const_fn, const_unsafe_cell_new, const_atomic_usize_new))] #![no_std] #[cfg(test)] #[macro_use] extern crate std; pub use mutex::*; pub use rw_lock::*; #[cfg(feature = "once")] ...
#![crate_type = "lib"] #![warn(missing_docs)] //! Synchronization primitives based on spinning #![cfg_attr(feature = "const_fn", feature(const_fn))] #![no_std] #[cfg(test)] #[macro_use] extern crate std; pub use mutex::*; pub use rw_lock::*; #[cfg(feature = "once")] pub use once::*; mod mutex; mod rw_lock; #[cf...
Fix compile error on nightly-2018-08-14
Fix compile error on nightly-2018-08-14 const_unsafe_cell_new and const_atomic_usize_new is stable now and don't need to be enabled by feature
Rust
mit
mvdnes/spin-rs,mvdnes/spinlock-rs
dfb74263acbf16f4872e231b84c0dd8c6111428c
src/lib/rand.rs
src/lib/rand.rs
/** * Bindings the runtime's random number generator (ISAAC). */ native "rust" mod rustrt { type rctx; fn rand_new() -> rctx; fn rand_next(rctx c) -> u32; fn rand_free(rctx c); } type rng = obj { fn next() -> u32; }; fn mk_rng() -> rng { obj rt_rng(rustrt.rctx c) { fn next() -> u32 { ret rustrt...
/** * Bindings the runtime's random number generator (ISAAC). */ native "rust" mod rustrt { type rctx; fn rand_new() -> rctx; fn rand_next(rctx c) -> u32; fn rand_free(rctx c); } type rng = obj { fn next() -> u32; }; fn mk_rng() -> rng { obj rt_rng(rustrt.rctx c) { fn next() -> u32 { ...
Reformat standard library; no code changes.
Reformat standard library; no code changes.
Rust
apache-2.0
rust-lang/rand
031e880ea7ad4695769c4223672967e369deaa15
protobuf-test/src/lib.rs
protobuf-test/src/lib.rs
#![cfg(test)] extern crate protobuf; extern crate protobuf_test_common; #[cfg(feature = "with-bytes")] extern crate bytes; mod v2; // `cfg(proto3)` is emitted by `build.rs` #[cfg(proto3)] mod v3; mod common; #[cfg(proto3)] mod google; mod interop; mod include_generated;
#![cfg(test)] extern crate protobuf; extern crate protobuf_test_common; #[cfg(feature = "with-bytes")] extern crate bytes; mod v2; mod v3; mod common; mod google; mod interop; mod include_generated;
Enable accidentally deleted v3 tests
Enable accidentally deleted v3 tests
Rust
mit
stepancheg/rust-protobuf,stepancheg/rust-protobuf,stepancheg/rust-protobuf
128bb9c646cb694d65c873dd767582f6b4dd4791
exec.rs
exec.rs
use super::*; use redox::*; impl Editor { pub fn exec(&mut self, Inst(n, cmd): Inst) { use super::Mode::*; use super::PrimitiveMode::*; use super::CommandMode::*; match self.cursor().mode { Command(Normal) => match cmd { 'i' => { self....
use super::*; use redox::*; impl Editor { pub fn exec(&mut self, Inst(n, cmd): Inst) { use super::Mode::*; use super::PrimitiveMode::*; use super::CommandMode::*; match self.cursor().mode { Command(Normal) => match cmd { 'i' => { self....
Add $ and 0 commands
Add $ and 0 commands
Rust
mit
redox-os/sodium
cff8835e2eaaa2d94342b258d6c423315ed24e86
benches/digest/mod.rs
benches/digest/mod.rs
macro_rules! bench_digest { ($name:ident, $engine:path, $bytes:expr) => { #[bench] fn $name(b: &mut Bencher) { use octavo::digest::Digest; let mut d = <$engine>::default(); let data = vec![0; $bytes]; b.iter(|| { d.update(&data[..]); ...
macro_rules! bench_digest { ($name:ident, $engine:path, $blocks:expr) => { #[bench] fn $name(b: &mut Bencher) { use octavo::digest::Digest; let bs = <$engine>::block_size(); let mut d = <$engine>::default(); let data = vec![0; bs]; b.ite...
Use block size in benches
feat(benches/digest): Use block size in benches
Rust
mit
libOctavo/octavo,hauleth/octavo
b2e4b7be514b475141da56912fa4a068eb77783f
src/vm.rs
src/vm.rs
use std::io; use std::io::Read; type Cell = u8; pub struct VM { cells: [Cell; 30_000], data_pointer: usize, } impl VM { pub fn new() -> VM { VM { cells: [0; 30_000], data_pointer: 0 } } pub fn output(&self) { print!("{}", self.cells[self.data_pointer]); } pub fn inpu...
use std::io; use std::io::Read; use command::Command; type Cell = u8; pub struct VM { cells: [Cell; 30_000], data_pointer: usize, } impl VM { pub fn new() -> VM { VM { cells: [0; 30_000], data_pointer: 0 } } pub fn output(&self) { print!("{}", self.cells[self.data_pointer]); ...
Add apply function to VM
Add apply function to VM
Rust
mit
nafarlee/thoughtfuck
905ff7b99544ebec7fd3610ace206d8a04d90ca1
test/src/lib.rs
test/src/lib.rs
/** * Copyright 2021 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law ...
/** * Copyright 2021 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law ...
Make example closer to docs
Make example closer to docs
Rust
apache-2.0
GoogleChromeLabs/wasm-bindgen-rayon,GoogleChromeLabs/wasm-bindgen-rayon,GoogleChromeLabs/wasm-bindgen-rayon
795d7da2ff0c34211fa817dfcab4cf8590669ffd
tests/codecs.rs
tests/codecs.rs
extern crate tokio_io; extern crate bytes; use bytes::{BytesMut, BufMut}; use tokio_io::codec::{BytesCodec, LinesCodec, Decoder, Encoder}; #[test] fn bytes_decoder() { let mut codec = BytesCodec::new(); let buf = &mut BytesMut::new(); buf.put_slice(b"abc"); assert_eq!("abc", codec.decode(buf).unwrap()...
extern crate tokio_io; extern crate bytes; use bytes::{BytesMut, BufMut}; use tokio_io::codec::{BytesCodec, LinesCodec, Decoder, Encoder}; #[test] fn bytes_decoder() { let mut codec = BytesCodec::new(); let buf = &mut BytesMut::new(); buf.put_slice(b"abc"); assert_eq!("abc", codec.decode(buf).unwrap()...
Add a reserve to a test to prevent an assertion
Add a reserve to a test to prevent an assertion Closes #91
Rust
apache-2.0
tokio-rs/tokio-io
5db454869ae07f5892bf5ac5d8d797bcb2c7558d
build.rs
build.rs
use std::env; use std::path::Path; use ctl10n; const LOCALES: &[&str] = &["zh", "en"]; fn main() { for locale in LOCALES { println!("cargo:rerun-if-changed=locales/{}.toml", locale); } println!("cargo:rerun-if-env-changed=LOCALE"); if let Err(err) = ctl10n::convert_strings_file( forma...
use std::env; use std::path::Path; use ctl10n; const LOCALES: &[&str] = &["zh", "en"]; fn main() { for locale in LOCALES { println!("cargo:rerun-if-changed=locales/{}.toml", locale); } println!("cargo:rerun-if-env-changed=LOCALE"); let locale_file = format!( "locales/{}.toml", ...
Remove the generated ctl10n macro before regeneration
Remove the generated ctl10n macro before regeneration Otherwise, we may get a broken macro
Rust
unlicense
iovxw/rssbot
85fb27fcb402904de245001913848777e72505d2
fuzz/fuzz_targets/fuzz_target_1.rs
fuzz/fuzz_targets/fuzz_target_1.rs
#![no_main] #[macro_use] extern crate libfuzzer_sys; extern crate quick_xml; use quick_xml::Reader; use quick_xml::events::Event; use std::io::Cursor; fuzz_target!(|data: &[u8]| { // fuzzed code goes here let cursor = Cursor::new(data); let mut reader = Reader::from_reader(cursor); let mut buf = vec![...
#![no_main] #[macro_use] extern crate libfuzzer_sys; extern crate quick_xml; use quick_xml::Reader; use quick_xml::events::Event; use std::io::Cursor; fuzz_target!(|data: &[u8]| { // fuzzed code goes here let cursor = Cursor::new(data); let mut reader = Reader::from_reader(cursor); let mut buf = vec![...
Fix fuzzer so it compiles
Fix fuzzer so it compiles
Rust
mit
tafia/quick-xml,tafia/quick-xml
b7c449c3279a70b78293de23f2f8771eba7c8086
src/rust/src/main.rs
src/rust/src/main.rs
extern crate clap; extern crate rusqlite; #[macro_use] extern crate rustc_serialize; extern crate uuid; mod loader; mod db; mod dbFsDirType; mod dbFsDir; mod dbFsFile; mod dbProvider; mod dbJob; mod dbJobProvide; mod dbJobDepend; mod dbVariableName; mod dbJobRequireVariable; mod dbVariablePair; mod dbJobRequireVaria...
extern crate clap; extern crate rusqlite; #[macro_use] extern crate rustc_serialize; extern crate uuid; mod loader; mod db; mod dbFsDirType; mod dbFsDir; mod dbFsFile; mod dbProvider; mod dbJob; mod dbJobProvide; mod dbJobDepend; mod dbVariableName; mod dbJobRequireVariable; mod dbVariablePair; mod dbJobRequireVaria...
Reorder so we can use cli to set db location
Reorder so we can use cli to set db location Signed-off-by: Owen Synge <d1d4fd964cef7d0e7c6a7c6237ad92c9cf2de236@jaysnest.de>
Rust
lgpl-2.1
osynge/whenenv-rust,osynge/whenenv-rust
cccd10dc6d597009f0766594e83923d18e6c746c
seax_scheme/src/lib.rs
seax_scheme/src/lib.rs
#![crate_name = "seax_scheme"] #![crate_type = "lib"] #![feature(convert,core,box_syntax,box_patterns)] #[macro_use] extern crate seax_svm as svm; pub mod ast; /// Contains the Scheme parser. /// /// This parser is based on the /// [Scheme grammar](final/html/r6rs/r6rs-Z-H-7.html) given in the /// [Revised<sup>6</su...
#![crate_name = "seax_scheme"] #![crate_type = "lib"] #![feature(convert,core,box_syntax,box_patterns)] #[macro_use] extern crate seax_svm as svm; pub mod ast; /// Contains the Scheme parser. /// /// This parser is based on the /// [Scheme grammar](final/html/r6rs/r6rs-Z-H-7.html) given in the /// [Revised<sup>6</su...
Move ForkTable rustdoc to the correct place
Move ForkTable rustdoc to the correct place
Rust
mit
hawkw/seax,hawkw/seax
fe066d8be5a32c5065fb04e51675cf450edca91c
16_vectors/src/main.rs
16_vectors/src/main.rs
fn main() { println!("Hello, world!"); }
fn main() { let v: Vec<i32> = Vec::new(); // Macro usage for vector let v_from_macro = vec![1, 2, 3]; }
Add examples of vector initialization
Add examples of vector initialization
Rust
mit
pgrzesik/learning-rust
291c79134fa5e2deeebb5a6133de5f8d3788f775
src/repl/value_printer.rs
src/repl/value_printer.rs
use std::fmt::Write; pub extern "C" fn encode_i8(buf: &mut String, val: i8) { write!(buf, "{}", val).unwrap(); } pub extern "C" fn encode_i8(buf: &mut String, val: i8) { write!(buf, "{}", val).unwrap(); }
use std::fmt::Write; use std::convert::Into; use llvm::builder::Builder; use llvm::value::Value; use common::types::Ty; macro_rules! encode_value( ($name:ident, $ty:ty) => ( #[allow(dead_code)] pub extern "C" fn $name(buf: &mut String, val: $ty) { write!(buf, "{}", val).unwrap(); } ); ); encode_...
Add encode_value macro and implement them for all types.
Add encode_value macro and implement them for all types.
Rust
apache-2.0
hyunsik/tokamak,hyunsik/tokamak,hyunsik/tokamak,hyunsik/tokamak,hyunsik/tokamak,hyunsik/tokamak
f07465f053730316f037549a30dfdeb18740be04
src/main.rs
src/main.rs
extern crate clap; use clap::{Arg, App}; use std::ffi::OsStr; use std::fs::File; use std::io; fn main() { let app = App::new(env!("CARGO_PKG_NAME")) .version(env!("CARGO_PKG_VERSION")) .author("Scott Olson <scott@solson.me>") .about(env!("CARGO_PKG_DESCRIPTION")) .arg(Arg::with_nam...
extern crate clap; use clap::{Arg, App, AppSettings}; use std::ffi::OsStr; use std::fs::File; use std::io; fn main() { let matches = App::new(env!("CARGO_PKG_NAME")) .version(env!("CARGO_PKG_VERSION")) .author("Scott Olson <scott@solson.me>") .about(env!("CARGO_PKG_DESCRIPTION")) ....
Print help on no arguments in a better way.
Print help on no arguments in a better way.
Rust
mit
solson/rin
ba17daeac8fa2645ce72d9e6fcfee987bd39c138
src/cargo/util/mod.rs
src/cargo/util/mod.rs
pub use self::config::Config; pub use self::process_builder::{process, ProcessBuilder}; pub use self::result::{Wrap, Require}; pub use self::errors::{CargoResult, CargoError, BoxError, ChainError, CliResult}; pub use self::errors::{CliError, FromError, ProcessError}; pub use self::errors::{process_error, internal_error...
pub use self::config::Config; pub use self::process_builder::{process, ProcessBuilder}; pub use self::result::{Wrap, Require}; pub use self::errors::{CargoResult, CargoError, BoxError, ChainError, CliResult}; pub use self::errors::{CliError, FromError, ProcessError}; pub use self::errors::{process_error, internal_error...
Make to_url public for rustc
Make to_url public for rustc
Rust
apache-2.0
apjanke/cargo,youprofit/cargo,tsurai/cargo,vyskocilm/cargo,tafia/cargo,apjanke/cargo,Gankro/cargo,lucab/cargo,ruud-v-a/cargo,eminence/cargo,achanda/cargo,durka/cargo,huonw/cargo,mceier/cargo,wesleywiser/cargo,huonw/cargo,takkanm/cargo,mceier/cargo,ThinTim/cargo,eminence/cargo,Turbo87/cargo,ucarion/cargo,lucab/cargo,vys...
00bbf21ea262fdbb90849f15aebefb1d8327bc5d
src/cli.rs
src/cli.rs
use vmx; pub struct ClearLocalInterruptsGuard; impl ClearLocalInterruptsGuard { pub fn new() -> Self { vmx::cli(); ClearLocalInterruptsGuard {} } } impl Drop for ClearLocalInterruptsGuard { fn drop(&mut self) { vmx::sti(); } }
use vmx; pub struct ClearLocalInterruptsGuard(()); impl ClearLocalInterruptsGuard { pub fn new() -> Self { vmx::cli(); ClearLocalInterruptsGuard(()) } } impl Default for ClearLocalInterruptsGuard { fn default() -> Self { ClearLocalInterruptsGuard::new() } } impl Drop for Clea...
Make ClearLocalInterruptsGuard a bottom type
Make ClearLocalInterruptsGuard a bottom type
Rust
mit
iankronquist/rustyvisor,iankronquist/rustyvisor,iankronquist/rustyvisor
67757c3e662e19747a927ba7a43c313ef2e9f74f
src/lib.rs
src/lib.rs
extern crate libc; use std::ffi::CStr; use std::str; use libc::c_char; #[no_mangle] pub extern "C" fn count_substrings(value: *const c_char, substr: *const c_char) -> i32 { let c_value = unsafe { CStr::from_ptr(value).to_bytes() }; let c_substr = unsafe { CStr::from_ptr(substr).to_bytes() }; match str::fr...
extern crate libc; use std::ffi::CStr; use std::str; use libc::c_char; #[no_mangle] pub extern "C" fn count_substrings(value: *const c_char, substr: *const c_char) -> i32 { let c_value = unsafe { CStr::from_ptr(value).to_bytes() }; let c_substr = unsafe { CStr::from_ptr(substr).to_bytes() }; match str::fr...
Replace hand-written loop with str.matches() call.
Replace hand-written loop with str.matches() call. This should fix #4.
Rust
mit
zsiciarz/rust-ffi-stringtools,zsiciarz/rust-ffi-stringtools,zsiciarz/rust-ffi-stringtools,zsiciarz/rust-ffi-stringtools,zsiciarz/rust-ffi-stringtools,zsiciarz/rust-ffi-stringtools,zsiciarz/rust-ffi-stringtools
20d0e71232717c59c64f2537b184d9ef670554f0
tests/unit/style/parsing/length.rs
tests/unit/style/parsing/length.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use parsing::parse; use style::parser::Parse; use style::values::specified::length::Length; #[test] fn test_calc(...
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use parsing::parse; use style::parser::Parse; use style::values::specified::length::Length; #[test] fn test_calc(...
Add a test for other valid uses of calc()
style: Add a test for other valid uses of calc()
Rust
mpl-2.0
mbrubeck/servo,splav/servo,dsandeephegde/servo,DominoTree/servo,anthgur/servo,dsandeephegde/servo,paulrouget/servo,canaltinova/servo,szeged/servo,canaltinova/servo,thiagopnts/servo,splav/servo,paulrouget/servo,eddyb/servo,notriddle/servo,eddyb/servo,pyfisch/servo,jimberlage/servo,fiji-flo/servo,fiji-flo/servo,dati91/se...
91afdaf698917650afe9b22c4cc1de5b91a18609
src/bin/10-signals/e10-sleep60.rs
src/bin/10-signals/e10-sleep60.rs
/// Exercise 10.10: Write a program that calls sleep(60) in an infinite loop. /// Every five times through the loop (every 5 minutes), fetch the current /// time of day and print the tm_sec field. Run the program overnight and /// explain the results. How would a program such as the cron daemon, /// which runs every mi...
/// Exercise 10.10: Write a program that calls sleep(60) in an infinite loop. /// Every five times through the loop (every 5 minutes), fetch the current /// time of day and print the tm_sec field. Run the program overnight and /// explain the results. How would a program such as the cron daemon, /// which runs every mi...
Add findings of Exercise 10.10
Add findings of Exercise 10.10
Rust
mit
philippkeller/apue-rust,philippkeller/apue-rust,philippkeller/apue-rust
e8bc8eb14f51d110ed842f4e308654b84ba8c484
json_typegen_cli/src/main.rs
json_typegen_cli/src/main.rs
extern crate json_typegen_shared; extern crate clap; use json_typegen_shared::codegen_from_macro; use clap::{Arg, App}; fn main() { let matches = App::new("JSON code generation CLI") .version("0.1.0") .about("Generate Rust types from JSON samples") ...
extern crate json_typegen_shared; extern crate clap; use json_typegen_shared::{codegen, codegen_from_macro, Options, infer_source_type}; use clap::{Arg, App}; use std::io::{self, Read, Write}; use std::fs::OpenOptions; fn main() { let matches = App::new("JSON code generation CLI") .version("0.1.0") ...
Reimplement support for non-macro input
CLI: Reimplement support for non-macro input
Rust
apache-2.0
evestera/json_sample,evestera/json_typegen,evestera/json_sample,evestera/json_typegen,evestera/json_typegen,evestera/json_sample
53c359b69d6acdcabee5a95a55bf63f7733308fb
exercises/saddle-points/example.rs
exercises/saddle-points/example.rs
pub fn find_saddle_points(input: &[Vec<u64>]) -> Vec<(usize, usize)> { let (width, height) = match (input.len(), input[0].len()) { (0, _) | (_, 0) => return Vec::new(), (n, k) => (n, k), }; let mut saddle_points = Vec::new(); for i in 0..width { let row_max = input[i].iter().ma...
pub fn find_saddle_points(input: &[Vec<u64>]) -> Vec<(usize, usize)> { let height = if !input.is_empty() && !input[0].is_empty() { input[0].len() } else { return Vec::new(); }; let mut saddle_points = Vec::new(); let col_mins: Vec<u64> = (0..height) .filter_map(|j| input.it...
Improve based on the given feedback
Improve based on the given feedback
Rust
mit
exercism/xrust,exercism/xrust,petertseng/exercism-rust,petertseng/exercism-rust,petertseng/exercism-rust
f360f8e1bc582a2a176dab7f0ae98242f4cab4fd
rebind_plugins/src/derive_action.rs
rebind_plugins/src/derive_action.rs
#![allow(dead_code, unused_imports, unused_variables)] use syntax::ast; use syntax::ast::{MetaItem, Expr}; use syntax::codemap::Span; use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::ext::deriving::generic::{Struct, Substructure, TraitDef, ty}; use syntax::ext::deriving::g...
#![allow(unused_variables)] use syntax::ast::MetaItem; use syntax::codemap::Span; use syntax::ext::base::{Annotatable, ExtCtxt}; pub fn expand_derive_action_annotation(context: &mut ExtCtxt, span: Span, meta_item: &MetaItem, ...
Remove unnecessary imports and warnings
Remove unnecessary imports and warnings
Rust
mit
burtonageo/rebind
819c9ba992c573cdc743564d97ab91c4f2fcbe46
src/lib.rs
src/lib.rs
extern crate flate2; extern crate regex; extern crate tar; extern crate time; #[macro_use] extern crate try_opt; mod macros; mod time_utils; pub mod backend; pub mod collections; pub mod signatures;
#![cfg_attr(unstable, feature(plugin))] #![cfg_attr(unstable, plugin(clippy))] extern crate flate2; extern crate regex; extern crate tar; extern crate time; #[macro_use] extern crate try_opt; mod macros; mod time_utils; pub mod backend; pub mod collections; pub mod signatures;
Use clippy plugin only on nightly
Use clippy plugin only on nightly
Rust
mit
mbrt/ruplicity,mbrt/ruplicity
eb0f2ee0f33a360cc38b086a86f27b092ea95adb
src/lib.rs
src/lib.rs
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Host Info //! /...
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Host Info //! /...
Include core_foundation crate on macOS only.
Include core_foundation crate on macOS only.
Rust
apache-2.0
endoli/hostinfo.rs
3a1a7e855c505cef8a1e7983d20da4fd02d88566
tests/test_downcast.rs
tests/test_downcast.rs
mod common; use self::common::*; use std::io; #[test] fn test_downcast() { assert_eq!( "oh no!", bail_literal().unwrap_err().downcast::<&str>().unwrap(), ); assert_eq!( "oh no!", bail_fmt().unwrap_err().downcast::<String>().unwrap(), ); assert_eq!( "oh no!",...
mod common; use self::common::*; use std::io; #[test] fn test_downcast() { assert_eq!( "oh no!", bail_literal().unwrap_err().downcast::<&str>().unwrap(), ); assert_eq!( "oh no!", bail_fmt().unwrap_err().downcast::<String>().unwrap(), ); assert_eq!( "oh no!",...
Add downcast_ref and downcast_mut tests
Add downcast_ref and downcast_mut tests
Rust
apache-2.0
dtolnay/anyhow
95bec6aea28ba3d985576a4e7149e9b36e6396fc
tests/common/parse.rs
tests/common/parse.rs
extern crate rustc_expand; extern crate rustc_parse as parse; extern crate rustc_span; extern crate syntax; use rustc_span::source_map::FilePathMapping; use rustc_span::FileName; use syntax::ast; use syntax::ptr::P; use syntax::sess::ParseSess; use std::panic; pub fn libsyntax_expr(input: &str) -> Option<P<ast::Expr...
extern crate rustc_expand; extern crate rustc_parse as parse; extern crate rustc_span; extern crate syntax; use rustc_span::source_map::FilePathMapping; use rustc_span::FileName; use syntax::ast; use syntax::ptr::P; use syntax::sess::ParseSess; use std::panic; pub fn libsyntax_expr(input: &str) -> Option<P<ast::Expr...
Update test suite to nightly-2020-01-10
Update test suite to nightly-2020-01-10
Rust
apache-2.0
dtolnay/syn
19254e3a850ca1ebea72dad2c59cf124d67200d3
main.rs
main.rs
#[allow(ctypes)]; #[no_std]; #[feature(asm)]; //#[no_core]; #[feature(macro_rules)]; mod core; pub mod stdio; pub mod idt; #[no_mangle] pub unsafe fn main() { idt::idt_install(); stdio::clear_screen(stdio::Green); stdio::write("Hello!aaa", 2, 3); let mut i: u32 = 0; let N: u32 = 80000000; wh...
#[allow(ctypes)]; #[no_std]; #[feature(asm)]; //#[no_core]; #[feature(macro_rules)]; mod core; pub mod stdio; pub mod idt; #[no_mangle] pub unsafe fn main() { idt::idt_install(); stdio::clear_screen(stdio::Green); stdio::write("Hello!aaa", 2, 3); let mut i: u32 = 0; let mut c: u8 = 65; // 'A' ...
Make character-printing loop more readable
Make character-printing loop more readable
Rust
mit
jvns/puddle,jvns/puddle
7c4b8d4c185ca740befe889d74146f3f6939d864
src/lib.rs
src/lib.rs
#![feature(plugin)] #![feature(test)] #![plugin(clippy)] #[cfg(test)] extern crate test; #[cfg(test)] extern crate rand; #[cfg(test)] #[macro_use] extern crate quickcheck; pub extern crate nalgebra; pub const EPSILON: f32 = 0.00001; pub mod aabb; pub mod ray;
#![deny(missing_docs)] #![feature(plugin)] #![feature(test)] #![plugin(clippy)] #[cfg(test)] extern crate test; #[cfg(test)] extern crate rand; #[cfg(test)] #[macro_use] extern crate quickcheck; pub extern crate nalgebra; pub const EPSILON: f32 = 0.00001; pub mod aabb; pub mod ray;
Enable linting for missing docs
Enable linting for missing docs
Rust
mit
svenstaro/bvh
b791f8c35ca4489608d6895761873020c4a31c1e
word-count/src/lib.rs
word-count/src/lib.rs
use std::collections::HashMap; pub fn word_count(phrase: &str) -> HashMap<String, u32> { let phrase = phrase.to_lowercase(); let words = phrase.split(|c: char| !c.is_alphanumeric()) .filter(|s| !s.is_empty()) .map(|w| w.to_string()) .collect::<Vec<_>>(); let mut word_counts = HashM...
use std::collections::HashMap; pub fn word_count(phrase: &str) -> HashMap<String, u32> { phrase.to_lowercase() .split(|c: char| !c.is_alphanumeric()) .filter(|s| !s.is_empty()) .map(|w| w.to_string()) .fold(HashMap::new(), |mut acc, w| { *acc.entry(w).or_insert(0) += 1; ...
Improve solution for Word Count
Improve solution for Word Count
Rust
mit
attilahorvath/exercism-rust
546fe95d720966dfa152b483e75e1508c203e780
build.rs
build.rs
use std::io::prelude::*; use std::path::Path; use std::fs::{File, create_dir}; fn main() { let dst = Path::new(concat!(env!("HOME"), "/.xr3wm/config.rs")); if !dst.exists() { match create_dir(dst.parent().unwrap()) { Ok(_) => { let mut f = File::create(&dst).unwrap(); ...
use std::io::prelude::*; use std::path::Path; use std::fs::{File, create_dir}; fn main() { let dst = Path::new(concat!(env!("HOME"), "/.xr3wm/config.rs")); if !dst.exists() { match create_dir(dst.parent().unwrap()) { Ok(_) => { let mut f = File::create(&dst).unwrap(); ...
Adjust default config to use the new split configs
Adjust default config to use the new split configs
Rust
mit
tsurai/xr3wm
7c55bf75ac0deb9bbf884c2eb632c50d4df31666
src/rho/host/curses.rs
src/rho/host/curses.rs
use ncurses::*; use std::sync::Arc; use std::sync::RwLock; use std::sync::mpsc::Sender; use std::sync::Arc; use std::sync::RwLock; use event::Modifier; use event::InputEvent; use client::generic::GenericClient; use buffer::Buffer; use host::Host; use host::Host; use buffer::Buffer; pub struct CursesHost { sender...
use ncurses::*; use std::char; use std::sync::Arc; use std::sync::RwLock; use std::sync::mpsc::Sender; use host::Host; use buffer::Buffer; use event::Modifier; use event::InputEvent; use client::generic::GenericClient; pub struct CursesHost { sender: Sender<InputEvent>, buffers: Arc<RwLock<Vec<Buffer>>>, } ...
Fix type signatures and implementation
Fix type signatures and implementation
Rust
mit
chrisseto/rho
9a19c84a0776210e659b51836988db4800d3924d
src/compile_options.rs
src/compile_options.rs
use cocoa::base::id; use std::collections::HashMap; #[allow(unused_imports)] use sys::MTLCompileOptions; pub struct CompileOptions { pub fast_math_enabled: bool, pub language_version: (), // Todo(George): Make this field the right type pub preprocessor_macros: HashMap<String, PreprocessorMacro> } impl Co...
use cocoa::base::id; use std::collections::HashMap; #[allow(unused_imports)] use sys::MTLCompileOptions; pub struct CompileOptions { pub fast_math_enabled: bool, pub language_version: (), // Todo(George): Make this field the right type pub preprocessor_macros: HashMap<String, PreprocessorMacroValue> } im...
Rename `PreprocessorMacro` type to `PreprocessorMacroValue`, and Integral preprocessor values are now called `Numeric`, and can be floats
Rename `PreprocessorMacro` type to `PreprocessorMacroValue`, and Integral preprocessor values are now called `Numeric`, and can be floats
Rust
apache-2.0
burtonageo/metl
42a17a3ae76fa4d83d1a850140dc77424b0ea460
src/broad/dispatcher.rs
src/broad/dispatcher.rs
/// Trait of dispatcher. /// /// A (collision) dispatcher typically takes two bodies in parameter and return the corresponding /// narrow phase algorithm. pub trait Dispatcher<G1, G2, NF> { /// Deduce the narrow phase from two bodies. fn dispatch(&self, &G1, &G2) -> Option<NF>; /// Tells whether a collision...
/// Trait of dispatcher. /// /// A (collision) dispatcher typically takes two bodies in parameter and return the corresponding /// narrow phase algorithm. pub trait Dispatcher<G1, G2, NF> { /// Deduce the narrow phase from two bodies. fn dispatch(&self, &G1, &G2) -> Option<NF>; /// Tells whether a collision...
Add a `::new()` constructor for `NoIdDispatcher`.
Add a `::new()` constructor for `NoIdDispatcher`.
Rust
bsd-3-clause
sebcrozet/ncollide,steveklabnik/ncollide,MichaelRiss/ncollide,MichaelRiss/ncollide,steveklabnik/ncollide,sebcrozet/ncollide
c6371d74a373900eeb7cedceeeeda8e15c3c3407
kernel/common/parse_ip.rs
kernel/common/parse_ip.rs
/// Get the port from a string (ip) pub fn parse_port(string: &str) -> &str { let a = match string.find(':') { Some(pos) => pos + 1, None => 0, }; let mut b = 0; for c in string.chars().skip(a) { match c { '0' | '1' | '2' | '3' | '4' | '5' | ...
/// Get the port from a string (ip) pub fn parse_port(string: &str) -> &str { let a = match string.find(':') { Some(pos) => pos + 1, None => 0, }; let mut b = 0; for c in string.chars().skip(a) { match c { '0' | '1' | '2' | '3' | '4' | '5' | ...
Optimize parse_host. And it's carefully reviewed for not being panicable.
Optimize parse_host. And it's carefully reviewed for not being panicable.
Rust
mit
NobbZ/redox,NobbZ/redox,nounoursheureux/redox,vvlevchenko/redox,tedsta/redox,fischmax/redox,achanda/redox,fischmax/redox,skylerberg/redox,imp/redox,bheesham/redox,fischmax/redox,nounoursheureux/redox,bheesham/redox,skylerberg/redox,stryan/redox,imp/redox,LazyOxen/redox,bheesham/redox,bheesham/redox,tedsta/redox,NobbZ/r...
4f8aacfa5a57c3384981b85fbcf3ed5b8c693493
libimagstore/src/store.rs
libimagstore/src/store.rs
use std::path::PathBuf; use std::result::Result as RResult; pub use entry::Entry; pub use error::StoreError; pub type Result<T> = RResult<T, StoreError>; pub struct Store { location: PathBuf, } impl Store { pub fn create(entry: Entry) -> Result<()> { unimplemented!() } pub fn read(path: Pa...
use std::path::PathBuf; use std::result::Result as RResult; use std::sync::Arc; use std::sync::RWLock; pub use entry::Entry; pub use error::StoreError; pub type Result<T> = RResult<T, StoreError>; pub struct Store { location: PathBuf, } impl Store { pub fn create(entry: Entry) -> Result<()> { unimp...
Store type: read() should return Arc<RWLock<>>, update() should take that
Fixup: Store type: read() should return Arc<RWLock<>>, update() should take that
Rust
lgpl-2.1
mario-kr/imag,matthiasbeyer/imag,mario-kr/imag,matthiasbeyer/imag
f2e3f09d68b0130c3d9588826a789c4c62f21d05
src/main.rs
src/main.rs
use std::io; use std::fs::{self, DirEntry}; use std::path::Path; fn walk_dirs(dir: &Path, cb: &Fn(&DirEntry)) -> io::Result<()> { if try!(fs::metadata(dir)).is_dir() { for entry in try!(fs::read_dir(dir)) { let entry = try!(entry); if try!(fs::metadata(entry.path())).is_dir() { ...
use std::io; use std::fs::{self, DirEntry}; use std::path::Path; fn walk_dirs(dir: &Path, cb: &Fn(&DirEntry)) -> io::Result<()> { if try!(fs::metadata(dir)).is_dir() { for entry in try!(fs::read_dir(dir)) { let entry = try!(entry); if try!(fs::metadata(entry.path())).is_dir() { ...
Handle possible errors of walk_dirs func
Handle possible errors of walk_dirs func
Rust
mit
kubkon/deqnap
697fdaac24c0f973da8569b1249d8c778e510082
src/test/run-pass/item-attributes.rs
src/test/run-pass/item-attributes.rs
// xfail-stage0 #[attr = "val"] mod mod1 { } fn main() { }
// xfail-stage0 #[attr = "val"] const int x = 10; #[attr = "val"] mod mod1 { } #[attr = "val"] native "rust" mod rustrt { } #[attr = "val"] type t = obj { }; #[attr = "val"] obj o() { } fn main() { }
Add test cases for outer attributes on all item types
test: Add test cases for outer attributes on all item types
Rust
apache-2.0
XMPPwocky/rust,emk/rust,ktossell/rust,stepancheg/rust-ide-rust,XMPPwocky/rust,pshc/rust,pelmers/rust,fabricedesre/rust,jroesch/rust,ebfull/rust,P1start/rust,pshc/rust,pelmers/rust,kimroen/rust,jashank/rust,stepancheg/rust-ide-rust,aepsil0n/rust,jashank/rust,michaelballantyne/rust-gpu,miniupnp/rust,j16r/rust,servo/rust,...
dafd813c16231834d3bce7875a8c616d1e49a8c1
tests/compile-fail/weak_memory/imperfectly_overlapping.rs
tests/compile-fail/weak_memory/imperfectly_overlapping.rs
// ignore-windows: Concurrency on Windows is not supported yet. #![feature(atomic_from_mut)] #![feature(core_intrinsics)] use std::intrinsics::atomic_load; use std::sync::atomic::Ordering::*; use std::sync::atomic::{AtomicU16, AtomicU32}; fn test_same_thread() { let mut qword = AtomicU32::new(42); assert_eq!(...
// ignore-windows: Concurrency on Windows is not supported yet. #![feature(atomic_from_mut)] #![feature(core_intrinsics)] use std::intrinsics::atomic_load; use std::sync::atomic::Ordering::*; use std::sync::atomic::{AtomicU16, AtomicU32}; fn split_u32(dword: &mut u32) -> &mut [u16; 2] { unsafe { std::mem::transmu...
Move transmute into a separate function
Move transmute into a separate function
Rust
apache-2.0
rust-lang/miri,rust-lang/miri,rust-lang/miri,rust-lang/miri
c8752415dc0775960accc5f6ae11be782910b3c6
src/test/rustdoc/deprecated-future.rs
src/test/rustdoc/deprecated-future.rs
#![feature(deprecated)] // @has deprecated_future/struct.S.html '//*[@class="stab deprecated"]' \ // 'Deprecated since 99.99.99: effectively never' #[deprecated(since = "99.99.99", note = "effectively never")] pub struct S;
#![feature(deprecated)] // @has deprecated_future/index.html '//*[@class="stab deprecated"]' \ // 'Deprecated' // @has deprecated_future/struct.S.html '//*[@class="stab deprecated"]' \ // 'Deprecated since 99.99.99: effectively never' #[deprecated(since = "99.99.99", note = "effectively never")] pub struct S...
Add rustdoc index page test for future deprecation attributes
Add rustdoc index page test for future deprecation attributes
Rust
apache-2.0
graydon/rust,aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,aidancully/rust,graydon/rust,graydon/rust,graydon/rust,aidancully/rust,aidancully/rust,aidancully/rust
b57628aafff6457a5bea1649310c1b586ffb2099
time-macros/src/peeking_take_while.rs
time-macros/src/peeking_take_while.rs
// Modified from the `peeking_take_while` crate. Copyright 2017 Nick Fitzgerald. License MIT OR // Apache-2. use std::iter::Peekable; pub(crate) struct PeekingTakeWhile<'a, I: Iterator, P> { iter: &'a mut Peekable<I>, pred: P, } impl<I: Iterator, P: Fn(&I::Item) -> bool> Iterator for PeekingTakeWhile<'_, I, ...
use std::iter::Peekable; #[allow(unused_imports)] use standback::prelude::*; pub(crate) struct PeekingTakeWhile<'a, I: Iterator, P> { iter: &'a mut Peekable<I>, pred: P, } impl<I: Iterator, P: Fn(&I::Item) -> bool> Iterator for PeekingTakeWhile<'_, I, P> { type Item = I::Item; fn next(&mut self) -> ...
Simplify shim in macro code
Simplify shim in macro code
Rust
apache-2.0
time-rs/time
ea27ba3e05b279f6c3430b1846de71527aa00215
futures-util/src/compat/stream01ext.rs
futures-util/src/compat/stream01ext.rs
use super::Compat; use futures::Stream as Stream01; impl<St: Stream01> Stream01CompatExt for St {} /// Extension trait for futures 0.1 [`Stream`][Stream01] pub trait Stream01CompatExt: Stream01 { /// Converts a futures 0.1 [`Stream<Item = T, Error = E>`][Stream01] into a /// futures 0.3 [`Stream<Item = Result...
use super::Compat; use futures::Stream as Stream01; impl<St: Stream01> Stream01CompatExt for St {} /// Extension trait for futures 0.1 [`Stream`][futures::Stream] pub trait Stream01CompatExt: Stream01 { /// Converts a futures 0.1 [`Stream<Item = T, Error = E>`][futures::Stream] /// into a futures 0.3 [`Stream...
Fix doc links in futures-util::compat
Fix doc links in futures-util::compat
Rust
apache-2.0
alexcrichton/futures-rs
615c2d2b155c469582e7f5e282bbffcd7e44ab16
src/lib.rs
src/lib.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #![feature(iter_arith, result_expect, path_ext, slice_bytes)] #![warn(missing_docs)] //! Melvin is pure Rust library...
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #![feature(iter_arith, result_expect, path_ext, slice_bytes)] #![warn(missing_docs)] //! Melvin is pure Rust library...
Hide stuff in public API
Hide stuff in public API and re-export important stuff (VG, PV, LV) at the toplevel. Signed-off-by: Andy Grover <b7d524d2f5cc5aebadb6b92b08d3ab26911cde33@redhat.com>
Rust
mpl-2.0
agrover/melvin
837569f82d023b629d46fec622f965659e8beec9
src/lib.rs
src/lib.rs
extern crate hyper; mod contentlength; pub mod http_version; pub mod download; /// Represents a byte, in `u64`. type Byte = u64;
extern crate hyper; use std::sync::{Arc, Mutex}; pub mod client; mod contentlength; pub mod download; pub mod http_version; /// Represents a number of bytes, in `u64`. type Byte = u64; /// Represents a 'chunk', which is just a piece of bytes. type Chunk = Vec<u8>; /// Represents a list of chunks type Chunks = Vec<Ch...
Add new custom types, import new mods
Add new custom types, import new mods
Rust
mit
derniercri/snatch
eef866275ed319496cef4659830897c445ab10af
src/lib.rs
src/lib.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
Add doc URL to the crate
Add doc URL to the crate
Rust
apache-2.0
ajroetker/rustc-serialize,SimonSapin/rustc-serialize,rust-lang-nursery/rustc-serialize,DenisKolodin/rustc-serialize,shepmaster/rustc-serialize,gbersac/rustc-serialize,rust-lang/rustc-serialize,indefini/rustc-serialize,rust-lang-deprecated/rustc-serialize
a00cd44d0dc0db59bbeefad9f09c19a7ee6a3d39
src/lib.rs
src/lib.rs
extern crate xswag_base as base; extern crate lalrpop_util; pub mod lex; pub mod ast; pub mod grammar; use base::diag::Report; use lalrpop_util::ParseError; pub fn parse_compilation_unit(file: &base::code::FileMap) -> (Result<ast::CompilationUnit, Report>, Vec<Report>) { // Stop at the first lexing error and...
extern crate xswag_base as base; extern crate lalrpop_util; pub mod lex; pub mod ast; pub mod grammar; use base::diag::Report; use base::code::Span; use lalrpop_util::ParseError; pub fn parse_compilation_unit(file: &base::code::FileMap) -> (Result<ast::CompilationUnit, Report>, Vec<Report>) { // Stop at the ...
Improve lalrpop error to `Report` conversion
Improve lalrpop error to `Report` conversion
Rust
mit
LukasKalbertodt/xswag-syntax-java
df4c5e8d0ab0562264ee3c6a900754679a3b950c
src/lib.rs
src/lib.rs
//! The mathematical constant tau. extern crate core; /// The mathematical constant [tau](http://tauday.com/), /// where pi is defined as tau/2. /// /// We provide it as `f64` for now. /// /// ```rust{.example} /// assert!(tau::TAU / 2.0 == core::f64::consts::PI); /// ``` #[unstable = "still waiting for associated co...
//! The mathematical constant tau. extern crate core; /// The mathematical constant [tau](http://tauday.com/), /// where pi is defined as tau/2. /// /// We provide it as `f64` for now. /// /// ```rust{.example} /// use std::num::FloatMath; /// use tau::TAU; /// assert_eq!(TAU.cos(), 1.0); /// ``` #[unstable = "still ...
Change tests to work around rustdoc limitation on extern crate.
Change tests to work around rustdoc limitation on extern crate.
Rust
mit
FranklinChen/rust-tau
958fe51f514f35d90cc606dd95e3c24e81c8fb35
src/lib.rs
src/lib.rs
//! A dead-simple test helper for rust. //! //! Example //! -------- //! //! ```rust //! use bear::fixture; //! //! // Get a content of 'tests/fixtures/hello.txt' //! let content = fixture("hello.txt"); //! //! // Do whatever you want with it //! ``` #![doc(html_logo_url = "https://simnalamburt.github.io/bear/cute....
//! A dead-simple test helper for rust. //! //! Example //! -------- //! //! ```rust //! use bear::fixture; //! //! // Get a content of 'tests/fixtures/hello.txt' //! let content = fixture("hello.txt"); //! //! // Do whatever you want with it //! ``` #![doc( html_logo_url = "https://simnalamburt.github.io/bear/cut...
Format codes with `cargo fmt`
Format codes with `cargo fmt`
Rust
bsd-2-clause
simnalamburt/bear
92981e29861e839779399cfa67d4cadcdb8ea16b
rust/hello.rs
rust/hello.rs
// Run with `rust run hello.rs` fn main() { println("Hello World!"); }
// Run with `rust run hello.rs` fn greeter(greeting_text: &str) { println(fmt!("Hello %s!", greeting_text)); } fn main() { greeter("World"); }
Update rust example to confort to the requirements stated in the README
Update rust example to confort to the requirements stated in the README
Rust
mit
pxlpnk/xhelloworlds,pxlpnk/xhelloworlds,pxlpnk/xhelloworlds,pxlpnk/xhelloworlds,pxlpnk/xhelloworlds,pxlpnk/xhelloworlds,pxlpnk/xhelloworlds,pxlpnk/xhelloworlds,pxlpnk/xhelloworlds,pxlpnk/xhelloworlds,pxlpnk/xhelloworlds,pxlpnk/xhelloworlds
4db393aea926554fcb1e2bbe9fe3af0289acf657
src/lib.rs
src/lib.rs
//! An implementation of [FLAC](https://xiph.org/flac), free lossless audio //! codec, written in Rust. //! //! The code is available on [GitHub](https://github.com/sourrust/flac). //! //! # Examples //! //! Basic decoding from a file. //! //! ``` //! use flac::StreamReader; //! use std::fs::File; //! //! match StreamR...
//! An implementation of [FLAC](https://xiph.org/flac), free lossless audio //! codec, written in Rust. //! //! The code is available on [GitHub](https://github.com/sourrust/flac). //! //! # Examples //! //! Basic decoding from a file. //! //! ``` //! use flac::StreamReader; //! use std::fs::File; //! //! match StreamR...
Remove the not about extended sample size
Remove the not about extended sample size
Rust
bsd-3-clause
sourrust/flac
667b6c7202b07b1c0e5d581e8cb6d9acad42feca
src/discord/message_processors/mod.rs
src/discord/message_processors/mod.rs
use async_trait::async_trait; use serenity::client::Context; use serenity::model::id::{ChannelId, GuildId, MessageId}; use serenity::model::user::User; use serenity::model::Permissions; use typemap_rev::TypeMap; use crate::database::settings::Setting; use crate::discord::message_processors::invite_link::InviteLinkProc...
use async_trait::async_trait; use serenity::client::Context; use serenity::model::id::{ChannelId, GuildId, MessageId}; use serenity::model::user::User; use serenity::model::Permissions; use typemap_rev::TypeMap; use crate::database::settings::Setting; use crate::discord::message_processors::invite_link::InviteLinkProc...
Fix spam filter not working when message contains invite links or blocked words
Fix spam filter not working when message contains invite links or blocked words
Rust
mit
Samoxive/SafetyJim,Samoxive/SafetyJim
a2a1f3482f4f01ad8086e9e4cab7c6f460ec5367
src/client.rs
src/client.rs
use hyper::client::Client; use hyper::client::response::Response; use hyper::error::Error; use hyper::header::Headers; use hyper::method::Method; /// Trait that represents some methods to send a specific request pub trait GetResponse { /// Given a specific URL, get the response from the target server fn get_ht...
use hyper::client::Client; use hyper::client::response::Response; use hyper::error::Error; use hyper::header::Headers; use hyper::method::Method; /// Trait that represents some methods to send a specific request pub trait GetResponse { /// Given a specific URL, get the header without the content body (useful to no...
Add a method trait to get a header response from a server request, without any content body
Add a method trait to get a header response from a server request, without any content body
Rust
mit
derniercri/snatch
42b515faa378e1f860d2453db7f3f39909e5f365
examples/sums.rs
examples/sums.rs
extern crate octavo; use octavo::digest::Digest; use octavo::digest::adler32::Adler32; use octavo::digest::crc32::CRC32; use octavo::digest::md5::MD5; use octavo::digest::sha3::*; fn hex<T: AsRef<[u8]>, D: Digest>(data: T, mut digest: D) -> String { digest.update(data); digest.hex_result() } fn main() { ...
extern crate octavo; use octavo::digest::Digest; use octavo::digest::adler32::Adler32; use octavo::digest::crc32::CRC32; use octavo::digest::md5::MD5; use octavo::digest::md4::MD4; use octavo::digest::sha3::*; fn hex<T: AsRef<[u8]>, D: Digest>(data: T, mut digest: D) -> String { digest.update(data); digest.h...
Add MD4 sum to example
Add MD4 sum to example
Rust
mit
bluss/octavo,Ticki/octavo,libOctavo/octavo,hauleth/octavo,steveklabnik/octavo
e92c9e2ffd5820b7b28330fdbbb302ce0cedab80
src/lib.rs
src/lib.rs
//! An implementation of [FLAC](https://xiph.org/flac), free lossless audio //! codec, written in Rust. //! //! # Examples //! //! Basic decoding from a file. //! //! ``` //! match flac::Stream::from_file("path/to/file.flac") { //! Ok(mut stream) => { //! // Copy of `StreamInfo` to help convert to a different aud...
//! An implementation of [FLAC](https://xiph.org/flac), free lossless audio //! codec, written in Rust. //! //! # Examples //! //! Basic decoding from a file. //! //! ``` //! match flac::Stream::from_file("path/to/file.flac") { //! Ok(mut stream) => { //! // Copy of `StreamInfo` to help convert to a different aud...
Remove reexport frame module items
Remove reexport frame module items
Rust
bsd-3-clause
sourrust/flac
e172a34e5a7d6053d2aa26697c5afec6ff4405a9
src/lib.rs
src/lib.rs
#[test] fn it_works() { }
pub struct Foo { a: u64, b: i8, } impl Foo { pub fn new() -> Foo { Foo { a: 42, b: 41 } } pub fn add(&mut self) { self.b += 1; } pub fn dec(&mut self) { self.b -= 1; } pub fn get(&self) -> u64 { self.a } } #[cfg(test)] mod test { use super...
Add some code for coverage testing
Add some code for coverage testing
Rust
mit
mvdnes/rust-travis-test,mvdnes/rust-travis-test
d00c956028d04ac22ab2ffd92914ce9b0c9418b6
extractor/build.rs
extractor/build.rs
use std::path::PathBuf; fn main() { let dir: PathBuf = ["../tree-sitter-ruby", "src"].iter().collect(); cc::Build::new() .include(&dir) .file(dir.join("parser.c")) .file(dir.join("scanner.cc")) .compile("tree-sitter-ruby"); }
use std::path::PathBuf; fn main() { let dir: PathBuf = ["../tree-sitter-ruby", "src"].iter().collect(); let mut build = cc::Build::new(); build .include(&dir) .file(&dir.join("parser.c")) .file(&dir.join("scanner.cc")); if !cfg!(windows) { build.cpp(true).compiler("clang...
Build with clang for non-windows platforms
Build with clang for non-windows platforms
Rust
mit
github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql
e62093d4d99c7e0c011e94760b22de6bfbb607a7
src/test/stdtest/rand.rs
src/test/stdtest/rand.rs
// -*- rust -*- use std; import std::rand; #[test] fn test() { let r1: rand::rng = rand::mk_rng(); log r1.next(); log r1.next(); { let r2 = rand::mk_rng(); log r1.next(); log r2.next(); log r1.next(); log r1.next(); log r2.next(); log r2.next();...
// -*- rust -*- use std; import std::rand; import std::str; #[test] fn test() { let r1: rand::rng = rand::mk_rng(); log r1.next(); log r1.next(); { let r2 = rand::mk_rng(); log r1.next(); log r2.next(); log r1.next(); log r1.next(); log r2.next(); ...
Add fs::rmdir() and tempfile/gen_str() tests.
Add fs::rmdir() and tempfile/gen_str() tests.
Rust
apache-2.0
rust-lang/rand
62b5deba941c5ee40e76422986c2d45c8ca8e01c
tools/examples/srecords.rs
tools/examples/srecords.rs
extern crate r68k_tools; use r68k_tools::srecords::write_s68; use std::io::LineWriter; use r68k_tools::memory::MemoryVec; fn main() { let mut lw = LineWriter::new(vec![]); let data: Vec<u8> = (0u8 .. 0xFFu8).collect(); let start = 0x2016; let mem = MemoryVec::new8(start, data); write_s68(&mut lw,...
extern crate r68k_tools; use r68k_tools::srecords::write_s68; use std::io::LineWriter; use r68k_tools::memory::MemoryVec; use r68k_tools::PC; fn main() { let mut lw = LineWriter::new(vec![]); let data: Vec<u8> = (0u8 .. 0xFFu8).collect(); let start = 0x2016; let mem = MemoryVec::new8(PC(start), data)...
Fix example for PC newtype
Fix example for PC newtype
Rust
mit
marhel/r68k,marhel/r68k
e6e0df32845e741fa8448fe2f1e16a47fc9f647a
src/lib.rs
src/lib.rs
#[cfg(test)] mod tests { #[test] fn it_works() { } }
// http://smallcultfollowing.com/babysteps/blog/2015/04/06/modeling-graphs-in-rust-using-vector-indices/ pub struct Graph { nodes: Vec<NodeData>, edges: Vec<EdgeData>, } impl Graph { pub fn add_node(&mut self) -> NodeIndex { let index = self.nodes.len(); self.nodes.push(NodeData { first_ou...
Use an existing graph implementation
Use an existing graph implementation Using the implementation of a linked graph described here: http://smallcultfollowing.com/babysteps/blog/2015/04/06/modeling-graphs-in-rust-using-vector-indices/
Rust
mit
charlieegan3/graph_match
5e983d7b3f03e9243d905e0579f32be00170c9af
src/test/ui/closures/2229_closure_analysis/run_pass/fru_syntax.rs
src/test/ui/closures/2229_closure_analysis/run_pass/fru_syntax.rs
// run-pass // Test that functional record update/struct update syntax works inside // a closure when the feature `capture_disjoint_fields` is enabled. #![feature(capture_disjoint_fields)] //~^ WARNING: the feature `capture_disjoint_fields` is incomplete //~| NOTE: `#[warn(incomplete_features)]` on by default //~| NO...
// run-pass // Test that functional record update/struct update syntax works inside // a closure when the feature `capture_disjoint_fields` is enabled. #![feature(capture_disjoint_fields)] //~^ WARNING: the feature `capture_disjoint_fields` is incomplete //~| NOTE: `#[warn(incomplete_features)]` on by default //~| NO...
Add a test for syntax like: ..t.s
Add a test for syntax like: ..t.s
Rust
apache-2.0
graydon/rust,aidancully/rust,graydon/rust,aidancully/rust,graydon/rust,aidancully/rust,graydon/rust,aidancully/rust,graydon/rust,aidancully/rust,graydon/rust,aidancully/rust
76dc41fea07a91d67ab264d0ae56c04e930b1055
src/lfsr.rs
src/lfsr.rs
use bit_vec::BitVec; pub fn shift(state: &mut BitVec) { let range = 1 .. state.len(); for i in range.rev() { let pred = state[i - 1]; state.set(i, pred); }; state.set(0, false); } #[cfg(test)] mod test { use bit_vec::BitVec; use super::shift; #[test] fn shift_works()...
use bit_vec::BitVec; pub trait LFSR { fn output(&self) -> bool; fn step(&mut self); } pub fn shift(state: &mut BitVec) { let range = 1 .. state.len(); for i in range.rev() { let pred = state[i - 1]; state.set(i, pred); }; state.set(0, false); } #[cfg(test)] mod test { us...
Add first pass at LFSR trait
Add first pass at LFSR trait
Rust
bsd-2-clause
ranweiler/lfsr-rs
0bbbaa6f6c68a36f83b2ff70419aa43e8863e286
src/main.rs
src/main.rs
fn main() { println!("Hello, world!"); }
#[macro_use] extern crate glium; fn main() { use glium::{glutin, Surface}; let mut events_loop = glutin::EventsLoop::new(); let window = glutin::WindowBuilder::new(); let context = glutin::ContextBuilder::new(); let display = glium::Display::new(window, context, &events_loop).unwrap(); #[deri...
Add glium hello world example
Add glium hello world example Taken from: http://glium.github.io/glium/book/tuto-02-triangle.html
Rust
mit
emmnm/bismuth
3eaa05c19753452b3a337094cdf24fe093b9985e
src/main.rs
src/main.rs
extern crate hyper; use std::io::Read; use hyper::Client; use hyper::header::Connection; static WEEKDAY_WEBSITE: &'static str = "http://www.hvilkenukeerdet.no"; fn main() { let client = Client::new(); let mut res = client .get(WEEKDAY_WEBSITE) .header(Connection::clos...
extern crate hyper; use std::io::Read; use hyper::Client; use hyper::header::Connection; static WEEKDAY_WEBSITE: &'static str = "http://www.hvilkenukeerdet.no"; fn main() { let client = Client::new(); let mut res = client .get(WEEKDAY_WEBSITE) .header(Connection::clos...
Simplify parsing of web page
Simplify parsing of web page This apporach uses string slicing instead of string splitting to lists that has to be worked on more.
Rust
mit
cristeahub/hvilkenukeerdet
6bfb283d92e58d08a3dd8122b24973d89db14cbe
src/main.rs
src/main.rs
extern crate tray_rust; use tray_rust::linalg; use tray_rust::film; use tray_rust::geometry; use tray_rust::geometry::Geometry; fn main() { let width = 800u; let height = 600u; let mut rt = film::RenderTarget::new(width, height); let camera = film::Camera::new(linalg::Transform::look_at( &lina...
extern crate tray_rust; use tray_rust::linalg; use tray_rust::film; use tray_rust::geometry; use tray_rust::geometry::Geometry; fn main() { let width = 800u; let height = 600u; let mut rt = film::RenderTarget::new(width, height); let camera = film::Camera::new(linalg::Transform::look_at( &lina...
Use new Intersection type in the simple hit marker render
Use new Intersection type in the simple hit marker render
Rust
mit
voidException/tray_rust,Twinklebear/tray_rust,GuzTech/tray_rust
313b66eb7162195f5980272184f39ade22df9b0c
src/main.rs
src/main.rs
extern crate rand; use rand::thread_rng; use rand::distributions::Range; use individual::Individual; mod individual; fn main() { let mut rng = thread_rng(); let range = Range::new(-512.03_f64, 511.97); // range for Schwefel problem // initialize population let population: Vec<_> = (0..128).map(|_| {...
extern crate rand; use rand::thread_rng; use rand::distributions::Range; use individual::Individual; mod individual; fn main() { let mut rng = thread_rng(); let range = Range::new(-512.03_f64, 511.97); // range for Schwefel problem // initialize population let mut population: Vec<_> = (0..128).map(|...
Replace population on each iteration
Replace population on each iteration Previously I wasn't mutating the prior generation, only ever the initial population. This makes more sense.
Rust
agpl-3.0
andschwa/rust-genetic-algorithm
360d7c2c1d7370059cca8cd4c5b820e80c9d1bed
src/test/run-pass/pred-not-bool.rs
src/test/run-pass/pred-not-bool.rs
// FIXME should be in run-pass // -*- rust -*- // error-pattern: Non-boolean return type // this checks that a pred with a non-bool return // type is rejected, even if the pred is never used pure fn bad(a: int) -> int { ret 37; } fn main() { }
// this checks that a pred with a non-bool return // type is rejected, even if the pred is never used pure fn bad(a: int) -> int { ret 37; } //! ERROR Non-boolean return type fn main() { }
Remove an outdated FIXME, change to use the new //! ERROR syntax
Remove an outdated FIXME, change to use the new //! ERROR syntax
Rust
apache-2.0
aepsil0n/rust,nwin/rust,reem/rust,bombless/rust,fabricedesre/rust,dwillmer/rust,rohitjoshi/rust,defuz/rust,dinfuehr/rust,mvdnes/rust,kimroen/rust,servo/rust,victorvde/rust,ruud-v-a/rust,Ryman/rust,pshc/rust,0x73/rust,sae-bom/rust,stepancheg/rust-ide-rust,achanda/rand,fabricedesre/rust,ktossell/rust,richo/rust,andars/ru...
c3db779e8b0e60633359c947b96e8f9a5e2c5ba6
src/character/audio.rs
src/character/audio.rs
use game::constants::PISTOL_AUDIO_PATH; use rodio; use rodio::Sink; use std::fs::File; use std::io::BufReader; pub struct CharacterAudio { sink: Sink, } impl CharacterAudio { pub fn new() -> CharacterAudio { #[allow(deprecated)] let endpoint = rodio::get_default_endpoint().unwrap(); CharacterAudio { ...
use game::constants::PISTOL_AUDIO_PATH; use rodio; use rodio::Sink; use std::fs::File; use std::io::BufReader; pub struct CharacterAudio { sink: Sink, } impl CharacterAudio { pub fn new() -> CharacterAudio { let endpoint = rodio::default_endpoint().unwrap(); CharacterAudio { sink: Sink::new(&endpoin...
Use "default_endpoint" instead of deprecated "get_default_endpoint"
Use "default_endpoint" instead of deprecated "get_default_endpoint"
Rust
apache-2.0
Laastine/zombie-shooter,Laastine/zombie-shooter