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 |
|---|---|---|---|---|
overloaded-index-autoderef.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 ... | (&self, z: &int) -> &int {
if *z == 0 {
&self.x
} else {
&self.y
}
}
}
impl IndexMut<int> for Foo {
fn index_mut(&mut self, z: &int) -> &mut int {
if *z == 0 {
&mut self.x
} else {
&mut self.y
}
}
}
trait Int {... | index | identifier_name |
overloaded-index-autoderef.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 ... |
}
impl IndexMut<int> for Foo {
fn index_mut(&mut self, z: &int) -> &mut int {
if *z == 0 {
&mut self.x
} else {
&mut self.y
}
}
}
trait Int {
fn get(self) -> int;
fn get_from_ref(&self) -> int;
fn inc(&mut self);
}
impl Int for int {
fn get(sel... | {
if *z == 0 {
&self.x
} else {
&self.y
}
} | identifier_body |
nested_macro_privacy.rs | // Copyright 2017 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 foo::{S, m};
S::default().i; //~ ERROR field `i` of struct `foo::S` is private
m!(S::default()); // ok
}
| main | identifier_name |
nested_macro_privacy.rs | // Copyright 2017 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 foo::{S, m};
S::default().i; //~ ERROR field `i` of struct `foo::S` is private
m!(S::default()); // ok
} | identifier_body | |
nested_macro_privacy.rs | // Copyright 2017 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 macro $m($e:expr) { $e.$i }
}
}
n!(foo, S, i, m);
fn main() {
use foo::{S, m};
S::default().i; //~ ERROR field `i` of struct `foo::S` is private
m!(S::default()); // ok
} | macro n($foo:ident, $S:ident, $i:ident, $m:ident) {
mod $foo {
#[derive(Default)]
pub struct $S { $i: u32 } | random_line_split |
a6.rs | fn main() { // Ciclos while, for, Enumerate
let mut x = 5;
let mut completado = false; // La variable mutable completado es de tipo booleano, es decir que solo tiene dos valores: false o true.
println!("Ciclo while");
while!completado { // El ciclo while termina cuando la sentencia se cumpla en este caso cuando ... | for i in 0..6 { // Este ciclo empiza por el primer número y termina uno antes del indicado, para este caso empieza en 0 y termina en 5
println!("{}", i);
};
println!("Ciclo for con enumerate()");
for (i,j) in (5..11).enumerate() { // enumerate cuenta las veces que se iterao se hace el ciclo, es importa... | // El ciclo for de rust luce mas parecido al de ruby.
println!("Ciclo for"); | random_line_split |
a6.rs | fn main() { // Ciclos while, for, Enumerate
let mut x = 5;
let mut completado = false; // La variable mutable completado es de tipo booleano, es decir que solo tiene dos valores: false o true.
println!("Ciclo while");
while!completado { // El ciclo while termina cuando la sentencia se cumpla en este caso cuando ... | ;
};
// El ciclo for de rust luce mas parecido al de ruby.
println!("Ciclo for");
for i in 0..6 { // Este ciclo empiza por el primer número y termina uno antes del indicado, para este caso empieza en 0 y termina en 5
println!("{}", i);
};
println!("Ciclo for con enumerate()");
for (i,j) in (5..11).e... | {
completado = true;
} | conditional_block |
a6.rs | fn main() | println!("Ciclo for con enumerate()");
for (i,j) in (5..11).enumerate() { // enumerate cuenta las veces que se iterao se hace el ciclo, es importante respetar los parentensis.
println!("i = {} y j = {}", i, j); // i imprime el número de iteración y j el rango en el que se esta iterando.
};
} | { // Ciclos while, for, Enumerate
let mut x = 5;
let mut completado = false; // La variable mutable completado es de tipo booleano, es decir que solo tiene dos valores: false o true.
println!("Ciclo while");
while !completado { // El ciclo while termina cuando la sentencia se cumpla en este caso cuando completad... | identifier_body |
a6.rs | fn | () { // Ciclos while, for, Enumerate
let mut x = 5;
let mut completado = false; // La variable mutable completado es de tipo booleano, es decir que solo tiene dos valores: false o true.
println!("Ciclo while");
while!completado { // El ciclo while termina cuando la sentencia se cumpla en este caso cuando complet... | main | identifier_name |
lib.rs | extern crate csv;
extern crate failure;
extern crate flate2;
extern crate tar;
extern crate unicode_casefold;
extern crate unicode_segmentation;
pub use failure::Error;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::io;
use std::io::prelude::*;
use std::result;
u... |
Entry::Vacant(vacant) => {
vacant.insert(1);
}
}
}
#[test]
fn grapheme_frequency() {
use std::str;
let mut builder = ModelBuilder::new();
builder.add_line("Hello world");
let mut csv = vec![];
builder.grapheme_frequencies(&mut csv).unwrap();
assert_eq!(str::fro... | {
*occupied.get_mut() += 1;
} | conditional_block |
lib.rs | extern crate csv;
extern crate failure;
extern crate flate2;
extern crate tar;
extern crate unicode_casefold;
extern crate unicode_segmentation;
pub use failure::Error;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::io;
use std::io::prelude::*;
use std::result;
u... |
#[test]
fn grapheme_frequency() {
use std::str;
let mut builder = ModelBuilder::new();
builder.add_line("Hello world");
let mut csv = vec![];
builder.grapheme_frequencies(&mut csv).unwrap();
assert_eq!(str::from_utf8(&csv).unwrap(),
"\
l,0.3
o,0.2
H,0.1
d,0.1
e,0.1
r,0.1
w,0.1
... | {
match map.entry(key.to_owned()) {
Entry::Occupied(mut occupied) => {
*occupied.get_mut() += 1;
}
Entry::Vacant(vacant) => {
vacant.insert(1);
}
}
} | identifier_body |
lib.rs | extern crate csv;
extern crate failure;
extern crate flate2;
extern crate tar;
extern crate unicode_casefold;
extern crate unicode_segmentation;
pub use failure::Error;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::io;
use std::io::prelude::*;
use std::result;
u... |
let mut builder = ModelBuilder::new();
builder.add_line("Help");
let mut csv = vec![];
builder.pair_frequencies(&mut csv).unwrap();
assert_eq!(str::from_utf8(&csv).unwrap(),
"\
\"\nH\",0.2
He,0.2
el,0.2
lp,0.2
\"p\n\",0.2
");
}
#[test]
fn word_frequency() {
use std::str;
le... | }
#[test]
fn pair_frequency() {
use std::str; | random_line_split |
lib.rs | extern crate csv;
extern crate failure;
extern crate flate2;
extern crate tar;
extern crate unicode_casefold;
extern crate unicode_segmentation;
pub use failure::Error;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::io;
use std::io::prelude::*;
use std::result;
u... | () -> ModelBuilder {
ModelBuilder {
grapheme_counts: HashMap::new(),
pair_counts: HashMap::new(),
word_counts: HashMap::new(),
}
}
/// Add a subtitle line to the `ModelBuilder`.
pub fn add_line(&mut self, line: &str) {
let grapheme_buffer = line.g... | new | identifier_name |
binops.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 test_class() {
let mut q = p(1, 2);
let mut r = p(1, 2);
unsafe {
error!("q = %x, r = %x",
(::core::cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&q))),
(::core::cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&r))));
}
assert!((q == r));
r.y = 17;
assert!((r.y!= q.y));
a... | {
p {
x: x,
y: y
}
} | identifier_body |
binops.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 ... | () {
let mut q = p(1, 2);
let mut r = p(1, 2);
unsafe {
error!("q = %x, r = %x",
(::core::cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&q))),
(::core::cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&r))));
}
assert!((q == r));
r.y = 17;
assert!((r.y!= q.y));
assert!((r.y == ... | test_class | identifier_name |
binops.rs | // 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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except accordin... | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | random_line_split | |
log.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 std::error::Error;
pub fn error(e: &Error) {
target::error(e)
} | // ANDROID //////////////////////////////////////////////////////////////////
#[cfg(target_os = "android")]
mod target {
use libc::*;
use std::error::Error;
use std::ffi::*;
const TAG: &'static [u8] = b"CryptoBox";
const LEVEL_ERROR: c_int = 6;
pub fn error(e: &Error) {
log(&format!("... | random_line_split | |
log.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 std::error::Error;
pub fn error(e: &Error) {
target::error(e)
}
// ANDROID /////////////////////////////... | (e: &Error) {
log(&format!("{}", e), LEVEL_ERROR)
}
fn log(msg: &str, lvl: c_int) {
let tag = CString::new(TAG).unwrap();
let msg = CString::new(msg.as_bytes()).unwrap_or(CString::new("<malformed log message>").unwrap());
unsafe {
__android_log_write(lvl, tag.as_ptr(... | error | identifier_name |
log.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 std::error::Error;
pub fn error(e: &Error) {
target::error(e)
}
// ANDROID /////////////////////////////... |
}
| {
writeln!(&mut stderr(), "ERROR: {}", e).unwrap();
} | identifier_body |
mod.rs | pub use self::mouse_joint::{MouseJointConfig, MouseJoint};
use std::rc::{Rc, Weak};
use std::cell::RefCell;
use std::mem;
use std::ptr;
use super::{Body, BodyHandleWeak};
use super::island::{Position, Velocity};
use ::dynamics::world::TimeStep;
mod mouse_joint;
pub type JointHandle<'a> = Rc<RefCell<Joint<'a>>>;
pub ... | self.get_joint_data_mut().is_island = is_island;
}
pub fn is_island(&self) -> bool {
self.get_joint_data().is_island
}
pub fn initialize_velocity_constraints(&mut self, step: TimeStep, positions: &Vec<Position>, velocities: &mut Vec<Velocity>) {
match self {
&mut Jo... |
pub fn set_island(&mut self, is_island: bool) { | random_line_split |
mod.rs | pub use self::mouse_joint::{MouseJointConfig, MouseJoint};
use std::rc::{Rc, Weak};
use std::cell::RefCell;
use std::mem;
use std::ptr;
use super::{Body, BodyHandleWeak};
use super::island::{Position, Velocity};
use ::dynamics::world::TimeStep;
mod mouse_joint;
pub type JointHandle<'a> = Rc<RefCell<Joint<'a>>>;
pub ... | (&self) -> bool {
self.get_joint_data().is_island
}
pub fn initialize_velocity_constraints(&mut self, step: TimeStep, positions: &Vec<Position>, velocities: &mut Vec<Velocity>) {
match self {
&mut Joint::Mouse(ref mut joint) => joint.initialize_velocity_constraints(step, positions, ... | is_island | identifier_name |
lib.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use channel::diem_channel::{self, Receiver};
use diem_config::{
config::{Peer, PeerRole},
network_id::NetworkContext,
};
use diem_crypto::x25519::PublicKey;
use diem_logger::prelude::*;
use diem_metrics::{
register_histogram... | self.process_payload(payload).await;
}
warn!(
NetworkSchema::new(&self.network_context),
"{} OnChain Discovery actor terminated", self.network_context,
);
}
}
#[cfg(test)]
mod tests {
use super::*;
use diem_config::config::HANDSHAKE_VERSION;
... |
while let Some(payload) = self.next_reconfig_event().await { | random_line_split |
lib.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use channel::diem_channel::{self, Receiver};
use diem_config::{
config::{Peer, PeerRole},
network_id::NetworkContext,
};
use diem_crypto::x25519::PublicKey;
use diem_logger::prelude::*;
use diem_metrics::{
register_histogram... | (seed: [u8; 32]) -> PublicKey {
let mut rng: StdRng = SeedableRng::from_seed(seed);
let private_key = PrivateKey::generate(&mut rng);
private_key.public_key()
}
}
| test_pubkey | identifier_name |
lib.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use channel::diem_channel::{self, Receiver};
use diem_config::{
config::{Peer, PeerRole},
network_id::NetworkContext,
};
use diem_crypto::x25519::PublicKey;
use diem_logger::prelude::*;
use diem_metrics::{
register_histogram... | ])
.set(mismatch);
}
/// Processes a received OnChainConfigPayload. Depending on role (Validator or FullNode), parses
/// the appropriate configuration changes and passes it to the ConnectionManager channel.
async fn process_payload(&mut self, payload: OnChainConfigPayload) {
... | {
let mismatch = onchain_keys.map_or(0, |pubkeys| {
if !pubkeys.contains(&self.expected_pubkey) {
error!(
NetworkSchema::new(&self.network_context),
"Onchain pubkey {:?} differs from local pubkey {}",
pubkeys,
... | identifier_body |
lib.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use channel::diem_channel::{self, Receiver};
use diem_config::{
config::{Peer, PeerRole},
network_id::NetworkContext,
};
use diem_crypto::x25519::PublicKey;
use diem_logger::prelude::*;
use diem_metrics::{
register_histogram... | else {
PeerRole::ValidatorFullNode
};
(peer_id, Peer::from_addrs(peer_role, addrs))
})
.collect();
vec![ConnectivityRequest::UpdateDiscoveredPeers(
DiscoverySource::OnChain,
discovered_peers,
)]
}
impl ConfigurationChangeListener {
//... | {
PeerRole::Validator
} | conditional_block |
main.rs | use std::io::BufReader;
use std::fs::File;
use std::str::FromStr;
use std::io;
use std::io::prelude::*;
use std::collections::HashSet;
use std::cmp::Reverse;
fn has_distinct_pair(set:&HashSet<i64>, sum: i64) -> bool {
for k in set.iter() {
let v = sum - k;
if *k!= v && set.contains(&v) {
... | {
for arg in std::env::args().skip(1) {
let value = print_medians(&arg).expect("failed to read");
println!("answer = {}", value);
}
} | identifier_body | |
main.rs | use std::io::BufReader;
use std::fs::File;
use std::str::FromStr;
use std::io;
use std::io::prelude::*;
use std::collections::HashSet;
use std::cmp::Reverse;
fn has_distinct_pair(set:&HashSet<i64>, sum: i64) -> bool {
for k in set.iter() {
let v = sum - k;
if *k!= v && set.contains(&v) {
... |
}
Ok(result)
}
fn main() {
for arg in std::env::args().skip(1) {
let value = print_medians(&arg).expect("failed to read");
println!("answer = {}", value);
}
}
| {
result = result + 1;
} | conditional_block |
main.rs | use std::io::BufReader;
use std::fs::File;
use std::str::FromStr;
use std::io;
use std::io::prelude::*;
use std::collections::HashSet;
use std::cmp::Reverse;
fn has_distinct_pair(set:&HashSet<i64>, sum: i64) -> bool {
for k in set.iter() {
let v = sum - k;
if *k!= v && set.contains(&v) {
... | let mut result = 0;
for s in -10000..10001 {
if has_distinct_pair(&set, s) {
result = result + 1;
}
}
Ok(result)
}
fn main() {
for arg in std::env::args().skip(1) {
let value = print_medians(&arg).expect("failed to read");
println!("answer = {}", value);... | random_line_split | |
main.rs | use std::io::BufReader;
use std::fs::File;
use std::str::FromStr;
use std::io;
use std::io::prelude::*;
use std::collections::HashSet;
use std::cmp::Reverse;
fn | (set:&HashSet<i64>, sum: i64) -> bool {
for k in set.iter() {
let v = sum - k;
if *k!= v && set.contains(&v) {
return true;
}
}
false
}
fn print_medians(file_name: &str) -> io::Result<u64> {
let f = File::open(file_name)?;
let reader = BufReader::new(f);
... | has_distinct_pair | identifier_name |
get_event_authorization.rs | //! `GET /_matrix/federation/*/event_auth/{roomId}/{eventId}`
//!
//! Endpoint to retrieve the complete auth chain for a given event.
pub mod v1 {
//! `/v1/` ([spec])
//!
//! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1event_authroomideventid
use ruma_common::{api::ru... |
}
}
| {
Self { auth_chain }
} | identifier_body |
get_event_authorization.rs | //! `GET /_matrix/federation/*/event_auth/{roomId}/{eventId}`
//!
//! Endpoint to retrieve the complete auth chain for a given event.
pub mod v1 {
//! `/v1/` ([spec])
//!
//! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1event_authroomideventid
use ruma_common::{api::ru... | (auth_chain: Vec<Box<RawJsonValue>>) -> Self {
Self { auth_chain }
}
}
}
| new | identifier_name |
mod.rs | // Copyright 2017 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... | CallTag::Batch(prom) => prom.resolve(success),
CallTag::Request(cb) => cb.resolve(cq, success),
CallTag::UnaryRequest(cb) => cb.resolve(cq, success),
CallTag::Abort(_) => {}
CallTag::Shutdown(prom) => prom.resolve(success),
CallTag::Spawn(notify) =... | }
/// Resolve the CallTag with given status.
pub fn resolve(self, cq: &CompletionQueue, success: bool) {
match self { | random_line_split |
mod.rs | // Copyright 2017 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... | (&mut self) -> Poll<T, Error> {
let mut guard = self.inner.lock();
if guard.stale {
panic!("Resolved future is not supposed to be polled again.");
}
if let Some(res) = guard.result.take() {
guard.stale = true;
return Ok(Async::Ready(res?));
}
... | poll | identifier_name |
mod.rs | // Copyright 2017 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
}
#[cfg(test)]
mod tests {
use std::sync::mpsc::*;
use std::sync::*;
use std::thread;
use super::*;
use crate::env::Environment;
#[test]
fn test_resolve() {
let env = Environment::new(1);
let (cq_f1, tag1) = CallTag::shutdown_pair();
let (cq_f2, tag2) = CallTag::... | {
match *self {
CallTag::Batch(ref ctx) => write!(f, "CallTag::Batch({:?})", ctx),
CallTag::Request(_) => write!(f, "CallTag::Request(..)"),
CallTag::UnaryRequest(_) => write!(f, "CallTag::UnaryRequest(..)"),
CallTag::Abort(_) => write!(f, "CallTag::Abort(..)"),
... | identifier_body |
wall.rs | use glium;
use types;
use camera;
use shaders;
use texture;
#[derive(Copy, Clone)]
struct Vertex {
position: [f32; 3],
normal: [f32; 3],
tex_coords: [f32; 2]
}
implement_vertex!(Vertex, position, normal, tex_coords);
pub struct Wall {
matrix: types::Mat,
buffer: glium::VertexBuffer<Vertex>,
d... | normal: [0.0, 0.0, -1.0],
tex_coords: [1.0, 1.0] },
Vertex { position: [-1.0, -1.0, 0.0],
normal: [0.0, 0.0, -1.0],
tex_coords: [0.0, 0.0] },
Vertex { position: [ 1.0, -1.0, 0.0],
normal: [0.... | let buffer = glium::vertex::VertexBuffer::new(window, &[
Vertex { position: [-1.0, 1.0, 0.0],
normal: [0.0, 0.0, -1.0],
tex_coords: [0.0, 1.0] },
Vertex { position: [ 1.0, 1.0, 0.0], | random_line_split |
wall.rs | use glium;
use types;
use camera;
use shaders;
use texture;
#[derive(Copy, Clone)]
struct | {
position: [f32; 3],
normal: [f32; 3],
tex_coords: [f32; 2]
}
implement_vertex!(Vertex, position, normal, tex_coords);
pub struct Wall {
matrix: types::Mat,
buffer: glium::VertexBuffer<Vertex>,
diffuse_texture: glium::texture::SrgbTexture2d,
normal_map: glium::texture::texture2d::Texture... | Vertex | identifier_name |
wall.rs | use glium;
use types;
use camera;
use shaders;
use texture;
#[derive(Copy, Clone)]
struct Vertex {
position: [f32; 3],
normal: [f32; 3],
tex_coords: [f32; 2]
}
implement_vertex!(Vertex, position, normal, tex_coords);
pub struct Wall {
matrix: types::Mat,
buffer: glium::VertexBuffer<Vertex>,
d... | u_light: light,
diffuse_tex: &self.diffuse_texture,
normal_tex: &self.normal_map
};
frame_buffer.draw(&self.buffer, &glium::index::NoIndices(strip),
&library.lit_texture,
&uniforms, ¶ms).unwrap();
}
}
| {
use glium::Surface;
use glium::DrawParameters;
let strip = glium::index::PrimitiveType::TriangleStrip;
let params = glium::DrawParameters {
depth: glium::Depth {
test: glium::draw_parameters::DepthTest::IfLess,
write: true,
.... | identifier_body |
htmlsourceelement.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::HTMLSourceElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLSour... |
}
impl HTMLSourceElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLSourceElement {
HTMLSourceElement {
htmlelement: HTMLElement::new_inherited(HTMLSourceElementTypeId, localName, document)
}
}
pub fn new(localName: DOMString, document: &JS... | {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLSourceElementTypeId))
} | identifier_body |
htmlsourceelement.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::HTMLSourceElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLSour... | <'a>(&'a self) -> &'a Reflector {
self.htmlelement.reflector()
}
}
| reflector | identifier_name |
htmlsourceelement.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::HTMLSourceElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLSour... | }
impl HTMLSourceElementDerived for EventTarget {
fn is_htmlsourceelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLSourceElementTypeId))
}
}
impl HTMLSourceElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLSourceElement {
... | use servo_util::str::DOMString;
#[deriving(Encodable)]
pub struct HTMLSourceElement {
pub htmlelement: HTMLElement | random_line_split |
wrapper.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A safe wrapper for DOM nodes that prevents layout from mutating the DOM, from letting DOM nodes
//! escape, an... |
// If this is a text node, use the parent element, since that's what
// controls our style.
if node.is_text_node() {
node = node.parent_node().unwrap();
debug_assert!(node.is_element());
}
let damage = {
let data = node.get_raw_data().unwrap(... | // We need the underlying node to potentially access the parent in the
// case of text nodes. This is safe as long as we don't let the parent
// escape and never access its descendants.
let mut node = unsafe { self.unsafe_get() }; | random_line_split |
wrapper.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A safe wrapper for DOM nodes that prevents layout from mutating the DOM, from letting DOM nodes
//! escape, an... | (&self) -> Option<AtomicRefMut<LayoutData>> {
self.get_raw_data().map(|d| d.layout_data.borrow_mut())
}
fn flow_debug_id(self) -> usize {
self.borrow_layout_data()
.map_or(0, |d| d.flow_construction_result.debug_id())
}
}
pub trait GetRawData {
fn get_raw_data(&self) -> Opti... | mutate_layout_data | identifier_name |
wrapper.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A safe wrapper for DOM nodes that prevents layout from mutating the DOM, from letting DOM nodes
//! escape, an... |
fn text_content(&self) -> TextContent {
if self.get_pseudo_element_type().is_replaced_content() {
let style = self.as_element().unwrap().resolved_style();
return TextContent::GeneratedContent(match style.as_ref().get_counters().content {
Content::Items(ref value) =... | {
self.mutate_layout_data().unwrap().flags.remove(flags);
} | identifier_body |
c_type.rs | pub fn rustify_pointers(c_type: &str) -> (String, String) {
let mut input = c_type.trim();
let leading_const = input.starts_with("const ");
if leading_const {
input = &input[6..];
}
let end = [
input.find(" const"),
input.find("*const"),
input.find("*"),
Some(... | () {
assert_eq!(rustify_ptr("char"), s("", "char"));
assert_eq!(rustify_ptr("char*"), s("*mut", "char"));
assert_eq!(rustify_ptr("const char*"), s("*const", "char"));
assert_eq!(rustify_ptr("char const*"), s("*const", "char"));
assert_eq!(rustify_ptr("char const *"), s("*const", ... | rustify_pointers | identifier_name |
c_type.rs | pub fn rustify_pointers(c_type: &str) -> (String, String) | let res = (ptrs.join(" "), inner);
trace!("rustify `{}` -> `{}` `{}`", c_type, res.0, res.1);
res
}
#[cfg(test)]
mod tests {
use super::rustify_pointers as rustify_ptr;
fn s(x: &str, y: &str) -> (String, String) {
(x.into(), y.into())
}
#[test]
fn rustify_pointers() {
... | {
let mut input = c_type.trim();
let leading_const = input.starts_with("const ");
if leading_const {
input = &input[6..];
}
let end = [
input.find(" const"),
input.find("*const"),
input.find("*"),
Some(input.len()),
].iter().filter_map(|&x| x).min().unwrap... | identifier_body |
c_type.rs | pub fn rustify_pointers(c_type: &str) -> (String, String) {
let mut input = c_type.trim();
let leading_const = input.starts_with("const ");
if leading_const {
input = &input[6..];
}
let end = [
input.find(" const"),
input.find("*const"),
input.find("*"),
Some(... | else { "*mut" }).collect();
if let (true, Some(p)) = (leading_const, ptrs.last_mut()) {
*p = "*const";
}
let res = (ptrs.join(" "), inner);
trace!("rustify `{}` -> `{}` `{}`", c_type, res.0, res.1);
res
}
#[cfg(test)]
mod tests {
use super::rustify_pointers as rustify_ptr;
fn s(x... | { "*const" } | conditional_block |
c_type.rs | pub fn rustify_pointers(c_type: &str) -> (String, String) {
let mut input = c_type.trim();
let leading_const = input.starts_with("const ");
if leading_const {
input = &input[6..];
}
let end = [
input.find(" const"),
input.find("*const"),
input.find("*"),
Some(... | }
#[test]
fn rustify_pointers() {
assert_eq!(rustify_ptr("char"), s("", "char"));
assert_eq!(rustify_ptr("char*"), s("*mut", "char"));
assert_eq!(rustify_ptr("const char*"), s("*const", "char"));
assert_eq!(rustify_ptr("char const*"), s("*const", "char"));
assert_eq!... | random_line_split | |
job.rs | //
// Copyright:: Copyright (c) 2016 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... | self.fips_custom_cert_filename,
new_config,
)
}
}
fn with_default<'a>(val: &'a str, default: &'a str, local: &bool) -> &'a str {
if!local ||!val.is_empty() {
val
} else {
default
}
}
pub fn clap_subcommand<'c>() -> App<'c, 'c> {
SubCommand::with_nam... | {
let project = try!(project::project_or_from_cwd(&self.project));
let mut new_config = config
.set_pipeline(&self.pipeline)
.set_user(with_default(&self.user, "you", &&self.local))
.set_server(with_default(&self.server, "localhost", &&self.local))
.set_e... | identifier_body |
job.rs | //
// Copyright:: Copyright (c) 2016 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... | () -> Self {
JobClapOptions {
stage: "",
phases: "",
change: "",
pipeline: "master",
job_root: "",
project: "",
user: "",
server: "",
ent: "",
org: "",
patchset: "",
ch... | default | identifier_name |
job.rs | //
// Copyright:: Copyright (c) 2016 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... |
fips::merge_fips_options_and_config(
self.fips,
self.fips_git_port,
self.fips_custom_cert_filename,
new_config,
)
}
}
fn with_default<'a>(val: &'a str, default: &'a str, local: &bool) -> &'a str {
if!local ||!val.is_empty() {
val
} e... | {
new_config.saml = Some(true)
} | conditional_block |
job.rs | //
// Copyright:: Copyright (c) 2016 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... | None
},
}
}
}
impl<'n> Options for JobClapOptions<'n> {
fn merge_options_and_config(&self, config: Config) -> DeliveryResult<Config> {
let project = try!(project::project_or_from_cwd(&self.project));
let mut new_config = config
.set_pipeline(&self... | a2_mode: if matches.is_present("a2-mode") {
Some(true)
} else { | random_line_split |
sort.rs | use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::process::Command;
static PROGNAME: &'static str = "./sort";
#[test]
fn numeric1() {
numeric_helper(1);
}
#[test]
fn numeric2() {
numeric_helper(2);
}
#[test]
fn numeric3() {
numeric_helper(3);
}
#[test]
fn numeric4() {
numeric_help... | Ok(_) => {},
Err(err) => panic!("{}", err)
}
assert_eq!(String::from_utf8(po.stdout).unwrap(), String::from_utf8(answer).unwrap());
} | });
let mut answer = vec!();
match f.read_to_end(&mut answer) { | random_line_split |
sort.rs | use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::process::Command;
static PROGNAME: &'static str = "./sort";
#[test]
fn numeric1() {
numeric_helper(1);
}
#[test]
fn numeric2() {
numeric_helper(2);
}
#[test]
fn numeric3() {
numeric_helper(3);
}
#[test]
fn numeric4() {
numeric_help... | ,
Err(err) => panic!("{}", err)
}
assert_eq!(String::from_utf8(po.stdout).unwrap(), String::from_utf8(answer).unwrap());
}
| {} | conditional_block |
sort.rs | use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::process::Command;
static PROGNAME: &'static str = "./sort";
#[test]
fn numeric1() {
numeric_helper(1);
}
#[test]
fn numeric2() |
#[test]
fn numeric3() {
numeric_helper(3);
}
#[test]
fn numeric4() {
numeric_helper(4);
}
#[test]
fn numeric5() {
numeric_helper(5);
}
fn numeric_helper(test_num: isize) {
let mut cmd = Command::new(PROGNAME);
cmd.arg("-n");
let po = match cmd.arg(format!("{}{}{}", "numeric", test_num, ".tx... | {
numeric_helper(2);
} | identifier_body |
sort.rs | use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::process::Command;
static PROGNAME: &'static str = "./sort";
#[test]
fn numeric1() {
numeric_helper(1);
}
#[test]
fn numeric2() {
numeric_helper(2);
}
#[test]
fn numeric3() {
numeric_helper(3);
}
#[test]
fn numeric4() {
numeric_help... | (test_num: isize) {
let mut cmd = Command::new(PROGNAME);
cmd.arg("-n");
let po = match cmd.arg(format!("{}{}{}", "numeric", test_num, ".txt")).output() {
Ok(p) => p,
Err(err) => panic!("{}", err)
};
let filename = format!("{}{}{}", "numeric", test_num, ".ans");
let mut f = File... | numeric_helper | identifier_name |
lib.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
mod handlers;
use crate::handlers::get_routes;
use diem_logger::prelude::*;
use diemdb::DiemDB;
use std::{net::SocketAddr, sync::Arc};
use tokio::runtime::{Builder, Runtime};
pub fn start_backup_service(address: SocketAddr, db: Arc<Di... | () {
let tmpdir = TempPath::new();
let db = Arc::new(DiemDB::new_for_test(&tmpdir));
let port = get_available_port();
let _rt = start_backup_service(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port), db);
// Endpoint doesn't exist.
let resp = get(&format!("http://12... | routing_and_error_codes | identifier_name |
lib.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
mod handlers;
use crate::handlers::get_routes;
use diem_logger::prelude::*;
use diemdb::DiemDB;
use std::{net::SocketAddr, sync::Arc};
use tokio::runtime::{Builder, Runtime};
pub fn start_backup_service(address: SocketAddr, db: Arc<Di... | "http://127.0.0.1:{}/state_range_proof/{}",
port, 123
))
.unwrap();
assert_eq!(resp.status(), 400);
let resp = get(&format!("http://127.0.0.1:{}/state_snapshot", port)).unwrap();
assert_eq!(resp.status(), 400);
// Params fail to parse (HashValue)
... | let resp = get(&format!( | random_line_split |
lib.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
mod handlers;
use crate::handlers::get_routes;
use diem_logger::prelude::*;
use diemdb::DiemDB;
use std::{net::SocketAddr, sync::Arc};
use tokio::runtime::{Builder, Runtime};
pub fn start_backup_service(address: SocketAddr, db: Arc<Di... | assert_eq!(resp.status(), 400);
let resp = get(&format!("http://127.0.0.1:{}/state_snapshot", port)).unwrap();
assert_eq!(resp.status(), 400);
// Params fail to parse (HashValue)
let resp = get(&format!("http://127.0.0.1:{}/state_range_proof/1/ff", port)).unwrap();
asser... | {
let tmpdir = TempPath::new();
let db = Arc::new(DiemDB::new_for_test(&tmpdir));
let port = get_available_port();
let _rt = start_backup_service(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port), db);
// Endpoint doesn't exist.
let resp = get(&format!("http://127.0... | identifier_body |
scope.rs | // https://rustbyexample.com/variable_bindings/scope.html
// http://rust-lang-ja.org/rust-by-example/variable_bindings/scope.html
fn | () {
// This binding lives in the main function
let long_lived_binding = 1;
// This is a block, and has a smaller scope than the main function
{
// This binding only exists in this block
let short_lived_binding = 2;
println!("inner short: {}", short_lived_binding);
// ... | main | identifier_name |
scope.rs | // https://rustbyexample.com/variable_bindings/scope.html
// http://rust-lang-ja.org/rust-by-example/variable_bindings/scope.html
fn main() { |
// This is a block, and has a smaller scope than the main function
{
// This binding only exists in this block
let short_lived_binding = 2;
println!("inner short: {}", short_lived_binding);
// This binding *shadows* the outer one
let long_lived_binding = 5_f32;
... | // This binding lives in the main function
let long_lived_binding = 1; | random_line_split |
scope.rs | // https://rustbyexample.com/variable_bindings/scope.html
// http://rust-lang-ja.org/rust-by-example/variable_bindings/scope.html
fn main() | // FIXME ^ Comment out this line
println!("outer long: {}", long_lived_binding);
// This binding also *shadows* the previous binding
let long_lived_binding = 'a';
println!("outer long: {}", long_lived_binding);
}
| {
// This binding lives in the main function
let long_lived_binding = 1;
// This is a block, and has a smaller scope than the main function
{
// This binding only exists in this block
let short_lived_binding = 2;
println!("inner short: {}", short_lived_binding);
// Thi... | identifier_body |
argument-passing.rs | // run-pass
struct X {
x: isize
}
fn f1(a: &mut X, b: &mut isize, c: isize) -> isize {
let r = a.x + *b + c;
a.x = 0;
*b = 10;
return r;
}
fn | <F>(a: isize, f: F) -> isize where F: FnOnce(isize) { f(1); return a; }
pub fn main() {
let mut a = X {x: 1};
let mut b = 2;
let c = 3;
assert_eq!(f1(&mut a, &mut b, c), 6);
assert_eq!(a.x, 0);
assert_eq!(b, 10);
assert_eq!(f2(a.x, |_| a.x = 50), 0);
assert_eq!(a.x, 50);
}
| f2 | identifier_name |
argument-passing.rs | // run-pass
struct X {
x: isize
}
fn f1(a: &mut X, b: &mut isize, c: isize) -> isize { | }
fn f2<F>(a: isize, f: F) -> isize where F: FnOnce(isize) { f(1); return a; }
pub fn main() {
let mut a = X {x: 1};
let mut b = 2;
let c = 3;
assert_eq!(f1(&mut a, &mut b, c), 6);
assert_eq!(a.x, 0);
assert_eq!(b, 10);
assert_eq!(f2(a.x, |_| a.x = 50), 0);
assert_eq!(a.x, 50);
} | let r = a.x + *b + c;
a.x = 0;
*b = 10;
return r; | random_line_split |
argument-passing.rs | // run-pass
struct X {
x: isize
}
fn f1(a: &mut X, b: &mut isize, c: isize) -> isize {
let r = a.x + *b + c;
a.x = 0;
*b = 10;
return r;
}
fn f2<F>(a: isize, f: F) -> isize where F: FnOnce(isize) { f(1); return a; }
pub fn main() | {
let mut a = X {x: 1};
let mut b = 2;
let c = 3;
assert_eq!(f1(&mut a, &mut b, c), 6);
assert_eq!(a.x, 0);
assert_eq!(b, 10);
assert_eq!(f2(a.x, |_| a.x = 50), 0);
assert_eq!(a.x, 50);
} | identifier_body | |
command.rs | // Copyright 2016 The Gfx-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | #[derive(Clone, Copy, PartialEq, Debug)]
pub struct DataPointer {
offset: u32,
size: u32,
}
pub struct DataBuffer(Vec<u8>);
impl DataBuffer {
/// Create a new empty data buffer.
pub fn new() -> DataBuffer {
DataBuffer(Vec::new())
}
/// Reset the contents.
pub fn reset(&mut self) {
... | /// The place of some data in the data buffer. | random_line_split |
command.rs | // Copyright 2016 The Gfx-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... |
fn clear_depth_stencil(&mut self, target: native::Dsv, depth: Option<target::Depth>,
stencil: Option<target::Stencil>) {
let flags = //warning: magic constants ahead
D3D11_CLEAR_FLAG(if depth.is_some() {1} else {0}) |
D3D11_CLEAR_FLAG(if stencil.is_some()... | {
match value {
command::ClearColor::Float(data) => {
self.parser.parse(Command::ClearColor(target, data));
},
_ => {
error!("Unable to clear int/uint target");
},
}
} | identifier_body |
command.rs | // Copyright 2016 The Gfx-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | (&mut self, target: native::Rtv, value: command::ClearColor) {
match value {
command::ClearColor::Float(data) => {
self.parser.parse(Command::ClearColor(target, data));
},
_ => {
error!("Unable to clear int/uint target");
},
... | clear_color | identifier_name |
command.rs | // Copyright 2016 The Gfx-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... |
}
}
fn bind_unordered_views(&mut self, uvs: &[pso::UnorderedViewParam<Resources>]) {
let mut views = [(); MAX_UNORDERED_VIEWS];
let mut count = 0;
for view in uvs.iter() {
views[view.2 as usize] = view.0;
count += 1;
}
if count!= 0 {
... | {
self.parser.parse(Command::BindShaderResources(stage, views));
} | conditional_block |
node.rs | // Copyright 2018 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::fmt::{Debug, Display};
use std::hash::Hash;
use boxfuture::BoxFuture;
use hashing::Digest;
use futures01::future::Future;
use petgraph::stable_graph;
use crate::entry::Entry;... | /// Creates an instance that represents that a Node dependency was cyclic along the given path.
///
fn cyclic(path: Vec<String>) -> Self;
}
///
/// A trait used to visualize Nodes in either DOT/GraphViz format.
///
pub trait NodeVisualizer<N: Node> {
///
/// Returns a GraphViz color scheme name for this visu... | /// Graph (generally while running).
///
fn invalidated() -> Self;
/// | random_line_split |
node.rs | // Copyright 2018 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::fmt::{Debug, Display};
use std::hash::Hash;
use boxfuture::BoxFuture;
use hashing::Digest;
use futures01::future::Future;
use petgraph::stable_graph;
use crate::entry::Entry;... | (&self) -> Option<String> {
None
}
}
pub trait NodeError: Clone + Debug + Eq + Send {
///
/// Creates an instance that represents that a Node was invalidated out of the
/// Graph (generally while running).
///
fn invalidated() -> Self;
///
/// Creates an instance that represents that a Node depend... | user_facing_name | identifier_name |
node.rs | // Copyright 2018 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::fmt::{Debug, Display};
use std::hash::Hash;
use boxfuture::BoxFuture;
use hashing::Digest;
use futures01::future::Future;
use petgraph::stable_graph;
use crate::entry::Entry;... |
}
pub trait NodeError: Clone + Debug + Eq + Send {
///
/// Creates an instance that represents that a Node was invalidated out of the
/// Graph (generally while running).
///
fn invalidated() -> Self;
///
/// Creates an instance that represents that a Node dependency was cyclic along the given path.
... | {
None
} | identifier_body |
cssparse.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 little helpers for hooking up the HTML parser with the CSS parser.
use std::cell::Cell;
use std::comm;
u... | do task::spawn {
// TODO: CSS parsing should take a base URL.
let _url = do provenance_cell.with_ref |p| {
match *p {
UrlProvenance(ref the_url) => (*the_url).clone(),
InlineProvenance(ref the_url, _) => (*the_url).clone()
}
};
... | random_line_split | |
cssparse.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 little helpers for hooking up the HTML parser with the CSS parser.
use std::cell::Cell;
use std::comm;
u... | (provenance: StylesheetProvenance,
resource_task: ResourceTask)
-> Port<Stylesheet> {
let (result_port, result_chan) = comm::stream();
let provenance_cell = Cell::new(provenance);
do task::spawn {
// TODO: CSS parsing should take a base URL.
let ... | spawn_css_parser | identifier_name |
char.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | #[stable(feature = "rust1", since = "1.0.0")]
pub struct ToUppercase(CaseMappingIter);
#[stable(feature = "rust1", since = "1.0.0")]
impl Iterator for ToUppercase {
type Item = char;
fn next(&mut self) -> Option<char> { self.0.next() }
}
/// An iterator over the titlecase mapping of a given character, returne... | /// An iterator over the uppercase mapping of a given character, returned from
/// the [`to_uppercase` method](../primitive.char.html#method.to_uppercase) on
/// characters. | random_line_split |
char.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | 's displayed width in columns, or `None` if it is a
/// control character other than `'\x00'`.
///
/// `is_cjk` determines behavior for characters in the Ambiguous category:
/// if `is_cjk` is `true`, these are 2 columns wide; otherwise, they are 1.
/// In CJK contexts, `is_cjk` should be `true`, el... | gIter::new(conversions::to_upper(self)))
}
/// Returns this character | identifier_body |
char.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | f) -> EscapeDefault { C::escape_default(self) }
/// Returns the number of bytes this character would need if encoded in
/// UTF-8.
///
/// # Examples
///
/// ```
/// let n = 'ß'.len_utf8();
///
/// assert_eq!(n, 2);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
p... | pe_default(sel | identifier_name |
basename.rs | #![crate_name = "uu_basename"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Jimmy Lu <jimmy.lu.2011@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#[macro_use]
extern crate uucore;
use std::io::Wri... | if name.ends_with(suffix) {
return name[..name.len() - suffix.len()].to_owned();
}
name.to_owned()
} | fn strip_suffix(name: &str, suffix: &str) -> String {
if name == suffix {
return name.to_owned();
}
| random_line_split |
basename.rs | #![crate_name = "uu_basename"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Jimmy Lu <jimmy.lu.2011@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#[macro_use]
extern crate uucore;
use std::io::Wri... | {
if name == suffix {
return name.to_owned();
}
if name.ends_with(suffix) {
return name[..name.len() - suffix.len()].to_owned();
}
name.to_owned()
} | identifier_body | |
basename.rs | #![crate_name = "uu_basename"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Jimmy Lu <jimmy.lu.2011@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#[macro_use]
extern crate uucore;
use std::io::Wri... | (args: Vec<String>) -> i32 {
//
// Argument parsing
//
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP)
.optflag("a", "multiple", "Support more than one argument. Treat every argument as a name.")
.optopt("s", "suffix", "Remove a trailing suffix. This option implies the -a option.",... | uumain | identifier_name |
basename.rs | #![crate_name = "uu_basename"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Jimmy Lu <jimmy.lu.2011@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#[macro_use]
extern crate uucore;
use std::io::Wri... | ;
for path in paths {
print!("{}{}", basename(&path, &suffix), line_ending);
}
0
}
fn basename(fullname: &str, suffix: &str) -> String {
// Remove all platform-specific path separators from the end
let mut path: String = fullname.chars().rev().skip_while(|&ch| is_separator(ch)).collect();
... | { "\n" } | conditional_block |
lib.rs | //! # The Rust Core Library
//!
//! The Rust Core Library is the dependency-free[^free] foundation of [The
//! Rust Standard Library](../std/index.html). It is the portable glue
//! between the language and its libraries, defining the intrinsic and
//! primitive building blocks of all Rust code. It links to no
//! upst... | #![deny(rust_2021_incompatible_or_patterns)]
#![deny(unsafe_op_in_unsafe_fn)]
#![warn(deprecated_in_future)]
#![warn(missing_debug_implementations)]
#![warn(missing_docs)]
#![allow(explicit_outlives_requirements)]
#![cfg_attr(bootstrap, allow(incomplete_features))] // if_let_guard
//
// Library features for const fns:
... | // Lints: | random_line_split |
tests.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use super::*;
use once_cell::sync::Lazy;
use parking_lot::Mutex;
use regex::Regex;
use std::fmt;
use std::sync::atomic::AtomicU64;
use std::s... | {
id: AtomicU64,
out: Arc<Mutex<Vec<String>>>,
}
impl TestSubscriber {
fn log(&self, s: String) {
self.out.lock().push(normalize(&s));
}
}
impl Subscriber for TestSubscriber {
fn enabled(&self, _metadata: &Metadata) -> bool {
true
}
fn new_span(&self, span: &Attributes) -> I... | TestSubscriber | identifier_name |
tests.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use super::*;
use once_cell::sync::Lazy;
use parking_lot::Mutex;
use regex::Regex;
use std::fmt;
use std::sync::atomic::AtomicU64;
use std::s... | /// Capture logs about tracing.
fn capture(f: impl FnOnce()) -> Vec<String> {
// Prevent races since tests run in multiple threads.
let _locked = THREAD_LOCK.lock();
let sub = TestSubscriber::default();
let out = sub.out.clone();
tracing::subscriber::with_default(sub, f);
let out = out.lock();
... | let s2 = "abc".to_string().intern();
assert_eq!(s1.as_ptr(), s2.as_ptr());
}
| random_line_split |
tests.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use super::*;
use once_cell::sync::Lazy;
use parking_lot::Mutex;
use regex::Regex;
use std::fmt;
use std::sync::atomic::AtomicU64;
use std::s... |
#[test]
fn test_intern() {
use crate::Intern;
let s1 = "abc".intern();
let s2 = "abc".to_string().intern();
assert_eq!(s1.as_ptr(), s2.as_ptr());
}
/// Capture logs about tracing.
fn capture(f: impl FnOnce()) -> Vec<String> {
// Prevent races since tests run in multiple threads.
let _locked =... | {
let callsite1 = create_callsite::<EventKindType, _>((33, 1), CallsiteInfo::default);
let callsite2 = create_callsite::<EventKindType, _>((33, 1), CallsiteInfo::default);
assert_eq!(callsite1 as *const _, callsite2 as *const _);
} | identifier_body |
method_self_arg2.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 ... | () -> u64 { unsafe { COUNT } }
#[derive(Copy, Clone)]
pub struct Foo;
impl Foo {
pub fn run_trait(self) {
unsafe { COUNT *= 17; }
// Test internal call.
Bar::foo1(&self);
Bar::foo2(self);
Bar::foo3(box self);
Bar::bar1(&self);
Bar::bar2(self);
Bar::... | get_count | identifier_name |
method_self_arg2.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 ... | } | random_line_split | |
method_self_arg2.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 foo2(self) {
unsafe { COUNT *= 3; }
}
fn foo3(self: Box<Foo>) {
unsafe { COUNT *= 5; }
}
}
| {
unsafe { COUNT *= 2; }
} | identifier_body |
evec-slice.rs | // run-pass
#![allow(unused_assignments)]
pub fn main() {
let x : &[isize] = &[1,2,3,4,5];
let mut z : &[isize] = &[1,2,3,4,5];
z = x;
assert_eq!(z[0], 1); | assert_eq!(z[4], 5);
let a : &[isize] = &[1,1,1,1,1];
let b : &[isize] = &[2,2,2,2,2];
let c : &[isize] = &[2,2,2,2,3];
let cc : &[isize] = &[2,2,2,2,2,2];
println!("{:?}", a);
assert!(a < b);
assert!(a <= b);
assert!(a!= b);
assert!(b >= a);
assert!(b > a);
println!(... | random_line_split | |
evec-slice.rs | // run-pass
#![allow(unused_assignments)]
pub fn main() | println!("{:?}", b);
assert!(b < c);
assert!(b <= c);
assert!(b!= c);
assert!(c >= b);
assert!(c > b);
assert!(a < c);
assert!(a <= c);
assert!(a!= c);
assert!(c >= a);
assert!(c > a);
println!("{:?}", c);
assert!(a < cc);
assert!(a <= cc);
assert!(a!= cc)... | {
let x : &[isize] = &[1,2,3,4,5];
let mut z : &[isize] = &[1,2,3,4,5];
z = x;
assert_eq!(z[0], 1);
assert_eq!(z[4], 5);
let a : &[isize] = &[1,1,1,1,1];
let b : &[isize] = &[2,2,2,2,2];
let c : &[isize] = &[2,2,2,2,3];
let cc : &[isize] = &[2,2,2,2,2,2];
println!("{:?}", a);
... | identifier_body |
evec-slice.rs | // run-pass
#![allow(unused_assignments)]
pub fn | () {
let x : &[isize] = &[1,2,3,4,5];
let mut z : &[isize] = &[1,2,3,4,5];
z = x;
assert_eq!(z[0], 1);
assert_eq!(z[4], 5);
let a : &[isize] = &[1,1,1,1,1];
let b : &[isize] = &[2,2,2,2,2];
let c : &[isize] = &[2,2,2,2,3];
let cc : &[isize] = &[2,2,2,2,2,2];
println!("{:?}", a)... | main | identifier_name |
driver.rs | use util::errors::{
Result,
Error,
};
use term::terminfo::TermInfo;
use term::terminfo::parm;
use term::terminfo::parm::{
Param,
Variables,
};
// String constants correspond to terminfo capnames and are used internally for name resolution.
const ENTER_CA: &'static str = "smcup";
const EXIT_CA: &'stati... | Cap::SetCursor(x, y) => {
let params = &[Param::Number(y as i16), Param::Number(x as i16)];
let mut vars = Variables::new();
parm::expand(cap, params, &mut vars).unwrap()
},
_ => {
cap.clone()
},
}
... | let params = &[Param::Number(attr as i16)];
let mut vars = Variables::new();
parm::expand(cap, params, &mut vars).unwrap()
}, | random_line_split |
driver.rs | use util::errors::{
Result,
Error,
};
use term::terminfo::TermInfo;
use term::terminfo::parm;
use term::terminfo::parm::{
Param,
Variables,
};
// String constants correspond to terminfo capnames and are used internally for name resolution.
const ENTER_CA: &'static str = "smcup";
const EXIT_CA: &'stati... | (&self) -> &'static str {
match *self {
Cap::EnterCa => ENTER_CA,
Cap::ExitCa => EXIT_CA,
Cap::ShowCursor => SHOW_CURSOR,
Cap::HideCursor => HIDE_CURSOR,
Cap::SetCursor(..) => SET_CURSOR,
Cap::Clear => CLEAR,
Cap::Reset => RESET... | resolve | identifier_name |
font.rs | * 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 app_units::Au;
use euclid::{Point2D, Rect, Size2D};
use font_context::{FontContext, FontSource};
use font_template::FontTemplateDescriptor;
use ordered_float::NotNan;
use platform::... | if character =='' {
// https://drafts.csswg.org/css-text-3/#word-spacing-property
let (length, percent) = options.word_spacing;
advance = (advance + length) + Au((advance.0 as f32 * percent.into_inner()) as i32);
}
if let Some(letter_sp... | let mut advance = Au::from_f64_px(self.glyph_h_advance(glyph_id)); | random_line_split |
font.rs | 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 app_units::Au;
use euclid::{Point2D, Rect, Size2D};
use font_context::{FontContext, FontSource};
use font_template::FontTemplateDescriptor;
use ordered_float::NotNan;
use platform::fo... | {
descriptor: FontDescriptor,
families: SmallVec<[FontGroupFamily; 8]>,
last_matching_fallback: Option<FontRef>,
}
impl FontGroup {
pub fn new(style: &FontStyleStruct) -> FontGroup {
let descriptor = FontDescriptor::from(style);
let families =
style.font_family.0.iter()
... | FontGroup | identifier_name |
chain.rs | // Copyright 2015, 2016 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 la... | {
let mut fail_unless = |cond: bool| if!cond &&!fail {
failed.push(name.clone());
flushln!("FAIL");
fail = true;
true
} else {false};
flush!(" - {}...", name);
let spec = {
let genesis = Genesis::from(blockchain.genesis());
let state = From::from(blockchain.pre_state.clone());
... | random_line_split | |
chain.rs | // Copyright 2015, 2016 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 la... | (json_data: &[u8]) -> Vec<String> {
json_chain_test(json_data, ChainEra::TransitionTest)
}
declare_test!{BlockchainTests_TestNetwork_bcSimpleTransitionTest, "BlockchainTests/TestNetwork/bcSimpleTransitionTest"}
declare_test!{BlockchainTests_TestNetwork_bcTheDaoTest, "BlockchainTests/TestNetwork/bcTheDaoTest"}
de... | do_json_test | identifier_name |
chain.rs | // Copyright 2015, 2016 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 la... |
declare_test!{BlockchainTests_TestNetwork_bcSimpleTransitionTest, "BlockchainTests/TestNetwork/bcSimpleTransitionTest"}
declare_test!{BlockchainTests_TestNetwork_bcTheDaoTest, "BlockchainTests/TestNetwork/bcTheDaoTest"}
declare_test!{BlockchainTests_TestNetwork_bcEIP150Test, "BlockchainTests/TestNetwork/bcEIP150Te... | {
json_chain_test(json_data, ChainEra::TransitionTest)
} | identifier_body |
main.rs | extern crate yars_raytracer; | use std::path::Path;
use yars_raytracer::vector3d::Vec3;
use yars_raytracer::algebra::InnerProductSpace;
use yars_raytracer::space_algebra::SO3;
use yars_raytracer::ray::Orientable;
use yars_raytracer::camera::CameraBuilder;
use yars_raytracer::scene::{Scene, Light, AmbientLight};
use yars_raytracer::shade::{Shader, P... | extern crate image;
use std::fs::File; | random_line_split |
main.rs | extern crate yars_raytracer;
extern crate image;
use std::fs::File;
use std::path::Path;
use yars_raytracer::vector3d::Vec3;
use yars_raytracer::algebra::InnerProductSpace;
use yars_raytracer::space_algebra::SO3;
use yars_raytracer::ray::Orientable;
use yars_raytracer::camera::CameraBuilder;
use yars_raytracer::scene... | () {
let WIDTH = 800;
let HEIGHT = 600;
let OUTPUT = "output.png";
let camera = (SO3::rotation_x(0.47) * CameraBuilder::new(WIDTH, HEIGHT, 45.0) +
Vec3(0.0, -2.0, 0.0))
.build();
let mut img = ImageBuffer::new(WIDTH, HEIGHT);
// Some test paramters
let a_colour = ... | main | identifier_name |
main.rs | extern crate yars_raytracer;
extern crate image;
use std::fs::File;
use std::path::Path;
use yars_raytracer::vector3d::Vec3;
use yars_raytracer::algebra::InnerProductSpace;
use yars_raytracer::space_algebra::SO3;
use yars_raytracer::ray::Orientable;
use yars_raytracer::camera::CameraBuilder;
use yars_raytracer::scene... | let mat1 = Material::new([0.5, 0.5, 0.5],
[0.5, 0.3, 0.01],
[0.5, 0.3, 0.01],
[0.1, 0.1, 0.05],
7.0);
let mat2 = Material::new([0.3, 0.2, 0.5],
[0.3, 0.1, 0.5],
... | {
let WIDTH = 800;
let HEIGHT = 600;
let OUTPUT = "output.png";
let camera = (SO3::rotation_x(0.47) * CameraBuilder::new(WIDTH, HEIGHT, 45.0) +
Vec3(0.0, -2.0, 0.0))
.build();
let mut img = ImageBuffer::new(WIDTH, HEIGHT);
// Some test paramters
let a_colour = Rg... | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.