file_name large_stringlengths 4 69 | prefix large_stringlengths 0 26.7k | suffix large_stringlengths 0 24.8k | middle large_stringlengths 0 2.12k | fim_type large_stringclasses 4
values |
|---|---|---|---|---|
def.rs | #[test]
fn parse_macro_def_no_params() {
super::test_parser(
r#"
<marker type="NODE_MACRO_DEF">macro test<marker type="NODE_MACRO_PARAM_LIST">()</marker> {
}</marker>
"#,
)
}
#[test]
fn parse_macro_def() {
super::test_parser(
r#"
<marker type="NODE_MACRO_DEF">mac... | () {
super::test_parser(
r#"
<marker type="KW_ABSTRACT">abstract</marker> block test {}
"#,
);
}
#[test]
fn parse_abstract_container_with_extends_list() {
super::test_parser(
r#"
abstract block test <marker type="NODE_EXTENDS_LIST">extends abc</marker> {}
"#,
);
... | parse_abstract_container_def | identifier_name |
def.rs | #[test]
fn parse_macro_def_no_params() {
super::test_parser(
r#"
<marker type="NODE_MACRO_DEF">macro test<marker type="NODE_MACRO_PARAM_LIST">()</marker> {
}</marker>
"#,
)
}
#[test]
fn parse_macro_def() {
super::test_parser(
r#"
<marker type="NODE_MACRO_DEF">mac... | } | random_line_split | |
client_basics.rs | extern crate riak;
use riak::Client;
use riak::bucket::{BucketProps, BucketTypeProps};
use riak::object::{DeleteObjectReq, FetchObjectReq, ObjectContent, StoreObjectReq};
use riak::yokozuna::{SearchQuery, YokozunaIndex};
use std::fs::File;
use std::io::Read;
#[test]
fn test_basics() {
// connect and ping
let ... |
}
assert_eq!(lives_on_nodes, 3);
assert!(has_primary_node);
// set properties for a bucket type
let mut bucket_props = BucketTypeProps::new("testbuckettype");
bucket_props.set_backend("leveldb");
riak.set_bucket_type_properties(bucket_props).unwrap();
// get the properties back for a ... | {
has_primary_node = true;
} | conditional_block |
client_basics.rs | extern crate riak;
use riak::Client;
use riak::bucket::{BucketProps, BucketTypeProps};
use riak::object::{DeleteObjectReq, FetchObjectReq, ObjectContent, StoreObjectReq};
use riak::yokozuna::{SearchQuery, YokozunaIndex};
use std::fs::File;
use std::io::Read;
#[test]
fn test_basics() |
// store an object
let contents = ObjectContent::new("this is a test".as_bytes());
let mut req = StoreObjectReq::new("testbucket", contents);
req.set_key("testkey");
riak.store_object(req).unwrap();
// fetch an object
let req = FetchObjectReq::new("testbucket", "testkey");
let object =... | {
// connect and ping
let mut riak = Client::new("10.0.0.2:8087").unwrap();
riak.ping().unwrap();
// get the server info
let (node, version) = riak.server_info().unwrap();
println!("connected to node {} running Riak version {}",
node,
version);
// set bucket prope... | identifier_body |
client_basics.rs | extern crate riak;
use riak::Client;
use riak::bucket::{BucketProps, BucketTypeProps};
use riak::object::{DeleteObjectReq, FetchObjectReq, ObjectContent, StoreObjectReq};
use riak::yokozuna::{SearchQuery, YokozunaIndex};
use std::fs::File;
use std::io::Read;
#[test]
fn | () {
// connect and ping
let mut riak = Client::new("10.0.0.2:8087").unwrap();
riak.ping().unwrap();
// get the server info
let (node, version) = riak.server_info().unwrap();
println!("connected to node {} running Riak version {}",
node,
version);
// set bucket pr... | test_basics | identifier_name |
client_basics.rs | extern crate riak; | use riak::yokozuna::{SearchQuery, YokozunaIndex};
use std::fs::File;
use std::io::Read;
#[test]
fn test_basics() {
// connect and ping
let mut riak = Client::new("10.0.0.2:8087").unwrap();
riak.ping().unwrap();
// get the server info
let (node, version) = riak.server_info().unwrap();
println!(... |
use riak::Client;
use riak::bucket::{BucketProps, BucketTypeProps};
use riak::object::{DeleteObjectReq, FetchObjectReq, ObjectContent, StoreObjectReq}; | random_line_split |
test_udp_socket.rs | use mio::*;
use mio::udp::*;
use bytes::{Buf, RingBuf, SliceBuf, MutBuf};
use std::str;
use localhost;
const LISTENER: Token = Token(0);
const SENDER: Token = Token(1);
pub struct UdpHandler {
tx: UdpSocket,
rx: UdpSocket,
msg: &'static str,
buf: SliceBuf<'static>,
rx_buf: RingBuf
}
impl UdpHandl... |
if events.is_writable() {
match token {
SENDER => {
let addr = self.rx.local_addr().unwrap();
let cnt = self.tx.send_to(self.buf.bytes(), &addr).unwrap()
.unwrap();
... | {
match token {
LISTENER => {
debug!("We are receiving a datagram now...");
let (cnt, _) = unsafe {
self.rx.recv_from(self.rx_buf.mut_bytes()).unwrap()
.unwrap()
... | conditional_block |
test_udp_socket.rs | use mio::*;
use mio::udp::*;
use bytes::{Buf, RingBuf, SliceBuf, MutBuf};
use std::str;
use localhost;
const LISTENER: Token = Token(0);
const SENDER: Token = Token(1);
pub struct UdpHandler {
tx: UdpSocket,
rx: UdpSocket,
msg: &'static str,
buf: SliceBuf<'static>,
rx_buf: RingBuf
}
impl UdpHandl... | (&mut self, event_loop: &mut EventLoop<UdpHandler>, token: Token, events: EventSet) {
if events.is_readable() {
match token {
LISTENER => {
debug!("We are receiving a datagram now...");
let (cnt, _) = unsafe {
self.rx.r... | ready | identifier_name |
test_udp_socket.rs | use mio::*;
use mio::udp::*;
use bytes::{Buf, RingBuf, SliceBuf, MutBuf};
use std::str;
use localhost;
| pub struct UdpHandler {
tx: UdpSocket,
rx: UdpSocket,
msg: &'static str,
buf: SliceBuf<'static>,
rx_buf: RingBuf
}
impl UdpHandler {
fn new(tx: UdpSocket, rx: UdpSocket, msg : &'static str) -> UdpHandler {
UdpHandler {
tx: tx,
rx: rx,
msg: msg,
... | const LISTENER: Token = Token(0);
const SENDER: Token = Token(1);
| random_line_split |
lub-glb-with-unbound-infer-var.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 ... | {
let a_f: fn(_) = |_| ();
let b_f: fn(_) = |_| ();
let c_f = match 22 {
0 => a_f,
_ => b_f,
};
c_f(4);
} | identifier_body | |
lub-glb-with-unbound-infer-var.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 ... | // in-progress PR.
fn main() {
let a_f: fn(_) = |_| ();
let b_f: fn(_) = |_| ();
let c_f = match 22 {
0 => a_f,
_ => b_f,
};
c_f(4);
} | random_line_split | |
lub-glb-with-unbound-infer-var.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 ... | () {
let a_f: fn(_) = |_| ();
let b_f: fn(_) = |_| ();
let c_f = match 22 {
0 => a_f,
_ => b_f,
};
c_f(4);
}
| main | identifier_name |
main.rs | use std::io::Write;
use std::str::FromStr;
fn main() |
fn gcd(mut n: u64, mut m: u64) -> u64 {
assert!(n!= 0 && m!= 0);
while m!= 0 {
if m < n {
let t = m;
m = n;
n = t;
}
m = m % n;
}
n
}
#[test]
fn test_gcd() {
assert_eq!(gcd(2 * 3 * 5 * 11 * 17, 3 * 7 * 11 * 13 * 19), 3 * 11);
}
| {
let mut numbers = Vec::new();
for arg in std::env::args().skip(1) {
numbers.push(u64::from_str(&arg).expect("error parsing argument"));
}
if numbers.len() == 0 {
writeln!(std::io::stderr(), "Usage: gcd NUMBER ...").unwrap();
std::process::exit(1);
}
let mut d = numbe... | identifier_body |
main.rs | use std::io::Write;
use std::str::FromStr;
fn | () {
let mut numbers = Vec::new();
for arg in std::env::args().skip(1) {
numbers.push(u64::from_str(&arg).expect("error parsing argument"));
}
if numbers.len() == 0 {
writeln!(std::io::stderr(), "Usage: gcd NUMBER...").unwrap();
std::process::exit(1);
}
let mut d = num... | main | identifier_name |
main.rs | use std::io::Write;
use std::str::FromStr;
fn main() {
let mut numbers = Vec::new();
for arg in std::env::args().skip(1) {
numbers.push(u64::from_str(&arg).expect("error parsing argument"));
}
if numbers.len() == 0 {
writeln!(std::io::stderr(), "Usage: gcd NUMBER...").unwrap();
... |
m = m % n;
}
n
}
#[test]
fn test_gcd() {
assert_eq!(gcd(2 * 3 * 5 * 11 * 17, 3 * 7 * 11 * 13 * 19), 3 * 11);
}
| {
let t = m;
m = n;
n = t;
} | conditional_block |
main.rs | use std::io::Write;
use std::str::FromStr;
fn main() {
let mut numbers = Vec::new();
for arg in std::env::args().skip(1) {
numbers.push(u64::from_str(&arg).expect("error parsing argument"));
}
if numbers.len() == 0 {
writeln!(std::io::stderr(), "Usage: gcd NUMBER...").unwrap();
... | }
println!("The greatest common divisor of {:?} is {}", numbers, d);
}
fn gcd(mut n: u64, mut m: u64) -> u64 {
assert!(n!= 0 && m!= 0);
while m!= 0 {
if m < n {
let t = m;
m = n;
n = t;
}
m = m % n;
}
n
}
#[test]
fn test_gcd() {
... |
let mut d = numbers[0];
for m in &numbers[1..] {
d = gcd(d, *m); | random_line_split |
error.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | (_err: ethkey::Error) -> Self {
ErrorKind::Auth.into()
}
}
impl From<crypto::Error> for Error {
fn from(_err: crypto::Error) -> Self {
ErrorKind::Auth.into()
}
}
#[test]
fn test_errors() {
assert_eq!(DisconnectReason::ClientQuit, DisconnectReason::from_u8(8));
let mut r = DisconnectReason::DisconnectRequeste... | from | identifier_name |
error.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | PeerNotFound {
description("Peer not found"),
display("Peer not found"),
}
#[doc = "Peer is disconnected"]
Disconnect(reason: DisconnectReason) {
description("Peer disconnected"),
display("Peer disconnected: {}", reason),
}
#[doc = "Invalid node id"]
InvalidNodeId {
description("Invalid n... | display("Expired message"),
}
#[doc = "Peer not found"] | random_line_split |
error.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... |
}
impl From<crypto::Error> for Error {
fn from(_err: crypto::Error) -> Self {
ErrorKind::Auth.into()
}
}
#[test]
fn test_errors() {
assert_eq!(DisconnectReason::ClientQuit, DisconnectReason::from_u8(8));
let mut r = DisconnectReason::DisconnectRequested;
for i in 0.. 20 {
r = DisconnectReason::from_u8(i);
... | {
ErrorKind::Auth.into()
} | identifier_body |
lib.rs | //! # Rocket - Code Generation
//!
//! This crate implements the code generation portions of Rocket. This includes
//! custom derives, custom attributes, procedural macros, and lints. The
//! documentation here is purely technical. The code generation facilities are
//! documented thoroughly in the [Rocket programming
... | //! URI_SEG := Valid HTTP URI Segment
//! DYNAMIC_PARAM := '<' IDENT '..'? '>' (string literal)
//! </pre>
//!
//! Note that the **route** attribute takes a method as its first argument,
//! while the remaining do not. That is, **route** looks like:
//!
//! #[route(GET, path = "/hello")]
//!
//! while the equivalen... | //!
//! INTEGER := isize, as defined by Rust
//! STRING := UTF-8 string literal, as defined by Rust
//! IDENT := Valid identifier, as defined by Rust
//! | random_line_split |
lib.rs | //! # Rocket - Code Generation
//!
//! This crate implements the code generation portions of Rocket. This includes
//! custom derives, custom attributes, procedural macros, and lints. The
//! documentation here is purely technical. The code generation facilities are
//! documented thoroughly in the [Rocket programming
... |
reg.register_macro("routes", macros::routes);
reg.register_macro("errors", macros::errors);
register_derives!(reg,
"derive_FromForm" => from_form_derive
);
register_decorators!(reg,
"error" => error_decorator,
"route" => route_decorator,
"get" => get_decorator,
... | {
::rocket::logger::init(::rocket::LoggingLevel::Debug);
} | conditional_block |
lib.rs | //! # Rocket - Code Generation
//!
//! This crate implements the code generation portions of Rocket. This includes
//! custom derives, custom attributes, procedural macros, and lints. The
//! documentation here is purely technical. The code generation facilities are
//! documented thoroughly in the [Rocket programming
... | "head" => head_decorator,
"patch" => patch_decorator,
"options" => options_decorator
);
register_lints!(reg, RocketLint);
}
| {
// Enable logging early if the DEBUG_ENV_VAR is set.
if env::var(DEBUG_ENV_VAR).is_ok() {
::rocket::logger::init(::rocket::LoggingLevel::Debug);
}
reg.register_macro("routes", macros::routes);
reg.register_macro("errors", macros::errors);
register_derives!(reg,
"derive_FromFo... | identifier_body |
lib.rs | //! # Rocket - Code Generation
//!
//! This crate implements the code generation portions of Rocket. This includes
//! custom derives, custom attributes, procedural macros, and lints. The
//! documentation here is purely technical. The code generation facilities are
//! documented thoroughly in the [Rocket programming
... | (reg: &mut Registry) {
// Enable logging early if the DEBUG_ENV_VAR is set.
if env::var(DEBUG_ENV_VAR).is_ok() {
::rocket::logger::init(::rocket::LoggingLevel::Debug);
}
reg.register_macro("routes", macros::routes);
reg.register_macro("errors", macros::errors);
register_derives!(reg,
... | plugin_registrar | identifier_name |
project.rs | use rustc_serialize::json;
use dao::ProtonDao;
use error::Error;
use project_types::{Project, SequenceData};
use utils;
/// Creates a new Proton project. Returns the public key of the root user.
pub fn new_project<PD: ProtonDao>(
dao: &PD,
name: &str,
layout_id: u32
) -> Result<String, Error> {
// C... |
println!("Channel ids loaded.");
print!("Getting data...");
// Create vector for sequence data
// Up to 512 channels per universe, plus one because DMX starts at 1
let mut seq_data = vec![vec![0; sequence.num_frames as usize]; 513];
// Get each channel's data and put ... | {
// TODO: make error
println!("No channels found");
panic!("No channels found");
} | conditional_block |
project.rs | use rustc_serialize::json;
use dao::ProtonDao;
use error::Error;
use project_types::{Project, SequenceData};
use utils;
/// Creates a new Proton project. Returns the public key of the root user.
pub fn new_project<PD: ProtonDao>(
dao: &PD,
name: &str,
layout_id: u32
) -> Result<String, Error> {
// C... | <PD: ProtonDao> (
dao: &PD,
proj_name: &str
) -> Result<String, Error> {
// Check that project exists
let project = try!(dao.get_project(proj_name));
let mut playlist_data = Vec::with_capacity(project.playlist.len());
// Go through each sequence in the playlist
for seqid in project.playli... | get_playlist_data | identifier_name |
project.rs | use rustc_serialize::json;
use dao::ProtonDao;
use error::Error;
use project_types::{Project, SequenceData};
use utils;
/// Creates a new Proton project. Returns the public key of the root user.
pub fn new_project<PD: ProtonDao>(
dao: &PD,
name: &str,
layout_id: u32
) -> Result<String, Error> {
// C... | // Get each channel's data and put it in the correct vector slot
for chanid in chan_ids {
let channel = try!(dao.get_channel(chanid));
let chan_data = try!(dao.get_data(seqid.to_owned(), chanid.to_owned()));
seq_data[channel.channel_dmx as usize] = chan_data;
... |
// Create vector for sequence data
// Up to 512 channels per universe, plus one because DMX starts at 1
let mut seq_data = vec![vec![0; sequence.num_frames as usize]; 513];
| random_line_split |
project.rs | use rustc_serialize::json;
use dao::ProtonDao;
use error::Error;
use project_types::{Project, SequenceData};
use utils;
/// Creates a new Proton project. Returns the public key of the root user.
pub fn new_project<PD: ProtonDao>(
dao: &PD,
name: &str,
layout_id: u32
) -> Result<String, Error> {
// C... |
if chan_ids.len() < 1 {
// TODO: make error
println!("No channels found");
panic!("No channels found");
}
println!("Channel ids loaded.");
print!("Getting data...");
// Create vector for sequence data
// Up to 512 channels per univer... | {
// Check that project exists
let project = try!(dao.get_project(proj_name));
let mut playlist_data = Vec::with_capacity(project.playlist.len());
// Go through each sequence in the playlist
for seqid in project.playlist.iter() {
print!("Getting sequence {}...", seqid);
// Get s... | identifier_body |
transaction.rs | // The transaction model for handling surface states in Smithay
//
// The caching logic in `cache.rs` provides surfaces with a queue of
// pending states identified with numeric commit ids, allowing the compositor
// to precisely control *when* a state become active. This file is the second
// half: these identified st... | impl TransactionState {
fn insert(&mut self, surface: WlSurface, id: Serial) {
if let Some(place) = self.surfaces.iter_mut().find(|place| place.0 == surface) {
// the surface is already in the list, update the serial
if place.1 < id {
place.1 = id;
}
... | blockers: Vec::new(),
}
}
}
| random_line_split |
transaction.rs | // The transaction model for handling surface states in Smithay
//
// The caching logic in `cache.rs` provides surfaces with a queue of
// pending states identified with numeric commit ids, allowing the compositor
// to precisely control *when* a state become active. This file is the second
// half: these identified st... |
}
}
}
| {
// this transaction is to be applied, yay!
self.transactions.remove(i).apply();
} | conditional_block |
transaction.rs | // The transaction model for handling surface states in Smithay
//
// The caching logic in `cache.rs` provides surfaces with a queue of
// pending states identified with numeric commit ids, allowing the compositor
// to precisely control *when* a state become active. This file is the second
// half: these identified st... |
pub(crate) fn is_same_as(&self, other: &PendingTransaction) -> bool {
let ptr1 = self.with_inner_state(|state| state as *const _);
let ptr2 = other.with_inner_state(|state| state as *const _);
ptr1 == ptr2
}
pub(crate) fn merge_into(&self, into: &PendingTransaction) {
if s... | {
self.with_inner_state(|state| state.blockers.push(Box::new(blocker) as Box<_>))
} | identifier_body |
transaction.rs | // The transaction model for handling surface states in Smithay
//
// The caching logic in `cache.rs` provides surfaces with a queue of
// pending states identified with numeric commit ids, allowing the compositor
// to precisely control *when* a state become active. This file is the second
// half: these identified st... | {
surfaces: Vec<(WlSurface, Serial)>,
blockers: Vec<Box<dyn Blocker + Send>>,
}
impl Default for TransactionState {
fn default() -> Self {
TransactionState {
surfaces: Vec::new(),
blockers: Vec::new(),
}
}
}
impl TransactionState {
fn insert(&mut self, surf... | TransactionState | identifier_name |
get_variable_length_field.rs | // Copyright (c) 2015 Robert Clipsham <robert@octarineparrot.com>
//
// 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... | fn main() {
let data = [1, 1, 1, 1, 2, 3, 4, 5, 6];
let packet = WithVariableLengthFieldPacket::new(&data[..]).unwrap();
assert_eq!(packet.get_var_length(), vec![2, 3, 4]);
} | payload: Vec<u8>
}
| random_line_split |
get_variable_length_field.rs | // Copyright (c) 2015 Robert Clipsham <robert@octarineparrot.com>
//
// 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... | () {
let data = [1, 1, 1, 1, 2, 3, 4, 5, 6];
let packet = WithVariableLengthFieldPacket::new(&data[..]).unwrap();
assert_eq!(packet.get_var_length(), vec![2, 3, 4]);
}
| main | identifier_name |
get_variable_length_field.rs | // Copyright (c) 2015 Robert Clipsham <robert@octarineparrot.com>
//
// 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... | {
let data = [1, 1, 1, 1, 2, 3, 4, 5, 6];
let packet = WithVariableLengthFieldPacket::new(&data[..]).unwrap();
assert_eq!(packet.get_var_length(), vec![2, 3, 4]);
} | identifier_body | |
attrib.rs | // rustfmt-wrap_comments: true
// Test attributes and doc comments are preserved.
//! Doc comment
#![attribute]
//! Crate doc comment
// Comment
// Comment on attribute
#![the(attribute)]
// Another comment
#[invalid attribute]
fn foo() {}
/// Blah blah blah.
/// Blah blah blah.
/// Blah blah blah.
/// Blah bla... |
/// Blah blah bing.
#[attrib1]
/// Blah blah bing.
#[attrib2]
// Another comment that needs rewrite because it's tooooooooooooooooooooooooooooooo loooooooooooong.
/// Blah blah bing.
fn f4(self) -> Cat {
}
// We want spaces around `=`
#[cfg(feature="nightly")]
fn f5(self)... | {
} | identifier_body |
attrib.rs | // rustfmt-wrap_comments: true
// Test attributes and doc comments are preserved.
//! Doc comment
#![attribute]
//! Crate doc comment
// Comment
// Comment on attribute
#![the(attribute)]
// Another comment
#[invalid attribute]
fn foo() {}
/// Blah blah blah.
/// Blah blah blah.
/// Blah blah blah.
/// Blah bla... | #[test]
#[should_panic(expected = "(")]
#[should_panic(expected = /* ( */ "(")]
#[should_panic(/* ((((( */expected /* ((((( */= /* ((((( */ "("/* ((((( */)]
#[should_panic(
/* (((((((( *//*
(((((((((()(((((((( */
expected = "("
// ((((((((
)]
fn foo() {}
// #1799
fn issue_1799() {
#[allow(unreachab... |
// #1777 | random_line_split |
attrib.rs | // rustfmt-wrap_comments: true
// Test attributes and doc comments are preserved.
//! Doc comment
#![attribute]
//! Crate doc comment
// Comment
// Comment on attribute
#![the(attribute)]
// Another comment
#[invalid attribute]
fn foo() {}
/// Blah blah blah.
/// Blah blah blah.
/// Blah blah blah.
/// Blah bla... | (pub u8);
| HP | identifier_name |
regions-infer-borrow-scope-within-loop.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 ... | <'r, T>(x: &'r T) -> &'r T {x}
fn foo(cond: &fn() -> bool, box: &fn() -> @int) {
let mut y: ∫
loop {
let x = box();
// Here we complain because the resulting region
// of this borrow is the fn body as a whole.
y = borrow(x); //~ ERROR illegal borrow: cannot root managed value long enough... | borrow | identifier_name |
regions-infer-borrow-scope-within-loop.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 ... | y = borrow(x); //~ ERROR illegal borrow: cannot root managed value long enough
assert!(*x == *y);
if cond() { break; }
}
assert!(*y!= 0);
}
fn main() {} | let x = box();
// Here we complain because the resulting region
// of this borrow is the fn body as a whole. | random_line_split |
regions-infer-borrow-scope-within-loop.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 ... |
fn main() {}
| {
let mut y: ∫
loop {
let x = box();
// Here we complain because the resulting region
// of this borrow is the fn body as a whole.
y = borrow(x); //~ ERROR illegal borrow: cannot root managed value long enough
assert!(*x == *y);
if cond() { break; }
}
assert!(*y !... | identifier_body |
regions-infer-borrow-scope-within-loop.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 ... |
}
assert!(*y!= 0);
}
fn main() {}
| { break; } | conditional_block |
issue-13058.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 ... |
fn main() {
check(&(3, 5));
}
| {
let cont_iter = cont.iter();
//~^ ERROR 24:26: 24:30: explicit lifetime required in the type of `cont` [E0621]
let result = cont_iter.fold(Some(0), |state, val| {
state.map_or(None, |mask| {
let bit = 1 << val;
if mask & bit == 0 {Some(mask|bit)} else {None}
})
});
... | identifier_body |
issue-13058.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 ... | <'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
{
let cont_iter = cont.iter();
//~^ ERROR 24:26: 24:30: explicit lifetime required in the type of `cont` [E0621]
let result = cont_iter.fold(Some(0), |state, val| {
state.map_or(None, |mask| {
let bit = 1 << val;
... | check | identifier_name |
issue-13058.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 ... | fn main() {
check(&(3, 5));
} | random_line_split | |
issue-13058.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 ... | else {None}
})
});
result.is_some()
}
fn main() {
check(&(3, 5));
}
| {Some(mask|bit)} | conditional_block |
mod.rs | // Copyright 2013 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 ... | //! Useful synchronization primitives
//!
//! This module contains useful safe and unsafe synchronization primitives.
//! Most of the primitives in this module do not provide any sort of locking
//! and/or blocking at all, but rather provide the necessary tools to build
//! other types of concurrent primitives.
#![sta... | random_line_split | |
timers.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::callback::ExceptionHandling::Report;
use dom::bindings::cell::DomRefCell;
use dom::bindings::co... | (&self) {
self.min_duration.set(None);
}
// see step 13 of https://html.spec.whatwg.org/multipage/#timer-initialisation-steps
fn user_agent_pad(&self, current_duration: MsDuration) -> MsDuration {
match self.min_duration.get() {
Some(min_duration) => {
cmp::max(m... | remove_min_duration | identifier_name |
timers.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::callback::ExceptionHandling::Report;
use dom::bindings::cell::DomRefCell;
use dom::bindings::co... | if self.suspended_since.get().is_some() {
// The timer will be scheduled when the pipeline is fully activated.
return;
}
let timers = self.timers.borrow();
if let Some(timer) = timers.last() {
let expected_event_id = self.invalidate_expected_event_id... |
fn schedule_timer_call(&self) { | random_line_split |
data_loader.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 hyper::mime::{Attr, Mime, SubLevel, TopLevel, Value};
use mime_classifier::MimeClassifier;
use net_traits::{Lo... | },
Err(DecodeError::InvalidDataUri) =>
send_error(url, NetworkError::Internal("invalid data uri".to_owned()), start_chan),
Err(DecodeError::NonBase64DataUri) =>
send_error(url, NetworkError::Internal("non-base64 data uri".to_owned()), start_chan),
}
}
| let _ = chan.send(Payload(bytes));
let _ = chan.send(Done(Ok(())));
}
| conditional_block |
data_loader.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 hyper::mime::{Attr, Mime, SubLevel, TopLevel, Value};
use mime_classifier::MimeClassifier;
use net_traits::{Lo... | pub fn decode(url: &Url) -> Result<DecodeData, DecodeError> {
assert!(url.scheme() == "data");
// Split out content type and data.
let parts: Vec<&str> = url[Position::BeforePath..Position::AfterQuery].splitn(2, ',').collect();
if parts.len()!= 2 {
return Err(DecodeError::InvalidDataUri);
}
... | pub type DecodeData = (Mime, Vec<u8>);
| random_line_split |
data_loader.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 hyper::mime::{Attr, Mime, SubLevel, TopLevel, Value};
use mime_classifier::MimeClassifier;
use net_traits::{Lo... | {
InvalidDataUri,
NonBase64DataUri,
}
pub type DecodeData = (Mime, Vec<u8>);
pub fn decode(url: &Url) -> Result<DecodeData, DecodeError> {
assert!(url.scheme() == "data");
// Split out content type and data.
let parts: Vec<&str> = url[Position::BeforePath..Position::AfterQuery].splitn(2, ',').col... | DecodeError | identifier_name |
data_loader.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 hyper::mime::{Attr, Mime, SubLevel, TopLevel, Value};
use mime_classifier::MimeClassifier;
use net_traits::{Lo... | send_error(url, NetworkError::Internal("invalid data uri".to_owned()), start_chan),
Err(DecodeError::NonBase64DataUri) =>
send_error(url, NetworkError::Internal("non-base64 data uri".to_owned()), start_chan),
}
}
| let url = load_data.url;
if cancel_listener.is_cancelled() {
return;
}
match decode(&url) {
Ok((content_type, bytes)) => {
let mut metadata = Metadata::default(url);
metadata.set_content_type(Some(content_type).as_ref());
if let Ok(chan) = start_send... | identifier_body |
mod.rs | //! **Canonicalization** is the key to constructing a query in the
//! middle of type inference. Ordinarily, it is not possible to store
//! types from type inference in query keys, because they contain
//! references to inference variables whose lifetimes are too short
//! and so forth. Canonicalizing a value T1 using... | <T>(
&self,
span: Span,
canonical: &Canonical<'tcx, T>,
) -> (T, CanonicalVarValues<'tcx>)
where
T: TypeFoldable<'tcx>,
{
// For each universe that is referred to in the incoming
// query, create a universe in our local inference context. In
// practic... | instantiate_canonical_with_fresh_inference_vars | identifier_name |
mod.rs | //! **Canonicalization** is the key to constructing a query in the
//! middle of type inference. Ordinarily, it is not possible to store
//! types from type inference in query keys, because they contain
//! references to inference variables whose lifetimes are too short
//! and so forth. Canonicalizing a value T1 using... |
/// Given the "infos" about the canonical variables from some
/// canonical, creates fresh variables with the same
/// characteristics (see `instantiate_canonical_var` for
/// details). You can then use `substitute` to instantiate the
/// canonical variable with these inference variables.
fn i... | {
// For each universe that is referred to in the incoming
// query, create a universe in our local inference context. In
// practice, as of this writing, all queries have no universes
// in them, so this code has no effect, but it is looking
// forward to the day when we *do* wa... | identifier_body |
mod.rs | //! **Canonicalization** is the key to constructing a query in the
//! middle of type inference. Ordinarily, it is not possible to store
//! types from type inference in query keys, because they contain
//! references to inference variables whose lifetimes are too short | //! - a value T2 where each unbound inference variable has been
//! replaced with a **canonical variable**;
//! - a map M (of type `CanonicalVarValues`) from those canonical
//! variables back to the original.
//!
//! We can then do queries using T2. These will give back constraints
//! on the canonical variables w... | //! and so forth. Canonicalizing a value T1 using `canonicalize_query`
//! produces two things:
//! | random_line_split |
mod.rs | //! **Canonicalization** is the key to constructing a query in the
//! middle of type inference. Ordinarily, it is not possible to store
//! types from type inference in query keys, because they contain
//! references to inference variables whose lifetimes are too short
//! and so forth. Canonicalizing a value T1 using... |
CanonicalVarKind::Region(ui) => self
.next_region_var_in_universe(
RegionVariableOrigin::MiscVariable(span),
universe_map(ui),
)
.into(),
CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion { universe,... | {
let universe_mapped = universe_map(universe);
let placeholder_mapped = ty::PlaceholderType { universe: universe_mapped, name };
self.tcx.mk_ty(ty::Placeholder(placeholder_mapped)).into()
} | conditional_block |
distinct.rs | extern crate timely;
use std::fmt::Debug;
use std::hash::Hash;
use timely::communication::Data;
use timely::progress::timestamp::RootTimestamp;
use timely::progress::nested::Summary::Local;
use timely::construction::*;
use timely::construction::operators::*;
fn main() {
timely::execute(std::env::args(), |root| ... | input2.advance_to(1000000);
input1.close();
input2.close();
// spin
while root.step() { }
});
}
fn create_subgraph<G: GraphBuilder, D>(builder: &G, source1: &Stream<G, D>, source2: &Stream<G, D>) -> (Stream<G, D>, Stream<G, D>)
where D: Data+Hash+Eq+Debug, G::Timestamp: Has... | root.step();
input1.advance_to(1000000); | random_line_split |
distinct.rs | extern crate timely;
use std::fmt::Debug;
use std::hash::Hash;
use timely::communication::Data;
use timely::progress::timestamp::RootTimestamp;
use timely::progress::nested::Summary::Local;
use timely::construction::*;
use timely::construction::operators::*;
fn main() {
timely::execute(std::env::args(), |root| ... | <G: GraphBuilder, D>(builder: &G, source1: &Stream<G, D>, source2: &Stream<G, D>) -> (Stream<G, D>, Stream<G, D>)
where D: Data+Hash+Eq+Debug, G::Timestamp: Hash {
builder.clone().subcomputation::<u64,_,_>(|subgraph| {
(subgraph.enter(source1).leave(),
subgraph.enter(source2).leave())
})
}
| create_subgraph | identifier_name |
distinct.rs | extern crate timely;
use std::fmt::Debug;
use std::hash::Hash;
use timely::communication::Data;
use timely::progress::timestamp::RootTimestamp;
use timely::progress::nested::Summary::Local;
use timely::construction::*;
use timely::construction::operators::*;
fn main() {
timely::execute(std::env::args(), |root| ... | {
builder.clone().subcomputation::<u64,_,_>(|subgraph| {
(subgraph.enter(source1).leave(),
subgraph.enter(source2).leave())
})
} | identifier_body | |
lib.rs | // This is a part of rust-encoding.
//
// Any copyright is dedicated to the Public Domain.
// https://creativecommons.org/publicdomain/zero/1.0/
//! Single-byte index tables for
//! [rust-encoding](https://github.com/lifthrasiir/rust-encoding).
#![cfg_attr(test, feature(test))]
#[cfg(test)]
#[macro_use]
extern crate... | pub mod koi8_r;
/// KOI8-U.
pub mod koi8_u;
/// MacRoman.
pub mod macintosh;
/// Windows code page 874.
pub mod windows_874;
/// Windows code page 1250.
pub mod windows_1250;
/// Windows code page 1251.
pub mod windows_1251;
/// Windows code page 1252.
pub mod windows_1252;
/// Windows code page 1253.
pub mod wi... | /// KOI8-R. | random_line_split |
lib.rs | pub fn bottle_or_bottles(n: i32) -> &'static str {
match n {
1 => "bottle",
_ => "bottles",
}
}
pub fn sing(n: i32) {
for i in (1..n + 1).rev() {
println!(
"{0} {1} of beer on the wall, {0} {1} of beer.",
i,
bottle_or_bottles(i)
);
... | n
);
} | random_line_split | |
lib.rs | pub fn bottle_or_bottles(n: i32) -> &'static str {
match n {
1 => "bottle",
_ => "bottles",
}
}
pub fn | (n: i32) {
for i in (1..n + 1).rev() {
println!(
"{0} {1} of beer on the wall, {0} {1} of beer.",
i,
bottle_or_bottles(i)
);
println!(
"Take one down and pass it around, {0} {1} of beer on the wall!",
i - 1,
bottle_or_bo... | sing | identifier_name |
lib.rs | pub fn bottle_or_bottles(n: i32) -> &'static str {
match n {
1 => "bottle",
_ => "bottles",
}
}
pub fn sing(n: i32) | {
for i in (1..n + 1).rev() {
println!(
"{0} {1} of beer on the wall, {0} {1} of beer.",
i,
bottle_or_bottles(i)
);
println!(
"Take one down and pass it around, {0} {1} of beer on the wall!",
i - 1,
bottle_or_bottles(i -... | identifier_body | |
puback.rs | //! PUBACK
use std::io::Read;
use crate::control::variable_header::PacketIdentifier;
use crate::control::{ControlType, FixedHeader, PacketType};
use crate::packet::{DecodablePacket, PacketError};
use crate::Decodable;
/// `PUBACK` packet
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct PubackPacket {
fixed_head... | }
}
pub fn packet_identifier(&self) -> u16 {
self.packet_identifier.0
}
pub fn set_packet_identifier(&mut self, pkid: u16) {
self.packet_identifier.0 = pkid;
}
}
impl DecodablePacket for PubackPacket {
type DecodePacketError = std::convert::Infallible;
fn decode_p... | random_line_split | |
puback.rs | //! PUBACK
use std::io::Read;
use crate::control::variable_header::PacketIdentifier;
use crate::control::{ControlType, FixedHeader, PacketType};
use crate::packet::{DecodablePacket, PacketError};
use crate::Decodable;
/// `PUBACK` packet
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct PubackPacket {
fixed_head... |
pub fn packet_identifier(&self) -> u16 {
self.packet_identifier.0
}
pub fn set_packet_identifier(&mut self, pkid: u16) {
self.packet_identifier.0 = pkid;
}
}
impl DecodablePacket for PubackPacket {
type DecodePacketError = std::convert::Infallible;
fn decode_packet<R: Read>(... | {
PubackPacket {
fixed_header: FixedHeader::new(PacketType::with_default(ControlType::PublishAcknowledgement), 2),
packet_identifier: PacketIdentifier(pkid),
}
} | identifier_body |
puback.rs | //! PUBACK
use std::io::Read;
use crate::control::variable_header::PacketIdentifier;
use crate::control::{ControlType, FixedHeader, PacketType};
use crate::packet::{DecodablePacket, PacketError};
use crate::Decodable;
/// `PUBACK` packet
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct PubackPacket {
fixed_head... | (pkid: u16) -> PubackPacket {
PubackPacket {
fixed_header: FixedHeader::new(PacketType::with_default(ControlType::PublishAcknowledgement), 2),
packet_identifier: PacketIdentifier(pkid),
}
}
pub fn packet_identifier(&self) -> u16 {
self.packet_identifier.0
}
... | new | identifier_name |
dedicatedworkerglobalscope.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::codegen::Bindings::DedicatedWorkerGlobalScopeBinding;
use dom::bindings::codegen::Bindings::Ded... | (worker_url: Url,
worker: TrustedWorkerAddress,
cx: Rc<Cx>,
resource_task: ResourceTask,
parent_sender: ScriptChan,
own_sender: ScriptChan,
receiver: Receiver<ScriptMsg>)... | new_inherited | identifier_name |
dedicatedworkerglobalscope.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::codegen::Bindings::DedicatedWorkerGlobalScopeBinding;
use dom::bindings::codegen::Bindings::Ded... | unsafe { JS_ClearPendingException(cx); }
return Err(DataClone);
}
let ScriptChan(ref sender) = self.parent_sender;
sender.send(WorkerPostMessage(self.worker, data, nbytes));
Ok(())
}
event_handler!(message, GetOnmessage, SetOnmessage)
}
trait PrivateDed... | ptr::null(), ptr::null_mut())
};
if result == 0 { | random_line_split |
add_metadata.rs | use super::Batch;
use super::act::Act;
use super::iterator::*;
use super::packet_batch::PacketBatch;
use common::*;
use interface::Packet;
use interface::PacketTx;
use std::marker::PhantomData;
pub type MetadataFn<T, M, M2> = Box<FnMut(&Packet<T, M>) -> M2 + Send>;
pub struct AddMetadataBatch<M, V>
where
M: Send ... |
}
| {
self.parent.get_task_dependencies()
} | identifier_body |
add_metadata.rs | use super::Batch;
use super::act::Act;
use super::iterator::*;
use super::packet_batch::PacketBatch;
use common::*;
use interface::Packet;
use interface::PacketTx;
use std::marker::PhantomData;
pub type MetadataFn<T, M, M2> = Box<FnMut(&Packet<T, M>) -> M2 + Send>;
pub struct AddMetadataBatch<M, V>
where
M: Send ... | (&mut self) -> usize {
self.parent.start()
}
#[inline]
unsafe fn next_payload(&mut self, idx: usize) -> Option<PacketDescriptor<V::Header, M>> {
self.parent.next_payload(idx).map(|p| PacketDescriptor {
packet: p.packet.reinterpret_metadata(),
})
}
}
impl<M, V> Act f... | start | identifier_name |
add_metadata.rs | use super::Batch;
use super::act::Act;
use super::iterator::*;
use super::packet_batch::PacketBatch;
use common::*;
use interface::Packet;
use interface::PacketTx;
use std::marker::PhantomData;
pub type MetadataFn<T, M, M2> = Box<FnMut(&Packet<T, M>) -> M2 + Send>;
pub struct AddMetadataBatch<M, V>
where
M: Send ... | }
} |
#[inline]
fn get_task_dependencies(&self) -> Vec<usize> {
self.parent.get_task_dependencies() | random_line_split |
add_metadata.rs | use super::Batch;
use super::act::Act;
use super::iterator::*;
use super::packet_batch::PacketBatch;
use common::*;
use interface::Packet;
use interface::PacketTx;
use std::marker::PhantomData;
pub type MetadataFn<T, M, M2> = Box<FnMut(&Packet<T, M>) -> M2 + Send>;
pub struct AddMetadataBatch<M, V>
where
M: Send ... |
}
#[inline]
fn done(&mut self) {
self.applied = false;
self.parent.done();
}
#[inline]
fn send_q(&mut self, port: &PacketTx) -> Result<u32> {
self.parent.send_q(port)
}
#[inline]
fn capacity(&self) -> i32 {
self.parent.capacity()
}
#[inlin... | {
self.parent.act();
{
let iter = PayloadEnumerator::<V::Header, V::Metadata>::new(&mut self.parent);
while let Some(ParsedDescriptor { mut packet, .. }) = iter.next(&mut self.parent) {
let metadata = (self.generator)(&packet);
... | conditional_block |
lib.rs | //! Prisma - The Rust Color Library
//! ===============================
//!
//! ## Table of Contents:
//! * [**Overview**](#overview)
//! - [**Color Models**](#color-models)
//! - [**Why Prisma?**](#why-prisma)
//! - [**A Tour by Example**](#a-tour-by-example)
//! * [**Details**](#details)
//! * [**Definiti... | //! * **[`Xyz`](struct.Xyz.html)** - The "parent" absolute color space other color spaces are defined in terms of
//! * **[`Lms`](lms/struct.Lms.html)** - A color space simulating human cone response
//! * **[`Lab`](struct.Lab.html)** - A uniform perception color space transformation of XYZ
//! * **[`Lchab`](struct.Lch... | random_line_split | |
conic.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/. */
//! Conic gradients
//!
//! Specification: https://drafts.csswg.org/css-images-4/#conic-gradients
//!
//! Conic gr... | }
}
/// Identifying key for a line decoration.
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq, Hash, MallocSizeOf)]
pub struct ConicGradientKey {
pub common: PrimKeyCommonData,
pub extend_mode: ExtendMode,
pu... | self.angle.to_bits().hash(state);
self.start_offset.to_bits().hash(state);
self.end_offset.to_bits().hash(state); | random_line_split |
conic.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/. */
//! Conic gradients
//!
//! Specification: https://drafts.csswg.org/css-images-4/#conic-gradients
//!
//! Conic gr... |
// Attempt to detect some of the common configurations with hard gradient stops. Allow
// those a higher maximum resolution to avoid the worst cases of aliasing artifacts with
// large conic gradients. A better solution would be to go back to rendering very large
// conic gradients via... | { (a - b).abs() < 0.01 } | identifier_body |
conic.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/. */
//! Conic gradients
//!
//! Specification: https://drafts.csswg.org/css-images-4/#conic-gradients
//!
//! Conic gr... |
}
prev_stop = Some(stop.offset);
}
let max_size = if has_hard_stops {
2048.0
} else {
1024.0
};
// Avoid rendering enormous gradients. Radial gradients are mostly made of soft transitions,
// so it is unlikely that render... | {
// a is the angle of the stop normalized into 0-1 space and repeating in the 0-0.25 range.
// If close to 0.0 or 0.25 it means the stop is vertical or horizontal. For those, the lower
// resolution isn't a big issue.
let a = item.params.a... | conditional_block |
conic.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/. */
//! Conic gradients
//!
//! Specification: https://drafts.csswg.org/css-images-4/#conic-gradients
//!
//! Conic gr... | {
pub extend_mode: ExtendMode,
pub center: DevicePoint,
pub scale: DeviceVector2D,
pub params: ConicGradientParams,
pub stops: GpuCacheHandle,
}
impl ConicGradientTask {
pub fn to_instance(&self, target_rect: &DeviceIntRect, gpu_cache: &mut GpuCache) -> ConicGradientInstance {
ConicGra... | ConicGradientTask | identifier_name |
mod.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 ... | //! The prelude is primarily concerned with exporting *traits* that are so
//! pervasive that it would be obnoxious to import for every use, particularly
//! those that define methods on primitive types.
#![stable(feature = "rust1", since = "1.0.0")]
pub mod v1; | //!
//! ```ignore
//! use std::prelude::v1::*;
//! ```
//! | random_line_split |
clap_app.rs | /*
Precached - A Linux process monitor and pre-caching daemon
Copyright (C) 2017-2020 the precached developers
This file is part of precached.
Precached is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Softwar... | .multiple(true)
.help(tr!("precachedtop-output-verbosity")),
)
.subcommand(
SubCommand::with_name("help").setting(AppSettings::DeriveDisplayOrder), //.about(tr!("precachedtop-help")),
)
.subcommand(
SubCommand::with_name("completions")
... | {
App::new("precachedtop")
.version(env!("CARGO_PKG_VERSION"))
.author("X3n0m0rph59 <x3n0m0rph59@gmail.com>")
// .versionless_subcommands(true)
// .subcommand_required_else_help(true)
.setting(AppSettings::GlobalVersion)
.setting(AppSettings::DeriveDisplayOrder)
... | identifier_body |
clap_app.rs | /*
Precached - A Linux process monitor and pre-caching daemon
Copyright (C) 2017-2020 the precached developers
This file is part of precached. |
Precached is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Precached is distributed in the hope that it will be useful,
... | random_line_split | |
clap_app.rs | /*
Precached - A Linux process monitor and pre-caching daemon
Copyright (C) 2017-2020 the precached developers
This file is part of precached.
Precached is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Softwar... | <'a, 'b>() -> App<'a, 'b>
where
'a: 'b,
{
App::new("precachedtop")
.version(env!("CARGO_PKG_VERSION"))
.author("X3n0m0rph59 <x3n0m0rph59@gmail.com>")
//.versionless_subcommands(true)
//.subcommand_required_else_help(true)
.setting(AppSettings::GlobalVersion)
.setting(... | get_app | identifier_name |
main.rs | extern crate iron;
extern crate rustc_serialize;
extern crate queryst;
use rustc_serialize::json::{self, Json};
use iron::prelude::*;
use iron::status;
use queryst::parse;
#[derive(RustcEncodable)]
pub struct PadJson {
str: String
}
fn left_pad(string: &str, len: u32, ch: &str) -> String {
let mut i ... |
fn main() {
fn handler(req: &mut Request) -> IronResult<Response> {
let query = req.url.query.clone().unwrap_or("".to_string());
let query_params: Json = parse(&query.to_string()).unwrap();
let obj = query_params.as_object().unwrap();
let string : &str = obj.get("s... | i = i + 1;
}
return padded_string;
} | random_line_split |
main.rs | extern crate iron;
extern crate rustc_serialize;
extern crate queryst;
use rustc_serialize::json::{self, Json};
use iron::prelude::*;
use iron::status;
use queryst::parse;
#[derive(RustcEncodable)]
pub struct PadJson {
str: String
}
fn left_pad(string: &str, len: u32, ch: &str) -> String {
let mut i ... | (req: &mut Request) -> IronResult<Response> {
let query = req.url.query.clone().unwrap_or("".to_string());
let query_params: Json = parse(&query.to_string()).unwrap();
let obj = query_params.as_object().unwrap();
let string : &str = obj.get("str").unwrap().as_string().u... | handler | identifier_name |
main.rs | extern crate iron;
extern crate rustc_serialize;
extern crate queryst;
use rustc_serialize::json::{self, Json};
use iron::prelude::*;
use iron::status;
use queryst::parse;
#[derive(RustcEncodable)]
pub struct PadJson {
str: String
}
fn left_pad(string: &str, len: u32, ch: &str) -> String {
let mut i ... |
Iron::new(handler).http("localhost:3000").unwrap();
}
| {
let query = req.url.query.clone().unwrap_or("".to_string());
let query_params: Json = parse(&query.to_string()).unwrap();
let obj = query_params.as_object().unwrap();
let string : &str = obj.get("str").unwrap().as_string().unwrap();
let len : u32 = obj.get... | identifier_body |
impl-not-adjacent-to-type.rs | // Copyright 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-MIT or ... | {
pub x: i32,
pub y: i32,
}
}
impl foo::Point {
fn x(&self) -> i32 { self.x }
}
fn main() {
assert_eq!((foo::Point { x: 1, y: 3}).x(), 1);
}
| Point | identifier_name |
impl-not-adjacent-to-type.rs | // Copyright 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-MIT or ... | fn x(&self) -> i32 { self.x }
}
fn main() {
assert_eq!((foo::Point { x: 1, y: 3}).x(), 1);
} | pub y: i32,
}
}
impl foo::Point { | random_line_split |
impl-not-adjacent-to-type.rs | // Copyright 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-MIT or ... | {
assert_eq!((foo::Point { x: 1, y: 3}).x(), 1);
} | identifier_body | |
instruction_analyzer.rs | //! Implements Instruction-level analysis used for lifting when information from radare2 is
//! insufficient.
//!
//! Instruction analysis may be abbreviated as `IA`
use std::borrow::Cow;
use capstone_rust::capstone as cs;
// TODO: Register must be replaced by Register information from arch-rs.
// This will be a part... |
/// Return a `Vec` of registers that are written to by this instruction
fn registers_written(&self) -> Vec<&IOperand> {
self.info().expect("Unable to get InstructionInfo").writes.iter().filter(|&x| match x {
&IOperand::Register(_) => true,
_ => false,
}).collect()
}... | {
self.info().expect("Unable to get InstructionInfo").reads.iter().filter(|&x| match x {
&IOperand::Register(_) => true,
_ => false,
}).collect()
} | identifier_body |
instruction_analyzer.rs | //! Implements Instruction-level analysis used for lifting when information from radare2 is
//! insufficient.
//!
//! Instruction analysis may be abbreviated as `IA`
use std::borrow::Cow;
use capstone_rust::capstone as cs;
// TODO: Register must be replaced by Register information from arch-rs.
// This will be a part... | (&self) -> bool {
self.info().expect("Unable to get InstructionInfo").writes.iter().any(|x| match x {
&IOperand::Memory { base: _, index: _, scale: _, disp: _ } => true,
_ => false,
})
}
/// Returns memory written to by the instruction, in standard sib form
fn memor... | has_memory_written | identifier_name |
instruction_analyzer.rs | //! Implements Instruction-level analysis used for lifting when information from radare2 is
//! insufficient.
//!
//! Instruction analysis may be abbreviated as `IA`
use std::borrow::Cow;
use capstone_rust::capstone as cs;
// TODO: Register must be replaced by Register information from arch-rs.
// This will be a part... | Err(e) => return Err(Cow::from(e.to_string())),
};
for instr in buf.iter() {
// TODO: Look into prefixes for opcode.
// See how this information is set in capstone.
self.info.mnemonic = Cow::from(instr.mnemonic);
let details = instr.detail.unw... | fn analyze(&mut self) -> Result<(), IAError> {
// Disassembly exactly one instruction
let buf = match self.cs.disasm(self.bytes.as_slice(), 0x0, 1) {
Ok(d) => d, | random_line_split |
struct.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | // 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.
// compile-flags:-Z... | // http://rust-lang.org/COPYRIGHT.
// | random_line_split |
struct.rs | // Copyright 2013 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 ... | {
let pair = Pair { x: 1, y: 2 };
let _z = ();
} | identifier_body | |
struct.rs | // Copyright 2013 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 ... | {
x: int,
y: int
}
fn main() {
let pair = Pair { x: 1, y: 2 };
let _z = ();
}
| Pair | identifier_name |
gravity.rs | extern crate nalgebra as na;
extern crate ncollide;
extern crate nphysics;
extern crate nphysics_testbed2d;
use na::{Vec2, Pnt3, Translation};
use ncollide::shape::{Ball, Plane};
use nphysics::world::World;
use nphysics::object::RigidBody;
use nphysics_testbed2d::Testbed;
fn main() | */
let mut rb = RigidBody::new_static(Plane::new(Vec2::new(0.0, -1.0)), 0.3, 0.6);
rb.append_translation(&Vec2::new(0.0, 10.0));
world.add_body(rb);
/*
* Create the balls
*/
let num = 1000usize;
let rad = 0.5;
let shift = 2.5 * rad;
let centerx = shift * (num ... | {
let mut testbed = Testbed::new_empty();
/*
* World
*/
let mut world = World::new();
world.set_gravity(Vec2::new(0.0, 9.81));
/*
* First plane
*/
let mut rb = RigidBody::new_static(Plane::new(Vec2::new(0.0, 1.0)), 0.3, 0.6);
rb.append_translation(&Vec2::new(0.0, -10.0... | identifier_body |
gravity.rs | extern crate nalgebra as na;
extern crate ncollide;
extern crate nphysics;
extern crate nphysics_testbed2d;
use na::{Vec2, Pnt3, Translation};
use ncollide::shape::{Ball, Plane};
use nphysics::world::World;
use nphysics::object::RigidBody;
use nphysics_testbed2d::Testbed;
fn | () {
let mut testbed = Testbed::new_empty();
/*
* World
*/
let mut world = World::new();
world.set_gravity(Vec2::new(0.0, 9.81));
/*
* First plane
*/
let mut rb = RigidBody::new_static(Plane::new(Vec2::new(0.0, 1.0)), 0.3, 0.6);
rb.append_translation(&Vec2::new(0.0, -1... | main | identifier_name |
gravity.rs | extern crate nalgebra as na;
extern crate ncollide;
extern crate nphysics;
extern crate nphysics_testbed2d;
use na::{Vec2, Pnt3, Translation};
use ncollide::shape::{Ball, Plane};
use nphysics::world::World;
use nphysics::object::RigidBody;
use nphysics_testbed2d::Testbed;
fn main() {
let mut testbed = Testbed::ne... | for j in 0usize.. 2 {
let x = i as f32 * 2.5 * rad - centerx;
let y = j as f32 * 2.5 * rad - centery * 2.0;
let mut rb = RigidBody::new_dynamic(Ball::new(rad), 1.0, 0.3, 0.6);
rb.append_translation(&Vec2::new(x, y));
let color;
if j == ... | let shift = 2.5 * rad;
let centerx = shift * (num as f32) / 2.0;
let centery = 2.0;
for i in (0usize .. num) { | random_line_split |
gravity.rs | extern crate nalgebra as na;
extern crate ncollide;
extern crate nphysics;
extern crate nphysics_testbed2d;
use na::{Vec2, Pnt3, Translation};
use ncollide::shape::{Ball, Plane};
use nphysics::world::World;
use nphysics::object::RigidBody;
use nphysics_testbed2d::Testbed;
fn main() {
let mut testbed = Testbed::ne... |
let body = world.add_body(rb);
testbed.set_color(&body, color);
}
}
/*
* Run the simulation.
*/
testbed.set_world(world);
testbed.run();
}
| {
// double the gravity for the green balls.
rb.set_lin_acc_scale(Vec2::new(0.0, 2.0));
color = Pnt3::new(0.0, 1.0, 0.0);
} | conditional_block |
mod.rs | use std::io;
use cfg_if::cfg_if;
use socket2::Socket;
cfg_if! {
if #[cfg(unix)] {
mod unix;
pub use self::unix::*;
}
}
#[cfg(unix)]
pub fn | <S>(socket: &S, ipv6_only: bool) -> io::Result<()>
where
S: std::os::unix::io::AsRawFd,
{
use std::os::unix::io::{FromRawFd, IntoRawFd};
let fd = socket.as_raw_fd();
let sock = unsafe { Socket::from_raw_fd(fd) };
let result = sock.set_only_v6(ipv6_only);
sock.into_raw_fd();
result
}
#[cfg(... | set_ipv6_only | identifier_name |
mod.rs | use std::io;
use cfg_if::cfg_if;
use socket2::Socket;
cfg_if! {
if #[cfg(unix)] {
mod unix;
pub use self::unix::*;
}
}
#[cfg(unix)]
pub fn set_ipv6_only<S>(socket: &S, ipv6_only: bool) -> io::Result<()>
where
S: std::os::unix::io::AsRawFd,
{
use std::os::unix::io::{FromRawFd, IntoRawF... |
#[cfg(windows)]
pub fn set_ipv6_only<S>(socket: &S, ipv6_only: bool) -> io::Result<()>
where
S: std::os::windows::io::AsRawSocket,
{
use std::os::windows::io::{FromRawSocket, IntoRawSocket};
let handle = socket.as_raw_socket();
let sock = unsafe { Socket::from_raw_socket(handle) };
let result = so... | result
} | random_line_split |
mod.rs | use std::io;
use cfg_if::cfg_if;
use socket2::Socket;
cfg_if! {
if #[cfg(unix)] {
mod unix;
pub use self::unix::*;
}
}
#[cfg(unix)]
pub fn set_ipv6_only<S>(socket: &S, ipv6_only: bool) -> io::Result<()>
where
S: std::os::unix::io::AsRawFd,
|
#[cfg(windows)]
pub fn set_ipv6_only<S>(socket: &S, ipv6_only: bool) -> io::Result<()>
where
S: std::os::windows::io::AsRawSocket,
{
use std::os::windows::io::{FromRawSocket, IntoRawSocket};
let handle = socket.as_raw_socket();
let sock = unsafe { Socket::from_raw_socket(handle) };
let result = s... | {
use std::os::unix::io::{FromRawFd, IntoRawFd};
let fd = socket.as_raw_fd();
let sock = unsafe { Socket::from_raw_fd(fd) };
let result = sock.set_only_v6(ipv6_only);
sock.into_raw_fd();
result
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.