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 |
|---|---|---|---|---|
atomic_cxchg_rel.rs | #![feature(core, core_intrinsics)]
extern crate core;
#[cfg(test)]
mod tests {
use core::intrinsics::atomic_cxchg_rel;
use core::cell::UnsafeCell;
use std::sync::Arc;
use std::thread;
// pub fn atomic_cxchg_rel<T>(dst: *mut T, old: T, src: T) -> T;
struct A<T> {
v: UnsafeCell<T>
}
... | (v: T) -> A<T> {
A { v: UnsafeCell::<T>::new(v) }
}
}
type T = usize;
macro_rules! atomic_cxchg_rel_test {
($init:expr, $old:expr, $new:expr, $result:expr) => ({
let value: T = $init;
let a: A<T> = A::<T>::new(value);
let data: Arc<A<T>> = Arc::<A<T>>::new(a);
let clone: Arc<A<... | new | identifier_name |
checksum.rs | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib_sys;
use translate::*;
use ChecksumType;
glib_wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Checksum(Boxed<glib_sys::GChecksum>);
... | get_type => || glib_sys::g_checksum_get_type(),
}
}
impl Checksum {
pub fn new(checksum_type: ChecksumType) -> Checksum {
unsafe { from_glib_full(glib_sys::g_checksum_new(checksum_type.to_glib())) }
}
pub fn reset(&mut self) {
unsafe {
glib_sys::g_checksum_reset(sel... | random_line_split | |
checksum.rs | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib_sys;
use translate::*;
use ChecksumType;
glib_wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Checksum(Boxed<glib_sys::GChecksum>);
... |
pub fn update(&mut self, data: &[u8]) {
let length = data.len() as isize;
unsafe {
glib_sys::g_checksum_update(self.to_glib_none_mut().0, data.to_glib_none().0, length);
}
}
pub fn type_get_length(checksum_type: ChecksumType) -> isize {
unsafe { glib_sys::g_che... | {
unsafe {
glib_sys::g_checksum_reset(self.to_glib_none_mut().0);
}
} | identifier_body |
checksum.rs | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib_sys;
use translate::*;
use ChecksumType;
glib_wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Checksum(Boxed<glib_sys::GChecksum>);
... | (checksum_type: ChecksumType) -> Checksum {
unsafe { from_glib_full(glib_sys::g_checksum_new(checksum_type.to_glib())) }
}
pub fn reset(&mut self) {
unsafe {
glib_sys::g_checksum_reset(self.to_glib_none_mut().0);
}
}
pub fn update(&mut self, data: &[u8]) {
l... | new | identifier_name |
order.rs | /*
* Panopticon - A libre disassembler
* Copyright (C) 2015,2017 Panopticon authors
*
* This program 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 optio... |
/// Computes the number of edge crossings in graph.
pub fn crossings(
bipartite: &HashMap<(usize, usize), Vec<(AdjacencyListEdgeDescriptor, AdjacencyListEdgeDescriptor)>>,
order: &Vec<Vec<AdjacencyListVertexDescriptor>>,
graph: &AdjacencyList<usize, usize>,
) -> usize {
use std::mem::swap;
let mu... | {
let mut alt = order.clone();
wmedian(iteration, &mut alt, rank, graph);
let alt_xings = crossings(&bipartite, &alt, graph);
if alt_xings < *xings {
*order = alt;
*xings = alt_xings;
}
} | identifier_body |
order.rs | /*
* Panopticon - A libre disassembler
* Copyright (C) 2015,2017 Panopticon authors
*
* This program 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 optio... | graph: &AdjacencyList<usize, usize>,
) -> usize {
use std::mem::swap;
let mut ret = 0;
for (&(r_top, r_bot), v) in bipartite.iter() {
assert!(r_top <= r_bot);
let ord_top = &order[r_top];
let ord_bot = &order[r_bot];
// sum #crossings of all edge pairs between adjacen... | /// Computes the number of edge crossings in graph.
pub fn crossings(
bipartite: &HashMap<(usize, usize), Vec<(AdjacencyListEdgeDescriptor, AdjacencyListEdgeDescriptor)>>,
order: &Vec<Vec<AdjacencyListVertexDescriptor>>, | random_line_split |
order.rs | /*
* Panopticon - A libre disassembler
* Copyright (C) 2015,2017 Panopticon authors
*
* This program 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 optio... | (
bipartite: &HashMap<(usize, usize), Vec<(AdjacencyListEdgeDescriptor, AdjacencyListEdgeDescriptor)>>,
order: &Vec<Vec<AdjacencyListVertexDescriptor>>,
graph: &AdjacencyList<usize, usize>,
) -> usize {
use std::mem::swap;
let mut ret = 0;
for (&(r_top, r_bot), v) in bipartite.iter() {
... | crossings | identifier_name |
order.rs | /*
* Panopticon - A libre disassembler
* Copyright (C) 2015,2017 Panopticon authors
*
* This program 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 optio... | swap(&mut vert_set1, &mut vert_set2);
}
// case split based on how the vertices are distributed along the adjacent ranks.
// a and b are the resp. endpoints of the two edges.
let has_crossing = match (vert_set1.len(), vert_set2.len()) ... | {
let mut vert_set1 = vec![];
let mut vert_set2 = vec![];
// sort vertices from the upper rank into vert_set1 and from the lower into vert_set2
// contents of the vectors are pairs (order,edge)
for (v, e) in vec![(e1src, e1), (e1tgt, e1), ... | conditional_block |
fingerprint.rs | is dirty or fresh, respectively.
///
/// Both units of work are always generated because a fresh package may still be
/// rebuilt if some upstream dependency changes.
pub type Preparation = (Freshness, Work, Work);
/// Prepare the necessary work for the fingerprint for a specific target.
///
/// When dealing with fin... | (unit: &Unit, compare: &CargoResult<()>) {
let mut e = match *compare {
Ok(..) => return,
Err(ref e) => &**e,
};
info!("fingerprint error for {}: {}", unit.pkg, e);
while let Some(cause) = e.cargo_cause() {
info!(" cause: {}", cause);
e = cause;
}
let mut e = e.c... | log_compare | identifier_name |
fingerprint.rs | the target is dirty or fresh, respectively.
///
/// Both units of work are always generated because a fresh package may still be
/// rebuilt if some upstream dependency changes.
pub type Preparation = (Freshness, Work, Work);
/// Prepare the necessary work for the fingerprint for a specific target.
///
/// When deali... |
impl Hash for MtimeSlot {
fn hash<H: Hasher>(&self, h: &mut H) {
self.0.lock().unwrap().hash(h)
}
}
impl Encodable for MtimeSlot {
fn encode<E: Encoder>(&self, e: &mut E) -> Result<(), E::Error> {
self.0.lock().unwrap().map(|ft| {
(ft.seconds_relative_to_1970(), ft.nanoseconds(... | }
})
})
}
} | random_line_split |
fingerprint.rs | is dirty or fresh, respectively.
///
/// Both units of work are always generated because a fresh package may still be
/// rebuilt if some upstream dependency changes.
pub type Preparation = (Freshness, Work, Work);
/// Prepare the necessary work for the fingerprint for a specific target.
///
/// When dealing with fin... | // induce a recompile, they're just dependencies in the sense that they need
// to be built.
let deps = try!(cx.dep_targets(unit).iter().filter(|u| {
!u.target.is_custom_build() &&!u.target.is_bin()
}).map(|unit| {
calculate(cx, unit).map(|fingerprint| {
(unit.pkg.package_id()... | {
if let Some(s) = cx.fingerprints.get(unit) {
return Ok(s.clone())
}
// First, calculate all statically known "salt data" such as the profile
// information (compiler flags), the compiler version, activated features,
// and target configuration.
let features = cx.resolve.features(unit.... | identifier_body |
wrap.rs | use ascii_canvas::AsciiView;
use std::cmp;
use super::*;
#[derive(Debug)]
pub struct Wrap {
items: Vec<Box<Content>>,
}
impl Wrap {
pub fn new(items: Vec<Box<Content>>) -> Self |
}
impl Content for Wrap {
fn min_width(&self) -> usize {
self.items.iter().map(|c| c.min_width()).max().unwrap()
}
fn emit(&self, view: &mut AsciiView) {
let columns = view.columns();
let mut row = 0; // current row
let mut height = 1; // max height of anything in this row... | {
let mut wrap_items = vec![];
for item in items {
item.into_wrap_items(&mut wrap_items);
}
Wrap { items: wrap_items }
} | identifier_body |
wrap.rs | use ascii_canvas::AsciiView;
use std::cmp;
use super::*;
#[derive(Debug)]
pub struct Wrap {
items: Vec<Box<Content>>,
}
impl Wrap {
pub fn new(items: Vec<Box<Content>>) -> Self {
let mut wrap_items = vec![];
for item in items {
item.into_wrap_items(&mut wrap_items);
}
... |
assert!(column + len <= columns);
let (c_row, c_column) = item.emit_at(view, row, column);
assert!(c_column >= column);
column = c_column + 2;
height = cmp::max(c_row - row + 1, height);
}
}
fn into_wrap_items(self: Box<Self>, wrap_items: &... | {
column = 0;
row += height;
height = 1;
} | conditional_block |
wrap.rs | use ascii_canvas::AsciiView;
use std::cmp;
use super::*;
#[derive(Debug)]
pub struct Wrap {
items: Vec<Box<Content>>,
}
impl Wrap {
pub fn new(items: Vec<Box<Content>>) -> Self {
let mut wrap_items = vec![];
for item in items {
item.into_wrap_items(&mut wrap_items);
}
... | } | } | random_line_split |
wrap.rs | use ascii_canvas::AsciiView;
use std::cmp;
use super::*;
#[derive(Debug)]
pub struct | {
items: Vec<Box<Content>>,
}
impl Wrap {
pub fn new(items: Vec<Box<Content>>) -> Self {
let mut wrap_items = vec![];
for item in items {
item.into_wrap_items(&mut wrap_items);
}
Wrap { items: wrap_items }
}
}
impl Content for Wrap {
fn min_width(&self) -> ... | Wrap | identifier_name |
cabi_mips.rs | // 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.
#![allow(non_upper_case_globals)]
use libc::c_uint;
use std::cmp;
use llvm;
use llvm::{... | // Copyright 2012-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 | random_line_split | |
cabi_mips.rs | // Copyright 2012-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-MI... | }
fn is_reg_ty(ty: Type) -> bool {
return match ty.kind() {
Integer
| Pointer
| Float
| Double => true,
_ => false
};
}
fn padding_ty(ccx: &CrateContext, align: uint, offset: uint) -> Option<Type> {
if ((align - 1 ) & offset) > 0 {
Some(Type::i32(ccx))
... | {
let orig_offset = *offset;
let size = ty_size(ty) * 8;
let mut align = ty_align(ty);
align = cmp::min(cmp::max(align, 4), 8);
*offset = align_up_to(*offset, align);
*offset += align_up_to(size, align * 8) / 8;
if is_reg_ty(ty) {
let attr = if ty == Type::i1(ccx) { Some(ZExtAttrib... | identifier_body |
cabi_mips.rs | // Copyright 2012-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-MI... | (off: uint, ty: Type) -> uint {
let a = ty_align(ty);
return align_up_to(off, a);
}
fn ty_align(ty: Type) -> uint {
match ty.kind() {
Integer => {
unsafe {
((llvm::LLVMGetIntTypeWidth(ty.to_ref()) as uint) + 7) / 8
}
}
Pointer => 4,
Fl... | align | identifier_name |
error.rs | use std::fmt;
use crate::error::RenderingError;
/// An enumeration of errors that can occur during filter primitive rendering.
#[derive(Debug, Clone)]
pub enum FilterError {
/// The filter was passed invalid input (the `in` attribute).
InvalidInput,
/// The filter was passed an invalid parameter.
Inva... | }
impl fmt::Display for FilterResolveError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
FilterResolveError::ReferenceToNonFilterElement => {
write!(f, "reference to a non-filter element")
}
FilterResolveError::InvalidLightSou... | {
match *self {
FilterError::InvalidInput => write!(f, "invalid value of the `in` attribute"),
FilterError::InvalidParameter(ref s) => write!(f, "invalid parameter value: {}", s),
FilterError::BadInputSurfaceStatus(ref status) => {
write!(f, "invalid status of... | identifier_body |
error.rs | use std::fmt;
use crate::error::RenderingError;
/// An enumeration of errors that can occur during filter primitive rendering.
#[derive(Debug, Clone)]
pub enum | {
/// The filter was passed invalid input (the `in` attribute).
InvalidInput,
/// The filter was passed an invalid parameter.
InvalidParameter(String),
/// The filter input surface has an unsuccessful status.
BadInputSurfaceStatus(cairo::Error),
/// A Cairo error.
///
/// This means... | FilterError | identifier_name |
error.rs | use std::fmt;
use crate::error::RenderingError;
/// An enumeration of errors that can occur during filter primitive rendering.
#[derive(Debug, Clone)]
pub enum FilterError {
/// The filter was passed invalid input (the `in` attribute).
InvalidInput,
/// The filter was passed an invalid parameter.
Inva... | impl fmt::Display for FilterResolveError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
FilterResolveError::ReferenceToNonFilterElement => {
write!(f, "reference to a non-filter element")
}
FilterResolveError::InvalidLightSource... | }
}
| random_line_split |
sccache_cargo.rs | //! System tests for compiling Rust code with cargo.
//!
//! Any copyright is dedicated to the Public Domain.
//! http://creativecommons.org/publicdomain/zero/1.0/
#![deny(rust_2018_idioms)]
#[cfg(all(not(target_os = "windows"), not(target_os = "macos")))]
#[macro_use]
extern crate log;
/// Test that building a simp... |
fn stop() {
trace!("sccache --stop-server");
drop(
sccache_command()
.arg("--stop-server")
.stdout(Stdio::null())
.stderr(Stdio::null())
.status(),
);
}
drop(
env_logger::Builder::new()
.for... | {
Command::new(assert_cmd::cargo::cargo_bin("sccache"))
} | identifier_body |
sccache_cargo.rs | //! System tests for compiling Rust code with cargo.
//!
//! Any copyright is dedicated to the Public Domain.
//! http://creativecommons.org/publicdomain/zero/1.0/
#![deny(rust_2018_idioms)]
#[cfg(all(not(target_os = "windows"), not(target_os = "macos")))]
#[macro_use]
extern crate log;
/// Test that building a simp... | #[cfg(all(not(target_os = "windows"), not(target_os = "macos")))]
fn test_rust_cargo_cmd(cmd: &str) {
use assert_cmd::prelude::*;
use chrono::Local;
use predicates::prelude::*;
use std::env;
use std::ffi::OsStr;
use std::fs;
use std::io::Write;
use std::path::Path;
use std::process::... | random_line_split | |
sccache_cargo.rs | //! System tests for compiling Rust code with cargo.
//!
//! Any copyright is dedicated to the Public Domain.
//! http://creativecommons.org/publicdomain/zero/1.0/
#![deny(rust_2018_idioms)]
#[cfg(all(not(target_os = "windows"), not(target_os = "macos")))]
#[macro_use]
extern crate log;
/// Test that building a simp... | (cmd: &str) {
use assert_cmd::prelude::*;
use chrono::Local;
use predicates::prelude::*;
use std::env;
use std::ffi::OsStr;
use std::fs;
use std::io::Write;
use std::path::Path;
use std::process::{Command, Stdio};
fn sccache_command() -> Command {
Command::new(assert_cmd... | test_rust_cargo_cmd | identifier_name |
build.rs | extern crate ctest;
use std::env;
use std::path::PathBuf;
fn main() |
// Don't perform `((type_t) -1) < 0)` checks for pointers because
// they are unsigned and always >= 0.
cfg.skip_signededness(|s| match s {
s if s.ends_with("_callback") => true,
"cubeb_devid" => true,
_ => false,
});
// g_cubeb_log_* globals aren't visible via cubeb.h, ski... | {
let root = PathBuf::from(env::var_os("DEP_CUBEB_ROOT").unwrap());
let mut cfg = ctest::TestGenerator::new();
// Include the header files where the C APIs are defined
cfg.header("cubeb.h")
.header("cubeb_mixer.h")
.header("cubeb_resampler.h");
// Include the directory where the h... | identifier_body |
build.rs | extern crate ctest;
use std::env;
use std::path::PathBuf;
fn | () {
let root = PathBuf::from(env::var_os("DEP_CUBEB_ROOT").unwrap());
let mut cfg = ctest::TestGenerator::new();
// Include the header files where the C APIs are defined
cfg.header("cubeb.h")
.header("cubeb_mixer.h")
.header("cubeb_resampler.h");
// Include the directory where the ... | main | identifier_name |
build.rs | extern crate ctest;
use std::env;
use std::path::PathBuf;
fn main() {
let root = PathBuf::from(env::var_os("DEP_CUBEB_ROOT").unwrap());
let mut cfg = ctest::TestGenerator::new();
// Include the header files where the C APIs are defined
cfg.header("cubeb.h")
.header("cubeb_mixer.h")
.he... | .include(root.join("include/cubeb"))
.include("../cubeb-sys/libcubeb/src");
cfg.type_name(|s, _, _| s.to_string())
.field_name(|_, f| match f {
"device_type" => "type".to_string(),
_ => f.to_string(),
});
// Don't perform `((type_t) -1) < 0)` checks for poi... | cfg.include(root.join("include")) | random_line_split |
closure-substs.rs | #![feature(nll)]
// Test that we enforce user-provided type annotations on closures.
fn foo<'a>() {
// Here `x` is free in the closure sig:
|x: &'a i32| -> &'static i32 {
return x; //~ ERROR lifetime may not live long enough
};
}
fn foo1() { | |x: &i32| -> &'static i32 {
return x; //~ ERROR lifetime may not live long enough
};
}
fn bar<'a>() {
// Here `x` is free in the closure sig:
|x: &'a i32, b: fn(&'static i32)| {
b(x); //~ ERROR lifetime may not live long enough
};
}
fn bar1() {
// Here `x` is bound in the closu... | // Here `x` is bound in the closure sig: | random_line_split |
closure-substs.rs | #![feature(nll)]
// Test that we enforce user-provided type annotations on closures.
fn foo<'a>() {
// Here `x` is free in the closure sig:
|x: &'a i32| -> &'static i32 {
return x; //~ ERROR lifetime may not live long enough
};
}
fn foo1() {
// Here `x` is bound in the closure sig:
|x: &i... | () {}
| main | identifier_name |
closure-substs.rs | #![feature(nll)]
// Test that we enforce user-provided type annotations on closures.
fn foo<'a>() {
// Here `x` is free in the closure sig:
|x: &'a i32| -> &'static i32 {
return x; //~ ERROR lifetime may not live long enough
};
}
fn foo1() {
// Here `x` is bound in the closure sig:
|x: &i... |
fn bar1() {
// Here `x` is bound in the closure sig:
|x: &i32, b: fn(&'static i32)| {
b(x); //~ ERROR borrowed data escapes outside of closure
};
}
fn main() {}
| {
// Here `x` is free in the closure sig:
|x: &'a i32, b: fn(&'static i32)| {
b(x); //~ ERROR lifetime may not live long enough
};
} | identifier_body |
ledger.rs | // Copyright 2017 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable... | use fidl::Error;
use magenta::{Vmo, self};
use sha2::{Sha256, Digest};
// Rust emits a warning if matched-on constants aren't all-caps
pub const OK: Status = Status_Ok;
pub const KEY_NOT_FOUND: Status = Status_KeyNotFound;
pub const NEEDS_FETCH: Status = Status_NeedsFetch;
pub const RESULT_COMPLETED: ResultState = Res... | use apps_ledger_services_public::*;
use fuchsia::read_entire_vmo; | random_line_split |
ledger.rs | // Copyright 2017 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable... | (res: Result<Status, Error>) {
let status = res.expect("ledger call failed to respond with a status");
assert_eq!(status, Status_Ok, "ledger call failed");
}
#[derive(Debug)]
pub enum ValueError {
NeedsFetch,
LedgerFail(Status),
Vmo(magenta::Status),
}
/// Convert the low level result of getting a... | ledger_crash_callback | identifier_name |
ledger.rs | // Copyright 2017 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable... |
/// Ledger page ids are exactly 16 bytes, so we need a way of determining
/// a unique 16 byte ID that won't collide based on some data we have
pub fn gen_page_id(input_data: &[u8]) -> [u8; 16] {
let mut hasher = Sha256::default();
hasher.input(input_data);
let full_hash = hasher.result();
let full_sl... | {
match res {
(OK, Some(vmo)) => {
let buffer = read_entire_vmo(&vmo).map_err(ValueError::Vmo)?;
Ok(Some(buffer))
},
(KEY_NOT_FOUND, _) => Ok(None),
(NEEDS_FETCH, _) => Err(ValueError::NeedsFetch),
(status, _) => Err(ValueError::LedgerFail(status)),
... | identifier_body |
issue-3979-xcrate.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... | (&self) -> isize {
self.x
}
}
impl Movable for Point {}
pub fn main() {
let mut p = Point{ x: 1, y: 2};
p.translate(3);
assert_eq!(p.X(), 4);
}
| X | identifier_name |
issue-3979-xcrate.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... |
struct Point { x: isize, y: isize }
impl Positioned for Point {
fn SetX(&mut self, x: isize) {
self.x = x;
}
fn X(&self) -> isize {
self.x
}
}
impl Movable for Point {}
pub fn main() {
let mut p = Point{ x: 1, y: 2};
p.translate(3);
assert_eq!(p.X(), 4);
} | random_line_split | |
issue-3979-xcrate.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... |
}
impl Movable for Point {}
pub fn main() {
let mut p = Point{ x: 1, y: 2};
p.translate(3);
assert_eq!(p.X(), 4);
}
| {
self.x
} | identifier_body |
utils.rs | (unrooted_must_root)]
impl PartialEq for Reflector {
fn eq(&self, other: &Reflector) -> bool {
unsafe { *self.object.get() == *other.object.get() }
}
}
impl Reflector {
/// Get the reflector.
#[inline]
pub fn get_jsobject(&self) -> HandleObject {
HandleObject { ptr: self.object.get(... | {
is_valid_start(c) || match c {
'-' |
'.' |
'0' ... '9' |
'\u{B7}' |
'\u{300}' ... '\u{36F}' |
'\u{203F}' ... '\u{2040}' => true,
_ => false,
}
} | identifier_body | |
utils.rs | usize];
/// Construct and cache the ProtoOrIfaceArray for the given global.
/// Fails if the argument is not a DOM global.
pub fn initialize_global(global: *mut JSObject) {
let proto_array: Box<ProtoOrIfaceArray> = box ()
([0 as *mut JSObject; PrototypeList::ID::Count as usize]);
unsafe {
asse... | is_valid_start | identifier_name | |
utils.rs | _or_iface_array(global: *mut JSObject) -> *mut ProtoOrIfaceArray {
unsafe {
assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL)!= 0);
JS_GetReservedSlot(global, DOM_PROTOTYPE_SLOT).to_private() as *mut ProtoOrIfaceArray
}
}
/// Contains references to lists of methods, attributes, and co... | let mut options = CompartmentOptions::default();
options.version_ = JSVersion::JSVERSION_LATEST;
options.traceGlobal_ = trace;
let obj =
RootedObject::new(cx,
JS_NewGlobalObject(cx, class, ptr::null_mut(),
... | unsafe { | random_line_split |
list.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 https://mozilla.org/MPL/2.0/. */
//! `list` specified values.
use crate::parser::{Parse, ParserContext};
#[cfg(feature = "gecko")]
use crate::val... | } | random_line_split | |
list.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 https://mozilla.org/MPL/2.0/. */
//! `list` specified values.
use crate::parser::{Parse, ParserContext};
#[cfg(feature = "gecko")]
use crate::val... | () -> Self {
ListStyleType::CounterStyle(CounterStyleOrNone::disc())
}
/// Convert from gecko keyword to list-style-type.
///
/// This should only be used for mapping type attribute to
/// list-style-type, and thus only values possible in that
/// attribute is considered here.
pub f... | disc | identifier_name |
book_account.rs | use crate::currency::Currency;
use crate::models::member::MemberId;
#[cfg(feature = "diesel_impl")]
use {diesel_derive_enum::DbEnum, diesel_derives::Queryable};
#[cfg(feature = "serde_impl")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "hash")]
use std::hash::{Hash, Hasher};
#[cfg_attr(feature = "serde_imp... | <H: Hasher>(&self, state: &mut H) {
self.id.hash(state);
}
}
#[cfg_attr(feature = "serde_impl", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "debug", derive(Debug))]
#[derive(PartialEq, Clone)]
pub struct NewBookAccount {
pub name: String,
pub account_type: BookAccountType,
pub credito... | hash | identifier_name |
book_account.rs | use crate::currency::Currency;
use crate::models::member::MemberId;
#[cfg(feature = "diesel_impl")]
use {diesel_derive_enum::DbEnum, diesel_derives::Queryable};
#[cfg(feature = "serde_impl")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "hash")]
use std::hash::{Hash, Hasher};
#[cfg_attr(feature = "serde_imp... | #[cfg_attr(feature = "serde_impl", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "debug", derive(Debug))]
#[derive(Clone)]
pub struct MasterAccounts {
pub bank_account_id: BookAccountId,
pub cash_account_id: BookAccountId,
pub sales_account_id: BookAccountId,
pub purchases_account_id: BookAccoun... | pub creditor: Option<MemberId>,
}
| random_line_split |
mod.rs | pub mod rotating_file;
#[cfg(test)]
pub mod test_utils;
use chrono::{DateTime, FixedOffset, NaiveDateTime, Timelike};
use chrono_tz::Tz;
#[cfg(feature = "gelf")]
use std::time::{SystemTime, UNIX_EPOCH};
pub struct PreciseTimestamp {
ts: f64,
}
impl PreciseTimestamp {
#[cfg(feature = "gelf")]
#[inline]
... | (tsd: DateTime<FixedOffset>) -> Self {
PreciseTimestamp {
ts: tsd.timestamp() as f64 + f64::from(tsd.naive_utc().nanosecond()) / 1e9,
}
}
#[inline]
pub fn from_datetime_tz(tsd: DateTime<Tz>) -> Self {
PreciseTimestamp {
ts: tsd.timestamp() as f64 + f64::from(... | from_datetime | identifier_name |
mod.rs | pub mod rotating_file;
#[cfg(test)]
pub mod test_utils;
use chrono::{DateTime, FixedOffset, NaiveDateTime, Timelike}; |
pub struct PreciseTimestamp {
ts: f64,
}
impl PreciseTimestamp {
#[cfg(feature = "gelf")]
#[inline]
pub fn now() -> Self {
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
PreciseTimestamp {
ts: now.as_secs() as f64 + f64::from(now.subsec_nanos()) / 1e9,
... | use chrono_tz::Tz;
#[cfg(feature = "gelf")]
use std::time::{SystemTime, UNIX_EPOCH}; | random_line_split |
mod.rs | pub mod rotating_file;
#[cfg(test)]
pub mod test_utils;
use chrono::{DateTime, FixedOffset, NaiveDateTime, Timelike};
use chrono_tz::Tz;
#[cfg(feature = "gelf")]
use std::time::{SystemTime, UNIX_EPOCH};
pub struct PreciseTimestamp {
ts: f64,
}
impl PreciseTimestamp {
#[cfg(feature = "gelf")]
#[inline]
... |
}
| {
self.ts
} | identifier_body |
feature-gate-thiscall-unwind.rs | // gate-test-abi_thiscall
// gate-test-c_unwind
// needs-llvm-components: x86
// compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib
#![no_core]
#![feature(no_core, lang_items)]
#[lang="sized"]
trait Sized { }
// Test that the "thiscall-unwind" ABI is feature-gated, and cannot be used when
// the `c_unwind`... |
type TA = extern "thiscall" fn(); //~ ERROR thiscall is experimental
type TAU = extern "thiscall-unwind" fn(); //~ ERROR thiscall-unwind ABI is experimental
extern "thiscall" {} //~ ERROR thiscall is experimental
extern "thiscall-unwind" {} //~ ERROR thiscall-unwind ABI is experimental | random_line_split | |
feature-gate-thiscall-unwind.rs | // gate-test-abi_thiscall
// gate-test-c_unwind
// needs-llvm-components: x86
// compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib
#![no_core]
#![feature(no_core, lang_items)]
#[lang="sized"]
trait Sized { }
// Test that the "thiscall-unwind" ABI is feature-gated, and cannot be used when
// the `c_unwind`... | ;
impl T for S {
extern "thiscall" fn m() {} //~ ERROR thiscall is experimental
extern "thiscall-unwind" fn mu() {} //~ ERROR thiscall-unwind ABI is experimental
}
impl S {
extern "thiscall" fn im() {} //~ ERROR thiscall is experimental
extern "thiscall-unwind" fn imu() {} //~ ERROR thiscall-unwind ABI... | S | identifier_name |
feature-gate-thiscall-unwind.rs | // gate-test-abi_thiscall
// gate-test-c_unwind
// needs-llvm-components: x86
// compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib
#![no_core]
#![feature(no_core, lang_items)]
#[lang="sized"]
trait Sized { }
// Test that the "thiscall-unwind" ABI is feature-gated, and cannot be used when
// the `c_unwind`... | //~ ERROR thiscall-unwind ABI is experimental
}
struct S;
impl T for S {
extern "thiscall" fn m() {} //~ ERROR thiscall is experimental
extern "thiscall-unwind" fn mu() {} //~ ERROR thiscall-unwind ABI is experimental
}
impl S {
extern "thiscall" fn im() {} //~ ERROR thiscall is experimental
extern "... | {} | identifier_body |
main.rs | extern crate regex;
use std::io;
use std::io::prelude::*;
use regex::Regex;
const LANGUAGES: &str =
"_div abap actionscript actionscript3 ada apache applescript apt_sources asm asp autoit \
avisynth bash basic4gl bf blitzbasic bnf boo c c_mac caddcl cadlisp cfdg cfm cil cobol cpp \
cpp-qt csharp css d ... | () {
let stdin = io::stdin();
let mut buf = String::new();
stdin.lock().read_to_string(&mut buf).unwrap();
println!(
"{}",
fix_tags(&LANGUAGES.split_whitespace().collect::<Vec<_>>(), &buf)
);
}
#[test]
fn test_replace() {
let input = "Lorem ipsum <code foo>saepe audire</code> el... | main | identifier_name |
main.rs | extern crate regex;
use std::io;
use std::io::prelude::*;
use regex::Regex;
const LANGUAGES: &str =
"_div abap actionscript actionscript3 ada apache applescript apt_sources asm asp autoit \
avisynth bash basic4gl bf blitzbasic bnf boo c c_mac caddcl cadlisp cfdg cfm cil cobol cpp \
cpp-qt csharp css d ... | {
let input = "Lorem ipsum <code foo>saepe audire</code> elaboraret ne quo, id equidem atomorum \
inciderint usu. <foo>In sit inermis deleniti percipit</foo>, ius ex tale civibus \
omittam. <barf>Vix ut doctus cetero invenire</barf>, his eu altera electram. \
Tota ... | identifier_body | |
main.rs | extern crate regex;
use std::io;
use std::io::prelude::*;
use regex::Regex;
const LANGUAGES: &str =
"_div abap actionscript actionscript3 ada apache applescript apt_sources asm asp autoit \
avisynth bash basic4gl bf blitzbasic bnf boo c c_mac caddcl cadlisp cfdg cfm cil cobol cpp \
cpp-qt csharp css d ... | ius ex tale civibus omittam. <barf>Vix ut doctus cetero invenire</barf>, his \
eu altera electram. Tota adhuc altera te sea, <lang bar>soluta appetere ut \
mel</lang>. Quo quis graecis vivendo te, <lang baz>posse nullam lobortis ex \
usu</l... | graecis vivendo te, <baz>posse nullam lobortis ex usu</code>. Eam volumus \
perpetua constituto id, mea an omittam fierent vituperatoribus.";
let expected = "Lorem ipsum <lang foo>saepe audire</lang> elaboraret ne quo, id equidem \
atomorum inciderint usu. <lan... | random_line_split |
instancing.rs | #[macro_use]
extern crate glium;
extern crate rand;
use glium::Surface;
use glium::glutin;
mod support;
fn main() | let pos: (f32, f32, f32) = (rand::random(), rand::random(), rand::random());
let dir: (f32, f32, f32) = (rand::random(), rand::random(), rand::random());
let pos = (pos.0 * 1.5 - 0.75, pos.1 * 1.5 - 0.75, pos.2 * 1.5 - 0.75);
let dir = (dir.0 * 1.5 - 0.75, dir.1 * 1.5 - 0... | {
use glium::DisplayBuild;
println!("This example draws 10,000 instanced teapots. Each teapot gets a random position and \
direction at initialization. Then the CPU updates and uploads the positions of each \
teapot at each frame.");
// building the display, ie. the main object... | identifier_body |
instancing.rs | #[macro_use]
extern crate glium;
extern crate rand;
use glium::Surface;
use glium::glutin;
mod support;
fn | () {
use glium::DisplayBuild;
println!("This example draws 10,000 instanced teapots. Each teapot gets a random position and \
direction at initialization. Then the CPU updates and uploads the positions of each \
teapot at each frame.");
// building the display, ie. the main obj... | main | identifier_name |
instancing.rs | #[macro_use]
extern crate glium;
extern crate rand;
use glium::Surface;
use glium::glutin;
mod support;
fn main() {
use glium::DisplayBuild;
println!("This example draws 10,000 instanced teapots. Each teapot gets a random position and \
direction at initialization. Then the CPU updates and upl... | ",
"
#version 140
in vec3 v_normal;
in vec3 v_color;
out vec4 f_color;
const vec3 LIGHT = vec3(-0.2, 0.8, 0.1);
void main() {
float lum = max(dot(normalize(v_normal), normalize(LIGHT)), 0.0);
vec3 ... | v_position = position;
v_normal = normal;
v_color = vec3(float(gl_InstanceID) / 10000.0, 1.0, 1.0);
gl_Position = vec4(position * 0.0005 + world_position, 1.0);
} | random_line_split |
rectangle.rs | //! A module for primitive rectangle drawing
pub use super::vga::Color;
use core::fmt::{Error, Write};
use super::vga::VGA;
/// Ann abstraction for drawing text inside a bounded box
///
/// A rectangle has boundaries. Drawing outside those boundaries will
/// not render any text on the screen.
///
/// Furthermore, ... |
self.set_cursor((cr, cc));
}
for ch in word.chars() {
// take char of special characters
match ch {
'\n' => {
// don't draw a new line, just move the cursor
cr += 1;
... | {
cc += 1;
} | conditional_block |
rectangle.rs | //! A module for primitive rectangle drawing
pub use super::vga::Color;
use core::fmt::{Error, Write};
use super::vga::VGA;
/// Ann abstraction for drawing text inside a bounded box
///
/// A rectangle has boundaries. Drawing outside those boundaries will
/// not render any text on the screen.
///
/// Furthermore, ... | self.vga.set_fg(color);
}
/// Set the background color
pub fn set_bg(&mut self, color: Color) {
self.vga.set_bg(color);
}
/// Set the cursor position
pub fn set_cursor(&mut self, (crow, ccol): (usize, usize)) {
let (row, col) = self.pos;
self.cursor = (crow, cc... | }
/// Set the foreground color
pub fn set_fg(&mut self, color: Color) { | random_line_split |
rectangle.rs | //! A module for primitive rectangle drawing
pub use super::vga::Color;
use core::fmt::{Error, Write};
use super::vga::VGA;
/// Ann abstraction for drawing text inside a bounded box
///
/// A rectangle has boundaries. Drawing outside those boundaries will
/// not render any text on the screen.
///
/// Furthermore, ... | {
height: usize,
width: usize,
pos: (usize, usize),
cursor: (usize, usize), // position relative to the rectangle
vga: VGA,
}
impl Rectangle {
/// Create a new Rectangle.
pub fn new(w: usize, h: usize, (row, col): (usize, usize)) -> Rectangle {
Rectangle {
height: h,
... | Rectangle | identifier_name |
lib.rs | // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
//! This crate implements a simple SQL query engine to work with TiDB pushed down executors.
//!
//! The query engine is able to scan and understand rows stored by TiDB, run against a
//! series of executors and then return the execution result. The qu... | pub use self::fast_hash_aggr_executor::BatchFastHashAggregationExecutor;
pub use self::index_scan_executor::BatchIndexScanExecutor;
pub use self::limit_executor::BatchLimitExecutor;
pub use self::selection_executor::BatchSelectionExecutor;
pub use self::simple_aggr_executor::BatchSimpleAggregationExecutor;
pub use self... | mod table_scan_executor;
mod top_n_executor;
mod util;
| random_line_split |
header.rs | /*
Copyright (C) 2017 Chris Jones
This program 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.
This program is dist... | (&self) -> String {
self.file_name.clone()
}
pub fn size(&self) -> i32 {
self.size
}
}
fn get_name(bytes: Vec<u8>) -> String {
match String::from_utf8(bytes) {
Ok(x) => trim_null_chars(x),
Err(_) => String::from(""),
}
}
fn get_size(bytes: Vec<u8>) -> i32 {
// ... | file_name | identifier_name |
header.rs | /*
Copyright (C) 2017 Chris Jones
This program 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.
This program is dist... |
fn get_size(bytes: Vec<u8>) -> i32 {
// For some reason, GNU tar writes the file size as a string instead of a number so we
// first parse it as a string, then parse the number from the string.
let size_string = match String::from_utf8(bytes) {
Ok(x) => trim_null_chars(x),
Err(_) => panic!... | {
match String::from_utf8(bytes) {
Ok(x) => trim_null_chars(x),
Err(_) => String::from(""),
}
} | identifier_body |
header.rs | /*
Copyright (C) 2017 Chris Jones
This program 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.
This program is dist... |
pub fn size(&self) -> i32 {
self.size
}
}
fn get_name(bytes: Vec<u8>) -> String {
match String::from_utf8(bytes) {
Ok(x) => trim_null_chars(x),
Err(_) => String::from(""),
}
}
fn get_size(bytes: Vec<u8>) -> i32 {
// For some reason, GNU tar writes the file size as a string... | pub fn file_name(&self) -> String {
self.file_name.clone()
} | random_line_split |
class-cast-to-trait.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 ... |
else {
println!("Not hungry!");
return false;
}
}
}
impl cat {
fn meow(&mut self) {
println!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
}
}
}
fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
cat {
... | {
println!("OM NOM NOM");
self.how_hungry -= 2;
return true;
} | conditional_block |
class-cast-to-trait.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 ... |
pub fn main() {
let mut nyan = cat(0u, 2, "nyan".to_owned());
let mut nyan: &mut noisy = &mut nyan;
nyan.speak();
}
| {
cat {
meows: in_x,
how_hungry: in_y,
name: in_name
}
} | identifier_body |
class-cast-to-trait.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 ... | (&mut self) { self.meow(); }
}
impl cat {
pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
println!("OM NOM NOM");
self.how_hungry -= 2;
return true;
}
else {
println!("Not hungry!");
return false;
}
}
}
impl cat {
fn meow(&mut self) {
prin... | speak | identifier_name |
class-cast-to-trait.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 ... | cat {
meows: in_x,
how_hungry: in_y,
name: in_name
}
}
pub fn main() {
let mut nyan = cat(0u, 2, "nyan".to_owned());
let mut nyan: &mut noisy = &mut nyan;
nyan.speak();
} |
fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { | random_line_split |
event.rs | // A subset of termion's event parsing.
// Termion (c) 2016 Ticki
// Licensed under the MIT license
use std::io::{Result, Error, ErrorKind};
use std::str;
#[derive(Debug)]
pub enum Event {
Key(Key),
Unknown(Vec<u8>)
}
#[derive(Debug)]
pub enum Key {
Escape,
Backspace,
Tab,
Left, Right, Up, D... | }
match c {
// Special key code.
b'~' => {
let str_buf = String::from_utf8(buf).unwrap();
// This CSI sequence can be a list of semicolon-separated
// numbers.
let nums: Vec<u8> = st... | c = iter.next().unwrap().unwrap(); | random_line_split |
event.rs | // A subset of termion's event parsing.
// Termion (c) 2016 Ticki
// Licensed under the MIT license
use std::io::{Result, Error, ErrorKind};
use std::str;
#[derive(Debug)]
pub enum Event {
Key(Key),
Unknown(Vec<u8>)
}
#[derive(Debug)]
pub enum Key {
Escape,
Backspace,
Tab,
Left, Right, Up, D... | <I>(c: u8, iter: &mut I) -> Result<char>
where I: Iterator<Item = Result<u8>>
{
let error = Err(Error::new(ErrorKind::Other, "Input character is not valid UTF-8"));
if c.is_ascii() {
Ok(c as char)
} else {
let bytes = &mut Vec::new();
bytes.push(c);
loop {
by... | parse_utf8_char | identifier_name |
event.rs | // A subset of termion's event parsing.
// Termion (c) 2016 Ticki
// Licensed under the MIT license
use std::io::{Result, Error, ErrorKind};
use std::str;
#[derive(Debug)]
pub enum Event {
Key(Key),
Unknown(Vec<u8>)
}
#[derive(Debug)]
pub enum Key {
Escape,
Backspace,
Tab,
Left, Right, Up, D... |
Some(Err(_)) | None => return Err(error),
})
}
b'\n' | b'\r' => Ok(Event::Key(Key::Char('\n'))),
b'\t' => Ok(Event::Key(Key::Char('\t'))),
b'\x7F' => Ok(Event::Key(Key::Backspace)),
c @ b'\x01'..=b'\x1A' => Ok(Event::Key(Key::Ctrl((c as u8 - 0x1 + b'a... | {
let ch = parse_utf8_char(c, iter)?;
Event::Key(Key::Alt(ch))
} | conditional_block |
traversal.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 context::{SharedStyleContext, StyleContext};
use dom::{OpaqueNode, TNode, TRestyleDamage, UnsafeNode};
use mat... | <Impl: SelectorImplExt>(bf: Box<BloomFilter>,
unsafe_node: &UnsafeNode,
context: &SharedStyleContext<Impl>) {
STYLE_BLOOM.with(move |style_bloom| {
assert!(style_bloom.borrow().is_none(),
... | put_thread_local_bloom_filter | identifier_name |
traversal.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 context::{SharedStyleContext, StyleContext};
use dom::{OpaqueNode, TNode, TRestyleDamage, UnsafeNode};
use mat... |
// Check to see whether we can share a style with someone.
let style_sharing_candidate_cache =
&mut context.local_context().style_sharing_candidate_cache.borrow_mut();
let sharing_result = match node.as_element() {
Some(element) => {
unsafe {
... | {
// Initialize layout data.
//
// FIXME(pcwalton): Stop allocating here. Ideally this should just be done by the HTML
// parser.
node.initialize_data();
// Get the parent node.
let parent_opt = node.layout_parent_node(root);
// Get the style bloom filter.
let mut bf = take_thread_... | identifier_body |
traversal.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 context::{SharedStyleContext, StyleContext};
use dom::{OpaqueNode, TNode, TRestyleDamage, UnsafeNode};
use mat... |
}
StyleSharingResult::StyleWasShared(index, damage) => {
style_sharing_candidate_cache.touch(index);
node.set_restyle_damage(damage);
}
}
}
let unsafe_layout_node = node.to_unsafe();
// Before running the children, we need to ins... | {
style_sharing_candidate_cache.insert_if_possible::<'ln, N>(&element);
} | conditional_block |
traversal.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 context::{SharedStyleContext, StyleContext};
use dom::{OpaqueNode, TNode, TRestyleDamage, UnsafeNode};
use mat... | /// layout computation. This computes the styles applied to each node.
#[inline]
#[allow(unsafe_code)]
pub fn recalc_style_at<'a, N, C>(context: &'a C,
root: OpaqueNode,
node: N)
where N: TNode,
C: StyleContext<'a, <N::ConcreteElement as El... | fn process_preorder(&self, node: N);
fn process_postorder(&self, node: N);
}
/// The recalc-style-for-node traversal, which styles each node and must run before | random_line_split |
authcode_store.rs | // Copyright 2015, 2016 Ethcore (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 later version.... |
/// Returns true if there are no tokens in this store
pub fn is_empty(&self) -> bool {
self.codes.is_empty()
}
}
#[cfg(test)]
mod tests {
use util::{H256, Hashable};
use super::*;
fn generate_hash(val: &str, time: u64) -> H256 {
format!("{}:{}", val, time).sha3()
}
#[test]
fn should_return_true_if_c... | {
let mut rng = try!(OsRng::new());
let code = rng.gen_ascii_chars().take(TOKEN_LENGTH).collect::<String>();
let readable_code = code.as_bytes()
.chunks(4)
.filter_map(|f| String::from_utf8(f.to_vec()).ok())
.collect::<Vec<String>>()
.join("-");
trace!(target: "signer", "New authentication token gen... | identifier_body |
authcode_store.rs | // Copyright 2015, 2016 Ethcore (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 later version.... |
let as_token = |code| format!("{}:{}", code, time).sha3();
// Check if it's the initial token.
if self.is_empty() {
let initial = &as_token(INITIAL_TOKEN) == hash;
// Initial token can be used only once.
if initial {
let _ = self.generate_new();
}
return initial;
}
// look for code
se... | {
warn!(target: "signer", "Received old authentication request. ({} vs {})", now, time);
return false;
} | conditional_block |
authcode_store.rs | // Copyright 2015, 2016 Ethcore (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 later version.... |
impl AuthCodes<DefaultTimeProvider> {
/// Reads `AuthCodes` from file and creates new instance using `DefaultTimeProvider`.
pub fn from_file(file: &Path) -> io::Result<AuthCodes> {
let content = {
if let Ok(mut file) = fs::File::open(file) {
let mut s = String::new();
let _ = try!(file.read_to_string(&... | codes: Vec<String>,
now: T,
} | random_line_split |
authcode_store.rs | // Copyright 2015, 2016 Ethcore (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 later version.... | ;
impl TimeProvider for DefaultTimeProvider {
fn now(&self) -> u64 {
time::UNIX_EPOCH.elapsed().expect("Valid time has to be set in your system.").as_secs()
}
}
/// No of seconds the hash is valid
const TIME_THRESHOLD: u64 = 7;
const TOKEN_LENGTH: usize = 16;
const INITIAL_TOKEN: &'static str = "initial";
/// Ma... | DefaultTimeProvider | identifier_name |
serviceworkerglobalscope.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 devtools;
use devtools_traits::DevtoolScriptControlMsg;
use dom::abstractworker::WorkerScriptMsg;
use dom::bin... | else if ret == timer_port_handle.id() {
Ok(MixedMessage::FromTimeoutThread(timer_event_port.recv()?))
} else {
panic!("unexpected select result!")
}
}
pub fn process_event(&self, msg: CommonScriptMsg) {
self.handle_script_event(ServiceWorkerScriptMsg::CommonWork... | {
Ok(MixedMessage::FromDevtools(devtools_port.recv()?))
} | conditional_block |
serviceworkerglobalscope.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 devtools;
use devtools_traits::DevtoolScriptControlMsg;
use dom::abstractworker::WorkerScriptMsg;
use dom::bin... | (&self, event: MixedMessage) -> bool {
match event {
MixedMessage::FromDevtools(msg) => {
match msg {
DevtoolScriptControlMsg::EvaluateJS(_pipe_id, string, sender) =>
devtools::handle_evaluate_js(self.upcast(), string, sender),
... | handle_event | identifier_name |
serviceworkerglobalscope.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 devtools;
use devtools_traits::DevtoolScriptControlMsg;
use dom::abstractworker::WorkerScriptMsg;
use dom::bin... | sender: self.sender.clone(),
}
}
}
#[dom_struct]
pub struct ServiceWorkerGlobalScope {
workerglobalscope: WorkerGlobalScope,
#[ignore_heap_size_of = "Defined in std"]
receiver: Receiver<ServiceWorkerScriptMsg>,
#[ignore_heap_size_of = "Defined in std"]
own_sender: Sender<Ser... | random_line_split | |
trait-inheritance-call-bound-inherited.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 a = &A { x: 3 };
assert!(gg(a) == 10);
} | identifier_body | |
trait-inheritance-call-bound-inherited.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 | // except according to those terms.
trait Foo { fn f(&self) -> int; }
trait Bar : Foo { fn g(&self) -> int; }
struct A { x: int }
impl Foo for A { fn f(&self) -> int { 10 } }
impl Bar for A { fn g(&self) -> int { 20 } }
// Call a function on Foo, given a T: Bar
fn gg<T:Bar>(a: &T) -> int {
a.f()
}
pub fn main(... | // 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 | random_line_split |
trait-inheritance-call-bound-inherited.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 ... | (&self) -> int { 20 } }
// Call a function on Foo, given a T: Bar
fn gg<T:Bar>(a: &T) -> int {
a.f()
}
pub fn main() {
let a = &A { x: 3 };
assert!(gg(a) == 10);
}
| g | identifier_name |
method-on-struct.rs | // Copyright 2013-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... | // gdb-check:$13 = {x = 200}
// gdb-command:print arg1
// gdb-check:$14 = -9
// gdb-command:print arg2
// gdb-check:$15 = -10
// gdb-command:continue
// === LLDB TESTS ==================================================================================
// lldb-command:run
// STACK BY REF
// lldb-command:print *self
/... | // gdb-command:continue
// OWNED MOVED
// gdb-command:print *self | random_line_split |
method-on-struct.rs | // Copyright 2013-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... | (self, arg1: int, arg2: int) -> int {
zzz(); // #break
self.x + arg1 + arg2
}
fn self_owned(self: Box<Struct>, arg1: int, arg2: int) -> int {
zzz(); // #break
self.x + arg1 + arg2
}
}
fn main() {
let stack = Struct { x: 100 };
let _ = stack.self_by_ref(-1, -2);
... | self_by_val | identifier_name |
method-on-struct.rs | // Copyright 2013-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... |
}
fn main() {
let stack = Struct { x: 100 };
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);
let owned = box Struct { x: 200 };
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
}
fn zzz() {()}
| {
zzz(); // #break
self.x + arg1 + arg2
} | identifier_body |
err.rs | use ::dynamic::CompositerError;
use ::graphic::GraphicError;
use ::pty_proc::shell::ShellError;
use std::error::Error;
use std::fmt;
pub type Result<T> = ::std::result::Result<T, NekoError>;
/// The enum `NekoError` defines the possible errors
/// from constructor Neko.
#[derive(Debug)]
pub enum NekoError {
/// T... | /// The function `cause` returns the lower-level cause of
/// this error if any.
fn cause(&self) -> Option<&Error> {
match *self {
NekoError::Dynamic(ref why) => Some(why),
NekoError::Graphic(ref why) => Some(why),
NekoError::Shell(ref why) => Some(why),
... | NekoError::Shell(_) => "The shell interface has occured an error",
// NekoError::Size => "Terminal too small",
}
}
| random_line_split |
err.rs | use ::dynamic::CompositerError;
use ::graphic::GraphicError;
use ::pty_proc::shell::ShellError;
use std::error::Error;
use std::fmt;
pub type Result<T> = ::std::result::Result<T, NekoError>;
/// The enum `NekoError` defines the possible errors
/// from constructor Neko.
#[derive(Debug)]
pub enum NekoError {
/// T... |
}
| {
NekoError::Shell(err)
} | identifier_body |
err.rs | use ::dynamic::CompositerError;
use ::graphic::GraphicError;
use ::pty_proc::shell::ShellError;
use std::error::Error;
use std::fmt;
pub type Result<T> = ::std::result::Result<T, NekoError>;
/// The enum `NekoError` defines the possible errors
/// from constructor Neko.
#[derive(Debug)]
pub enum NekoError {
/// T... | (&self) -> Option<&Error> {
match *self {
NekoError::Dynamic(ref why) => Some(why),
NekoError::Graphic(ref why) => Some(why),
NekoError::Shell(ref why) => Some(why),
// NekoError::Size => Some(()),
}
}
}
impl From<CompositerError> for NekoError {
f... | cause | identifier_name |
mod.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/. */
//! Generic types that share their serialization implementations
//! for both specified and computed values.
use ... |
}
}
}
impl<ColorType> SVGPaint<ColorType> {
/// Convert to a value with a different kind of color
pub fn convert<F, OtherColor>(&self, f: F) -> SVGPaint<OtherColor>
where F: Fn(&ColorType) -> OtherColor {
SVGPaint {
kind: self.kind.convert(&f),
fallback:... | {
SVGPaintKind::PaintServer(server.clone())
} | conditional_block |
mod.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/. */
//! Generic types that share their serialization implementations
//! for both specified and computed values.
use ... | <ColorType> {
/// `none`
None,
/// `<color>`
Color(ColorType),
/// `url(...)`
PaintServer(SpecifiedUrl),
/// `context-fill`
ContextFill,
/// `context-stroke`
ContextStroke,
}
impl<ColorType> SVGPaintKind<ColorType> {
/// Convert to a value with a different kind of color
... | SVGPaintKind | identifier_name |
mod.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/. */
//! Generic types that share their serialization implementations
//! for both specified and computed values.
use ... | ///
/// Do not use this type anywhere except within FontSettings
/// because it serializes with the preceding space
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct FontSettingTagFloat(pub f32);
impl ToCss for FontSettingTagInt {
fn to_css<W>(&self, dest: &mut W) -> ... | /// A number value to be used for font-variation-settings | random_line_split |
mod.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/. */
//! Generic types that share their serialization implementations
//! for both specified and computed values.
use ... |
}
| {
self.kind.to_css(dest)?;
if let Some(ref fallback) = self.fallback {
fallback.to_css(dest)?;
}
Ok(())
} | identifier_body |
persistent_state.rs | use fs::{DataDir, BaseDir};
use configuration::Configuration;
use mru_list::MRUList;
/// Represents the persistent runtime data of the system. This is things like MRU lists
/// that we expect to get written to disk and be available the next time we start.
/// Therefore, it excludes things like buffer collections. Thin... |
const MRU_FILE : &'static str = "mru.toml";
impl PersistentState {
/// Constructs a new PersistentState object based on the default configuration.
pub fn new(config: &Configuration) -> PersistentState {
PersistentState {
mru: MRUList::new(config.max_mru_items())
}
}
pub fn... | random_line_split | |
persistent_state.rs | use fs::{DataDir, BaseDir};
use configuration::Configuration;
use mru_list::MRUList;
/// Represents the persistent runtime data of the system. This is things like MRU lists
/// that we expect to get written to disk and be available the next time we start.
/// Therefore, it excludes things like buffer collections. Thin... | (config: &Configuration) -> PersistentState {
PersistentState {
mru: MRUList::new(config.max_mru_items())
}
}
pub fn load(config: &Configuration, data_dir: &DataDir) -> PersistentState {
let _timer = timer!("PersistentState::load");
let mut rd = PersistentState::new... | new | identifier_name |
persistent_state.rs | use fs::{DataDir, BaseDir};
use configuration::Configuration;
use mru_list::MRUList;
/// Represents the persistent runtime data of the system. This is things like MRU lists
/// that we expect to get written to disk and be available the next time we start.
/// Therefore, it excludes things like buffer collections. Thin... |
}
| {
&mut self.mru
} | identifier_body |
persistent_state.rs | use fs::{DataDir, BaseDir};
use configuration::Configuration;
use mru_list::MRUList;
/// Represents the persistent runtime data of the system. This is things like MRU lists
/// that we expect to get written to disk and be available the next time we start.
/// Therefore, it excludes things like buffer collections. Thin... |
}
pub fn mru(&mut self) -> &mut MRUList {
&mut self.mru
}
}
| {
data_dir.get_proposed_path(MRU_FILE)
.map(|path| self.mru.save(&path)
.map(|num_bytes| info!("Wrote {} bytes to {:?}", num_bytes, &path)));
} | conditional_block |
implicit_infer.rs | use rustc_data_structures::fx::FxHashMap;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::Span;
use super::explicit::ExplicitPredicatesMap;
use ... | tcx.hir().krate().visit_all_item_likes(&mut visitor);
}
global_inferred_outlives
}
pub struct InferVisitor<'cx, 'tcx> {
tcx: TyCtxt<'tcx>,
global_inferred_outlives: &'cx mut FxHashMap<DefId, RequiredPredicates<'tcx>>,
predicates_added: &'cx mut bool,
explicit_map: &'cx mut ExplicitPre... | {
debug!("infer_predicates");
let mut predicates_added = true;
let mut global_inferred_outlives = FxHashMap::default();
// If new predicates were added then we need to re-calculate
// all crates since there could be new implied predicates.
while predicates_added {
predicates_added = f... | identifier_body |
implicit_infer.rs | use rustc_data_structures::fx::FxHashMap;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::Span;
use super::explicit::ExplicitPredicatesMap;
use ... |
_ => {}
}
}
}
/// We also have to check the explicit predicates
/// declared on the type.
///
/// struct Foo<'a, T> {
/// field1: Bar<T>
/// }
///
/// struct Bar<U> where U:'static, U: Foo {
/// ...
/// }
///
/// Here, we should fetch the explicit predicates, wh... | {
// This corresponds to `<T as Foo<'a>>::Bar`. In this case, we should use the
// explicit predicates as well.
debug!("Projection");
check_explicit_predicates(
tcx,
tcx.associated_item(obj.item_def_id).container.id(... | conditional_block |
implicit_infer.rs | use rustc_data_structures::fx::FxHashMap;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::Span;
use super::explicit::ExplicitPredicatesMap;
use ... | (&mut self, _foreign_item: &'tcx hir::ForeignItem<'tcx>) {}
}
fn insert_required_predicates_to_be_wf<'tcx>(
tcx: TyCtxt<'tcx>,
field_ty: Ty<'tcx>,
field_span: Span,
global_inferred_outlives: &FxHashMap<DefId, RequiredPredicates<'tcx>>,
required_predicates: &mut RequiredPredicates<'tcx>,
explici... | visit_foreign_item | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.