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
809f54a2f62e4a3e2dc5b2065c40325f385f8494
tasks/the-twelve-days-of-christmas/src/main.rs
tasks/the-twelve-days-of-christmas/src/main.rs
fn showpresents(count: usize) { let days = ["second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"]; let presents = ["Two turtle doves", "Three french hens", "Four calling birds", "F...
fn main() { let days = ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"]; let gifts = ["A Patridge in a Pear Tree", "Two Turtle Doves and", "Three French Hens", "Four Calling ...
Correct Twelve Days of Christmas Implementation
Correct Twelve Days of Christmas Implementation - The lyrics given on the required page (http://www.lyricsmode.com/lyrics/c/christmas_carols/the_twelve_days_of_christmas.html) make this task much easier than you'd expect - I've also updated the implementation on the official site (https://rosettacode.org/wiki/The_Twe...
Rust
unlicense
Hoverbear/rust-rosetta
22f3c594ce9c6b3b7f9cc6160937965a7fa29ca6
examples/perlin.rs
examples/perlin.rs
// Copyright 2013 The noise-rs developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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 o...
// Copyright 2013 The noise-rs developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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 o...
Update to use new for loop protocol, and fix for new `as` binding rules
Update to use new for loop protocol, and fix for new `as` binding rules
Rust
apache-2.0
Razaekel/noise-rs,bfops/noise-rs,phoenixenero/noise-rs,bjz/noise-rs,amaranth/noise-rs,brendanzab/noise-rs
6bbb5c4b2139862ac1fb0503746db0789a473f44
benches/negamax.rs
benches/negamax.rs
#![feature(test)] extern crate minimax; extern crate test; use test::Bencher; use minimax::*; #[derive(Clone)] pub struct Board; #[derive(Copy, Clone)] pub struct Place; pub struct Eval; pub struct Noop; impl Move for Place { type G = Noop; fn apply(&self, _: &mut Board) { } fn undo(&self, _: &mut Boar...
#![feature(test)] extern crate minimax; extern crate test; use test::Bencher; use minimax::*; #[derive(Clone)] pub struct Board; #[derive(Copy, Clone)] pub struct Place; pub struct Eval; pub struct Noop; impl Move for Place { type G = Noop; fn apply(&self, _: &mut Board) { } fn undo(&self, _: &mut Boar...
Make idiomatic the negemax benchmark's move generation function.
Make idiomatic the negemax benchmark's move generation function.
Rust
mit
kinghajj/minimax-rs
2189bb988f7682c429003e41e9f505122ce1785c
src/applescript.rs
src/applescript.rs
use std::process::Command; pub struct Output { pub status: i32, pub stdout: String, pub stderr: String, } /// Run an AppleScript. /// /// * `script`: The AppleScript code to run. /// pub fn run(script: &str) -> Output { let cmd_result = Command::new("osascript") .arg("-e") .arg(script) .output()...
use std::process::{Command, ExitStatus}; /// The output of a finished process. /// /// This varies from Output in std::process in that stdout/stderr are /// both strings rather than Vec<u8>. pub struct Output { pub status: ExitStatus, pub stdout: String, pub stderr: String, } /// Run an AppleScript. /// /// *...
Add a note about the similarity to std::process::ExitStatus
Add a note about the similarity to std::process::ExitStatus
Rust
mit
alexwlchan/safari.rs,alexwlchan/safari.rs
fc3836af76472f334a24c5ed86809d08bd419d79
stream-delimit/src/byte_consumer.rs
stream-delimit/src/byte_consumer.rs
#![deny(missing_docs)] use varint::consume_single_varint; use stream::*; use std::io::Read; /// A consumer for a byte stream pub struct ByteConsumer<'a> { read: &'a mut Read, type_: StreamType, } impl<'a> ByteConsumer<'a> { /// Return a ByteConsumer from for single messages, varint or leb128-delimited ...
#![deny(missing_docs)] use varint::consume_single_varint; use stream::*; use std::io::Read; /// A consumer for a byte stream pub struct ByteConsumer<T: Read> { read: T, type_: StreamType, } impl <T: Read> ByteConsumer<T> { /// Return a ByteConsumer from for single messages, varint or leb128-delimited ...
Make ByteConsumer own its reader
Make ByteConsumer own its reader This is in preparation for making pq multi-threaded; the trait `Read` is not `Send` and so with the previous declaration (read: &'a mut Read) ByteConsumer was _not_ Send and could not be moved into a closure, i.e., with thread::spawn. This commit modifies the API of ByteConsumer by ma...
Rust
mit
sevagh/pqrs,sevagh/pq,sevagh/pq,sevagh/pqrs
05ff346e295b77b4565e3c27fe81bf5b41470205
src/js_types/js_obj.rs
src/js_types/js_obj.rs
use std::collections::btree_map::BTreeMap; use js_types::js_type::{JsType, JsThing}; pub struct JsObj { proto: Option<Box<JsObj>>, dict: BTreeMap<JsType, JsType>, } impl JsThing for JsObj {} impl JsObj { pub fn new() -> JsObj { JsObj { proto: None, dict: BTreeMap::new(), ...
use std::collections::hash_map::HashMap; use js_types::js_type::{JsType, JsThing}; pub struct JsObj { proto: Option<Box<JsObj>>, dict: HashMap<JsType, JsType>, } impl JsThing for JsObj {} impl JsObj { pub fn new() -> JsObj { JsObj { proto: None, dict: HashMap::new(), ...
Use HashMap in JsObj instead of BTreeMap
Use HashMap in JsObj instead of BTreeMap
Rust
mit
rustoscript/french-press
4ca33c110451cab121d8e060e85eae23e2d0f071
src/lib.rs
src/lib.rs
#[test] fn it_works() { }
#![feature(libc)] extern crate libc; pub fn readline() -> Option<String> { // Buffer to hold readline input let buffer = String::new(); let isatty = unsafe { libc::isatty(libc::STDIN_FILENO as i32) } != 0; if isatty { println!("stdin is a tty"); } else { println!("stdin is not a ...
Check if stdin is from a tty
Check if stdin is from a tty
Rust
mit
kkawakam/rustyline,gwenn/rustyline,dubrowgn/rustyline,cavedweller/rustyline,dubrowgn/rustyline
0d617995b255c9e8ebfc14c3358c4dbd96e25e24
ruma-identity-service-api/src/lib.rs
ruma-identity-service-api/src/lib.rs
#![doc(html_favicon_url = "https://www.ruma.io/favicon.ico")] #![doc(html_logo_url = "https://www.ruma.io/images/logo.png")] pub mod authentication; pub mod keys; pub mod status; pub mod tos;
#![doc(html_favicon_url = "https://www.ruma.io/favicon.ico")] #![doc(html_logo_url = "https://www.ruma.io/images/logo.png")] //! (De)serializable types for the Matrix Identity Service API. #![warn(missing_docs)] pub mod authentication; pub mod keys; pub mod status; pub mod tos;
Add crate-level docs and warn on missing docs
identity-service-api: Add crate-level docs and warn on missing docs
Rust
mit
ruma/ruma
42239e69bf43ee7dbda05cf757f86f10a0f16272
tests/compile-fail/repeat.rs
tests/compile-fail/repeat.rs
fn main() { let data: [u8; std::isize::MAX as usize] = [42; std::isize::MAX as usize]; //~^ ERROR: rustc layout computation failed: SizeOverflow([u8; assert_eq!(data.len(), 1024); }
fn main() { let data: [u8; std::usize::MAX] = [42; std::usize::MAX]; //~^ ERROR: rustc layout computation failed: SizeOverflow([u8; assert_eq!(data.len(), 1024); }
Make layout SizeOverflow test trigger on i686.
Make layout SizeOverflow test trigger on i686.
Rust
apache-2.0
aidancully/rust,rust-lang/miri,aidancully/rust,GBGamer/rust,graydon/rust,aidancully/rust,graydon/rust,graydon/rust,rust-lang/miri,GBGamer/rust,rust-lang/miri,GBGamer/rust,GBGamer/rust,aidancully/rust,graydon/rust,rust-lang/miri,tsion/miri,graydon/rust,GBGamer/rust,GBGamer/rust,graydon/rust,GBGamer/rust,GBGamer/rust,aid...
5588311ceaa48c51a8b70b80d11f0830faeb61f3
puyocore/src/field/field_with_height.rs
puyocore/src/field/field_with_height.rs
use field::{Field, FieldHeight}; pub struct FieldWithHeight<F: Field> { field: F, height: [u16; 8], } impl<F: Field> FieldWithHeight<F> { pub fn new() -> FieldWithHeight<F> { FieldWithHeight::<F> { field: F::new(), height: [0; 8], } } } impl<F: Field> FieldHeig...
use field::{Field, FieldHeight}; pub struct FieldWithHeight<F: Field> { field: F, height: [u16; 8], } impl<F: Field> FieldWithHeight<F> { pub fn new() -> FieldWithHeight<F> { FieldWithHeight::<F> { field: F::new(), height: [0; 8], } } pub fn field(&self) ->...
Add field() and field_mut() to FieldWithHeight
Add field() and field_mut() to FieldWithHeight
Rust
mit
mayah/rust-puyoai,mayah/rust-puyoai
cdcd2f337a5be43b59638cc7ded1b26e05abc94c
tests/trait_impl.rs
tests/trait_impl.rs
#![no_std] #[macro_use] extern crate static_assertions; assert_impl!(byte; u8, Send, Sync); #[test] fn str_impl() { assert_impl!(str, Send, Sync, AsRef<[u8]>); }
#![no_std] #[macro_use] extern crate static_assertions; assert_impl!(byte; u8, Send, Sync); #[cfg(feature = "failure")] assert_impl!(ptr; *const u8, Send, Sync); #[test] fn str_impl() { assert_impl!(str, Send, Sync, AsRef<[u8]>); }
Add failure case for assert_impl
[Tests] Add failure case for assert_impl
Rust
apache-2.0
nvzqz/static-assertions-rs
c96bdc580f22d156ba1faa75c7d3187edf16c60f
traits/src/lib.rs
traits/src/lib.rs
pub trait Summarizable { fn summary(&self) -> String; } pub struct NewsArticle { pub headline: String, pub location: String, pub author: String, pub content: String, } impl Summarizable for NewsArticle { fn summary(&self) -> String { format!("{}, by {} ({})", self.headline, self.author...
pub trait Summarizable { fn summary(&self) -> String; } pub struct NewsArticle { pub headline: String, pub location: String, pub author: String, pub content: String, } impl Summarizable for NewsArticle { fn summary(&self) -> String { format!("{}, by {} ({})", self.headline, self.author...
Add struct Tweet and implement Summarizable trait for it
Add struct Tweet and implement Summarizable trait for it
Rust
mit
pgrzesik/learning-rust
7c5bdd7751ae7ccfc87cf2a8ca3a9ccea36a3f6a
src/fake_extctxt.rs
src/fake_extctxt.rs
use syntax; use syntax::codemap::DUMMY_SP; use syntax::ext::base::ExtCtxt; use syntax::feature_gate::GatedCfg; /// Create a fake ExtCtxt to perform macro quasiquotes outside of rustc plugins pub fn with_fake_extctxt<T, F: Fn(&ExtCtxt) -> T>(f: F) -> T { let ps = syntax::parse::ParseSess::new(); let mut fg_cfg = Ve...
use syntax; use syntax::codemap::DUMMY_SP; use syntax::ext::base::ExtCtxt; use syntax::feature_gate::GatedCfg; /// Create a fake ExtCtxt to perform macro quasiquotes outside of rustc plugins pub fn with_fake_extctxt<T, F: Fn(&ExtCtxt) -> T>(f: F) -> T { let ps = syntax::parse::ParseSess::new(); let mut fg_cfg = Ve...
Update NameAndSpan after rustc refactor
Update NameAndSpan after rustc refactor
Rust
mit
tempbottle/rust-peg,daramos/rust-peg,daramos/rust-peg,tempbottle/rust-peg,kevinmehall/rust-peg,kevinmehall/rust-peg
c5a83812f6e1acacb33a493906d0b9b84aceb93f
src/geometry/differential_geometry.rs
src/geometry/differential_geometry.rs
//! Defines the DifferentialGeometry type which is used to pass information //! about the hit piece of geometry back from the intersection to the shading use linalg::{Point, Normal}; use geometry::{Geometry, Instance}; /// Stores information about a hit piece of geometry of some object in the scene #[deriving(Copy)] ...
//! Defines the DifferentialGeometry type which is used to pass information //! about the hit piece of geometry back from the intersection to the shading use linalg::{Point, Normal}; use geometry::{Geometry, Instance}; /// Stores information about a hit piece of geometry of some object in the scene #[deriving(Copy)] ...
Use 'static lifetime bound to require that geom is a real struct
Use 'static lifetime bound to require that geom is a real struct This bound requires that the underlying object implementing the trait is a real struct, not a reference or etc. See http://stackoverflow.com/questions/26212397/rust-lang-references-to-traits-in-structs/26213294#26213294 for some more info
Rust
mit
GuzTech/tray_rust,Twinklebear/tray_rust,voidException/tray_rust
503bf6e67140164af0639eed1e4db2b41f5f9043
src/util/units/rectangle.rs
src/util/units/rectangle.rs
use util::units::{Point, Size}; pub struct Rectangle { location: Point, size: Size, } impl Rectangle { pub fn new(location: Point, size: Size) -> Rectangle { Rectangle { location: location, size: size } } pub fn move_dir(&self, location: Point) -> Rectangle { Rectangle { location...
use util::units::{Point, Size}; pub struct Rectangle { location: Point, size: Size, } impl Rectangle { pub fn new(location: Point, size: Size) -> Rectangle { Rectangle { location: location, size: size } } pub fn move_dir(&self, location: Point) -> Rectangle { Rectangle { location...
Allow Rectangle to return its own size as well as width/height
Allow Rectangle to return its own size as well as width/height
Rust
bsd-3-clause
jgilchrist/rslike
305e666479d3cf01dd016ed57a9ba84cc2fdf3de
src/main.rs
src/main.rs
extern crate clap; extern crate hyper; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate toml; mod config; mod issue; mod jira_api; mod jira_client; mod jira_request; mod search_command; mod search_response; mod workflow; use clap::{App, SubCommand}; fn main() { let workflow = workflo...
extern crate clap; extern crate hyper; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate toml; mod config; mod issue; mod jira_api; mod jira_client; mod jira_request; mod search_command; mod search_response; mod workflow; use clap::{Arg, App, SubCommand}; fn main() { let workflow = wo...
Make possible to take argument in subcommand
:art: Make possible to take argument in subcommand
Rust
mit
dorayakikun/alfred_jira_workflow
d014f172648d4fda44ef485cdb577b945156f2f9
examples/rust/src/main.rs
examples/rust/src/main.rs
extern crate lcm; // mod exlcm; mod exlcm { include!(concat!(env!("OUT_DIR"), "/exlcm/example_t.rs")); } // mod exlcm_backup; // use exlcm_backup as exlcm; fn main() { let mut lcm = lcm::Lcm::new(); let mut my_data = exlcm::ExampleT::new(); // let mut my_data = exlcm::Example::new(); my_data.tim...
extern crate lcm; // mod exlcm; mod exlcm { include!(concat!(env!("OUT_DIR"), "/exlcm/example_t.rs")); } // mod exlcm_backup; // use exlcm_backup as exlcm; fn main() { let mut lcm = lcm::Lcm::new(); let mut my_data = exlcm::ExampleT::new(); // let mut my_data = exlcm::Example::new(); my_data.tim...
Handle return value in example.
Handle return value in example.
Rust
lgpl-2.1
adeschamps/lcm,adeschamps/lcm,adeschamps/lcm,adeschamps/lcm,adeschamps/lcm,adeschamps/lcm,adeschamps/lcm,adeschamps/lcm
221b3d873d079471e158ec21fe00e6cdbdb67259
2015-03-12.solution.rs
2015-03-12.solution.rs
# Rust solution via @jrick use std::cmp; use std::num::{Int, NumCast}; fn percents<T: Int>(input: &Vec<T>) -> Vec<f64> { let mul = f64::from(input.iter().fold(T::zero(), |m, &e| cmp::max(m, e))).unwrap(); input.iter().map(|elem| mul * f64::from(*elem).unwrap()).collect() } fn main() { let input = vec![99...
// Rust solution via @jrick use std::cmp; use std::num::{Int, NumCast}; fn percents<T: Int>(input: &Vec<T>) -> Vec<f64> { let (min, max) = input.iter().fold((T::max_value(), T::min_value()), |m, &e| (cmp::min(m.0, e), cmp::max(m.1, e)) ); let diff = f64::from(max - min).unwrap(); input.iter()....
Print minimum value as 0%
Print minimum value as 0%
Rust
mit
Zamicol/Challenge,Zamicol/Challenge,Zamicol/Challenge
043fab3fd5731d9b3e76468c1d92445c4f11bebb
src/test/ui/issues/issue-50865-private-impl-trait/auxiliary/lib.rs
src/test/ui/issues/issue-50865-private-impl-trait/auxiliary/lib.rs
#![crate_type = "lib"] pub fn bar<P>( // Error won't happen if "bar" is not generic _baz: P, ) { hide_foo()(); } fn hide_foo() -> impl Fn() { // Error won't happen if "iterate" hasn't impl Trait or has generics foo } fn foo() { // Error won't happen if "foo" isn't used in "iterate" or has generics }
// revisions: default miropt //[miropt]compile-flags: -Z mir-opt-level=2 // ~^ This flag is for #77668, it used to be ICE. #![crate_type = "lib"] pub fn bar<P>( // Error won't happen if "bar" is not generic _baz: P, ) { hide_foo()(); } fn hide_foo() -> impl Fn() { // Error won't happen if "iterate" hasn't im...
Make it regression test of issue-77668
Make it regression test of issue-77668
Rust
apache-2.0
graydon/rust,graydon/rust,aidancully/rust,graydon/rust,aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,graydon/rust,aidancully/rust,aidancully/rust,aidancully/rust
83de90b93e67933887bb9cf58282a9ee3de91a8b
src/bin/aux2bib.rs
src/bin/aux2bib.rs
extern crate clap; use clap::{App, Arg}; fn main() { let matches = App::new("aux2bib") .version("0.1.0") .author("Nathan Musoke") .about("gets BibTeX keys from Inspire") .arg(Arg::with_name("INPUT") ...
#[macro_use(crate_version, crate_authors)] extern crate clap; use clap::{App, Arg}; fn main() { let matches = App::new("aux2bib") .version(crate_version!()) .author(crate_authors!(",\n")) .about("gets BibTeX keys from Inspire") ...
Use clap macros for version and author
Use clap macros for version and author
Rust
apache-2.0
musoke/inspirer,musoke/inspirer
9453e520ccdf358d193eba5536ef51b81635ba32
crates/pagecache/src/util.rs
crates/pagecache/src/util.rs
#[inline] pub(crate) fn u64_to_arr(number: u64) -> [u8; 8] { number.to_le_bytes() } #[inline] pub(crate) fn arr_to_u64(arr: &[u8]) -> u64 { debug_assert_eq!(arr.len(), 8); u64::from(arr[0]) + ((u64::from(arr[1])) << 8) + ((u64::from(arr[2])) << 16) + ((u64::from(arr[3])) << 24) ...
use std::convert::TryInto; #[inline] pub(crate) fn u64_to_arr(number: u64) -> [u8; 8] { number.to_le_bytes() } #[inline] pub(crate) fn arr_to_u64(arr: &[u8]) -> u64 { arr.try_into().map(u64::from_le_bytes).unwrap() } #[inline] pub(crate) fn arr_to_u32(arr: &[u8]) -> u32 { arr.try_into().map(u32::from_le_...
Replace the hand-crafted array to u64/u32 conversions by the std one
Replace the hand-crafted array to u64/u32 conversions by the std one
Rust
apache-2.0
spacejam/sled,spacejam/sled,spacejam/sled
08158b660a5238d9701b811000333f9fb0f01f90
examples/drop_odd.rs
examples/drop_odd.rs
extern crate libnfqueue as nfq; use nfq::{Handle, ProtocolFamily, CopyMode, VerdictHandler, Message, Verdict}; fn main() { let mut handle = Handle::new().ok().unwrap(); let mut queue = handle.queue(0, Decider{count: 0}).unwrap(); handle.bind(ProtocolFamily::INET).ok(); queue.mode(CopyMode::Packet(409...
extern crate libnfqueue as nfq; use nfq::{Handle, ProtocolFamily, CopyMode, VerdictHandler, Message, Verdict}; fn main() { let mut handle = Handle::new().ok().unwrap(); let mut count = 0; let mut queue = handle.queue(0, move |message: &mut Message| { let id = message.header().id(); coun...
Use a closure for drop odd
Use a closure for drop odd
Rust
mit
terminalcloud/libnetfilter_queue,bluepeppers/libnetfilter_queue,steveklabnik/libnetfilter_queue
161a3d86073077f789143dbe9398372ac445e984
src/models.rs
src/models.rs
use super::schema::notes; use rocket::{Request, Data, Outcome}; use rocket::data::{self, FromData}; use rocket::http::Status; use rocket::Outcome::*; use serde_json; use rocket_contrib::JSON; #[derive(Queryable)] #[derive(Serialize,Deserialize)] pub struct Note { pub id: i32, pub title: String, pub body: S...
use super::schema::notes; use rocket::{Request, Data}; use rocket::data::{self, FromData}; use rocket::http::Status; use rocket::Outcome::*; use serde_json; use rocket_contrib::JSON; #[derive(Queryable)] #[derive(Serialize,Deserialize)] pub struct Note { pub id: i32, pub title: String, pub body: String, ...
Remove unused variable and import warnings
Remove unused variable and import warnings
Rust
mit
fanderzon/rocket-api
0adfeec65940ea720960ba6ca21fb5c182a2d179
src/notification.rs
src/notification.rs
use gobject::GObject; use libc::c_char; use glib::GError; pub type NotifyNotification = _NotifyNotification; #[repr(C)] struct NotifyNotificationPrivate; #[repr(C)] struct _NotifyNotification { _parent_object: GObject, _priv_: NotifyNotificationPrivate } extern "C" { pub fn notify_notification_new(summa...
use gobject::GObject; use libc::c_char; use glib::GError; #[repr(C)] struct NotifyNotificationPrivate; #[repr(C)] pub struct NotifyNotification { _parent_object: GObject, _priv_: NotifyNotificationPrivate } extern "C" { pub fn notify_notification_new(summary: *const c_char, ...
Define NotifyNotification directly instead of using a type alias
Define NotifyNotification directly instead of using a type alias
Rust
mit
crumblingstatue/rust-libnotify-sys
c0c2a8d9c1b2d4f41ad7d61d11a0980116dc795c
tests/fmt.rs
tests/fmt.rs
#[test] fn fmt() { if option_env!("RUSTC_TEST_SUITE").is_some() { return; } let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); let dev_dir = root_dir.join("clippy_dev"); let output = std::process::Command::new("cargo") .current_dir(dev_dir) .args(&["run", "...
#[test] fn fmt() { if option_env!("RUSTC_TEST_SUITE").is_some() { return; } let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); let dev_dir = root_dir.join("clippy_dev"); let output = std::process::Command::new("cargo") .current_dir(dev_dir) .args(&["+nightl...
Work around rustup fallback error on Windows
Work around rustup fallback error on Windows
Rust
apache-2.0
aidancully/rust,graydon/rust,aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,graydon/rust,graydon/rust,aidancully/rust,aidancully/rust,aidancully/rust,graydon/rust
d45e727370b535b087168d5625d3d7253a26b66f
src/tree/traits.rs
src/tree/traits.rs
use super::values::*; /// /// The treenode trait is implemented by things that can act as part of a tree /// pub trait TreeNode { /// /// Counts the number of children of this tree node /// fn count_children(&self) -> u32; /// /// Retrieves the child at the specified index /// fn get_c...
use super::values::*; /// /// The treenode trait is implemented by types that can act as part of a tree /// pub trait TreeNode { /// /// Counts the number of children of this tree node /// fn count_children(&self) -> u32; /// /// Retrieves the child at the specified index /// fn get_ch...
Add a new 'mutable' trait to treenode
Add a new 'mutable' trait to treenode
Rust
apache-2.0
Logicalshift/tame-tree
f4779f2c13f121d6f31e5a4abf366765350f493c
tests/parsing_tests.rs
tests/parsing_tests.rs
extern crate lrs; #[test] fn parse_Num() { } #[test] fn parse_Sym() { } #[test] fn parse_Atom() { } #[test] fn parse_List() { } #[test] fn parse_Expr() { } #[test] fn parse_Node() { } #[test] fn parse_Lang() { }
extern crate lrs; #[test] fn parse_num() { } #[test] fn parse_sym() { } #[test] fn parse_atom() { } #[test] fn parse_list() { } #[test] fn parse_expr() { } #[test] fn parse_node() { } #[test] fn parse_lang() { }
Change parsing tests to snake case
Change parsing tests to snake case
Rust
apache-2.0
jzhu98/telescope
8f305a821d72c01d6baa36ca8944e273985315ff
src/breeze_frontends/frontend/dummy.rs
src/breeze_frontends/frontend/dummy.rs
//! Dummy frontend that does nothing. use frontend_api::{FrontendAction, Renderer, AudioSink}; /// Renderer that just does nothing. #[derive(Default)] pub struct DummyRenderer; impl Renderer for DummyRenderer { fn render(&mut self, _frame_data: &[u8]) -> Option<FrontendAction> { None } fn set_rom_title(&mut ...
//! Dummy frontend that does nothing. use frontend_api::{FrontendAction, Renderer, AudioSink}; /// Renderer that just does nothing, apart from saving the PPU output for later use. This allows /// users to extract single rendered frames without having to implement `Renderer`. #[derive(Default)] pub struct DummyRendere...
Save last frame of output
DummyRenderer: Save last frame of output
Rust
unknown
jonas-schievink/sneeze,jonas-schievink/breeze-emu
b640da7d24035de9ff2ddfbb176d14432fae762a
src/reports.rs
src/reports.rs
use nom::{Err, Needed}; pub fn report_error(err: Err<&[u8], u32>) { match err { Err::Code(_) => { println!("Parsing error: Unknown origin"); } Err::Node(_, n) => { println!("Parsing error: Unknown origin"); for e in n { report_error(e); ...
use nom::{Err, Needed}; pub fn report_error(err: Err<&[u8], u32>) { match err { Err::Code(_) => { println!("Parsing error: Unknown origin"); } Err::Node(_, n) => { println!("Parsing error: Unknown origin"); for e in n { report_error(e); ...
Switch reporters to using display format
Switch reporters to using display format
Rust
mit
snewt/bnf
bbaab63f844d64ca726a2a83c18774b3957c7169
src/test/ui/associated-types/issue-62200.rs
src/test/ui/associated-types/issue-62200.rs
struct S {} trait T<'a> { type A; } impl T<'_> for S { type A = u32; } fn foo(x: impl Fn(<S as T<'_>>::A) -> <S as T<'_>>::A) {} //~^ ERROR binding for associated type `Output` references an anonymous lifetime fn main() {}
struct S {} trait T<'a> { type A; } impl T<'_> for S { type A = u32; } fn foo(x: impl Fn(<S as T<'_>>::A) -> <S as T<'_>>::A) {} //~^ ERROR binding for associated type `Output` references an anonymous lifetime //~^^ NOTE lifetimes appearing in an associated type are not considered constrained fn main() {}
Include the note in the test.
Include the note in the test.
Rust
apache-2.0
graydon/rust,graydon/rust,aidancully/rust,aidancully/rust,graydon/rust,aidancully/rust,graydon/rust,graydon/rust,aidancully/rust,graydon/rust,aidancully/rust,aidancully/rust
57c19a896edc158d04ef5aa1b47724d00568b6fd
fahrenheit_to_celsius/src/main.rs
fahrenheit_to_celsius/src/main.rs
fn main() { println!("Hello, world!"); }
use std::io; fn main() { println!("Enter value in Fahrenheit:"); let mut f = String::new(); io::stdin().read_line(&mut f) .expect("Failed to read line!"); let f: f32 = f.trim().parse().expect("Enter valid Fahrenheit value!"); let c = (f - 32.0) * (5.0/9.0); println!("Fahrenheit...
Implement converting from fahrenheit to celsius
Implement converting from fahrenheit to celsius
Rust
mit
pgrzesik/learning-rust
d3f63288d71b7c50f53ea2dc9ac0f776ccd036ec
lib.rs
lib.rs
#![feature(libc)] extern crate libc; use libc::{c_int, c_uint}; #[repr(C)] #[derive(Copy)] pub struct RawEvent { pub etype: u8, pub emod: u8, pub key: u16, pub ch: u32, pub w: i32, pub h: i32, pub x: i32, pub y: i32, } extern "C" { pub fn tb_init() -> c_int; pub fn tb_shutdown...
#![feature(libc)] extern crate libc; use libc::c_int; #[repr(C)] #[derive(Copy)] pub struct RawEvent { pub etype: u8, pub emod: u8, pub key: u16, pub ch: u32, pub w: i32, pub h: i32, pub x: i32, pub y: i32, } extern "C" { pub fn tb_init() -> c_int; pub fn tb_shutdown(); p...
Use c_int instead of c_uint to be more inline with termbox
Use c_int instead of c_uint to be more inline with termbox
Rust
mit
gchp/termbox-sys
3413078bc4daa893c8feb2da36b04ebc8f7f6dbb
src/ref_into.rs
src/ref_into.rs
pub trait RefInto<'a, T>: MutInto<'a, T> { fn ref_into(&'a self) -> T; } pub trait MutInto<'a, T> { fn mut_into(&'a mut self) -> T; }
pub trait RefInto<'a, T>: MutInto<'a, T> { fn ref_into(&'a self) -> T; } pub trait MutInto<'a, T> { fn mut_into(&'a mut self) -> T; } impl<'a, T: 'a> RefInto<'a, &'a T> for T { fn ref_into(&'a self) -> &'a T { self } } impl<'a, T: 'a> RefInto<'a, &'a T> for &'a T { fn ref_into(&'a self)...
Add basic `RefInto` and `MutInto` implementations
Add basic `RefInto` and `MutInto` implementations
Rust
apache-2.0
kylewlacy/glitter,kylewlacy/glitter
1ebdfb10b6cf5cc16d8bfb592ad9ae501c8d8e1e
build.rs
build.rs
extern crate capnpc; fn main() { // CAPNP_INCLUDE_DIR=$(shell dirname $(shell which capnp))/../include let prefix = { let output = ::std::process::Command::new("which").arg("capnp") .output().unwrap().stdout; let path = ::std::path::Path::new(::std::str::from_utf8(&output).unwrap(...
use std::str; use std::path::Path; use std::process::Command; extern crate capnpc; fn main() { // CAPNP_INCLUDE_DIR=$(shell dirname $(shell which capnp))/../include let prefix = { let output = Command::new("which") .arg("capnp") .output() ...
Use imports to shorten lines
Use imports to shorten lines
Rust
mit
dwrensha/capnproto-rust,dwrensha/capnp-rpc-rust,placrosse/capnproto-rust,dwrensha/capnp-rpc-rust,tempbottle/capnproto-rust
d12dd5ec94030b8d1c8b480c910209fafd83a90a
src/api/cocoa/mod.rs
src/api/cocoa/mod.rs
use {SystrayError}; pub struct Window { } impl Window { pub fn new() -> Result<Window, SystrayError> { Err(SystrayError::NotImplementedError) } }
use std; use {SystrayError}; pub struct Window { } impl Window { pub fn new() -> Result<Window, SystrayError> { Err(SystrayError::NotImplementedError) } pub fn quit(&self) { unimplemented!() } pub fn set_tooltip(&self, _: &String) -> Result<(), SystrayError> { unimplemented...
Add dummy `unimplemented!()` for cocoa api
Add dummy `unimplemented!()` for cocoa api
Rust
bsd-3-clause
qdot/systray-rs,qdot/systray-rs
aff0c339b486f29006ba791983cd716e2a2ff307
src/arch/x86_64/stop.rs
src/arch/x86_64/stop.rs
#[cfg(feature = "acpi")] use acpi; use syscall::io::{Io, Pio}; #[no_mangle] pub unsafe extern fn kreset() -> ! { println!("kreset"); // 8042 reset { println!("Reset with 8042"); let mut port = Pio::<u8>::new(0x64); while port.readf(2) {} port.write(0xFE); } // TODO...
#[cfg(feature = "acpi")] use acpi; use syscall::io::{Io, Pio}; #[no_mangle] pub unsafe extern fn kreset() -> ! { println!("kreset"); // 8042 reset { println!("Reset with 8042"); let mut port = Pio::<u8>::new(0x64); while port.readf(2) {} port.write(0xFE); } // Use ...
Fix TODO: Use triple fault to guarantee reboot
Fix TODO: Use triple fault to guarantee reboot Cause interrupt, since the IDT is dorked we can't find the INT 3 handler (double fault), and the double fault handler can't be found (triple fault).
Rust
mit
redox-os/kernel,redox-os/kernel,redox-os/kernel
560def15113d3d54b262d2b9365b6952e5e5ee3a
src/test/run-pass/deriving-global.rs
src/test/run-pass/deriving-global.rs
// Copyright 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-MIT or ...
// Copyright 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-MIT or ...
Fix a pretty printing test
test: Fix a pretty printing test The pretty printer handles inlines comments quite badly
Rust
apache-2.0
dinfuehr/rust,ktossell/rust,defuz/rust,avdi/rust,ebfull/rust,shepmaster/rand,emk/rust,miniupnp/rust,erickt/rust,erickt/rust,jroesch/rust,hauleth/rust,untitaker/rust,aturon/rust,bombless/rust,GBGamer/rust,servo/rust,rohitjoshi/rust,omasanori/rust,0x73/rust,cllns/rust,zaeleus/rust,seanrivera/rust,jroesch/rust,pczarn/rust...
206898f996deeceae8d3a18fd75f8fe39e8fa8dc
src/main.rs
src/main.rs
mod vm; mod command; mod parse; mod program; use vm::VM; use program::Program; use std::io::Write; use std::env; use std::path::Path; use std::fs::File; use std::io::prelude::*; fn main() { let vm = VM::new(); let program = Program::new(); match env::args().nth(1) { None => repl(vm, program), ...
mod vm; mod command; mod parse; mod program; use vm::VM; use program::Program; use parse::parse; use std::io::Write; use std::env; use std::path::Path; use std::fs::File; use std::io::prelude::*; fn main() { let vm = VM::new(); let program = Program::new(); match env::args().nth(1) { None => repl...
Simplify qualification with use statement
Simplify qualification with use statement
Rust
mit
nafarlee/thoughtfuck
33029f440f9be98f2460fcaf7c2d87defac902e9
evaluate/src/main.rs
evaluate/src/main.rs
extern crate document; extern crate xpath; use std::collections::hashmap::HashMap; use document::{Document,ToAny}; use xpath::{XPathEvaluationContext,XPathFactory}; use xpath::expression::XPathExpression; fn main() { let mut args = std::os::args(); let arg = match args.remove(1) { Some(x) => x, ...
extern crate document; extern crate xpath; use std::io::File; use std::collections::hashmap::HashMap; use document::ToAny; use document::parser::Parser; use xpath::{XPathEvaluationContext,XPathFactory}; use xpath::expression::XPathExpression; fn main() { let mut args = std::os::args(); let filename = matc...
Update evaluate tool to parse a file
Update evaluate tool to parse a file
Rust
mit
shepmaster/sxd-rust
f3589d68354f42dc98e96aa47827405f364289dd
src/lib.rs
src/lib.rs
#![feature( btree_range, collections, collections_bound, question_mark, rustc_private, pub_restricted, )] // From rustc. #[macro_use] extern crate rustc; extern crate rustc_borrowck; extern crate rustc_data_structures; extern crate rustc_mir; extern crate rustc_trans; extern crate rustc_const_m...
#![feature( btree_range, collections, collections_bound, question_mark, rustc_private, pub_restricted, )] // From rustc. #[macro_use] extern crate rustc; extern crate rustc_borrowck; extern crate rustc_data_structures; extern crate rustc_mir; extern crate rustc_const_math; extern crate syntax; ...
Remove unused extern crate rustc_trans.
Remove unused extern crate rustc_trans.
Rust
apache-2.0
rust-lang/miri,GBGamer/rust,graydon/rust,rust-lang/miri,graydon/rust,GBGamer/rust,graydon/rust,aidancully/rust,aidancully/rust,aidancully/rust,GBGamer/rust,GBGamer/rust,aidancully/rust,rust-lang/miri,graydon/rust,rust-lang/miri,aidancully/rust,aidancully/rust,GBGamer/rust,GBGamer/rust,tsion/miri,graydon/rust,GBGamer/ru...
8b5ca90e166e20fc93e1af7ca4f213825139f767
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...
Trim down the crate attribute listings
Trim down the crate attribute listings
Rust
apache-2.0
ajroetker/rustc-serialize,DenisKolodin/rustc-serialize,shepmaster/rustc-serialize,SimonSapin/rustc-serialize,rust-lang-nursery/rustc-serialize,rust-lang/rustc-serialize,gbersac/rustc-serialize,rust-lang-deprecated/rustc-serialize,indefini/rustc-serialize
81123178d68ea1a61fd9acffd7f5fe355774478a
src/asn1-rs/serial/int.rs
src/asn1-rs/serial/int.rs
use std::io; use tag; use err; use serial; impl serial::traits::Asn1Info for u64 { fn asn1_type(&self) -> tag::Type { tag::Type::from("INTEGER") } fn asn1_class(&self) -> tag::Class { tag::Class::Universal } fn asn1_tagnum(&self) -> tag::TagNum { tag::TagNum::from(2u8) } fn asn1_construct...
use std::io; use tag; use err; use serial; use byte::write_byte; impl serial::traits::Asn1Info for u64 { fn asn1_type(&self) -> tag::Type { tag::Type::from("INTEGER") } fn asn1_class(&self) -> tag::Class { tag::Class::Universal } fn asn1_tagnum(&self) -> tag::TagNum { tag::TagNum::from(2u8) ...
Add serialize implementation for u64
Add serialize implementation for u64
Rust
apache-2.0
keeperofdakeys/asn1-rs,keeperofdakeys/asn1-rs
d93d401e27e496ee790c8ed575c041813f16bc8f
src/lib.rs
src/lib.rs
extern crate gl as gl_lib; mod context; pub use gl_lib as gl; pub use context::Context;
extern crate gl as gl_lib; mod context; pub mod gl { pub use super::gl_lib::*; } pub use context::Context;
Fix gl exports in certain circumstances
Fix gl exports in certain circumstances
Rust
apache-2.0
kylewlacy/glitter,kylewlacy/glitter
d594f3701a5c50e00bb496288477010e31c38a69
src/test/run-pass/issue-2930.rs
src/test/run-pass/issue-2930.rs
// Generated from pipe compiler mod stream { fn init<T: send>() -> (client::stream<T>, server::stream<T>) { pipes::entangle() } enum stream<T: send> { send(T, server::stream<T>), } mod client { fn send<T: send>(+pipe: stream<T>, +x_0: T) -> stream<T> { { let (...
proto! stream { stream:send<T:send> { send(T) -> stream<T> } } fn main() { let (bc, _bp) = stream::init(); stream::client::send(bc, ~"abc"); }
Use a proper protocol definition instead of the already-expanded code.
Use a proper protocol definition instead of the already-expanded code.
Rust
apache-2.0
stepancheg/rust-ide-rust,dinfuehr/rust,KokaKiwi/rust,quornian/rust,nham/rust,quornian/rust,kimroen/rust,bombless/rust,mahkoh/rust,ebfull/rust,AerialX/rust-rt-minimal,sae-bom/rust,pshc/rust,krzysz00/rust,l0kod/rust,Ryman/rust,XMPPwocky/rust,dinfuehr/rust,nwin/rust,aneeshusa/rust,Ryman/rust,achanda/rand,AerialX/rust,P1st...
deede62d1baf945fc1baf6bd3c99e3c506d7e389
tests/deps/src/lib.rs
tests/deps/src/lib.rs
// Copyright 2017 Serde Developers // // 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 accordin...
// Copyright 2017 Serde Developers // // 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 accordin...
Add error banner when running test suite without nightly compiler
Add error banner when running test suite without nightly compiler
Rust
apache-2.0
bolinfest/serde-jsonrc,serde-rs/json,google/serde_json_lenient
6d1c8df21cc42e0264af83af54ccd4720c24316c
src/wrappers.rs
src/wrappers.rs
//! Tools for wrapping devices. use types::{AudioDevice, Sample, Time}; /// Bundles an AudioDevice with allocated input and output buffers. /// /// To use the device, input samples must first be manually dropped into the /// `inputs` buffer, then `tick` may be called to generate outputs. The output /// samples can b...
//! Tools for wrapping devices. use std::ops::{Deref, DerefMut}; use types::{AudioDevice, Sample, Time}; /// Bundles an AudioDevice with allocated input and output buffers. /// /// To use the device, input samples must first be manually dropped into the /// `inputs` buffer, then `tick` may be called to generate out...
Implement deref for Buffered wrapper
Implement deref for Buffered wrapper
Rust
apache-2.0
oxcable/oxcable,thenyeguy/oxcable,oxcable/oxcable,thenyeguy/oxcable
5c79da766a8f5c12789c2d9b0e6ad3291228816f
src/rust-crypto/lib.rs
src/rust-crypto/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. #![license = "MIT/A...
// 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. #![crate_name = "ru...
Fix unused attribute warning regarding the license attribute
Fix unused attribute warning regarding the license attribute
Rust
apache-2.0
exe-dealer/rust-md5,DaGenix/rust-crypto,andreasots/rust-crypto,andreasots/rust-crypto,nmathewson/rust-crypto,thinkingfish/rust-crypto,mseri/rust-crypto,PeterReid/rust-crypto,nmathewson/rust-crypto,tempbottle/rust-crypto,canndrew/rust-crypto,thinkingfish/rust-crypto,PeterReid/rust-crypto,tempbottle/rust-crypto,DaGenix/r...
b9f68712843ea3e4c029fd0fe915fab75aad2d84
protocol/src/types/uuid.rs
protocol/src/types/uuid.rs
use {Parcel, Error, Settings}; use std::io::prelude::*; use uuid::Uuid; impl Parcel for Uuid { fn read(read: &mut Read, settings: &Settings, _: &mut hint::Hints) -> Result<Self, Error> { let bytes: Result<Vec<u8>, _> = read.bytes().take(16).collect(); let bytes = by...
use {Parcel, Error, Settings}; use hint; use std::io::prelude::*; use uuid::Uuid; impl Parcel for Uuid { const TYPE_NAME: &'static str = "Uuid"; fn read(read: &mut Read, _: &Settings, _: &mut hint::Hints) -> Result<Self, Error> { let bytes: Result<Vec<u8>, _> = read.by...
Fix the UUID Parcel implementation
Fix the UUID Parcel implementation
Rust
mit
dylanmckay/protocol,dylanmckay/protocol
ee07bdfe44224d8c101772b607fff73b7f9ca665
src/rustup/env_var.rs
src/rustup/env_var.rs
use std::ffi::OsString; use std::env; use std::path::{Path, PathBuf}; use std::process::Command; pub fn append_path(name: &str, value: Vec<PathBuf>, cmd: &mut Command) { let old_value = env::var_os(name); let mut parts: Vec<PathBuf>; if let Some(ref v) = old_value { parts = env::split_paths(v).coll...
use std::ffi::OsString; use std::env; use std::path::{Path, PathBuf}; use std::process::Command; #[allow(unused)] pub fn append_path(name: &str, value: Vec<PathBuf>, cmd: &mut Command) { let old_value = env::var_os(name); let mut parts: Vec<PathBuf>; if let Some(ref v) = old_value { parts = env::sp...
Allow append_path to be unused
Allow append_path to be unused
Rust
apache-2.0
Boddlnagg/rustup.rs,nodakai/rustup.rs,polonez/rustup.rs,theindigamer/rustup.rs,rust-lang/rustup,theindigamer/rustup.rs,rust-lang/rustup,inejge/rustup.rs,theindigamer/rustup.rs,rust-lang/rustup,polonez/rustup.rs,polonez/rustup.rs,nodakai/rustup.rs,Boddlnagg/rustup.rs,rust-lang/rustup,inejge/rustup.rs,Boddlnagg/rustup.rs...
98013f632e7f4becb75c4964f38be9f8a9be0d64
build.rs
build.rs
fn main() { if cfg!(r#static) { println!("cargo:rustc-link-lib=static=odbc"); } if cfg!(target_os = "macos") { // if we're on Mac OS X we'll kindly add DYLD_LIBRARY_PATH to rustc's // linker search path if let Some(dyld_paths) = option_env!("DYLD_LIBRARY_PATH") { ...
fn main() { if cfg!(r#static) { let static_path = std::env::var("ODBC_SYS_STATIC_PATH").unwrap_or("/usr/lib".to_string()); println!("cargo:rerun-if-env-changed=ODBC_SYS_STATIC_PATH"); println!("cargo:rustc-link-search=native={}", static_path); println!("cargo:rustc-link-lib=static=od...
Add optional search path for static linking
Add optional search path for static linking
Rust
mit
pacman82/odbc-sys
a5bdc43a46fb02faeec64fd13b67db11197cef97
src/test/compile-fail/issue-30730.rs
src/test/compile-fail/issue-30730.rs
// Copyright 2016 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-MIT or ...
// Copyright 2016 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-MIT or ...
Improve previous compile fail test
Improve previous compile fail test
Rust
apache-2.0
aidancully/rust,GBGamer/rust,GBGamer/rust,aidancully/rust,GBGamer/rust,aidancully/rust,graydon/rust,aidancully/rust,GBGamer/rust,graydon/rust,graydon/rust,GBGamer/rust,graydon/rust,graydon/rust,GBGamer/rust,aidancully/rust,graydon/rust,GBGamer/rust,aidancully/rust,GBGamer/rust
ec294134a1f380937872d46b19fd9448d19e5b09
client/src/lib.rs
client/src/lib.rs
extern crate base; #[macro_use] extern crate glium; #[macro_use] extern crate log; pub mod render; pub mod event_manager; mod config; mod game; pub use config::Config; pub fn start_game(config: Config, world_provider: &base::world::Provider) -> Result<(), ()> { game::run(&config, world_provider) }
//! This crate contains functionality for the client only. This is mainly //! graphics and input handling. //! extern crate base; #[macro_use] extern crate glium; #[macro_use] extern crate log; pub mod render; pub mod event_manager; mod config; mod game; pub use config::Config; pub fn start_game(config: Config, wo...
Add short documentation of the root module for `client`
Add short documentation of the root module for `client`
Rust
apache-2.0
adRichter/plantex,adRichter/plantex
654be5c058ecc91927240bc5f307a3f71425c853
src/main.rs
src/main.rs
/* ** A simple program that allows basic arithmetic operations using roman numerals and conversions to decimal numbers. */ fn main() { println!("Bismillah"); }
/* ** A simple program that allows basic arithmetic operations using roman numerals and conversions to decimal numbers. */ fn main() { let roman_number = "CLIII"; let decimal_number = to_decimal(&roman_number); println!("The roman number {} is equal to {} in decimal numbers", roman_number, decimal_number); let ...
Add function to convert roman numerals into decimal numbers.
Add function to convert roman numerals into decimal numbers.
Rust
mit
tzkhan/roman-rust
8dd53ec44da28907d8da6914c23916308e26f961
rebind_plugins/src/derive_action.rs
rebind_plugins/src/derive_action.rs
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::generic::{combine_substructure, EnumMatching, FieldInfo, ...
#![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...
Add file allow annotations for warnings
Add file allow annotations for warnings
Rust
mit
burtonageo/rebind
9d9d173acb61850f767ea7599dba1d68782d498c
src/lib.rs
src/lib.rs
#![cfg_attr(feature="clippy", feature(plugin))] #![cfg_attr(feature="clippy", plugin(clippy))] #![feature(conservative_impl_trait)] #![feature(collections_bound)] #![feature(btree_range)] #![feature(step_by)] #![allow(dead_code)] extern crate chrono; extern crate nom; mod time_unit; mod schedule; pub use schedule::S...
#![cfg_attr(feature="clippy", feature(plugin))] #![cfg_attr(feature="clippy", plugin(clippy))] #![feature(conservative_impl_trait)] #![feature(step_by)] extern crate chrono; extern crate nom; mod time_unit; mod schedule; pub use schedule::Schedule;
Remove unneeded features (and unneeded attribute)
Remove unneeded features (and unneeded attribute)
Rust
apache-2.0
zslayton/cron
ef42bcd7c7c350195b9ff7c2d9da0037c595dd24
tests/struct_derive.rs
tests/struct_derive.rs
#[macro_use] extern crate serde_elm; #[allow(dead_code)] #[derive(Elm)] struct Simple { name: String } #[test] fn should_assert_elm_generation_was_done() { assert!(true); }
#[macro_use] extern crate serde_elm; use std::env; #[allow(dead_code)] #[derive(Elm)] struct Simple { name: String } #[test] fn should_assert_elm_generation_was_done() { let mut path = env::current_dir().unwrap(); path.push("generated"); path.push("Simple.elm"); assert!(path.exists()); asser...
Test is the file actually is created
Test is the file actually is created
Rust
mit
mijnadres/serde_elm
ec69bffd1e732a55a3211cfd65f3bef6aed33a39
src/validate.rs
src/validate.rs
/// Validation provider pub trait Validator { fn is_valid(&self, line: &str) -> bool; } impl Validator for () { fn is_valid(&self, _line: &str) -> bool { true } }
//! Input buffer validation API (Multi-line editing) /// This trait provides an extension interface for determining whether /// the current input buffer is valid. Rustyline uses the method /// provided by this trait to decide whether hitting the enter key /// will end the current editing session and return the current...
Improve documentation for new Validation trait
Improve documentation for new Validation trait
Rust
mit
kkawakam/rustyline
8e80d59f5b0e00c842d7c27c4a8b7554198b64c4
build.rs
build.rs
use std::io::Command; use std::os; fn main() { let curr_dir = os::getenv("CARGO_MANIFEST_DIR").unwrap(); let nvim_dir = Path::new(curr_dir).join("neovim"); Command::new("make").arg("libnvim").cwd(&nvim_dir).status().unwrap(); let nvim_lib_dir = nvim_dir.join_many(&["build", "src", "nvim"]); let de...
use std::io::Command; use std::os; fn main() { let curr_dir = Path::new(os::getenv("CARGO_MANIFEST_DIR").unwrap()); Command::new("git").arg("submodule").arg("update").arg("--init").cwd(&curr_dir).status().unwrap(); let nvim_dir = Path::new(curr_dir).join("neovim"); Command::new("make").arg("libnvim")....
Make sure the submodule is brought in
Make sure the submodule is brought in
Rust
unlicense
oakes/neovim-rs
4fd7ffbe75306d2e9adc4ac547551d6cf1352eac
build.rs
build.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. extern crate gcc; ...
// 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. extern crate gcc; ...
Use Inline assembly for msvc target from non-windows host
Use Inline assembly for msvc target from non-windows host When cross-compiling for msvc from a non-windows host, inline assembly is typically supported (for example via clang or clang-cl). Given that clang also doesn't support masm or have ml.exe compatibility, it's best to use the C implementations of `util_helpers` ...
Rust
apache-2.0
DaGenix/rust-crypto,DaGenix/rust-crypto
64c051b190a9ca2181972bbbe3f88f152a1530c2
src/index_data.rs
src/index_data.rs
pub use std::mem; pub use std::slice; pub enum IndexDatumType { UnsignedByte, UnsignedShort } pub trait IndexData { fn index_datum_type() -> IndexDatumType; fn index_bytes(&self) -> &[u8]; fn index_elements(&self) -> usize; } pub trait IndexDatum { fn index_datum_type() -> IndexDatumType; }
pub use std::mem; pub use std::slice; pub enum IndexDatumType { UnsignedByte, UnsignedShort } pub trait IndexData { fn index_datum_type() -> IndexDatumType; fn index_bytes(&self) -> &[u8]; fn index_elements(&self) -> usize; } pub trait IndexDatum { fn index_datum_type() -> IndexDatumType; } ...
Add `IndexDatum` impls for `u8`/`u16`
Add `IndexDatum` impls for `u8`/`u16`
Rust
apache-2.0
kylewlacy/glitter,kylewlacy/glitter
e4b310c8d501d1539083156f9ec8d1688a481600
challenges/src/set4/challenge32.rs
challenges/src/set4/challenge32.rs
use super::hmac_client; use super::hmac_server; use rand; use rand::Rng; use errors::*; pub fn run() -> Result<(), Error> { let skip_exercise = true; if skip_exercise { return Err(ChallengeError::Skipped("Runs very long.").into()); } let mut rng = rand::thread_rng(); let key: Vec<u8> = ...
use super::hmac_client; use super::hmac_server; use rand; use rand::Rng; use errors::*; pub fn run() -> Result<(), Error> { println!("Challenge 32: takes about three minutes, pleases wait ..."); let mut rng = rand::thread_rng(); let key: Vec<u8> = rng.gen_iter().take(20).collect(); let mut server = ...
Print message instead of disabling challenge
Print message instead of disabling challenge
Rust
mit
aopicier/cryptopals-rust
cb4694387e56627d1ffc982bad3a370f6ddef866
examples/serde-syntex-example/src/main.rs
examples/serde-syntex-example/src/main.rs
#![cfg_attr(nightly, feature(custom_derive, plugin))] #![cfg_attr(nightly, plugin(serde_macros))] extern crate serde; extern crate serde_json; #[cfg(feature = "serde_macros")] include!("main.rs.in"); #[cfg(not(feature = "serde_macros"))] include!(concat!(env!("OUT_DIR"), "/main.rs"));
#![cfg_attr(feature = "serde_macros", feature(custom_derive, plugin))] #![cfg_attr(feature = "serde_macros", plugin(serde_macros))] extern crate serde; extern crate serde_json; #[cfg(feature = "serde_macros")] include!("main.rs.in"); #[cfg(not(feature = "serde_macros"))] include!(concat!(env!("OUT_DIR"), "/main.rs")...
Fix nightly check in serde-syntex-example
Fix nightly check in serde-syntex-example
Rust
apache-2.0
serde-rs/serde,erickt/serde,oli-obk/rust-serde
3bda1a1b52c02b07f1f66d4bd035aac5655974b8
src/calculator.rs
src/calculator.rs
use parser::Expr; use parser::Expr::*; // The main entry point for the calculator itself. // It receives an expression tree, and recursively reduces it to a single signed 64-bit integer pub fn evaluate(expr: &Expr) -> i64 { match expr { &Int(ref i) => *i, &Plus(box ref l, box ref r...
use parser::Expr; use parser::Expr::*; // The main entry point for the calculator itself. // It receives an expression tree, and recursively reduces it to a single signed 64-bit integer pub fn evaluate(expr: &Expr) -> i64 { match expr { &Int(ref i) => *i, &Plus(box ref l, box ref r...
Handle divide by zero errors
Handle divide by zero errors
Rust
mit
bitwalker/rustcalc
9e244251a0c05ba5c06fd94970b01d11cfbb73f1
tests/run-pass/std.rs
tests/run-pass/std.rs
use std::cell::Cell; use std::rc::Rc; use std::sync::Arc; fn rc_cell() -> Rc<Cell<i32>> { let r = Rc::new(Cell::new(42)); let x = r.get(); r.set(x + x); r } // TODO(solson): also requires destructors to run for the second borrow to work // TODO(solson): needs StructWrappedNullablePointer support // fn...
use std::cell::{Cell, RefCell}; use std::rc::Rc; use std::sync::Arc; fn rc_cell() -> Rc<Cell<i32>> { let r = Rc::new(Cell::new(42)); let x = r.get(); r.set(x + x); r } fn rc_refcell() -> i32 { let r = Rc::new(RefCell::new(42)); *r.borrow_mut() += 10; let x = *r.borrow(); x } fn arc() ...
Enable an old test that works now!
Enable an old test that works now!
Rust
apache-2.0
GBGamer/rust,tsion/miri,rust-lang/miri,aidancully/rust,rust-lang/miri,GBGamer/rust,graydon/rust,GBGamer/rust,graydon/rust,aidancully/rust,graydon/rust,aidancully/rust,aidancully/rust,rust-lang/miri,GBGamer/rust,graydon/rust,aidancully/rust,GBGamer/rust,GBGamer/rust,aidancully/rust,rust-lang/miri,GBGamer/rust,GBGamer/ru...
2a57763cab24c16a02b67d2ab262df552f43b021
src/syntax_highlight/mod.rs
src/syntax_highlight/mod.rs
#[cfg(all(feature="syntax-highlight", not(windows)))] mod syntect; #[cfg(all(feature="syntax-highlight", not(windows)))] pub use self::syntect::*; #[cfg(any(not(feature="syntax-highlight"), windows))] mod null; #[cfg(any(not(feature="syntax-highlight"), windows))] pub use self::null::*;
#[cfg(feature="syntax-highlight")] mod syntect; #[cfg(feature="syntax-highlight")] pub use self::syntect::*; #[cfg(not(feature="syntax-highlight"))] mod null; #[cfg(not(feature="syntax-highlight"))] pub use self::null::*;
Remove platform check for syntax-highlight
chore: Remove platform check for syntax-highlight Now that there is `null` syntax highlighting, let people attempt to enable the real version if they want to, even on unsupported platforms. Really, the motivation is I'm running into a rustfmt bug and trying to work around it.
Rust
mit
cobalt-org/cobalt.rs,cobalt-org/cobalt.rs,cobalt-org/cobalt.rs,cobalt-org/cobalt.rs
4f85489b71b0cb851337e28fdc82a6a1491dcdf1
src/gist/gist_file.rs
src/gist/gist_file.rs
extern crate rustc_serialize; use self::rustc_serialize::json::{ToJson, Json}; use std::collections::BTreeMap; use std::fs::File; use std::io::{self, Read}; use std::path::Path; pub struct GistFile { pub name: String, pub contents: String, } impl GistFile { pub fn new(name: String) -> GistFile { ...
extern crate rustc_serialize; use self::rustc_serialize::json::{ToJson, Json}; use std::collections::BTreeMap; use std::fs::File; use std::io::{self, Read}; use std::path::Path; pub struct GistFile { pub name: String, pub contents: String, } impl GistFile { pub fn new(name: String) -> GistFile { ...
Simplify GistFile's read functions return types.
Simplify GistFile's read functions return types.
Rust
bsd-2-clause
LesPepitos/gist
cfb5ca83d4cbb6468f857213c20007b573faa8a4
dev/parse.rs
dev/parse.rs
extern crate proc_macro; use proc_macro::TokenStream; use syn::{parse_macro_input, File}; #[proc_macro] pub fn r#mod(input: TokenStream) -> TokenStream { parse_macro_input!(input as File); "fn main() {}".parse().unwrap() }
extern crate proc_macro; use proc_macro::TokenStream; use syn::{parse_macro_input, File}; #[proc_macro] pub fn r#mod(input: TokenStream) -> TokenStream { let file = parse_macro_input!(input as File); println!("{:#?}", file); "fn main() {}".parse().unwrap() }
Debug print the dev syntax tree
Debug print the dev syntax tree
Rust
apache-2.0
dtolnay/syn
5e798a52c80801364ebbf2e0eff0acb72a53185f
src/js_types/js_type.rs
src/js_types/js_type.rs
use std::cmp::Ordering; use std::hash::{Hash, Hasher}; use uuid::Uuid; pub struct JsType { uid: Uuid, t: Box<JsT>, } impl JsType { fn new(t: Box<JsT>) -> JsType { JsType { uid: Uuid::new_v4(), t: t, } } } impl PartialEq for JsType { fn eq(&self, other: &Sel...
use std::cmp::Ordering; use std::hash::{Hash, Hasher}; use uuid::Uuid; pub trait JsTrait {} pub struct JsT { uid: Uuid, t: Box<JsTrait>, } impl JsT { pub fn new(t: Box<JsTrait>) -> JsT { JsT { uid: Uuid::new_v4(), t: t, } } } impl PartialEq for JsT { fn eq...
Rename JsType to JsT, JsT to JsTrait
Rename JsType to JsT, JsT to JsTrait
Rust
mit
rustoscript/french-press
265f057f25bc50ea8cc926a924336d3ca27ade6c
src/main.rs
src/main.rs
#[macro_use] extern crate clap; #[macro_use] extern crate log; extern crate git2; mod cd; mod cli; mod logger; mod repository; mod settings; use std::process::exit; use settings::Settings; fn main() { match run_cli() { Ok(_) => {} Err((message, exit_code)) => { error!("{}", message);...
#[macro_use] extern crate clap; #[macro_use] extern crate log; extern crate git2; mod cd; mod cli; mod logger; mod repository; mod settings; use std::process::exit; use settings::Settings; fn main() { match run_cli() { Ok(_) => {} Err((message, exit_code)) => { error!("{}", message);...
Return an error result, instead of pretending unimplemented commands are ok
Return an error result, instead of pretending unimplemented commands are ok
Rust
mit
jhelwig/homers
ef29db773e8367e68e957f435f70ee96a85d9a8f
tests/ui/lint_without_lint_pass.rs
tests/ui/lint_without_lint_pass.rs
#![deny(clippy::internal)] #![feature(rustc_private)] #[macro_use] extern crate rustc; use rustc::lint; #[macro_use] extern crate clippy_lints; declare_clippy_lint! { pub TEST_LINT, correctness, "" } declare_clippy_lint! { pub TEST_LINT_REGISTERED, correctness, "" } pub struct Pass; impl li...
#![deny(clippy::internal)] #![feature(rustc_private)] #[macro_use] extern crate rustc; use rustc::lint::{LintArray, LintPass}; #[macro_use] extern crate clippy_lints; declare_clippy_lint! { pub TEST_LINT, correctness, "" } declare_clippy_lint! { pub TEST_LINT_REGISTERED, correctness, "" } p...
Add tests for declare_lint_pass and impl_lint_pass
Add tests for declare_lint_pass and impl_lint_pass
Rust
apache-2.0
graydon/rust,graydon/rust,graydon/rust,aidancully/rust,graydon/rust,aidancully/rust,aidancully/rust,graydon/rust,aidancully/rust,aidancully/rust,graydon/rust,aidancully/rust
d03467971de5a3a89e7583fcbb485ff6454adbf0
diesel/src/pg/mod.rs
diesel/src/pg/mod.rs
//! Provides types and functions related to working with PostgreSQL //! //! Much of this module is re-exported from database agnostic locations. //! However, if you are writing code specifically to extend Diesel on //! PostgreSQL, you may need to work with this module directly. pub mod expression; pub mod types; #[do...
//! Provides types and functions related to working with PostgreSQL //! //! Much of this module is re-exported from database agnostic locations. //! However, if you are writing code specifically to extend Diesel on //! PostgreSQL, you may need to work with this module directly. pub mod expression; pub mod types; mod ...
Move reexport to the other reexports
Move reexport to the other reexports
Rust
apache-2.0
diesel-rs/diesel,sgrif/diesel,diesel-rs/diesel,sgrif/diesel
2022fc461e2cb03b98011f4f999ffb375bd08ca7
examples/tvdb-lookup.rs
examples/tvdb-lookup.rs
extern crate tvdb; extern crate argparse; use argparse::{ArgumentParser, StoreTrue, Store}; fn main(){ let mut series_name = "".to_owned(); let mut season_no = 1; let mut episode_no = 1; { let mut ap = ArgumentParser::new(); ap.refer(&mut series_name).add_argument("series", Store, "S...
extern crate tvdb; extern crate argparse; use argparse::{ArgumentParser, Store}; fn main(){ let mut series_name = "".to_owned(); let mut season_no = 1; let mut episode_no = 1; { let mut ap = ArgumentParser::new(); ap.refer(&mut series_name).add_argument("series", Store, "Series name"...
Remove unused StoreTrue from example
Remove unused StoreTrue from example
Rust
unlicense
dbr/tvdb-rs
d03e07b708c1f1f0fc0e4769e9990043d4f3cf8f
src/derive/mod.rs
src/derive/mod.rs
extern crate syn; use syn::DeriveInput; pub fn generate_elm(_: &DeriveInput) { // do nothing }
extern crate syn; use std::env; use std::fs::File; use std::io::{Write, BufWriter}; use syn::DeriveInput; pub fn generate_elm(_: &DeriveInput) { let mut path = env::current_dir().unwrap(); path.push("generated/test.txt"); let file = File::create(path).unwrap(); let ref mut w = BufWriter::new(file); ...
Write a test file to generated directory
Write a test file to generated directory
Rust
mit
mijnadres/serde_elm
b5d64dab892eeeecbdcf667ab8c797d5d3c4fdc7
src/osc_types.rs
src/osc_types.rs
use errors; // see OSC Type Tag String: http://opensoundcontrol.org/spec-1_0 // padding: zero bytes (n*4) pub enum OscType { OscInt(i32), OscFloat(f32), OscString(String), OscBlob(Vec<u8>), OscTime(u32, u32), // nonstandard argument types // ignore them if not implemented OscLong(i64), ...
use errors; // see OSC Type Tag String: http://opensoundcontrol.org/spec-1_0 // padding: zero bytes (n*4) pub enum OscType { OscInt(i32), OscFloat(f32), OscString(String), OscBlob(Vec<u8>), OscTime(u32, u32), // nonstandard argument types // ignore them if not implemented OscLong(i64), ...
Define `OscMessage` and `OscBundle` structs
Define `OscMessage` and `OscBundle` structs
Rust
apache-2.0
klingtnet/rosc
375846bda50964f4dcfc1f36341666f22b608e28
tests/fpe.rs
tests/fpe.rs
// This file is part of libfringe, a low-level green threading library. // Copyright (c) Ben Segall <talchas@gmail.com> // Copyright (c) edef <edef@edef.eu> // See the LICENSE file included in this distribution. #![cfg(target_os = "linux")] #![feature(test)] #![feature(thread_local)] #![feature(asm)] extern crate fring...
// This file is part of libfringe, a low-level green threading library. // Copyright (c) Ben Segall <talchas@gmail.com> // Copyright (c) edef <edef@edef.eu> // See the LICENSE file included in this distribution. #![cfg(target_os = "linux")] #![feature(test)] #![feature(thread_local)] #![feature(asm)] extern crate fring...
Rewrite the FPE test to not use Context directly
Rewrite the FPE test to not use Context directly
Rust
apache-2.0
nathan7/libfringe,nathan7/libfringe
85df9aad678192e2f31fb224a025846525887ab7
src/engine/sequential.rs
src/engine/sequential.rs
use traits::Grid; use traits::Engine; use traits::Consumer; pub struct Sequential<G: Grid, C: Consumer> { grid: G, consumer: C } impl<G: Grid, C: Consumer> Sequential<G, C> { pub fn new(grid: G, consumer: C) -> Self { Sequential { grid: grid, consumer: consumer } ...
use traits::Cell; use traits::Consumer; use traits::Grid; use traits::Engine; pub struct Sequential<C: Cell, G: Grid<Cell=C>, Con: Consumer<Cell=C>> { grid: G, consumer: Con } impl<C: Cell, G: Grid<Cell=C>, Con: Consumer<Cell=C>> Sequential<C, G, Con> { pub fn new(grid: G, consumer: Con) -> Self { ...
Support for the new constraint.
Support for the new constraint.
Rust
mit
0nkery/celly
455bdbba70613201cac16828d87db806d61126cb
src/key.rs
src/key.rs
pub trait Key: Copy + PartialEq + Ord + Default { type Bytes: AsRef<[u8]>; fn into_bytes(self) -> Self::Bytes; fn from_bytes(bytes: Self::Bytes) -> Self; } macro_rules! impl_key { ($type:ident, $size:expr) => { impl Key for $type { type Bytes = [u8; $size]; fn into_byte...
pub trait Key: Copy + PartialEq + Ord + Default { type Bytes: AsRef<[u8]>; fn into_bytes(self) -> Self::Bytes; fn from_bytes(bytes: Self::Bytes) -> Self; } macro_rules! impl_key { ($type:ident, $size:expr) => { impl Key for $type { type Bytes = [u8; $size]; fn into_byte...
Correct pointer size cfg variables
Correct pointer size cfg variables
Rust
apache-2.0
adevore/rudy
c430364450f395343b7fdebf3db28070eabdadc8
src/extensions.rs
src/extensions.rs
use std::cell::Cell; pub trait Incrementor { fn increment(&self); } impl Incrementor for Cell<u8> { fn increment(&self) { self.set(self.get() + 1); } } impl Incrementor for Cell<u16> { fn increment(&self) { self.set(self.get() + 1); } }
use std::cell::Cell; use std::num::One; pub trait Incrementor { fn increment(&self); } impl<T: Copy + Num> Incrementor for Cell<T> { fn increment(&self) { self.set(self.get() + One::one()); } }
Change incrementor to be more generic
Change incrementor to be more generic
Rust
mit
murphm8/zaty
9eda82f4a3d0dca0642157e9071b94f64eb830fe
components/net/sniffer_task.rs
components/net/sniffer_task.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/. */ //! A task that sniffs data use std::comm::{channel, Receiver, Sender, Disconnected}; use std::task::TaskBuilder; ...
/* 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/. */ //! A task that sniffs data use std::comm::{channel, Receiver, Sender, Disconnected}; use std::task::TaskBuilder; ...
Break out of loop if can't send data
Break out of loop if can't send data Fixes #4046
Rust
mpl-2.0
GyrosOfWar/servo,vks/servo,brendandahl/servo,pyecs/servo,jgraham/servo,dmarcos/servo,saneyuki/servo,evilpie/servo,ryancanhelpyou/servo,mt2d2/servo,dmarcos/servo,DominoTree/servo,codemac/servo,paulrouget/servo,brendandahl/servo,pyfisch/servo,codemac/servo,Shraddha512/servo,dagnir/servo,hyowon/servo,pyfisch/servo,wartman...
096030bccc15c591962758d6c94ceca8baa6d955
src/lib.rs
src/lib.rs
#![feature(slice_concat_ext)] use unicode_segmentation::UnicodeSegmentation; use std::slice::SliceConcatExt; extern crate unicode_segmentation; pub fn normalize_tag(tag: &str) -> Result<String, &'static str> { if tag.is_empty() { Err("Tag is empty") } else { let lc = tag.to_lowercase(); ...
#![feature(slice_concat_ext)] use unicode_segmentation::UnicodeSegmentation; use std::slice::SliceConcatExt; extern crate unicode_segmentation; pub fn normalize_tag(tag: &str) -> Result<String, &'static str> { if tag.is_empty() { Err("Tag is empty") } else { let lc = tag.to_lowercase(); ...
Check if empty after normalization
Check if empty after normalization
Rust
mit
mneumann/normalize-tag-rs
2ec85b4c7ba202894b037ddbae2f130f5d2b91d6
src/lib.rs
src/lib.rs
#![feature(plugin_registrar, quote)] extern crate rustc; extern crate syntax; use rustc::plugin::Registry; use syntax::ast::TokenTree; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, MacItems, MacResult}; use syntax::parse::tts_to_parser; mod block; mod parser; mod generator; #[plugin_registrar] pub fn p...
#![feature(plugin_registrar, quote)] extern crate rustc; extern crate syntax; use rustc::plugin::Registry; use syntax::ast::TokenTree; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, MacItems, MacResult}; use syntax::parse::tts_to_parser; mod block; mod parser; mod generator; #[plugin_registrar] pub fn p...
Allow `non_snake_case` in the generated code.
Allow `non_snake_case` in the generated code.
Rust
apache-2.0
cmr/speculate.rs
5b42821565cd7dcc014044e51168d7414a828301
src/lib.rs
src/lib.rs
#[macro_use] extern crate log; extern crate "rustc-serialize" as rustc_serialize; pub mod hpack; pub mod http; pub mod client; mod tests { }
#![feature(io, net, core, std_misc)] #[macro_use] extern crate log; extern crate "rustc-serialize" as rustc_serialize; pub mod hpack; pub mod http; pub mod client; mod tests { }
Add feature annotations for currently unstable features used
Add feature annotations for currently unstable features used
Rust
mit
stepancheg/solicit,Galvanization/solicit,jinnjuice/solicit,mlalic/solicit,tempbottle/solicit,gwicke/solicit
8ce43a80622e2db28d0b72a755d7e4ac259356ba
zguide/hwserver.rs
zguide/hwserver.rs
/*! * Hello World server in Rust * Binds REP socket to tcp://*:5555 * Expects "Hello" from client, replies with "World" */ extern mod zmq; use std::libc; fn main() { #[fixed_stack_segment]; let context = zmq::Context::new(); let responder = context.socket(zmq::REP).unwrap(); assert!(responder.bind(...
/*! * Hello World server in Rust * Binds REP socket to tcp://*:5555 * Expects "Hello" from client, replies with "World" */ extern mod zmq; use std::rt; fn main() { #[fixed_stack_segment]; let context = zmq::Context::new(); let responder = context.socket(zmq::REP).unwrap(); assert!(responder.bind("t...
Use std::rt::io::Timer instead of an unsafe sleep()
Use std::rt::io::Timer instead of an unsafe sleep()
Rust
apache-2.0
tempbottle/rust-zmq,alexkamp/rust-zmq,erickt/rust-zmq,pblasucci/rust-zmq,petehayes102/rust-zmq,jedisct1/rust-zmq,cristicbz/rust-zmq,dginev/rust-zmq,pfernie/rust-zmq
67b386bad03d8550a5b651076d20813b9c52cebb
src/lib.rs
src/lib.rs
extern crate hyper; extern crate pbr; extern crate ansi_term; use std::sync::{Arc, Mutex}; #[macro_use] pub mod logs; pub mod authorization; pub mod cargo_helper; pub mod client; pub mod contentlength; pub mod download; pub mod filesize; pub mod http_version; pub mod response; pub mod util; pub mod write; /// Repre...
extern crate hyper; extern crate pbr; extern crate ansi_term; use std::sync::{Arc, Mutex}; #[macro_use] pub mod logs; pub mod authorization; pub mod cargo_helper; pub mod client; pub mod contentlength; pub mod download; pub mod filesize; pub mod http_version; pub mod response; pub mod util; pub mod write; /// Repre...
Add new type for an URL
Add new type for an URL
Rust
mit
k0pernicus/zou
f77dd5ac9371897d30dd3a8c43023e14f86dd0bf
src/test/ui/rust-2021/future-prelude-collision-unneeded.rs
src/test/ui/rust-2021/future-prelude-collision-unneeded.rs
// edition:2018 // check-pass #![allow(unused)] #![deny(rust_2021_prelude_collisions)] struct S; impl S { fn try_into(self) -> S { S } } // See https://github.com/rust-lang/rust/issues/86633 fn main() { let s = S; let s2 = s.try_into(); }
// edition:2018 // check-pass #![allow(unused)] #![deny(rust_2021_prelude_collisions)] struct S; impl S { fn try_into(self) -> S { S } } struct X; trait Hey { fn from_iter(_: i32) -> Self; } impl Hey for X { fn from_iter(_: i32) -> Self { X } } fn main() { // See https://gi...
Add test for trait check in prelude collision lint.
Add test for trait check in prelude collision lint.
Rust
apache-2.0
aidancully/rust,graydon/rust,graydon/rust,aidancully/rust,aidancully/rust,aidancully/rust,aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,graydon/rust,graydon/rust
5663a50ed6d36538efca048c5f4832ddbd8e7a0a
src/platform/word_wrap.rs
src/platform/word_wrap.rs
use std::io::{self, Write}; const CHARS_PER_LINE: usize = 78; const SPACE: u8 = 32; const LF: u8 = 10; // This is a *very* naive algorithm. It assumes the cursor is // currently at column 0, and that the string to be printed is // ASCII, among other things. It's good enough for our needs // and much more lightweight ...
use std::io::{self, Write}; const CHARS_PER_LINE: usize = 78; const SPACE: u8 = 32; const LF: u8 = 10; // This is a *very* naive algorithm. It assumes the cursor is // currently at column 0, and that the string to be printed is // ASCII, among other things. It's good enough for our needs // and much more lightweight ...
Make word wrap support words longer than CHARS_PER_LINE.
Make word wrap support words longer than CHARS_PER_LINE.
Rust
unlicense
toolness/werewolves-and-wanderer-rs,toolness/werewolves-and-wanderer-rs,toolness/werewolves-and-wanderer-rs,toolness/werewolves-and-wanderer-rs
31a18ab00ab50758ce7e731efe84d1409806a61e
tests/struct_derive.rs
tests/struct_derive.rs
#[macro_use] extern crate serde_elm; use std::env; use std::fs::File; use std::io::{Read, Error}; use std::path::Path; #[allow(dead_code)] #[derive(Elm)] struct Simple { name: String } #[test] fn should_assert_elm_generation_was_done() { let root = env::current_dir().unwrap(); let mut path = root.clone(); ...
#[macro_use] extern crate serde_elm; use std::env; use std::fs::File; use std::io::{Read, Error}; use std::path::Path; #[allow(dead_code)] #[derive(Elm)] struct Simple { name: String } #[test] fn should_assert_elm_generation_was_done() { let model_name = "Simple"; assert!(content_equal_for(model_name)) } fn c...
Make content check accept a model name
Make content check accept a model name
Rust
mit
mijnadres/serde_elm
5b3558b9ff72bbfbc3a0cb01b5f27b76c60318df
src/main.rs
src/main.rs
#![feature(plugin)] #![plugin(clippy)] #[macro_use] extern crate kafka; extern crate log; extern crate openssl; extern crate toml; mod flowgger; const DEFAULT_CONFIG_FILE: &'static str = "flowgger.toml"; fn main() { println!("Starting flowgger 0.1.2"); let config_file = std::env::args().skip(1).next().unwr...
#![feature(plugin)] #![plugin(clippy)] #[macro_use] extern crate kafka; extern crate log; extern crate openssl; extern crate toml; mod flowgger; const DEFAULT_CONFIG_FILE: &'static str = "flowgger.toml"; const FLOWGGER_VERSION_STRING: &'static str = "0.1.2"; fn main() { println!("Flowgger v{}", FLOWGGER_VERSIO...
Make the version string a variable, at least.
Make the version string a variable, at least.
Rust
unknown
jedisct1/zok,jedisct1/flowgger,jedisct1/zok,jedisct1/flowgger,salpalvv/flowgger,salpalvv/flowgger
002e549a9b8ec005640359d76ae28679cb2d28f1
src/repo.rs
src/repo.rs
//! Git repository representation for git-global. use std::fmt; use git2; /// A git repository, represented by the full path to its base directory. #[derive(PartialEq, Eq, Hash, Clone)] pub struct Repo { path: String, } impl Repo { pub fn new(path: String) -> Repo { Repo { path: path, ...
//! Git repository representation for git-global. use std::fmt; use std::path::PathBuf; use git2; /// A git repository, represented by the full path to its base directory. #[derive(Clone, Eq, Hash, PartialEq)] pub struct Repo { path: PathBuf, } impl Repo { pub fn new(path: String) -> Repo { Repo { ...
Mark Repo.path be a PathBuf instead of a String
Mark Repo.path be a PathBuf instead of a String This is the beginning of an effort to bring in changes from the "refactoring" branch that I forgot about before publishing 0.2.0.
Rust
mit
peap/git-global
e8ff455dbce28e641cbcae19596562fe0631a8f7
01-10/p10.rs
01-10/p10.rs
enum Node<T> { One(T), Many(uint, T) } fn pack<T: Clone+Eq>(list: &[T]) -> ~[~[T]] { let mut it = list.iter(); let mut result = ~[]; let mut l = 1; loop { match it.nth(l - 1) { Some(e) => { let mut slice = ~[]; slice.push(e.clone()); ...
enum Node<T> { One(T), Many(uint, T) } fn pack<T: Clone+Eq>(list: &[T]) -> ~[~[T]] { let mut it = list.iter(); let mut result = ~[]; let mut l = 1; loop { match it.nth(l - 1) { Some(e) => { let mut slice = ~[]; slice.push(e.clone()); ...
Remove unique vector matching from Problem 10
Remove unique vector matching from Problem 10
Rust
cc0-1.0
Armavica/99-Problems-Rust
e857d14808b0fdfd1ad2a47bcf3b3e628aadb14b
build/build.rs
build/build.rs
extern crate gcc; use std::path::Path; use std::process::Command; struct Perl { bin: String, } impl Perl { fn new() -> Perl { Perl { bin: std::env::var("PERL").unwrap(), } } fn cfg(&self, key: &str) -> String { let out = Command::new(&self.bin) .arg("-...
extern crate gcc; use std::path::Path; use std::process::Command; struct Perl { bin: String, } impl Perl { fn new() -> Perl { Perl { bin: std::env::var("PERL").unwrap_or("perl".to_owned()), } } fn cfg(&self, key: &str) -> String { let out = Command::new(&self.bin)...
Use default perl if env variable is not set.
Use default perl if env variable is not set. This makes it easier to run under perlbrew that can transparently switch between perl versions.
Rust
bsd-2-clause
vickenty/perl-sys,vickenty/perl-sys
fba6adfae48d55984934872a81d533dc405b7cd3
crates/proc-macro-srv-cli/src/main.rs
crates/proc-macro-srv-cli/src/main.rs
use proc_macro_srv::cli; fn main() { cli::run().unwrap(); }
//! A standalone binary for `proc-macro-srv`. use proc_macro_srv::cli; fn main() { cli::run().unwrap(); }
Add doc comment to pass tidy check
Add doc comment to pass tidy check
Rust
apache-2.0
rust-analyzer/rust-analyzer,rust-analyzer/rust-analyzer,rust-analyzer/rust-analyzer,rust-analyzer/rust-analyzer,rust-analyzer/rust-analyzer
35356865cc090fa504afb3b6f9dc5e38b182f755
src/lib.rs
src/lib.rs
extern crate r2d2; extern crate postgres; use postgres::{PostgresConnection, PostgresConnectParams, IntoConnectParams, SslMode}; use postgres::error::PostgresConnectError; pub struct PostgresPoolManager { params: PostgresConnectParams, ssl_mode: SslMode, } impl PostgresPoolManager { pub fn new<T: IntoCon...
extern crate r2d2; extern crate postgres; use postgres::{PostgresConnection, PostgresConnectParams, IntoConnectParams, SslMode}; use postgres::error::PostgresConnectError; pub struct PostgresPoolManager { params: PostgresConnectParams, ssl_mode: SslMode, } impl PostgresPoolManager { pub fn new<T: IntoCon...
Use batch_execute instead of execute
Use batch_execute instead of execute It'll should speed up the check since we'll end up with 1 round trip instead of 3 and don't care about the result anyway.
Rust
mit
alexcrichton/r2d2-postgres,sfackler/r2d2-postgres
6245dd205f648a407bfd9e35a2f04fbf8692a59c
data/localize_macros.rs
data/localize_macros.rs
// This file was generated automatically by crowbook-localize. // It is probably not a good idea to edit it manually. // // # Usage: // // ```rust, no_run // extern crate crowbook_intl_runtime; // #[macro_use] mod localize_macros; // crowbook_intl_runtime::set_lang("en"); // lformat!("Hello, {}", name); // set_lang("fr...
// This file was generated automatically by crowbook-localize. // It is probably not a good idea to edit it manually. // // # Usage: // // ```rust, no_run // extern crate crowbook_intl_runtime; // #[macro_use] mod localize_macros; // crowbook_intl_runtime::set_lang("en"); // lformat!("Hello, {}", name); // set_lang("fr...
Remove unnecessary import and function definition
Remove unnecessary import and function definition
Rust
mpl-2.0
lise-henry/crowbook-intl
a45486f2d05ce1081fab5709f629ae765368509b
exercises/test4.rs
exercises/test4.rs
// test4.rs // This test covers the sections: // - Modules // - Macros // Write a macro that passes the test! No hints this time, you can do it! // I AM NOT DONE #[cfg(test)] mod tests { use super::*; #[test] fn test_my_macro() { assert_eq!(my_macro!("world!"), "Hello world!"); } }
// test4.rs // This test covers the sections: // - Modules // - Macros // Write a macro that passes the test! No hints this time, you can do it! // I AM NOT DONE #[cfg(test)] mod tests { use super::*; #[test] fn test_my_macro_world() { assert_eq!(my_macro!("world!"), "Hello world!"); } ...
Add a second test case
Add a second test case
Rust
mit
carols10cents/rustlings,carols10cents/rustlings
d74bd6f90330389ce90341ff6c72fc1fc40425de
src/io/mod.rs
src/io/mod.rs
// // SOS: the Stupid Operating System // by Hawk Weisman (hi@hawkweisman.me) // // Copyright (c) 2015 Hawk Weisman // Released under the terms of the MIT license. See `LICENSE` in the root // directory of this repository for more information. // pub mod term; /// This is basically a braindead reimplementation of...
// // SOS: the Stupid Operating System // by Hawk Weisman (hi@hawkweisman.me) // // Copyright (c) 2015 Hawk Weisman // Released under the terms of the MIT license. See `LICENSE` in the root // directory of this repository for more information. // pub mod term; use core::ops; /// This is basically a braindead reim...
Add a `<<` operator on `Write`ers like on C++ IOStream
Add a `<<` operator on `Write`ers like on C++ IOStream
Rust
apache-2.0
rachlmac/sos-kernel,hawkw/sos-kernel,hawkw/sos-kernel,rachlmac/sos-kernel,rachlmac/sos-kernel,hawkw/sos-kernel
7f0a1fbdce1e1b598f409fc024d5efd078cffe6a
tests/leaks.rs
tests/leaks.rs
// It's OK to destroy a heap when some GcRefs still exist. (!) // // Rust's safety rules ensure that the GcRefs won't still be accessible // afterwards, so if this happens, it means the values were leaked. extern crate cell_gc; use cell_gc::Heap; use std::mem; use std::sync::Arc; #[test] fn test_leaked_ref() { l...
// It's OK to destroy a heap when some GcRefs have not been dropped. (!) // // Rust's safety rules ensure that the GcRefs won't still be accessible // afterwards, so if this happens, it means the values were leaked. extern crate cell_gc; use cell_gc::Heap; use std::mem; use std::sync::Arc; #[test] fn test_leaked_ref...
Make a comment on a test less sensational.
Make a comment on a test less sensational.
Rust
mit
jorendorff/cell-gc,jorendorff/cell-gc
12b528651f408d144e46edaff4dba8b5c5f95b9f
daemon/platform/windows/process_helper.rs
daemon/platform/windows/process_helper.rs
use anyhow::{bail, Result}; use std::process::{Child, Command}; use crate::task_handler::ProcessAction; use log::info; pub fn compile_shell_command(command_string: &str) -> Command { // Chain two `powershell` commands, one that sets the output encoding to utf8 and then the user provided one. let mut command =...
use anyhow::{bail, Result}; use std::process::{Child, Command}; use crate::task_handler::ProcessAction; use log::info; pub fn compile_shell_command(command_string: &str) -> Command { // Chain two `powershell` commands, one that sets the output encoding to utf8 and then the user provided one. let mut command =...
Use ProcessAction in Windows handler for clippy
Use ProcessAction in Windows handler for clippy
Rust
mit
Nukesor/Pueue,Nukesor/Pueuew
ecfeac58aae332b5f88388624d9656ec6750e011
src/test/rustdoc/raw-ident-eliminate-r-hashtag.rs
src/test/rustdoc/raw-ident-eliminate-r-hashtag.rs
// ignore-tidy-linelength pub mod internal { pub struct r#mod; /// See [name], [other name] /// /// [name]: mod /// [other name]: ../internal/struct.mod.html // @has 'raw_ident_eliminate_r_hashtag/internal/struct.B.html' '//a[@href="../raw_ident_eliminate_r_hashtag/internal/struct.mod.html"]' ...
// ignore-tidy-linelength pub mod internal { // @has 'raw_ident_eliminate_r_hashtag/internal/struct.mod.html' pub struct r#mod; /// See [name], [other name] /// /// [name]: mod /// [other name]: crate::internal::mod // @has 'raw_ident_eliminate_r_hashtag/internal/struct.B.html' '//a[@href=...
Use intradoc-links for the whole test, add a @has check
Use intradoc-links for the whole test, add a @has check Co-authored-by: Joshua Nelson <d6955d9721560531274cb8f50ff595a9bd39d66f@yottadb.com>
Rust
apache-2.0
graydon/rust,aidancully/rust,aidancully/rust,graydon/rust,aidancully/rust,graydon/rust,aidancully/rust,graydon/rust,graydon/rust,graydon/rust,aidancully/rust,aidancully/rust
8ac39e56f9ce785570d5c9b0e26ce30b8f200f0c
build.rs
build.rs
use std::env; use std::fs::{copy, create_dir_all, read_dir}; use std::path::{Path, PathBuf}; use std::io; fn main() { let res_dir_source = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("resources/"); let res_dir_target = Path::new(&env::var("OUT_DIR").unwrap()).join("../../../resources/"); //co...
use std::env; use std::fs::{copy, create_dir_all, read_dir}; use std::path::{Path, PathBuf}; use std::io; fn main() { let res_dir_source = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("resources/"); let res_dir_target = Path::new(&env::var("OUT_DIR").unwrap()).join("../../../resources/"); //co...
Convert try! to ? operator.
Convert try! to ? operator.
Rust
mit
aochagavia/rocket