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 |
|---|---|---|---|---|---|---|---|---|---|
0b9d0df041ac6589fc2f558af4f70d89ee382fe5 | tests/test_path.rs | tests/test_path.rs | #[macro_use]
mod macros;
use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
use std::iter::FromIterator;
use syn::{Expr, Type};
#[test]
fn parse_interpolated_leading_component() {
// mimics the token stream corresponding to `$mod::rest`
let tokens = TokenStream::from_ite... | #[macro_use]
mod macros;
use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
use quote::quote;
use std::iter::FromIterator;
use syn::{Expr, Type};
#[test]
fn parse_interpolated_leading_component() {
// mimics the token stream corresponding to `$mod::rest`
let tokens = Tok... | Clean up path test using quote | Clean up path test using quote
| Rust | apache-2.0 | dtolnay/syn |
73ac6ab24c09515672c587482c2c098359767545 | src/traits.rs | src/traits.rs | use serde::{ Serialize, Deserialize };
pub trait Cell: Clone + Serialize + Deserialize {
type Coord: Coord;
fn step<'a, I>(&'a self, neighbors: I) -> Self
where I: Iterator<Item=Option<&'a Self>>;
fn with_coord<C: Coord>(C) -> Self;
fn coord(&self) -> &Self::Coord;
fn set_coord<C: Coord>(... | use serde::{ Serialize, Deserialize };
pub trait Cell: Clone + Serialize + Deserialize {
type Coord: Coord;
fn step<'a, I>(&'a self, neighbors: I) -> Self
where I: Iterator<Item=Option<&'a Self>>;
fn with_coord<C: Coord>(C) -> Self;
fn coord(&self) -> &Self::Coord;
fn set_coord<C: Coord>(... | Allow to change grid from consumer. | Allow to change grid from consumer.
| Rust | mit | 0nkery/celly |
499fbe73ecd14b08c818df777558cffdfdaa0722 | src/engine/strat_engine/device.rs | src/engine/strat_engine/device.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/.
// Functions for dealing with devices.
use std::{fs::File, os::unix::prelude::AsRawFd};
use devicemapper::Bytes;
u... | // 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/.
// Functions for dealing with devices.
use std::{fs::File, os::unix::prelude::AsRawFd};
use devicemapper::Bytes;
u... | Remove a bunch of safety notes | Remove a bunch of safety notes
clippy made us add this a long time ago. I think that was one of its
worst ideas.
Signed-off-by: mulhern <7b51bcf507bcd7afb72bf8663752c0ddbeb517f6@redhat.com>
| Rust | mpl-2.0 | stratis-storage/stratisd,stratis-storage/stratisd,stratis-storage/stratisd |
32c1c9f55c7a5575aa462bcec9e00cd11273841a | src/test/run-pass/chan-poweroftwo.rs | src/test/run-pass/chan-poweroftwo.rs | // -*- rust -*-
// Regression test for circular_buffer initialization
use std;
import std.option;
import std._uint;
import std._vec;
// 12-byte unit for the channel buffer. Assuming that the default
// buffer size needs to hold 8 units, then the minimum buffer size
// needs to be 96. That's not a power of two so ne... | // -*- rust -*-
// Regression tests for circular_buffer when using a unit
// that has a size that is not a power of two
use std;
import std.option;
import std._uint;
import std._vec;
// A 12-byte unit to send over the channel
type record = rec(i32 val1, i32 val2, i32 val3);
// Assuming that the default buffer size... | Simplify the test for circular_buffer initialization | Simplify the test for circular_buffer initialization
| Rust | apache-2.0 | omasanori/rust,vhbit/rust,michaelballantyne/rust-gpu,KokaKiwi/rust,huonw/rand,mitsuhiko/rust,mahkoh/rust,reem/rust,l0kod/rust,ebfull/rust,XMPPwocky/rust,jbclements/rust,pczarn/rust,cllns/rust,aneeshusa/rust,quornian/rust,jashank/rust,ktossell/rust,rprichard/rust,richo/rust,nwin/rust,robertg/rust,kimroen/rust,dwillmer/r... |
0eb383dfbeb80792fe74dd65658acf5e0b73ac56 | tests/book.rs | tests/book.rs | extern crate crowbook;
use crowbook::{Book, InfoLevel};
use std::io;
#[test]
fn test_book() {
let book = Book::new_from_file(&format!("{}/{}", env!("CARGO_MANIFEST_DIR"), "tests/test.book"), InfoLevel::Error, &[]).unwrap();
book.render_html(&mut io::sink()).unwrap();
book.render_tex(&mut io::sink()).unwrap... | extern crate crowbook;
use crowbook::{Book, InfoLevel};
use std::io;
#[test]
fn test_book() {
let book = Book::new_from_file(&format!("{}/{}", env!("CARGO_MANIFEST_DIR"), "tests/test.book"), InfoLevel::Error, &[]).unwrap();
book.render_html(&mut io::sink()).unwrap();
book.render_tex(&mut io::sink()).unwrap... | Comment a test failing on windows to investigate | Comment a test failing on windows to investigate
| Rust | lgpl-2.1 | lise-henry/crowbook,lise-henry/crowbook,lise-henry/crowbook,lise-henry/crowbook |
7ddda5f4ee6a6c7faf08e893d332414385a6e740 | examples/error/option_with_result/option_result.rs | examples/error/option_with_result/option_result.rs | // Our first attempt uses `unwrap` and provides unhelpful errors.
fn double_first(vec: Vec<&str>) -> i32 {
// Returns an error if the input vector is empty:
let first = vec.first().unwrap();
// Returns an error if the element doesn't parse to a number:
2 * first.parse::<i32>().unwrap()
}
fn main() {
... | // Our first attempt uses `unwrap` and unhelpfully panics.
fn double_first(vec: Vec<&str>) -> i32 {
// Panics if the input vector is empty:
let first = vec.first().unwrap();
// Panics if the element doesn't parse to a number:
2 * first.parse::<i32>().unwrap()
}
fn main() {
let numbers = vec!["93",... | Fix Options with Results up a little | Fix Options with Results up a little
fixes #777
| Rust | apache-2.0 | realcr/rust-by-example,chriskrycho/rust-by-example,realcr/rust-by-example,chriskrycho/rust-by-example |
ece4392a0a0900957b3c47412c8ca419767de136 | rust/word-count/src/lib.rs | rust/word-count/src/lib.rs | #![feature(ascii_ctype)]
use std::ascii::AsciiExt;
use std::collections::HashMap;
pub fn word_count(text: &str) -> HashMap<String, u32> {
let iter = text.split(|x: char| x.is_ascii_punctuation() || x == ' ')
.filter(|x| !x.is_empty())
.map(|x| x.to_lowercase());
let mut result: HashMap<String,... | #![feature(ascii_ctype)]
use std::ascii::AsciiExt;
use std::collections::HashMap;
pub fn word_count(text: &str) -> HashMap<String, u32> {
let mut result: HashMap<String, u32> = HashMap::new();
let iter = text.split(|x: char| x.is_ascii_punctuation() || x == ' ')
.filter(|x| !x.is_empty())
.map... | Use entry instead of get | Use entry instead of get
It looks better
| Rust | bsd-2-clause | gyn/exercism,gyn/exercism,gyn/exercism,gyn/exercism |
1d393d45d701d718832a4ee69a255af8955900cf | src/main.rs | src/main.rs | extern crate hyper;
mod get;
mod post;
use hyper::{Get, Post};
use hyper::server::{Handler, Server, Request, Response};
use hyper::status::StatusCode;
struct HttpTin;
impl Handler for HttpTin {
fn handle(&self, request: Request, mut response: Response) {
println!("{} {} {}", request.remote_addr, request... | extern crate hyper;
mod get;
mod post;
use hyper::{Get, Post};
use hyper::header;
use hyper::server::{Handler, Server, Request, Response};
use hyper::status::StatusCode;
struct HttpTin {
server: String,
}
impl HttpTin {
pub fn new() -> Self {
let server = format!("{}/{}", env!("CARGO_PKG_NAME"), env... | Add Server header to response | Add Server header to response
| Rust | apache-2.0 | imp/httptin,imp/httptin |
938c3207b0943ce53e58e6268c9c3e97fd000f89 | src/main.rs | src/main.rs | use std::process::Command;
use std::os::unix::process::CommandExt;
fn main() {
Command::new("java")
.arg("-Xms512m")
.arg("-Xmx1536m")
.arg("-Xss2m")
.args(&["-jar", "/Users/dnw/.sbt/launchers/0.13.13/sbt-launch.jar"])
.arg("shell")
.exec();
}
| use std::process::Command;
use std::process::exit;
use std::os::unix::process::CommandExt;
fn main() {
let err = Command::new("java")
.arg("-Xms512m")
.arg("-Xmx1536m")
.arg("-Xss2m")
.args(&["-jar", "/Users/dnw/.sbt/launchers/0.13.13/sbt-launch.jar"])
.arg("shell")
... | Handle failure to exec command | Handle failure to exec command
| Rust | apache-2.0 | dwijnand/sbtl,dwijnand/sbtl |
fef990f3a77843634f7c37f4e7094547754d8672 | src/lib.rs | src/lib.rs | // Rx -- Reactive programming for Rust
// Copyright 2016 Ruud van Asseldonk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// A copy of the License has been included in the root of the repository.
#![feature(fn_traits, unboxed_c... | // Rx -- Reactive programming for Rust
// Copyright 2016 Ruud van Asseldonk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// A copy of the License has been included in the root of the repository.
#![feature(fn_traits, unboxed_c... | Implement Observable for &I: IntoIterator | Implement Observable for &I: IntoIterator
| Rust | apache-2.0 | ruud-v-a/rx |
3957f8a928b12670bd2787540da0c999c78bf9fb | src/lib.rs | src/lib.rs | pub fn puzzle(input: &str) -> String {
String::from("no")
}
#[cfg(test)]
mod test {
use super::*;
}
| use std::collections::HashMap;
pub fn puzzle(input: &str) -> String {
String::from("no")
}
struct Column {
freqs: HashMap<char, u32>,
}
impl Column {
fn add_char(&mut self, ch: char) {
let count = self.freqs.entry(ch).or_insert(0);
*count += 1;
}
fn most_common_char(&self) -> cha... | Write a struct with methods for representing a column | Write a struct with methods for representing a column
Does not compile
| Rust | mit | carols10cents/adventofcode-rs |
b891be55e4371d332e33ba54ac26d9c454fd55ab | examples/ddvol/src/raw.rs | examples/ddvol/src/raw.rs | //! Importers for RAW volume files. A raw volume file is the raw bytes of
//! volume data in little endian, with X increasing first, then Y, then Z.
use std::io::BufReader;
use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use std::mem;
use std::iter;
use num::{self, NumCast};
use vol::Volume;
use vec... | //! Importers for RAW volume files. A raw volume file is the raw bytes of
//! volume data in little endian, with X increasing first, then Y, then Z.
use std::io::BufReader;
use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use std::mem;
use std::iter;
use num::{self, NumCast};
use vol::Volume;
use vec... | Fix amount of space we allocate for non-1 byte types | Fix amount of space we allocate for non-1 byte types
| Rust | mit | Twinklebear/ispc-rs,Twinklebear/rust-ispc-integration |
bf26c8c661d2843cb04c29b5ad9746d32348fa3d | src/util/mod.rs | src/util/mod.rs | // Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors
//
// 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
//
// Unl... | // Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors
//
// 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
//
// Unl... | Implement `Deserialize` for `ServiceSpec` via serde/toml. | [sup] Implement `Deserialize` for `ServiceSpec` via serde/toml.
This change allows a `ServiceSpec` to be created from a TOML string
representation with custom type error checking, validation of
required fields, etc. A future feature will use this implementation to
read a `.toml` file from disk.
The following related ... | Rust | apache-2.0 | habitat-sh/habitat,habitat-sh/habitat,habitat-sh/habitat,rsertelon/habitat,rsertelon/habitat,rsertelon/habitat,habitat-sh/habitat,rsertelon/habitat,habitat-sh/habitat,rsertelon/habitat,rsertelon/habitat,rsertelon/habitat,habitat-sh/habitat,habitat-sh/habitat,habitat-sh/habitat |
7131fb244fb1246d2835f5ad7426e607ee7c4a1f | protobuf-codegen/src/gen/mod_rs.rs | protobuf-codegen/src/gen/mod_rs.rs | use crate::compiler_plugin;
use crate::gen::code_writer::CodeWriter;
pub(crate) fn gen_mod_rs(mods: &[String]) -> compiler_plugin::GenResult {
let v = CodeWriter::with_no_error(|w| {
w.comment(&format!("{}generated", "@"));
w.write_line("");
for m in mods {
w.write_line(&format!... | use crate::compiler_plugin;
use crate::gen::code_writer::CodeWriter;
pub(crate) fn gen_mod_rs(mods: &[String]) -> compiler_plugin::GenResult {
let v = CodeWriter::with_no_error(|w| {
w.comment(&format!("{}generated", "@"));
w.write_line("");
let mut mods: Vec<&String> = mods.into_iter().col... | Fix generated mod.rs to pass cargo fmt -- --check | Fix generated mod.rs to pass cargo fmt -- --check
| Rust | mit | stepancheg/rust-protobuf,stepancheg/rust-protobuf,stepancheg/rust-protobuf |
642568094c1042d310ac3bd53d2a5a9204c40a70 | src/lib.rs | src/lib.rs | //! Bit utilities for Rust
//!
//! This will eventually expand to include Nibbles and packing them into bytes and integers.
| //! Bit utilities for Rust
//!
//! This will eventually expand to include Nibbles and packing them into bytes and integers.
pub trait BitInformation {
/// Gets the number of bits contained in this type
fn number_of_bits(&self) -> usize;
/// Checks to see if bit X is set
fn has_x_bit(&self, po... | Add BitInformation and implement it for u8 | Add BitInformation and implement it for u8
| Rust | apache-2.0 | Techern/bit_utils-rs |
e3a039303e4974ee8db0dd3113a84b71c43ec2eb | src/lib.rs | src/lib.rs | #![feature(libc)]
extern crate libc;
extern crate "glib-2_0-sys" as glib;
extern crate "gobject-2_0-sys" as gobject;
pub mod notification;
pub use notification::*;
use libc::{
c_char
};
use glib::types::{
gboolean,
};
use glib::GList;
extern "C" {
pub fn notify_init(app_name: *const c_char) -> gboole... | #![feature(libc)]
extern crate libc;
extern crate "glib-2_0-sys" as glib;
extern crate "gobject-2_0-sys" as gobject;
pub mod notification;
pub use notification::*;
use libc::c_char;
use glib::types::gboolean;
use glib::GList;
extern "C" {
pub fn notify_init(app_name: *const c_char) -> gboolean;
pub fn not... | Clean up some use declarations | Clean up some use declarations
| Rust | mit | crumblingstatue/rust-libnotify-sys |
8006852c7509b89f7a7a68f43142339058ec40b0 | src/measure.rs | src/measure.rs | // Copyright 2014 Birunthan Mohanathas
//
// Licensed under the MIT license <http://opensource.org/licenses/MIT>. This
// file may not be copied, modified, or distributed except according to those
// terms.
pub struct Measure {
name: String,
value: f32,
}
impl Measure {
pub fn new(name: &str) -> Measure {... | // Copyright 2014 Birunthan Mohanathas
//
// Licensed under the MIT license <http://opensource.org/licenses/MIT>. This
// file may not be copied, modified, or distributed except according to those
// terms.
pub struct Measure {
name: String,
number_value: f32,
string_value: String,
}
impl Measure {
pu... | Store string value as well in Measure | Store string value as well in Measure
| Rust | mit | poiru/rainmeter-rust |
6b732c339c850ef0e6dfffca6b51aa3dad991f64 | src/lib.rs | src/lib.rs | extern crate base64;
extern crate hyper;
extern crate iso8601;
extern crate xml;
mod error;
mod parser;
mod request;
mod value;
mod utils;
pub use error::{RequestError, Fault};
pub use request::{Request, RequestResult};
pub use value::Value;
/// A response from the server.
///
/// XML-RPC specifies that a call shoul... | //! An XML-RPC implementation in Rust.
//!
//! The `xmlrpc` crate provides a minimal implementation of the [XML-RPC spec][spec].
//!
//! [Repo link][repo].
//!
//! [spec]: http://xmlrpc.scripting.com/spec.html
//! [repo]: https://github.com/jonas-schievink/xml-rpc-rs
extern crate base64;
extern crate hyper;
extern cra... | Add some simple docs to the crate | Add some simple docs to the crate
Not sure if there's anything else to say
Closes #14
| Rust | cc0-1.0 | jonas-schievink/xml-rpc-rs |
fe13b988e1b8df65c05d3124ee5425ec9d5660e1 | blog/src/lib.rs | blog/src/lib.rs | pub struct Post {
state: Option<Box<State>>,
content: String
}
impl Post {
pub fn new() -> Post {
Post {
state: Some(Box::new(Draft {})),
content: String::new()
}
}
}
trait State {}
struct Draft {}
impl State for Draft {}
| pub struct Post {
state: Option<Box<State>>,
content: String
}
impl Post {
pub fn new() -> Post {
Post {
state: Some(Box::new(Draft {})),
content: String::new()
}
}
pub fn add_text(&mut self, text: &str) {
self.content.push_str(text);
}
}
trait ... | Implement method for adding text to Post | Implement method for adding text to Post
| Rust | mit | pgrzesik/learning-rust |
de8b84f9cd6a4fadbfc03270544b32a345f8b5b7 | beacon_chain/types/src/active_state.rs | beacon_chain/types/src/active_state.rs | use super::Hash256;
use super::attestation_record::AttestationRecord;
pub struct ActiveState {
pub pending_attestations: Vec<AttestationRecord>,
pub recent_block_hashes: Vec<Hash256>,
}
impl ActiveState {
/// Returns a new instance where all fields are empty vectors.
pub fn zero() -> Self {
Se... | use super::Hash256;
use super::{
AttestationRecord,
SpecialRecord,
};
pub struct ActiveState {
pub pending_attestations: Vec<AttestationRecord>,
pub pending_specials: Vec<SpecialRecord>,
pub recent_block_hashes: Vec<Hash256>,
pub randao_mix: Hash256,
}
| Update `ActiveState` as per new spec | Update `ActiveState` as per new spec
| Rust | apache-2.0 | sigp/lighthouse,sigp/lighthouse,sigp/lighthouse,sigp/lighthouse |
7566e26b44a9837af83950652e0268802f861e9c | src/example_algorithms.rs | src/example_algorithms.rs | use {DeciderImpl, Decider, Decision, Result};
use std::time::Instant;
#[derive(Copy, Clone)]
/// The most naive implementation of a rate-limiter ever: Always
/// allows every cell through.
pub struct Allower {}
impl Allower {
pub fn new() -> Allower {
Allower {}
}
}
impl DeciderImpl for Allower {
... | use {DeciderImpl, Decider, Decision, Result};
use std::time::Instant;
#[derive(Copy, Clone)]
/// The most naive implementation of a rate-limiter ever: Always
/// allows every cell through.
/// # Example
/// ```
/// use ratelimit_meter::{Decider};
/// use ratelimit_meter::example_algorithms::Allower;
/// let mut allo... | Add a doctest/example for Allower (even if it's useless) | Add a doctest/example for Allower (even if it's useless)
| Rust | mit | antifuchs/ratelimit_meter |
a6033301326abaed331762402f61c946ae3884af | build.rs | build.rs | use std::fs;
use std::path::Path;
fn main() {
// Copy connectr.ini.in to connectr.ini if connectr.ini does not exist.
//
// The local changes in connectr.ini are always preserved, so you can
// set private keys without worrying about git.
let ini_file = Path::new("connectr.ini");
if !ini_file.ex... | use std::fs;
use std::path::Path;
fn main() {
// Copy connectr.ini.in to connectr.ini if connectr.ini does not exist.
//
// The local changes in connectr.ini are always preserved, so you can
// set private keys without worrying about git.
let ini_file = Path::new("connectr.ini");
if !ini_file.ex... | Clean up more touchbar->rubrail stuff | Clean up more touchbar->rubrail stuff
| Rust | apache-2.0 | mrmekon/connectr,mrmekon/connectr |
2f2ebdffa25eca60540de6e15500ae99c4900526 | comparison/src/c_xxhash.rs | comparison/src/c_xxhash.rs | mod ffi {
use libc::{c_void, size_t, uint32_t, uint64_t};
#[allow(non_camel_case_types)]
type XXH32_hash_t = uint32_t;
#[allow(non_camel_case_types)]
type XXH64_hash_t = uint64_t;
extern "C" {
pub fn XXH32(input: *const c_void, length: size_t, seed: uint32_t) -> XXH32_hash_t;
... | mod ffi {
use libc::{c_void, size_t};
#[allow(non_camel_case_types)]
type XXH32_hash_t = u32;
#[allow(non_camel_case_types)]
type XXH64_hash_t = u64;
extern "C" {
pub fn XXH32(input: *const c_void, length: size_t, seed: u32) -> XXH32_hash_t;
pub fn XXH64(input: *const c_void, ... | Remove usages of deprecated libc types | Remove usages of deprecated libc types
| Rust | mit | shepmaster/twox-hash |
d9301bf9e21cc0ac0792631bc3b7d98fcf09d767 | src/main.rs | src/main.rs | extern crate case;
extern crate docopt;
extern crate env_logger;
extern crate git2;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
extern crate xml;
extern crate toml;
use std::error::Error;
use std::process;
use env::Env;
use library::Library;
//generated by build.rs
mod gir_version;
mod ana... | extern crate case;
extern crate docopt;
extern crate env_logger;
extern crate git2;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
extern crate xml;
extern crate toml;
use std::error::Error;
use std::process;
use env::Env;
use library::Library;
//generated by build.rs
mod gir_version;
mod ana... | Set RUST_LOG to warn by default | Set RUST_LOG to warn by default
| Rust | mit | EPashkin/gir,gtk-rs/gir,gtk-rs/gir,GuillaumeGomez/gir,gkoz/gir,EPashkin/gir,GuillaumeGomez/gir,gtk-rs/gir,GuillaumeGomez/gir,gkoz/gir |
3e0aae2805550a64f98ed8f034797d55673d52b9 | examples/opening.rs | examples/opening.rs | //! An example of opening an image.
extern crate image;
use std::env;
use std::fs::File;
use std::path::PathBuf;
use image::GenericImage;
fn main() {
let file = if env::args().count() == 2 {
env::args().nth(1).unwrap()
} else {
panic!("Please enter a file")
};
// Use the open functio... | //! An example of opening an image.
extern crate image;
use std::env;
use std::fs::File;
use std::path::Path;
use image::GenericImage;
fn main() {
let file = if env::args().count() == 2 {
env::args().nth(1).unwrap()
} else {
panic!("Please enter a file")
};
// Use the open function t... | Upgrade examples to latest rust | Upgrade examples to latest rust
| Rust | mit | huonw/image,PistonDevelopers/image,JaySon-Huang/image,hetzge/image,theotherphil/image,TyOverby/rust-image,PistonDevelopers/image,tomaka/image,mbrubeck/image,twoodford/image,nwin/rust-image,bvssvni/image,dtwood/piston-image,lady-segfault/image |
d6c108ff224362c1697cb43146ce7bd37d8fe360 | src/100_doors.rs | src/100_doors.rs | // Implements http://rosettacode.org/wiki/100_doors
use std::iter::range_inclusive;
#[cfg(not(test))]
fn main() {
let drs = doors();
for (i, x) in drs.iter().enumerate() {
println!("Door {} is {}", i+1, x);
}
}
fn doors() -> Vec<DoorState> {
let mut ret = Vec::with_capacity(100);
for f in r... | // Implements http://rosettacode.org/wiki/100_doors
use std::iter::range_inclusive;
#[cfg(not(test))]
fn main() {
let drs = doors();
for (i, x) in drs.iter().enumerate() {
println!("Door {} is {}", i+1, x);
}
}
fn doors() -> Vec<DoorState> {
range_inclusive(1.0, 100.0).map(|f| {
let x... | Make 100 Doors problem's solution more functional. | Make 100 Doors problem's solution more functional.
| Rust | unlicense | magum/rust-rosetta,ZoomRmc/rust-rosetta,crespyl/rust-rosetta,ghotiphud/rust-rosetta,crr0004/rust-rosetta,Hoverbear/rust-rosetta,JIghtuse/rust-rosetta,sakeven/rust-rosetta,magum/rust-rosetta,pfalabella/rust-rosetta |
736b31de32b0fa47cf89f509dcf2c13cb48bbfb5 | 27_message_passing/src/main.rs | 27_message_passing/src/main.rs | fn main() {
println!("Hello, world!");
}
| use std::thread;
use std::sync::mpsc;
fn main() {
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
let val = String::from("Hello there");
tx.send(val).unwrap();
});
}
| Create channel and spawn a thread that sends string through it | Create channel and spawn a thread that sends string through it
| Rust | mit | pgrzesik/learning-rust |
0e03503f539b15d116fad5517e52d5cc7013d0c6 | src/librustc_back/target/i686_unknown_linux_gnu.rs | src/librustc_back/target/i686_unknown_linux_gnu.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 ... | Use -m32 on 32bit Linux | Use -m32 on 32bit Linux
| Rust | apache-2.0 | AerialX/rust,rohitjoshi/rust,jashank/rust,bombless/rust-docs-chinese,gifnksm/rust,defuz/rust,kwantam/rust,ebfull/rust,l0kod/rust,mihneadb/rust,AerialX/rust,miniupnp/rust,mihneadb/rust,zaeleus/rust,GBGamer/rust,barosl/rust,pshc/rust,sae-bom/rust,reem/rust,mdinger/rust,mvdnes/rust,mihneadb/rust,robertg/rust,AerialX/rust-... |
0ba5113a1315c0c5649f163132a8a4a532ee51e1 | benches/basic.rs | benches/basic.rs | #![feature(plugin, core, test)]
#![plugin(speculate)]
extern crate test;
speculate! {
bench "noop" |b| {
b.iter(|| ());
}
describe "xor" {
context "0 to 1000" {
before {
let limit = 1000u32;
}
bench "using `fold`" |b| {
... | #![feature(plugin, core, test)]
#![plugin(speculate)]
extern crate test;
speculate! {
bench "noop" |b| {
b.iter(|| ());
}
describe "xor" {
context "0 to 1000" {
before {
let limit = 1000u32;
}
bench "using `fold`" |b| {
... | Fix for `rustc 1.0.0-dev (ecf8c64e1 2015-03-21) (built 2015-03-21)`. | Fix for `rustc 1.0.0-dev (ecf8c64e1 2015-03-21) (built 2015-03-21)`.
| Rust | apache-2.0 | cmr/speculate.rs |
31514cf67fbde4bd27e691be37f1a617b5eb6e10 | src/bin/open.rs | src/bin/open.rs | extern crate document;
use std::cmp::min;
use std::io::File;
use std::io::BufferedWriter;
use std::io::stdio::stdout_raw;
use document::parser::Parser;
fn pretty_error(xml: &str, position: uint) -> &str {
let s = xml.slice_from(position);
let l = s.chars().count();
s.slice_chars(0, min(l, 15))
}
fn main... | extern crate document;
use std::cmp::min;
use std::io::File;
use std::io::BufferedWriter;
use std::io::stdio::stdout_raw;
use document::parser::Parser;
fn pretty_error(xml: &str, position: uint) -> &str {
let s = xml.slice_from(position);
let l = s.chars().count();
s.slice_chars(0, min(l, 15))
}
#[allow... | Allow the main method to be dead code when compiling tests | Allow the main method to be dead code when compiling tests
| Rust | mit | shepmaster/sxd-document,shepmaster/sxd-document |
719f274fc69d0d1762fc9f6f77bff010584f945d | src/peg/main.rs | src/peg/main.rs | #[feature(globs)];
use std::str;
use std::rt::io;
use std::rt::io::file;
use std::rt::io::{Reader,Writer};
use std::os;
use peg::{compile_grammar};
use codegen::RustWriter;
mod peg;
mod codegen;
mod grammar;
fn main() {
let args = os::args();
let source = str::from_utf8(file::open(&Path::new(args[1]), io::Open, io... | #[feature(globs)];
#[feature(managed_boxes)];
use std::str;
use std::rt::io::stdout;
use std::rt::io::fs::File;
use std::os;
use peg::{compile_grammar};
use codegen::RustWriter;
mod peg;
mod codegen;
mod grammar;
fn main() {
let args = os::args();
let source = str::from_utf8(File::open(&Path::new(args[1])).read_to... | Update for fs changes (again) | Update for fs changes (again)
| Rust | mit | loganmhb/rust-peg,tempbottle/rust-peg,kevinmehall/rust-peg,kevinmehall/rust-peg,a-wortman/rust-peg,jsgf/rust-peg,jsgf/rust-peg,daramos/rust-peg,daramos/rust-peg,a-wortman/rust-peg,tempbottle/rust-peg,loganmhb/rust-peg |
9046085506e30b5fbcd92d51a122abe077be0caf | src/components/script/dom/blob.rs | src/components/script/dom/blob.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 dom::bindings::utils::{Reflectable, Reflector};
use dom::bindings::codegen::BlobBinding;
use script_task::{pag... | /* 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 dom::bindings::utils::{Reflectable, Reflector};
use dom::bindings::codegen::BlobBinding;
use dom::window::Wind... | Make Blob create its binding eagerly. | Make Blob create its binding eagerly.
| Rust | mpl-2.0 | jgraham/servo,evilpie/servo,codemac/servo,akosel/servo,thiagopnts/servo,shrenikgala/servo,aweinstock314/servo,pyfisch/servo,mbrubeck/servo,szeged/servo,mrobinson/servo,dati91/servo,dmarcos/servo,cbrewster/servo,rentongzhang/servo,Adenilson/prototype-viewing-distance,boghison/servo,dvberkel/servo,karlito40/servo,DominoT... |
76d1e63a1e632a6215758c937522e25df4325779 | server/src/web/mod.rs | server/src/web/mod.rs | use db::Pool;
use rocket::{self, Rocket, Request};
use rocket_contrib::{JSON, Value};
mod teams;
mod members;
pub fn app(pool: Pool) -> Rocket {
rocket::ignite()
.manage(pool)
.mount("/teams", teams::routes())
.mount("/members", members::routes())
.catch(errors![not_found, server_e... | use db::Pool;
use rocket::{self, Rocket, Request};
use rocket_contrib::{JSON, Value};
use std::env;
mod teams;
mod members;
pub fn app(pool: Pool) -> Rocket {
set_log_level();
rocket::ignite()
.manage(pool)
.mount("/teams", teams::routes())
.mount("/members", members::routes())
... | Configure Rocket to log minimally | feat: Configure Rocket to log minimally
| Rust | mit | mob-rs/mob |
3033cc9a160fdf14ba591d55a3d0ba8a1e28f34b | amqp0/parser-nom/src/lib.rs | amqp0/parser-nom/src/lib.rs | // Copyright 2016 Alexander Reece
//
// 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... | // Copyright 2016 Alexander Reece
//
// 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... | Disable use of generated code. | [client] Disable use of generated code.
| Rust | apache-2.0 | alreece45/amqp-rs |
0755c41ae26af20c940a80b3c1f686ab5916e655 | src/test/ui/consts/const-nonzero.rs | src/test/ui/consts/const-nonzero.rs | // build-pass (FIXME(62277): could be check-pass?)
use std::num::NonZeroU8;
const X: NonZeroU8 = unsafe { NonZeroU8::new_unchecked(5) };
const Y: u8 = X.get();
fn main() {
}
| // run-pass
#![feature(const_nonzero_int_methods)]
use std::num::NonZeroU8;
const X: NonZeroU8 = unsafe { NonZeroU8::new_unchecked(5) };
const Y: u8 = X.get();
const ZERO: Option<NonZeroU8> = NonZeroU8::new(0);
const ONE: Option<NonZeroU8> = NonZeroU8::new(1);
fn main() {
assert_eq!(Y, 5);
assert!(ZERO.is... | Test `NonZeroU8::new` in a const context | Test `NonZeroU8::new` in a const context
| Rust | apache-2.0 | graydon/rust,aidancully/rust,graydon/rust,aidancully/rust,graydon/rust,graydon/rust,aidancully/rust,aidancully/rust,graydon/rust,aidancully/rust,graydon/rust,aidancully/rust |
24f4388b5b96ce937c9d377144825a6c0c0c6317 | components/style/properties/longhand/table.mako.rs | components/style/properties/longhand/table.mako.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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Table", inherited=False) %>
${he... | /* 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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Table", inherited=False) %>
${he... | Add spec links for table properties | Add spec links for table properties
| Rust | mpl-2.0 | nnethercote/servo,peterjoel/servo,cbrewster/servo,notriddle/servo,eddyb/servo,ConnorGBrewster/servo,jimberlage/servo,paulrouget/servo,thiagopnts/servo,notriddle/servo,CJ8664/servo,DominoTree/servo,jimberlage/servo,mbrubeck/servo,dati91/servo,cbrewster/servo,saneyuki/servo,dsandeephegde/servo,ConnorGBrewster/servo,splav... |
4d7a38443335056a00f0abe873a547f470a2d05e | x86_64/src/layout.rs | x86_64/src/layout.rs | // Magic addresses used to lay out x86_64 VMs.
// The 'zero page', a.k.a linux kernel bootparams.
pub const ZERO_PAGE_START: usize = 0x7000;
// Initial stack for the boot CPU.
pub const BOOT_STACK_POINTER: usize = 0x8000;
// Initial pagetables.
pub const PML4_START: usize = 0x9000;
pub const PDPTE_START: usize = 0xa00... | // Magic addresses used to lay out x86_64 VMs.
// The 'zero page', a.k.a linux kernel bootparams.
pub const ZERO_PAGE_START: usize = 0x7000;
// Initial stack for the boot CPU.
pub const BOOT_STACK_START: usize = 0x8000;
pub const BOOT_STACK_POINTER: usize = 0x8ff0;
// Initial pagetables.
pub const PML4_START: usize = ... | Move boot stack pointer to the top of the page. | Move boot stack pointer to the top of the page.
x86 stacks grow down, so starting at 0x8000 it was decreasing into the
bootparams page. Give the stack its own page and start at the top of
it.
Signed-off-by: Tim Deegan <37082fa8971583550ab9cdbdba4fa6331346f458@amazon.com>
| Rust | apache-2.0 | firecracker-microvm/firecracker,firecracker-microvm/firecracker,firecracker-microvm/firecracker,firecracker-microvm/firecracker,firecracker-microvm/firecracker |
94a273b7a40cfa88f66485faf99fc22d7bbe04c2 | src/util/mod.rs | src/util/mod.rs | #[inline]
pub fn split_values_vec(values: Vec<String>) -> String {
let string = values.into_iter().collect::<Vec<String>>()
.join(",").to_owned();
string.clone()
}
| use types::flag_type::FlagType;
#[inline]
pub fn split_values_vec(values: Vec<String>) -> String {
let string = values.into_iter().collect::<Vec<String>>()
.join(",").to_owned();
string.clone()
}
#[inline]
pub fn split_flags_vec(values: Vec<FlagType>) -> String {
let string = values.into_iter().ma... | Add new util method to treat FlagType vector | util: Add new util method to treat FlagType vector
| Rust | mit | cosmo0920/ruroonga_command |
d0081d3a3f1fbef2286b82b2fa5a40480081e4a8 | list/src/lib.rs | list/src/lib.rs | extern crate common;
use common::args::Args;
use common::first_run::check_first_run;
use common::project_paths::{project_paths, CONFIG_EXTENSION};
use std::path::PathBuf;
pub fn exec(args: Args) -> Result<(), String> {
let project_paths = project_paths(&args);
check_first_run(&project_paths.project_directory... | extern crate common;
use common::args::Args;
use common::first_run::check_first_run;
use common::project_paths::{project_paths, CONFIG_EXTENSION};
use std::path::PathBuf;
pub fn exec(args: Args) -> Result<(), String> {
let project_paths = project_paths(&args);
check_first_run(&project_paths.project_directory... | Sort the list of configs and tab space | Sort the list of configs and tab space
| Rust | mit | brianp/muxed,brianp/muxed |
7bde0cdb46b9ceaf2ee70c8baac4465835faeac0 | src/examples/decoder/main.rs | src/examples/decoder/main.rs | extern crate serialize;
extern crate toml = "github.com/mneumann/rust-toml#toml:0.1";
use std::os;
#[deriving(ToStr,Decodable)]
struct Config {
host: ~str,
port: Option<uint>,
ids: ~[uint],
products: ~[Product]
}
#[deriving(ToStr,Decodable)]
struct Product {
id: uint,
name: ~str
}
fn main() ... | extern crate serialize;
extern crate toml = "github.com/mneumann/rust-toml#toml:0.1";
use std::os;
#[deriving(Show,Decodable)]
struct Config {
host: ~str,
port: Option<uint>,
ids: ~[uint],
products: ~[Product]
}
#[deriving(Show,Decodable)]
struct Product {
id: uint,
name: ~str
}
fn main() {
... | Change ToStr to Show in examples | Change ToStr to Show in examples
| Rust | mit | mneumann/rust-toml |
685444008bb2631564b56068bcbf2462bf0cc6af | src/test/rustdoc-ui/coverage/allow_missing_docs.rs | src/test/rustdoc-ui/coverage/allow_missing_docs.rs | // compile-flags:-Z unstable-options --show-coverage
// check-pass
//! Make sure to have some docs on your crate root
#[allow(missing_docs)]
pub mod mod_foo {
pub struct Bar;
}
/// This is a struct with a `#[allow(missing_docs)]`
pub struct AllowTheMissingDocs {
#[allow(missing_docs)]
pub empty_str: Stri... | // compile-flags:-Z unstable-options --show-coverage
// check-pass
//! Make sure to have some docs on your crate root
#[allow(missing_docs)]
pub mod mod_foo {
pub struct Bar;
}
/// This is a struct with a `#[allow(missing_docs)]`
pub struct AllowTheMissingDocs {
#[allow(missing_docs)]
pub empty_str: Stri... | Extend test to ensure that items inherit lint level from the parent | Extend test to ensure that items inherit lint level from the parent
| Rust | apache-2.0 | graydon/rust,graydon/rust,aidancully/rust,graydon/rust,graydon/rust,aidancully/rust,aidancully/rust,aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,aidancully/rust |
c3b7a6e350044e230490880068497606d57058bd | src/main.rs | src/main.rs | //
// Copyright:: Copyright (c) 2015 Chef Software, Inc.
// License:: Apache License, Version 2.0
//
// 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... | //
// Copyright:: Copyright (c) 2015 Chef Software, Inc.
// License:: Apache License, Version 2.0
//
// 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... | Make `make clean build` work again by removing regex_macros | Make `make clean build` work again by removing regex_macros
- we don't seem to use the `regex!` macro
- `make clean build` fails me with trying to find the `regex_macros` crate
- `make clean build` with this change succeeds with rustc 1.12.0 and 1.14.0
So, I think we should remove that.
| Rust | apache-2.0 | chef/delivery-cli,chef/delivery-cli,chef/delivery-cli |
56377fc4f8ccbf7e186ac4f6716e54a9b44b05f9 | src/rust_string.rs | src/rust_string.rs | use alloc::string::String;
use core::mem;
#[repr(C)]
pub struct RustString {
repr: String,
}
impl RustString {
pub fn from(s: String) -> Self {
RustString { repr: s }
}
pub fn from_ref(s: &String) -> &Self {
unsafe { &*(s as *const String as *const RustString) }
}
pub fn from... | use alloc::string::String;
use core::mem::{self, MaybeUninit};
// ABI compatible with C++ rust::String (not necessarily alloc::string::String).
#[repr(C)]
pub struct RustString {
repr: [MaybeUninit<usize>; mem::size_of::<String>() / mem::size_of::<usize>()],
}
impl RustString {
pub fn from(s: String) -> Self ... | Resolve improper ctype lint affecting RustString | Resolve improper ctype lint affecting RustString
| Rust | apache-2.0 | dtolnay/cxx,dtolnay/cxx,dtolnay/cxx,dtolnay/cxx |
72676ca5aabb2b0b851010d355af4bfb38a776a3 | src/main.rs | src/main.rs | extern crate icecore;
use icecore::data::FileStore;
use icecore::data::DataStore;
fn main() {
let foo = "bar";
let store = FileStore::new(String::from_str("_documents"));
store.write(foo.as_bytes());
}
| extern crate icecore;
use icecore::data::{FileStore, DataStore};
use getopts::{optopt, getopts};
use std::os;
fn insert(data: &str) {
let store = FileStore::new("./_documents");
store.write(foo.as_bytes());
}
fn main() {
let args: Vec<String> = os::args();
match args[1].as_slice() {
"inser... | Split the insert with arguements | Split the insert with arguements
| Rust | mit | jacquesrott/icecore,jacquesrott/icecore |
54bc97987de19ab41d3f712028799fe15533adc5 | src/main.rs | src/main.rs | extern crate ghoti;
extern crate getopts;
use getopts::Options;
use ghoti::correction;
use std::env;
fn print_usage(opts: Options) {
let usage = "Usage: ghoti [options] <word>";
print!("{}", opts.usage(usage));
}
fn main() {
// Set up CLI options
let mut opts = Options::new();
opts.optflag("h", ... | extern crate ghoti;
extern crate getopts;
use getopts::Options;
use ghoti::correction;
use std::env;
fn print_usage(opts: Options) {
let usage = "Usage: ghoti [options] <word>";
print!("{}", opts.usage(usage));
}
fn main() {
// Set up CLI options
let mut opts = Options::new();
opts.optflag("h", ... | Convert input to lowercase before correcting | Convert input to lowercase before correcting
| Rust | mit | iKevinY/ghoti.rs |
57f160b7eb39b60f6cb54c8f71b22545ca9104c4 | src/main.rs | src/main.rs | #[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_contrib;
mod airport_data;
mod path;
mod server_route;
use anyhow::{Context, Result};
use rocket::config::{Config, Environment};
use rocket_contrib::serve::StaticFiles;
#[rocket::main]
async fn main() -> Result<()> {
airport_data::ensure_updated... | #[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_contrib;
mod airport_data;
mod path;
mod server_route;
use anyhow::{Context, Result};
use rocket::config::{Config, Environment};
use rocket_contrib::serve::StaticFiles;
#[rocket::main]
async fn main() -> Result<()> {
let config = {
let e... | Load airport data after loading Rocket config | backend: Load airport data after loading Rocket config
This gives the user a faster feedback loop if they're testing different config settings.
| Rust | agpl-3.0 | Acizza/srfinder,Acizza/srfinder,Acizza/srfinder,Acizza/srfinder |
918c679d941d9384c6beee3db4487361b4a64b6e | lettre/examples/smtp.rs | lettre/examples/smtp.rs | extern crate lettre;
use lettre::{EmailTransport, SimpleSendableEmail};
use lettre::smtp::SmtpTransportBuilder;
fn main() {
let email = SimpleSendableEmail::new(
"user@localhost",
vec!["root@localhost"],
"file_id",
"Hello file",
);
// Open a local connection on port 25
... | extern crate lettre;
use lettre::{EmailTransport, SimpleSendableEmail};
use lettre::smtp::{SecurityLevel, SmtpTransportBuilder};
fn main() {
let email = SimpleSendableEmail::new(
"user@localhost",
vec!["root@localhost"],
"file_id",
"Hello ß☺ example",
);
// Open a local co... | Use utf-8 chars in example email | feat(transport): Use utf-8 chars in example email
| Rust | mit | amousset/lettre,amousset/rust-smtp,lettre/lettre,amousset/lettre |
7ddb95428cce2957ae8837cc3161708cf9e6ee1c | test/com/facebook/buck/features/rust/testdata/cxx_with_rust_dep/morehello.rs | test/com/facebook/buck/features/rust/testdata/cxx_with_rust_dep/morehello.rs | extern "C" {
fn evenmorehello();
}
pub fn helloer() {
println!("I'm saying \"hello\" again!");
unsafe { evenmorehello() };
}
| extern "C" {
fn evenmorehello();
}
pub fn helloer() {
println!("I'm saying \"hello\" again!");
unsafe {
evenmorehello()
};
}
| Update formatter to rustfmt 2.0 | Update formatter to rustfmt 2.0
Reviewed By: zertosh
fbshipit-source-id: fac317220355b9e4b067199b05e36ab79ffcf802
| Rust | apache-2.0 | JoelMarcey/buck,JoelMarcey/buck,JoelMarcey/buck,JoelMarcey/buck,JoelMarcey/buck,JoelMarcey/buck,JoelMarcey/buck,JoelMarcey/buck,JoelMarcey/buck,JoelMarcey/buck,JoelMarcey/buck,JoelMarcey/buck,JoelMarcey/buck |
fa801fee9c5061ae2c6f9b6f10da9626dc4bc817 | image/src/main.rs | image/src/main.rs | #![feature(old_path)]
extern crate piston;
extern crate graphics;
extern crate sdl2_window;
extern crate opengl_graphics;
use std::old_path::*;
use std::cell::RefCell;
use opengl_graphics::{
GlGraphics,
OpenGL,
Texture,
};
use sdl2_window::Sdl2Window;
fn main() {
let opengl = OpenGL::_3_2;
let w... | extern crate piston;
extern crate graphics;
extern crate sdl2_window;
extern crate opengl_graphics;
use std::path::Path;
use std::cell::RefCell;
use opengl_graphics::{
GlGraphics,
OpenGL,
Texture,
};
use sdl2_window::Sdl2Window;
fn main() {
let opengl = OpenGL::_3_2;
let window = Sdl2Window::new(
... | Upgrade image example to new path | Upgrade image example to new path
| Rust | mit | dannyflax/piston-examples,Potpourri/piston-examples,Abica/piston-examples,sinistersnare/piston-examples,placrosse/piston-examples,carols10cents/piston-examples |
12e5c4d00e32a987f099b3e6929ec03d5ecf15eb | tests/lib.rs | tests/lib.rs | #![feature(test)]
extern crate test;
extern crate warc_parser;
mod tests{
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
fn read_sample_file(sample_name: &str) -> String{
let full_path = "sample/".to_string()+sample_name;
let mut f = File::op... | #![feature(test)]
extern crate test;
extern crate warc_parser;
mod tests{
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
fn read_sample_file(sample_name: &str) -> Vec<u8> {
let full_path = "sample/".to_string()+sample_name;
let mut f = File::... | Read test input as bytes instead of strings | Read test input as bytes instead of strings
| Rust | mit | sbeckeriv/warc_nom_parser |
5c42e3d6eace1c9088413a134c32ae98be6fd7c9 | tests/tga.rs | tests/tga.rs | extern crate image;
use std::io::File;
#[test]
fn test_open_and_save_tga() {
let path = Path::new("./tests/images/tga/testsuite/ctc24.tga");
let img = image::open(&path).unwrap();
let fout = File::create(&Path::new("./tests/output/tga-ctc24.png")).unwrap();
let _ = img.save(fout, image::PNG);
let... | extern crate image;
use std::io::{fs, File, USER_RWX};
#[test]
fn test_open_and_save_tga() {
let _ = fs::mkdir(&Path::new("./tests/output"), USER_RWX);
let path = Path::new("./tests/images/tga/testsuite/ctc24.tga");
let img = image::open(&path).unwrap();
let fout = File::create(&Path::new("./tests/out... | Fix tests, create output directory. | Fix tests, create output directory.
| Rust | mit | ruud-v-a/image,hetzge/image,lady-segfault/image,tomaka/image,TyOverby/rust-image,nwin/rust-image,PistonDevelopers/image,theotherphil/image,bvssvni/image,xanium4332/image,JaySon-Huang/image,dtwood/piston-image,huonw/image,PistonDevelopers/image,twoodford/image,mbrubeck/image |
13acc3385cacd2711733ecc664e2bc1b5dbf97cf | src/molecules.rs | src/molecules.rs | use atoms::*;
use molecule::*;
pub const WATER: &'static Molecule = &Molecule {
compounds: &[
MoleculeCompound { atom: HYDROGEN, amount: 2 },
MoleculeCompound { atom: OXYGEN, amount: 1 }
]
};
pub const TABLE_SALT: &'static Molecule = &Molecule {
compounds: &[
MoleculeCompound { ato... | use atoms::*;
use molecule::*;
pub const WATER: &'static Molecule<'static> = &Molecule {
compounds: &[
MoleculeCompound { atom: HYDROGEN, amount: 2 },
MoleculeCompound { atom: OXYGEN, amount: 1 }
]
};
pub const TABLE_SALT: &'static Molecule<'static> = &Molecule {
compounds: &[
Mole... | Fix build error on stable branch | Fix build error on stable branch
| Rust | mit | feroxide/feroxide,feroxide/feroxide |
78d47414a0a5476774a5232ec58901878757eda2 | src/macros.rs | src/macros.rs | macro_rules! steps {
($fut:ty { $($step:ident($ty:ty),)+ }) => (
enum Step {
$($step($ty),)+
}
enum Out {
$($step(<$ty as Future>::Item),)+
}
impl $fut {
fn either_poll(&mut self) -> Result<Async<Out>> {
match self.step {
... | macro_rules! steps {
($fut:ty { $($step:ident($ty:ty),)+ }) => (
enum Step {
$($step($ty),)+
}
enum Out {
$($step(<$ty as Future>::Item),)+
}
impl $fut {
fn either_poll(&mut self) -> Result<Async<Out>> {
match self.step {
... | Add example to params! docstring | Add example to params! docstring
| Rust | apache-2.0 | blackbeam/mysql_async |
55ef54e4bb4f2a69f80827d899a739f322ab323e | stylesheet.rs | stylesheet.rs | /*!
CSS stylesheets, owned types, immutable after creation
*/
use std::net::url::Url;
use util::DataStream;
pub struct Stylesheet {
inner: n::s::CssStylesheet
}
impl Stylesheet {
static fn new(url: Url, input: DataStream) -> Stylesheet {
Stylesheet {
inner: parser::parse_stylesheet(move u... | /*!
CSS stylesheets, owned types, immutable after creation
*/
use std::net::url::Url;
use util::DataStream;
pub struct Stylesheet {
inner: netsurfcss::stylesheet::CssStylesheet
}
impl Stylesheet {
static fn new(url: Url, input: DataStream) -> Stylesheet {
Stylesheet {
inner: parser::parse... | Stop relying on everything being reexported in netsurfcss | Stop relying on everything being reexported in netsurfcss
| Rust | mpl-2.0 | servo/rust-css |
f46d1974313c83886508088ff1beac3a107c3790 | tests/compile-fail/check_arg_count.rs | tests/compile-fail/check_arg_count.rs | #![feature(core_intrinsics)]
use std::intrinsics;
fn main() {
unsafe { intrinsics::forget(); } //~ ERROR this function takes 1 argument but 0 arguments were supplied
}
| #![feature(core_intrinsics)]
use std::intrinsics;
fn main() {
unsafe { intrinsics::forget(); } //~ ERROR this function takes 1 argument but 0 arguments were supplied
unsafe { intrinsics::forget(1, 2); } //~ ERROR this function takes 1 argument but 2 arguments were supplied
}
| Test for too many args. | Test for too many args.
| Rust | apache-2.0 | rust-lang/miri,rust-lang/miri,rust-lang/miri,rust-lang/miri |
bf529fb6e6c561e8adf7556dd52b542c8498b3c8 | src/test/run-pass/associated-const-outer-ty-refs.rs | src/test/run-pass/associated-const-outer-ty-refs.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 ... | Remove 'static bound in assoc const test. | Remove 'static bound in assoc const test.
Types do not have to be `'static` to be referenced in
associated consts.
| Rust | apache-2.0 | GBGamer/rust,aidancully/rust,graydon/rust,GBGamer/rust,GBGamer/rust,aidancully/rust,aidancully/rust,aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,graydon/rust,GBGamer/rust,GBGamer/rust,aidancully/rust,GBGamer/rust,GBGamer/rust,graydon/rust,graydon/rust,GBGamer/rust |
bc0d673af06e52be16ef8b5fa6c1d15217f40013 | src/deflate/deflater.rs | src/deflate/deflater.rs | use crate::atomicmin::AtomicMin;
use crate::{PngError, PngResult};
use libdeflater::{CompressionError, CompressionLvl, Compressor};
pub fn deflate(data: &[u8], max_size: &AtomicMin) -> PngResult<Vec<u8>> {
let mut compressor = Compressor::new(CompressionLvl::best());
let capacity = max_size.get().unwrap_or(dat... | use crate::atomicmin::AtomicMin;
use crate::{PngError, PngResult};
use libdeflater::{CompressionError, CompressionLvl, Compressor};
pub fn deflate(data: &[u8], max_size: &AtomicMin) -> PngResult<Vec<u8>> {
let mut compressor = Compressor::new(CompressionLvl::best());
let capacity = max_size.get().unwrap_or(dat... | Fix a hard error in clippy | Fix a hard error in clippy
| Rust | mit | shssoichiro/oxipng,shssoichiro/oxipng,shssoichiro/oxipng |
6450ee91beada599a86f0020e438608ca2a13850 | src/test/run-pass/cfgs-on-items.rs | src/test/run-pass/cfgs-on-items.rs | // Copyright 2012 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 2012 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 pretty printing for cfg test. | Fix pretty printing for cfg test.
| Rust | apache-2.0 | zubron/rust,ebfull/rust,kimroen/rust,mdinger/rust,pythonesque/rust,gifnksm/rust,SiegeLord/rust,vhbit/rust,emk/rust,aneeshusa/rust,jroesch/rust,michaelballantyne/rust-gpu,bombless/rust,pshc/rust,andars/rust,barosl/rust,rprichard/rust,ktossell/rust,ktossell/rust,carols10cents/rust,cllns/rust,stepancheg/rust-ide-rust,clln... |
3ce9d5c26982ff0516946dda7fa8d29580fa25b3 | src/test/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.rs | src/test/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.rs | #![feature(unsafe_block_in_unsafe_fn)]
#![warn(unsafe_op_in_unsafe_fn)]
#![deny(unused_unsafe)]
unsafe fn unsf() {}
unsafe fn foo() {
unsf();
//~^ WARNING call to unsafe function is unsafe and requires unsafe block
}
unsafe fn bar() {
unsafe { unsf() } // no error
}
unsafe fn baz() {
unsafe { unsafe... | #![feature(unsafe_block_in_unsafe_fn)]
#![warn(unsafe_op_in_unsafe_fn)]
#![deny(unused_unsafe)]
#![deny(safe_packed_borrows)]
unsafe fn unsf() {}
const PTR: *const () = std::ptr::null();
static mut VOID: () = ();
#[repr(packed)]
pub struct Packed {
data: &'static u32,
}
const PACKED: Packed = Packed { data: &0 }... | Add more cases to the test | Add more cases to the test
| Rust | apache-2.0 | aidancully/rust,graydon/rust,aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,graydon/rust,aidancully/rust,graydon/rust,graydon/rust,aidancully/rust,aidancully/rust |
eca6d6504741a05f1a436d37fc81c982e9f476a2 | src/snipcode_triangulation_app.rs | src/snipcode_triangulation_app.rs |
// Extern crates.
use piston::*;
use graphics::*;
// Local crate.
use test_colors;
use test_polygons;
use conversion;
use snipcode_triangulation;
pub struct App;
impl Game for App {
fn render(&self, c: &Context, gl: &mut Gl) {
let polygon = test_polygons::SQUARE_CLOCKWISE;
let polygon = conversi... |
// Extern crates.
use piston::*;
use graphics::*;
use glfw;
// Local crate.
use test_colors;
use test_polygons;
use conversion;
use snipcode_triangulation;
pub struct App {
test_polygon_index: uint,
}
impl Game for App {
fn render(&self, c: &Context, gl: &mut Gl) {
let polygon = test_polygons::ALL[s... | Change polygon with up/down arrow keys | Change polygon with up/down arrow keys
| Rust | mit | PistonDevelopers/graphics-lab |
9e5bda6c92881f4bfe178f219d6281b24c49dde7 | examples/warp.rs | examples/warp.rs | #![deny(warnings)]
#[macro_use]
extern crate rust_embed;
extern crate warp;
use std::borrow::Cow;
use warp::{filters::path::Tail, http::Response, Filter, Rejection, Reply};
#[derive(RustEmbed)]
#[folder = "examples/public/"]
struct Asset;
fn main() {
let index_hml = warp::get2().and(warp::path::end()).and_then(||... | #![deny(warnings)]
#[macro_use]
extern crate rust_embed;
extern crate warp;
use std::borrow::Cow;
use warp::{filters::path::Tail, http::Response, Filter, Rejection, Reply};
#[derive(RustEmbed)]
#[folder = "examples/public/"]
struct Asset;
fn main() {
let index_hml = warp::get2().and(warp::path::end()).and_then(||... | Fix mime_guess error in Warp example | Fix mime_guess error in Warp example
Signed-off-by: Mcat12 <e5fb9e52b4630b5e6ff37359b0ce008b386ead24@yahoo.com>
| Rust | mit | pyros2097/rust-embed |
0d563378304d11654ee863f543fc947ef5228e36 | src/plain_formatter.rs | src/plain_formatter.rs | use formatter::RdbParseFormatter;
use std::io;
pub struct PlainFormatter {
out: Box<Writer+'static>
}
impl PlainFormatter {
pub fn new() -> PlainFormatter {
let out = box io::stdout() as Box<Writer>;
PlainFormatter { out: out }
}
}
impl RdbParseFormatter for PlainFormatter {
fn start_... | use formatter::RdbParseFormatter;
use std::io;
pub struct PlainFormatter {
out: Box<Writer+'static>
}
impl PlainFormatter {
pub fn new() -> PlainFormatter {
let out = box io::stdout() as Box<Writer>;
PlainFormatter { out: out }
}
}
impl RdbParseFormatter for PlainFormatter {
fn start_... | Write auxiliary fields as they are | Write auxiliary fields as they are
| Rust | mit | badboy/rdb-rs,badboy/rdb-rs,kbknapp/rdb-rs,kbknapp/rdb-rs,badboy/rdb-rs,kbknapp/rdb-rs |
0bca925552f8318e724be427d9df0bc82ec7bc03 | rust/wordcount.rs | rust/wordcount.rs | use std::collections::BTreeMap;
use std::io;
use std::io::BufRead;
fn main() {
let mut counts: BTreeMap<String, isize> = BTreeMap::new();
let stdin = io::stdin();
for line_result in stdin.lock().lines() {
if let Ok(line) = line_result {
let lowercase_line = line.to_lowercase();
... | use std::collections::BTreeMap;
use std::io;
use std::io::BufRead;
fn main() {
let mut counts: BTreeMap<String, isize> = BTreeMap::new();
let stdin = io::stdin();
for line_result in stdin.lock().lines() {
match line_result {
Ok(line) => {
let lowercase_line = line.to_low... | Use match instead of if let | Use match instead of if let
| Rust | mit | rtoal/ple,rtoal/ple,rtoal/ple,rtoal/ple,rtoal/polyglot,rtoal/ple,rtoal/polyglot,rtoal/ple,rtoal/ple,rtoal/ple,rtoal/polyglot,rtoal/ple,rtoal/ple,rtoal/polyglot,rtoal/polyglot,rtoal/ple,rtoal/polyglot,rtoal/ple,rtoal/polyglot,rtoal/polyglot,rtoal/polyglot,rtoal/ple,rtoal/polyglot,rtoal/polyglot,rtoal/polyglot,rtoal/ple,... |
352f41ed40eb840bc73566051d09535ac4a2306c | src/derive/mod.rs | src/derive/mod.rs | extern crate syn;
use std::env;
use std::fs::File;
use std::io::{Write, BufWriter};
use syn::DeriveInput;
pub fn generate_elm(ast: &DeriveInput) {
let mut path = env::current_dir().unwrap();
let name = &ast.ident;
path.push(format!("generated/{}.elm", name));
let file = File::create(path).unwrap();
... | extern crate syn;
use std::env;
use std::fs::{File, create_dir};
use std::io::{Write, BufWriter};
use syn::DeriveInput;
pub fn generate_elm(ast: &DeriveInput) {
let mut path = env::current_dir().unwrap();
path.push("generated");
if path.exists() && path.is_file() { panic!("expecting \"generated\" to be a ... | Create generated directory unless it is already created | Create generated directory unless it is already created
| Rust | mit | mijnadres/serde_elm |
366ee3d7e00fa6265e7b15c89e3560ef7f63e02d | src/engine/map.rs | src/engine/map.rs | use engine::{IntoMap, Tile};
use util::units::{Point, Size};
use std::path::AsPath;
use std::fs::File;
use std::io::Read;
pub struct Map {
pub tiles: Vec<Vec<Tile>>,
pub size: Size,
}
impl Map {
pub fn new<T>(maplike: T) -> Map where T: IntoMap {
let result = maplike.as_map();
let map =... | use engine::{IntoMap, Tile};
use util::units::{Point, Size};
use std::path::AsPath;
use std::fs::File;
use std::io::Read;
pub struct Map {
pub tiles: Vec<Vec<Tile>>,
pub size: Size,
}
impl Map {
pub fn new<T>(maplike: T) -> Map where T: IntoMap {
maplike.as_map().unwrap()
}
pub fn from_... | Remove an antipattern better represented with 'unwrap' | Remove an antipattern better represented with 'unwrap'
Grabbing a result value and panicking on Err is the semantics of unwrap,
and does not require a dedicated match statement
| Rust | bsd-3-clause | jgilchrist/rslike |
ccbdbd5616ec4770250154399390ae12cf053b9d | src/connecter.rs | src/connecter.rs | use getopts::{Options,Matches};
use std::net::{TcpStream,SocketAddr};
use std::io::{BufStream,Write};
use std::old_io;
pub fn connect(matches: &Matches) {
let host = matches.free.get(0).unwrap();
let port = match matches.free.get(1).unwrap().parse::<u16>() {
Ok(n) => { n }
Err(_) => {
... | use getopts::{Options,Matches};
use std::net::{TcpStream,SocketAddr};
use std::io::{BufStream,Write};
use std::old_io;
pub fn connect(matches: &Matches) {
let host = matches.free.get(0).unwrap();
let port = match matches.free.get(1).unwrap().parse::<u16>() {
Ok(n) => { n }
Err(_) => {
... | Replace peer_addr hack with flush hack. To determine whether other end has closed socket -- still can't figure out a better way to do this, and terminate immediately as `nc(1)` does. | Replace peer_addr hack with flush hack.
To determine whether other end has closed socket -- still can't figure
out a better way to do this, and terminate immediately as `nc(1)` does.
| Rust | mit | lukeasrodgers/rust-nc |
f1fc95bc81d965d92dbb3469d65d155ad6143589 | crossbeam-channel/examples/stopwatch.rs | crossbeam-channel/examples/stopwatch.rs | //! Prints the elapsed time every 1 second and quits on Ctrl+C.
#[macro_use]
extern crate crossbeam_channel;
extern crate signal_hook;
use std::io;
use std::thread;
use std::time::{Duration, Instant};
use crossbeam_channel::{tick, unbounded, Receiver};
use signal_hook::iterator::Signals;
use signal_hook::SIGINT;
//... | //! Prints the elapsed time every 1 second and quits on Ctrl+C.
#[macro_use]
extern crate crossbeam_channel;
extern crate signal_hook;
use std::io;
use std::thread;
use std::time::{Duration, Instant};
use crossbeam_channel::{bounded, tick, Receiver};
use signal_hook::iterator::Signals;
use signal_hook::SIGINT;
// C... | Use a bounded channel for signals | Use a bounded channel for signals | Rust | apache-2.0 | crossbeam-rs/crossbeam,crossbeam-rs/crossbeam,crossbeam-rs/crossbeam,aturon/crossbeam,crossbeam-rs/crossbeam |
cf66aac05db2c3b25a464d3e2413ef8e81eed9bd | src/io/mod.rs | src/io/mod.rs | //! Definition of types, traits, ... for I/O functionality
| //! Definition of types, traits, ... for I/O functionality
use core::result;
pub type Result<T> = result::Result<T, ()>;
pub trait Read {
fn read(&mut self, buf: &mut [u8]) -> Result<usize>;
}
pub trait Write {
fn write(&mut self, buf: &[u8]) -> Result<usize>;
fn flush(&mut self) -> Result<()>;
}
| Add traits Read and Write | io: Add traits Read and Write
| Rust | mit | uni-rs/uni.rs |
60895adb980455249d11662b8b670d759330f6cc | src/support/src/arm.rs | src/support/src/arm.rs | use core::intrinsics::*;
use core::ops::FnOnce;
#[cfg(not(test))]
#[inline(always)]
/// NOP instruction
pub fn nop() {
unsafe { asm!("nop" :::: "volatile"); }
}
#[cfg(test)]
/// NOP instruction (mock)
pub fn nop() {
}
#[cfg(not(test))]
#[inline(always)]
/// WFI instruction
pub unsafe fn wfi() {
asm!("wfi" ::::... | use core::intrinsics::*;
use core::ops::FnOnce;
#[cfg(not(test))]
#[inline(always)]
/// NOP instruction
pub fn nop() {
unsafe { asm!("nop" :::: "volatile"); }
}
#[cfg(test)]
/// NOP instruction (mock)
pub fn nop() {
}
#[cfg(not(test))]
#[inline(always)]
/// WFI instruction
pub unsafe fn wfi() {
asm!("wfi" ::::... | Remove stale definitions for __aeabi_unwind_cpp_* | Remove stale definitions for __aeabi_unwind_cpp_*
| Rust | apache-2.0 | google/tock-on-titan,google/tock-on-titan,google/tock-on-titan |
58758f0275172da24ee311e354cd9a7fe79c6e39 | compiler/rustc_data_structures/src/macros.rs | compiler/rustc_data_structures/src/macros.rs | /// Type size assertion. The first argument is a type and the second argument is its expected size.
#[macro_export]
macro_rules! static_assert_size {
($ty:ty, $size:expr) => {
const _: [(); $size] = [(); ::std::mem::size_of::<$ty>()];
};
}
#[macro_export]
macro_rules! enum_from_u32 {
($(#[$attr:met... | /// Type size assertion. The first argument is a type and the second argument is its expected size.
#[macro_export]
macro_rules! static_assert_size {
($ty:ty, $size:expr) => {
const _: [(); $size] = [(); ::std::mem::size_of::<$ty>()];
};
}
#[macro_export]
macro_rules! enum_from_u32 {
($(#[$attr:met... | Allow variant attributes in `enum_from_u32!` | Allow variant attributes in `enum_from_u32!`
| Rust | apache-2.0 | aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,graydon/rust,aidancully/rust,graydon/rust,graydon/rust,graydon/rust,aidancully/rust,aidancully/rust,aidancully/rust |
101f83ecef7e71a1c6b81795c81ce7fb85333c77 | src/test/run-pass/bind-native-fn.rs | src/test/run-pass/bind-native-fn.rs | // From #1174:
// xfail-test bots are crashing on this on x86_64
use std;
import str;
import libc::*;
#[nolink]
native mod libc {
fn write(fd: c_int, buf: *u8, nbyte: size_t);
}
fn main() {
let s = "hello world\n";
let b = str::bytes(s);
let l = str::len(s);
let b8 = unsafe { vec::unsafe::to_ptr(... | // From #1174:
use std;
import str;
import libc::*;
#[nolink]
native mod libc {
fn write(fd: core::libc::c_int, buf: *u8, nbyte: core::libc::size_t);
}
fn main() {
let s = "hello world\n";
let b = str::bytes(s);
let l = str::len(s);
let b8 = unsafe { vec::unsafe::to_ptr(b) };
libc::write(0i32... | Fix a missing un-xfailed case | Fix a missing un-xfailed case
Issue #1230
| Rust | apache-2.0 | nham/rust,pshc/rust,AerialX/rust,ktossell/rust,reem/rust,jbclements/rust,omasanori/rust,sarojaba/rust-doc-korean,XMPPwocky/rust,quornian/rust,graydon/rust,cllns/rust,LeoTestard/rust,GrahamDennis/rand,fabricedesre/rust,aneeshusa/rust,graydon/rust,jashank/rust,andars/rust,mvdnes/rust,ejjeong/rust,kimroen/rust,waynenilsen... |
bda03a95fcdd21552a7e04843d377f06fef03b93 | enum-map/tests/bool.rs | enum-map/tests/bool.rs | #![no_std]
#[macro_use]
extern crate enum_map;
#[test]
fn test_bool() {
let mut map = enum_map! { false => 24, true => 42 };
assert_eq!(map[false], 24);
assert_eq!(map[true], 42);
map[false] += 1;
assert_eq!(map[false], 25);
for (key, item) in &mut map {
if !key {
*item += ... | #[macro_use]
extern crate enum_map;
#[test]
fn test_bool() {
let mut map = enum_map! { false => 24, true => 42 };
assert_eq!(map[false], 24);
assert_eq!(map[true], 42);
map[false] += 1;
assert_eq!(map[false], 25);
for (key, item) in &mut map {
if !key {
*item += 1;
}... | Test if keys are correctly serialized for Option<T> | Test if keys are correctly serialized for Option<T>
| Rust | apache-2.0 | xfix/enum-map |
3febd0507c9feff5bc3df4eff94922303df5304f | src/sdl2/macros.rs | src/sdl2/macros.rs | macro_rules! impl_raw_accessors(
($(($t:ty, $raw:ty)),+) => (
$(
impl $t {
#[inline]
pub fn raw(&self) -> $raw { self.raw }
}
)+
)
);
macro_rules! impl_owned_accessors(
($(($t:ty, $owned:ident)),+) => (
$(
impl $t {
#[inlin... | macro_rules! impl_raw_accessors(
($(($t:ty, $raw:ty)),+) => (
$(
impl $t {
#[inline]
pub unsafe fn raw(&self) -> $raw { self.raw }
}
)+
)
);
macro_rules! impl_owned_accessors(
($(($t:ty, $owned:ident)),+) => (
$(
impl $t {
... | Mark raw() and owned() accessors as unsafe. | Mark raw() and owned() accessors as unsafe.
We don't want to encourage casual use of these functions from user
code; raw pointers and ffi interop are inherently unsafe.
| Rust | mit | inrustwetrust/rust-sdl2,Rust-SDL2/rust-sdl2,AngryLawyer/rust-sdl2,beni55/rust-sdl2,bfops/rust-sdl2,Rust-SDL2/rust-sdl2,vadixidav/rust-sdl2,caldwell/rust-sdl2,Cobrand/rust-sdl2,PistonDevelopers/rust-sdl2,Cobrand/rust-sdl2,Rust-SDL2/rust-sdl2,wilsoniya/rust-sdl2,nukep/rust-sdl2,crumblingstatue/rust-sdl2,tempbottle/rust-s... |
f15614a1c88026ccfe8ef901a2e4f815f879e159 | src/write.rs | src/write.rs | use SChunks;
use std::fs::File;
use std::io::{Error, Write};
/// This function takes as parameter a file name and a vector of chaunks.
/// The function will create a file, and append to the buffer each chunk.
pub fn write_file(local_file: &mut File, chunks: &SChunks) -> Result<(), Error> {
// Get the access to th... | use SChunks;
use std::fs::File;
use std::io::{Error, Write};
/// This function fills the buffer of a given local file, with the content of chunks.
pub fn write_file(local_file_buf: &mut File, chunks: &SChunks) -> Result<(), Error> {
// Get the access to the chunks
let chunks_m = chunks.lock().unwrap();
/... | Update the module, comments from @jean-serge | Update the module, comments from @jean-serge
| Rust | mit | derniercri/snatch |
6c9d685019fdd85a8aeaeee0cbbb82472563aac6 | src/portable.rs | src/portable.rs | use std::io;
use std::path::Path;
#[cfg(windows)]
use crate::fs::_remove_dir_contents;
#[cfg(not(windows))]
use crate::unix::_remove_dir_contents;
/// Deletes the contents of `dir_path`, but not the directory iteself.
///
/// If `dir_path` is a symlink to a directory, deletes the contents
/// of that directory. Fai... | use std::io;
use std::path::Path;
#[cfg(windows)]
use crate::fs::_remove_dir_contents;
#[cfg(not(windows))]
use crate::unix::_remove_dir_contents;
/// Deletes the contents of `dir_path`, but not the directory iteself.
///
/// If `dir_path` is a symlink to a directory, deletes the contents
/// of that directory. Fai... | Add test case for remove_dir_contents | Add test case for remove_dir_contents
We check a few error behaviours too.
Signed-off-by: Ian Jackson <d68d4287c1430ca128ad85033356c9d259238c74@chiark.greenend.org.uk>
| Rust | apache-2.0 | XAMPPRocky/remove_dir_all |
5dcce6a9655f3579b64404feeb7a41d0f7368394 | examples/markup.rs | examples/markup.rs | extern crate cursive;
use cursive::Cursive;
use cursive::utils::markup::MarkdownText;
use cursive::views::{Dialog, TextView};
// Make sure you compile with the `markdown` feature!
//
// cargo run --example markup --features markdown
fn main() {
let mut siv = Cursive::new();
let text = MarkdownText("Isn't *t... | extern crate cursive;
use cursive::Cursive;
#[cfg(feature = "markdown")]
use cursive::utils::markup::MarkdownText;
use cursive::views::{Dialog, TextView};
// Make sure you compile with the `markdown` feature!
//
// cargo run --example markup --features markdown
fn main() {
let mut siv = Cursive::new();
#[cf... | Fix example without markdown feature | Fix example without markdown feature
| Rust | mit | Gyscos/Cursive |
21b9d5f852b85742f9dde5b90d344662fb507567 | rust/luhn/src/lib.rs | rust/luhn/src/lib.rs | pub fn is_valid(id: &str) -> bool {
// check the length
if id.len() < 2 {
return false;
}
let mut index: u32 = 0;
let mut sum: u32 = 0;
for c in id.chars().rev() {
if c.is_whitespace() {
continue;
}
let mut v: u32;
match c.to_digit(10) {
... | pub fn is_valid(id: &str) -> bool {
// check the length
if id.len() < 2 {
return false;
}
let mut index: u32 = 0;
let mut sum: u32 = 0;
for c in id.chars().rev() {
if c.is_whitespace() {
continue;
}
let mut v: u32;
if let Some(d) = c.to_dig... | Use if let to replace match | Use if let to replace match
Seems if let is idiomatic
| Rust | bsd-2-clause | gyn/exercism,gyn/exercism,gyn/exercism,gyn/exercism |
46ff816459f3a34cbdf324d760914a6d018dcbe0 | src/lib.rs | src/lib.rs | pub mod SessionHandler {
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
use std::env;
pub fn create(profile_name: &str) {
println!("Creating session for profile \"{}\"...", profile_name);
println!("{}",read_aws_config_file());
}
pub fn show() {
... | extern crate rusoto_core;
extern crate rusoto_sts;
extern crate rusoto_dynamodb;
pub mod SessionHandler {
use rusoto_core::{DefaultCredentialsProvider, Region};
use rusoto_core::{default_tls_client, ProfileProvider, ProvideAwsCredentials};
use rusoto_sts::{StsClient, StsAssumeRoleSessionCredentialsProvider... | Update create session function with small sts example | Update create session function with small sts example
| Rust | mit | amongil/bluenine |
d252d0ad5434bcf77076729ab766eeff98f20ead | src/test/run-pass/x86stdcall.rs | src/test/run-pass/x86stdcall.rs | // Copyright 2012-2015 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-2015 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... | Test fixes and rebase conflicts, round 4 | Test fixes and rebase conflicts, round 4
| Rust | apache-2.0 | jroesch/rust,pelmers/rust,miniupnp/rust,gifnksm/rust,zachwick/rust,philyoon/rust,zachwick/rust,l0kod/rust,jroesch/rust,pshc/rust,cllns/rust,ruud-v-a/rust,graydon/rust,KokaKiwi/rust,KokaKiwi/rust,ebfull/rust,cllns/rust,mvdnes/rust,pelmers/rust,victorvde/rust,philyoon/rust,avdi/rust,jroesch/rust,zachwick/rust,mihneadb/ru... |
ccb77e66643a76974371fa038e6c3abf597ab14e | tests/compiletest.rs | tests/compiletest.rs | #[rustversion::attr(not(nightly), ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
}
| #[rustversion::attr(not(nightly), ignore)]
#[cfg_attr(miri, ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
}
| Exclude ui tests from cargo miri test | Exclude ui tests from cargo miri test
| Rust | apache-2.0 | dtolnay/anyhow |
2a7906e8c1ff2d2fd5fee31dbf778c340e50c832 | mod_path/lib.rs | mod_path/lib.rs | #![feature(plugin_registrar, quote, rustc_private)]
extern crate syntax;
extern crate rustc;
use syntax::codemap::Span;
use syntax::parse::token;
use syntax::ast::{TokenTree, Ident};
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager, IdentTT, get_single_str_from_tts};
use syntax::util::small_vector::S... | #![feature(plugin_registrar, quote, rustc_private)]
extern crate syntax;
extern crate rustc;
extern crate rustc_plugin;
use syntax::codemap::Span;
use syntax::parse::token;
use syntax::ast::{TokenTree, Ident};
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager, IdentTT, get_single_str_from_tts};
use sy... | Update mod_path for Rust nightly | Update mod_path for Rust nightly
| Rust | mit | SimonSapin/rust-std-candidates |
cfe2d2a6894e0ff2f7c8b10b11de275955cfdfc1 | linkhack.rs | linkhack.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/. */
// Some crumminess to make sure we link correctly
#[cfg(target_os = "linux")]
#[link(name = "azure")]
#[link(name... | /* 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/. */
// Some crumminess to make sure we link correctly
#[cfg(target_os = "linux")]
#[link(name = "azure")]
#[link(name... | Fix fontconfig / expat link order | Fix fontconfig / expat link order
| Rust | mpl-2.0 | Adenilson/rust-azure,dzbarsky/rust-azure,mrobinson/rust-azure,notriddle/rust-azure,mrobinson/rust-azure,servo/rust-azure,nox/rust-azure,akiss77/rust-azure,dzbarsky/rust-azure,nox/rust-azure,akiss77/rust-azure,akiss77/rust-azure,mmatyas/rust-azure,servo/rust-azure,vvuk/rust-azure,vvuk/rust-azure,mmatyas/rust-azure,servo... |
6a677478e754b1e042356763ef2a52aa5525d8de | rust/run-length-encoding/src/lib.rs | rust/run-length-encoding/src/lib.rs | pub fn encode(text: &str) -> String {
if text.is_empty() {
return "".to_string();
}
let mut last = text.chars().nth(0).unwrap();
let mut count = 0;
let mut result = String::new();
for c in text.chars() {
if c == last {
count += 1;
continue;
}
... | pub fn encode(text: &str) -> String {
let mut count = 0;
let mut result = String::new();
let mut iter = text.chars().peekable();
while let Some(c) = iter.next() {
count += 1;
if iter.peek() != Some(&c) {
if count > 1 {
result.push_str(&count.to_string());
... | Use peekable to simplify rust code for run-length-encoding | Use peekable to simplify rust code for run-length-encoding
It is a good solution to check next element by peek function
| Rust | bsd-2-clause | gyn/exercism,gyn/exercism,gyn/exercism,gyn/exercism |
fd7739c9d4d9b9e5fe449e80ad2b27f2215c3603 | 23_closures/src/main.rs | 23_closures/src/main.rs | fn main() {
println!("Hello, world!");
}
| use std::thread;
use std::time::Duration;
fn main() {
simulated_expensive_calculation(2);
}
fn simulated_expensive_calculation(intensity: i32) -> i32 {
println!("Very expensive calculation...");
thread::sleep(Duration::from_secs(2));
intensity
} | Implement function that will simulate expensive calculation | Implement function that will simulate expensive calculation
| Rust | mit | pgrzesik/learning-rust |
76f2145d90025d1a0f6273548f85d7536d0a409a | src/combos.rs | src/combos.rs | use cards::Card;
// All these functions need reverse sorted vectors of Cards
pub fn has_pair(card_vec: &Vec<&Card>) -> bool {
has_set(2, card_vec)
}
fn has_set(set_size: u8, card_vec: &Vec<&Card>) -> bool {
let mut prev: &Card = card_vec[0];
let mut count: u8 = 1;
for card in card_vec.iter().skip(1) {... | use cards::Card;
// All these functions need sorted vectors of Cards
pub fn has_pair<'r>(card_vec: &'r Vec<&Card>) -> Option<&'r Card> {
has_set(2, card_vec)
}
fn has_set<'r>(set_size: u8, card_vec: &'r Vec<&Card>) -> Option<&'r Card> {
let mut prev: &&Card = match card_vec.last() {
Some(x) => x,
... | Change has_set to return an option with the found set | Change has_set to return an option with the found set
| Rust | mit | JelteF/pokers |
fc04e3d0fd90b9fc2897df2f27245960b9151b10 | example/src/main.rs | example/src/main.rs | extern crate includedir;
extern crate phf;
include!(concat!(env!("OUT_DIR"), "/data.rs"));
fn main() {
println!("{:?}", FILES.get("data/foo"));
for name in FILES.file_names() {
println!("Found: {}", name);
}
}
#[test]
fn test() {
assert_eq!(FILES.get("data/foo").expect("data/foo not present"... | extern crate includedir;
extern crate phf;
include!(concat!(env!("OUT_DIR"), "/data.rs"));
fn main() {
println!("{:?}", FILES.get("data/foo"));
for name in FILES.file_names() {
println!("Found: {}", name);
}
}
#[test]
fn test() {
assert_eq!(FILES.get("data/foo").expect("data/foo not present"... | Fix test by sorting vector | Fix test by sorting vector
| Rust | bsd-3-clause | tilpner/includedir |
aaf902bf8ff406f1dd300ad86b4fb5eeccb4fbe9 | src/test/ui/consts/try-operator.rs | src/test/ui/consts/try-operator.rs | // run-pass
#![feature(try_trait_v2)]
#![feature(const_trait_impl)]
#![feature(const_try)]
#![feature(const_convert)]
fn main() {
const fn foo() -> Result<bool, ()> {
Err(())?;
Ok(true)
}
const FOO: Result<bool, ()> = foo();
assert_eq!(Err(()), FOO);
}
| // run-pass
#![feature(try_trait_v2)]
#![feature(const_trait_impl)]
#![feature(const_try)]
#![feature(const_convert)]
fn main() {
const fn result() -> Result<bool, ()> {
Err(())?;
Ok(true)
}
const FOO: Result<bool, ()> = result();
assert_eq!(Err(()), FOO);
const fn option() -> Op... | Add test for try operator with Option | Add test for try operator with Option
| Rust | apache-2.0 | aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,graydon/rust,aidancully/rust,aidancully/rust,aidancully/rust,graydon/rust,graydon/rust,aidancully/rust,graydon/rust |
15a512fa46592bad0fdd195ad067da2582175a91 | src/test/mod.rs | src/test/mod.rs | use super::*;
mod bad;
mod doubled_bytes;
mod ignore_garbage;
mod pairs;
mod single_bytes;
mod wrap;
#[cfg(feature = "nightly")]
mod bench;
#[test]
// this doesn't really fit anywhere else
fn correct_b2s_types() {
#[cfg(feature = "fnv")]
let _: &::fnv::FnvBuildHasher = BLOCK_START_TO_INDEX.hasher();
#[cf... | use super::*;
mod bad;
mod doubled_bytes;
mod ignore_garbage;
mod pairs;
mod single_bytes;
mod wrap;
#[cfg(feature = "nightly")]
mod bench;
#[test]
fn correct_b2s_types() {
#[cfg(feature = "fnv")]
let _: &::fnv::FnvBuildHasher = BLOCK_START_TO_INDEX.hasher();
#[cfg(not(feature = "fnv"))]
let _: &::st... | Add Send + Sync tests for Error and WrapOptions | Add Send + Sync tests for Error and WrapOptions
| Rust | apache-2.0 | nuew/base65536 |
9d298ddb56a8b7255f4d9aef90d2a39d1c1bfaed | src/lib.rs | src/lib.rs | #![feature(plugin_registrar, quote)]
#![feature(rustc_private)]
extern crate rustc;
extern crate syntax;
extern crate rustc_serialize;
use rustc::plugin::Registry;
mod plugin;
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_macro("json", plugin::expand);
}
| #![feature(plugin_registrar, quote)]
#![feature(rustc_private)]
extern crate rustc;
extern crate rustc_plugin;
extern crate syntax;
extern crate rustc_serialize;
use rustc_plugin::Registry;
mod plugin;
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_macro("json", plugin::expand);
... | Use plugin API from rustc_plugin crate. | Use plugin API from rustc_plugin crate.
In rust-lang/rust@1430a3500076ad504a0b30be77fd2ad4468ea769 the plugin
API has been moved to a separate `rustc_plugin` crate.
| Rust | mit | tomjakubowski/json_macros,zsiciarz/json_macros |
333dab322d3385733d7c69c2951728ce810b6a00 | src/lib.rs | src/lib.rs | mod error;
pub mod reader;
#[test]
fn it_works() {
}
| pub mod error;
pub mod reader;
pub type Result<T> = std::result::Result<T, error::Error>;
#[test]
fn it_works() {
}
| Add `Result<T> `and make `error` module public | Add `Result<T> `and make `error` module public
| Rust | apache-2.0 | l1048576/fbx_direct |
c19d8b2fe7c6c29ee96320b733a585a4ecb78f51 | fahrenheit_to_celsius/src/main.rs | fahrenheit_to_celsius/src/main.rs | 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... | 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_to_c(f);
println!("Fahrenheit: {}", f);
... | Refactor fahrenheit to celsius conversion to function | Refactor fahrenheit to celsius conversion to function
| Rust | mit | pgrzesik/learning-rust |
afc74d4ecf1d2a2004ef4003dcdba3c280275a3b | src/package/pkg.rs | src/package/pkg.rs | //Following semver here
#[derive(Clone, RustcDecodable, RustcEncodable)]
pub struct Version {
pub major: u16,
pub minor: u16,
pub patch: u32
}
#[derive(Clone, RustcDecodable, RustcEncodable)]
pub struct Package {
pub name: String,
pub version: Version,
pub crc32: u32,
pub child_url: String,... | //Following semver here
#[derive(Clone, RustcDecodable, RustcEncodable)]
pub struct Version {
pub major: u16,
pub minor: u16,
pub patch: u32
}
#[derive(Clone, RustcDecodable, RustcEncodable)]
pub struct Package {
pub name: String,
pub version: Version,
pub crc32: u32,
pub child_url: String,... | Make variables of PackageList public | Make variables of PackageList public
| Rust | bsd-3-clause | hch12907/wiz |
88753670e59fddcc3e8c4ff0ae555d41e7819749 | src/main.rs | src/main.rs | fn main() {
}
| ///
/// Should program usage be printed?
///
/// # Arguments
///
/// * `args` - Program arguments, excluding program name.
///
pub fn should_print_usage(args: &Vec<String>) -> bool {
args.len() != 1 || args[0] == "-h" || args[0] == "--help"
}
///
/// Prints program usage to the standard output.
///
pub fn print_us... | Add obtaining of program arguments. | Add obtaining of program arguments.
| Rust | apache-2.0 | s3rvac/yabir |
36eb131cbbb822460c85a4bf8c7356ebdead7c46 | src/main.rs | src/main.rs | extern crate getopts;
use std::os;
/// Muxed. A tmux project manager with no runtime dependencies.
mod initializer;
mod help;
mod creator;
mod editor;
/// The main execution method.
/// Uses getopts to fetch arguments and pass them to the initializer for
/// inspection.
fn main() {
let args: Vec<String> = os::ar... | //! Muxed. A tmux project manager with no runtime dependencies.
extern crate getopts;
use std::os;
mod initializer;
mod help;
mod creator;
mod editor;
/// The main execution method.
/// Uses getopts to fetch arguments and pass them to the initializer for
/// inspection.
fn main() {
let args: Vec<String> = os::ar... | Move index description to the top of the file. | Move index description to the top of the file.
| Rust | mit | brianp/muxed,brianp/muxed |
4b8796391412c4e1116e4049dde0b3eb492922ad | diesel_compile_tests/tests/compile-fail/pg_specific_expressions_cant_be_used_in_a_sqlite_query.rs | diesel_compile_tests/tests/compile-fail/pg_specific_expressions_cant_be_used_in_a_sqlite_query.rs | #[macro_use] extern crate diesel;
use diesel::*;
use diesel::sql_types::*;
use diesel::dsl::*;
table! {
users {
id -> Integer,
name -> VarChar,
}
}
sql_function!(fn lower(x: VarChar) -> VarChar);
#[derive(Insertable)]
#[table_name="users"]
struct NewUser(#[column_name = "name"] &'static str)... | #[macro_use] extern crate diesel;
use diesel::*;
use diesel::sql_types::*;
use diesel::dsl::*;
table! {
users {
id -> Integer,
name -> VarChar,
}
}
sql_function!(fn lower(x: VarChar) -> VarChar);
#[derive(Insertable)]
#[table_name="users"]
struct NewUser(#[column_name = "name"] &'static str)... | Revert "Remove on_conflict_do_nothing test case" | Revert "Remove on_conflict_do_nothing test case"
This reverts commit f810fe8cc1a17a2932399e9dce828c4ddcd01ef8.
| Rust | apache-2.0 | diesel-rs/diesel,sgrif/diesel,diesel-rs/diesel,sgrif/diesel |
fb2d704b2f29459f0f50812c73726a49e864b57e | src/bin/open.rs | src/bin/open.rs | extern crate document;
use std::cmp::min;
use std::io::File;
use std::io::BufferedWriter;
use std::io::stdio::stdout_raw;
use document::parser::Parser;
fn pretty_error(xml: &str, position: uint) -> &str {
let s = xml.slice_from(position);
let l = s.chars().count();
s.slice_chars(0, min(l, 15))
}
#[allow... | extern crate document;
use std::cmp::min;
use std::io::File;
use std::io::BufferedWriter;
use std::io::stdio;
use document::parser::Parser;
fn pretty_error(xml: &str, position: uint) -> &str {
let s = xml.slice_from(position);
let l = s.chars().count();
s.slice_chars(0, min(l, 15))
}
fn process_input<R>... | Allow processing input from stdin | Allow processing input from stdin
Closes #5
| Rust | mit | shepmaster/sxd-document,shepmaster/sxd-document |
c18fe7fb4cab1544199c8bd95850ca6328d421ee | src/boards/mod.rs | src/boards/mod.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... | Use MBED board only for lpc_17xx mcu | Use MBED board only for lpc_17xx mcu | Rust | apache-2.0 | gapry/zinc,posborne/zinc,0xc0170/zinc,troplin/zinc,richo/zinc,richo/zinc,tempbottle/zinc,posborne/zinc,richo/zinc,ryankurte/zinc,ntwyman/zinc,flxo/zinc,hugwijst/zinc,darayus/zinc,0xc0170/zinc,tempbottle/zinc,hackndev/zinc,troplin/zinc,ryankurte/zinc,troplin/zinc,mcoffin/zinc,mcoffin/zinc,ryankurte/zinc,placrosse/zinc,f... |
6a73bd1c538a21909a6d2f83cd581c5771cc4636 | src/liquidwrapper.rs | src/liquidwrapper.rs | use std::fs::File;
use std::io::Read;
use templatewrapper::TemplateWrapper;
pub struct LiquidTemplate {
template: String,
}
impl TemplateWrapper for LiquidTemplate {
fn new(template_file: String) -> LiquidTemplate {
let mut template = String::new();
File::open(template_file).unwrap().read_to... | extern crate liquid;
use std::fs::File;
use std::io::Read;
use templatewrapper::TemplateWrapper;
pub struct LiquidTemplate {
template: String,
}
impl TemplateWrapper for LiquidTemplate {
fn new(template_file: String) -> LiquidTemplate {
let mut template = String::new();
File::open(template_... | Add Renderable to Liquid Wrapper | Add Renderable to Liquid Wrapper
| Rust | agpl-3.0 | SbWiki/SbWiki |
2dcec879761b0ac7f67e42f64c6bcf5fb090eebc | src/categories.rs | src/categories.rs | // Sync available crate categories from `src/categories.txt`.
// Runs when the server is started.
use pg;
use env;
use util::errors::CargoResult;
pub fn sync() -> CargoResult<()> {
let conn = pg::Connection::connect(&env("DATABASE_URL")[..],
pg::TlsMode::None).unwrap()... | // Sync available crate categories from `src/categories.txt`.
// Runs when the server is started.
use pg;
use env;
use util::errors::CargoResult;
pub fn sync() -> CargoResult<()> {
let conn = pg::Connection::connect(&env("DATABASE_URL")[..],
pg::TlsMode::None).unwrap()... | Use splitn on the category slug/display name pairs | Use splitn on the category slug/display name pairs
| Rust | apache-2.0 | rust-lang/crates.io,Susurrus/crates.io,steveklabnik/crates.io,rust-lang/crates.io,steveklabnik/crates.io,steveklabnik/crates.io,rust-lang/crates.io,rust-lang/crates.io,Susurrus/crates.io,Susurrus/crates.io,Susurrus/crates.io,steveklabnik/crates.io |
ae1c35a7587b6ef19b2c5c7753279ff91f48cfdd | src/user_view.rs | src/user_view.rs | use std::thread;
use std::sync::mpsc::{channel, Sender, Receiver, self};
use message::Message;
pub struct UserView<'a> {
_incoming_sender: Sender<Message>,
_view_guard: thread::JoinGuard<'a, ()>
}
pub fn start<'a>() -> UserView<'a> {
let (tx, rx) = channel::<Message>();
let view_guard = spawn_view(rx... | use std::io;
use std::thread;
use std::sync::mpsc;
use message::Message;
pub struct UserView<'a> {
_input_recv: mpsc::Receiver<String>,
_input_guard: thread::JoinGuard<'a, ()>
}
pub fn start<'a>() -> UserView<'a> {
let (input_send, input_recv) = mpsc::channel::<String>();
UserView {
_input_r... | Add thread for UserInput and remove thread for view | Add thread for UserInput and remove thread for view
| Rust | mit | timonv/lax |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.