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 |
|---|---|---|---|---|
test_cargo_run.rs | use std::path;
use support::{project, execs};
use support::{COMPILING, RUNNING};
use hamcrest::{assert_that, existing_file};
fn setup() |
test!(simple {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.0.1"
authors = []
"#)
.file("src/main.rs", r#"
fn main() { println!("hello"); }
"#);
assert_that(p.cargo_process("cargo-r... | {
} | identifier_body |
test_cargo_run.rs | use std::path;
use support::{project, execs};
use support::{COMPILING, RUNNING};
use hamcrest::{assert_that, existing_file};
fn | () {
}
test!(simple {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.0.1"
authors = []
"#)
.file("src/main.rs", r#"
fn main() { println!("hello"); }
"#);
assert_that(p.cargo_process("c... | setup | identifier_name |
check_compile.rs | // Copyright 2015 Sean Patrick Santos
//
// 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 in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.... | // | random_line_split |
check_compile.rs | // Copyright 2015 Sean Patrick Santos
//
// 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 agree... | () {
let probe = <Probe>::default();
assert!(!probe.check_compile("ain't it a C progarm, bub!")
.unwrap().status.success());
}
| check_compile_fail | identifier_name |
check_compile.rs | // Copyright 2015 Sean Patrick Santos
//
// 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 agree... | {
let probe = <Probe>::default();
assert!(!probe.check_compile("ain't it a C progarm, bub!")
.unwrap().status.success());
} | identifier_body | |
fastcall-inreg.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (_: f32, _: i32, _: i32, _: i32) {}
// CHECK: @f4(i32 inreg %arg0, float %arg1, i32 inreg %arg2, i32 %arg3)
#[no_mangle]
pub extern "fastcall" fn f4(_: i32, _: f32, _: i32, _: i32) {}
// CHECK: @f5(i64 %arg0, i32 %arg1)
#[no_mangle]
pub extern "fastcall" fn f5(_: i64, _: i32) {}
// CHECK:... | f3 | identifier_name |
fastcall-inreg.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | #[no_mangle]
pub extern "fastcall" fn f5(_: i64, _: i32) {}
// CHECK: @f6(i1 inreg zeroext %arg0, i32 inreg %arg1, i32 %arg2)
#[no_mangle]
pub extern "fastcall" fn f6(_: bool, _: i32, _: i32) {}
} | pub extern "fastcall" fn f4(_: i32, _: f32, _: i32, _: i32) {}
// CHECK: @f5(i64 %arg0, i32 %arg1) | random_line_split |
fastcall-inreg.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
// CHECK: @f6(i1 inreg zeroext %arg0, i32 inreg %arg1, i32 %arg2)
#[no_mangle]
pub extern "fastcall" fn f6(_: bool, _: i32, _: i32) {}
}
| {} | identifier_body |
rt-messaging-ping-pong.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 ... | ;
ping_pong_bench(n, m);
}
| {
(10000, 4)
} | conditional_block |
rt-messaging-ping-pong.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 ... | () {
let mut args = env::args();
let (n, m) = if args.len() == 3 {
let n = args.nth(1).unwrap().parse::<usize>().unwrap();
let m = args.next().unwrap().parse::<usize>().unwrap();
(n, m)
} else {
(10000, 4)
};
ping_pong_bench(n, m);
}
| main | identifier_name |
rt-messaging-ping-pong.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 ... | // Create a channel: B->A
let (btx, brx) = channel();
let guard_a = thread::spawn(move|| {
let (tx, rx) = (atx, brx);
for _ in 0..n {
tx.send(()).unwrap();
rx.recv().unwrap();
}
});
let guard_b = thread::spawn(... | let (atx, arx) = channel(); | random_line_split |
rt-messaging-ping-pong.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 ... | {
let mut args = env::args();
let (n, m) = if args.len() == 3 {
let n = args.nth(1).unwrap().parse::<usize>().unwrap();
let m = args.next().unwrap().parse::<usize>().unwrap();
(n, m)
} else {
(10000, 4)
};
ping_pong_bench(n, m);
} | identifier_body | |
page_printer.rs | //! Page Printer
//!
//! Convert a page into human-readable string representations according to its
//! encodings and store methods.
use std::io;
use page::{Page, c_api};
use types::Ty;
/// PagePrinter trait
pub trait PagePrinter {
/// Write the rows into io::Write instace
fn write(&[&Ty], &Page, &mut io::Write)... | Ty::F32 => {
write!(buf,
"{}",
unsafe { c_api::read_f32_raw(page.chunk(col_idx), row_idx) })
}
Ty::F64 => {
write!(buf,
"{}",
unsafe { c_api::read_f64_raw(page.chunk(col_idx), row_idx) })
... | unsafe { c_api::read_i64_raw(page.chunk(col_idx), row_idx) })
} | random_line_split |
page_printer.rs | //! Page Printer
//!
//! Convert a page into human-readable string representations according to its
//! encodings and store methods.
use std::io;
use page::{Page, c_api};
use types::Ty;
/// PagePrinter trait
pub trait PagePrinter {
/// Write the rows into io::Write instace
fn write(&[&Ty], &Page, &mut io::Write)... | (tys: &[&Ty], page: &Page, buf: &mut io::Write) {
for row_idx in 0..page.value_count() {
// newline for rows
if row_idx!= 0 {
write!(buf, "\n");
}
for (col_idx, ty) in izip!(0..tys.len(), tys.iter()) {
// comma for column values
if col_idx!= 0 {
write!(bu... | write | identifier_name |
page_printer.rs | //! Page Printer
//!
//! Convert a page into human-readable string representations according to its
//! encodings and store methods.
use std::io;
use page::{Page, c_api};
use types::Ty;
/// PagePrinter trait
pub trait PagePrinter {
/// Write the rows into io::Write instace
fn write(&[&Ty], &Page, &mut io::Write)... |
Ty::F32 => {
write!(buf,
"{}",
unsafe { c_api::read_f32_raw(page.chunk(col_idx), row_idx) })
}
Ty::F64 => {
write!(buf,
"{}",
unsafe { c_api::read_f64_raw(page.chunk(col_idx), row_idx) })
... | {
write!(buf,
"{}",
unsafe { c_api::read_i64_raw(page.chunk(col_idx), row_idx) })
} | conditional_block |
page_printer.rs | //! Page Printer
//!
//! Convert a page into human-readable string representations according to its
//! encodings and store methods.
use std::io;
use page::{Page, c_api};
use types::Ty;
/// PagePrinter trait
pub trait PagePrinter {
/// Write the rows into io::Write instace
fn write(&[&Ty], &Page, &mut io::Write)... | write!(buf, "true")
}
}
Ty::I8 => {
write!(buf,
"{}",
unsafe { c_api::read_i8_raw(page.chunk(col_idx), row_idx) })
}
Ty::I16 => {
write!(buf,
"{}",
unsafe... | {
for row_idx in 0..page.value_count() {
// newline for rows
if row_idx != 0 {
write!(buf, "\n");
}
for (col_idx, ty) in izip!(0..tys.len(), tys.iter()) {
// comma for column values
if col_idx != 0 {
write!(buf, ",");
}
match **ty {
... | identifier_body |
pango.rs | // Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co
//
// This file is part of cancer.
//
// cancer 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
// (a... |
Normal,
Oblique,
Italic,
}
#[repr(C)]
#[derive(Debug)]
pub enum PangoUnderline {
None,
Single,
Double,
Low,
Error,
}
#[repr(C)]
pub struct PangoFont(c_void);
#[repr(C)]
pub struct PangoFontMap(c_void);
#[repr(C)]
pub struct PangoFontset(c_void);
#[repr(C)]
pub struct PangoFontDescription(c_void);
#[repr(... | ngoStyle { | identifier_name |
pango.rs | // Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co
//
// This file is part of cancer.
//
// cancer 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
// (a... | #[repr(C)]
#[derive(Debug)]
pub enum PangoWeight {
Thin = 100,
UltraLight = 200,
Light = 300,
SemiLight = 350,
Book = 380,
Normal = 400,
Medium = 500,
SemiBold = 600,
Bold = 700,
UltraBold = 800,
Heavy = 900,
UltraHeavy = 1000,
}
#[repr(C)]
#[derive(Debug)]
pub enum ... | pub string: *mut PangoGlyphString,
}
| random_line_split |
transaction.rs | // Copyright 2015, Igor Shaula
// Licensed under the MIT License <LICENSE or
// http://opensource.org/licenses/MIT>. This file
// may not be copied, modified, or distributed
// except according to those terms.
//! Structure for a registry transaction.
//! Part of `transactions` feature.
//!
//!```no_run
//!extern crat... | pub fn rollback(&self) -> io::Result<()> {
unsafe {
match ktmw32::RollbackTransaction(self.handle) {
0 => Err(io::Error::last_os_error()),
_ => Ok(()),
}
}
}
fn close_(&mut self) -> io::Result<()> {
unsafe {
match h... | }
}
}
| random_line_split |
transaction.rs | // Copyright 2015, Igor Shaula
// Licensed under the MIT License <LICENSE or
// http://opensource.org/licenses/MIT>. This file
// may not be copied, modified, or distributed
// except according to those terms.
//! Structure for a registry transaction.
//! Part of `transactions` feature.
//!
//!```no_run
//!extern crat... |
pub fn rollback(&self) -> io::Result<()> {
unsafe {
match ktmw32::RollbackTransaction(self.handle) {
0 => Err(io::Error::last_os_error()),
_ => Ok(()),
}
}
}
fn close_(&mut self) -> io::Result<()> {
unsafe {
match... | {
unsafe {
match ktmw32::CommitTransaction(self.handle) {
0 => Err(io::Error::last_os_error()),
_ => Ok(()),
}
}
} | identifier_body |
transaction.rs | // Copyright 2015, Igor Shaula
// Licensed under the MIT License <LICENSE or
// http://opensource.org/licenses/MIT>. This file
// may not be copied, modified, or distributed
// except according to those terms.
//! Structure for a registry transaction.
//! Part of `transactions` feature.
//!
//!```no_run
//!extern crat... | (&mut self) -> io::Result<()> {
unsafe {
match handleapi::CloseHandle(self.handle) {
0 => Err(io::Error::last_os_error()),
_ => Ok(()),
}
}
}
}
impl Drop for Transaction {
fn drop(&mut self) {
self.close_().unwrap_or(());
}
}
| close_ | identifier_name |
ambiguity.rs | #![deny(rustdoc::broken_intra_doc_links)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
pub fn ambiguous() {}
pub struct ambiguous {}
#[macro_export]
macro_rules! multi_conflict { () => {} }
#[allow(non_camel_case_types)] |
pub const type_and_value: i32 = 0;
pub mod foo {
pub enum bar {}
pub fn bar() {}
}
/// [`ambiguous`] is ambiguous. //~ERROR `ambiguous`
///
/// [ambiguous] is ambiguous. //~ERROR ambiguous
///
/// [`multi_conflict`] is a three-way conflict. //~ERROR `multi_conflict`
///
/// Ambiguous [type_and_value]. //~ER... | pub struct multi_conflict {}
pub fn multi_conflict() {}
pub mod type_and_value {} | random_line_split |
ambiguity.rs | #![deny(rustdoc::broken_intra_doc_links)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
pub fn ambiguous() {}
pub struct | {}
#[macro_export]
macro_rules! multi_conflict { () => {} }
#[allow(non_camel_case_types)]
pub struct multi_conflict {}
pub fn multi_conflict() {}
pub mod type_and_value {}
pub const type_and_value: i32 = 0;
pub mod foo {
pub enum bar {}
pub fn bar() {}
}
/// [`ambiguous`] is ambiguous. //~ERROR `ambig... | ambiguous | identifier_name |
decoder.rs | use crate::errors::{ErrorKind, Result};
use simple_asn1::{BigUint, OID};
/// Supported PEM files for EC and RSA Public and Private Keys
#[derive(Debug, PartialEq)]
enum PemType {
EcPublic,
EcPrivate,
RsaPublic,
RsaPrivate,
}
#[derive(Debug, PartialEq)]
enum Standard {
// Only for RSA
Pkcs1,
... | pem_type: PemType::RsaPublic,
standard: Standard::Pkcs1,
}),
// No "EC PRIVATE KEY"
// https://security.stackexchange.com/questions/84327/converting-ecc-private-key-to-pkcs1-format
// "there ... | {
match pem::parse(input) {
Ok(content) => {
let pem_contents = content.contents;
let asn1_content = match simple_asn1::from_der(pem_contents.as_slice()) {
Ok(asn1) => asn1,
Err(_) => return Err(ErrorKind::InvalidKeyFormat.into(... | identifier_body |
decoder.rs | use crate::errors::{ErrorKind, Result};
use simple_asn1::{BigUint, OID};
/// Supported PEM files for EC and RSA Public and Private Keys
#[derive(Debug, PartialEq)]
enum PemType {
EcPublic,
EcPrivate,
RsaPublic,
RsaPrivate,
}
#[derive(Debug, PartialEq)]
enum | {
// Only for RSA
Pkcs1,
// RSA/EC
Pkcs8,
}
#[derive(Debug, PartialEq)]
enum Classification {
Ec,
Rsa,
}
/// The return type of a successful PEM encoded key with `decode_pem`
///
/// This struct gives a way to parse a string to a key for use in jsonwebtoken.
/// A struct is necessary as it pr... | Standard | identifier_name |
decoder.rs | use crate::errors::{ErrorKind, Result};
use simple_asn1::{BigUint, OID};
/// Supported PEM files for EC and RSA Public and Private Keys
#[derive(Debug, PartialEq)]
enum PemType {
EcPublic,
EcPrivate,
RsaPublic,
RsaPrivate,
}
#[derive(Debug, PartialEq)]
enum Standard {
// Only for RSA
Pkcs1,
... | }
None
} | return Some(Classification::Rsa);
}
}
_ => {}
} | random_line_split |
decoder.rs | use crate::errors::{ErrorKind, Result};
use simple_asn1::{BigUint, OID};
/// Supported PEM files for EC and RSA Public and Private Keys
#[derive(Debug, PartialEq)]
enum PemType {
EcPublic,
EcPrivate,
RsaPublic,
RsaPrivate,
}
#[derive(Debug, PartialEq)]
enum Standard {
// Only for RSA
Pkcs1,
... |
}
}
None
}
| {} | conditional_block |
tests.rs | extern crate rand;
extern crate xxtea;
use std::str;
use rand::Rng;
fn rand_string() -> String {
let num = rand::thread_rng().gen_range(1, 256);
(0..num).map(|_| rand::random::<char>()).collect()
}
pub fn to_hex_string(bytes: &[u8] ) -> String {
let strs: Vec<String> = bytes.iter()
.map(|b| format... |
#[test]
fn test() {
for _ in 0..100 {
run_test_case();
}
}
| {
let set1_unaligned : [u8; 10] = [17, 18, 19, 20, 0, 0, 0, 0, 52, 238];
let set1_encrypted : [u8; 12] = [153, 30, 118, 66, 15, 149, 77, 188, 228, 138, 105, 92];
let set1_aligned : [u8; 12] = [17, 18, 19, 20, 0, 0, 0, 0, 52, 238, 0, 0];
let key = "Snakeoil";
let result1: Vec<... | identifier_body |
tests.rs | extern crate rand;
extern crate xxtea;
use std::str;
use rand::Rng;
fn rand_string() -> String {
let num = rand::thread_rng().gen_range(1, 256);
(0..num).map(|_| rand::random::<char>()).collect()
}
pub fn to_hex_string(bytes: &[u8] ) -> String { | strs.join(" ")
}
fn run_test_case() {
let data = rand_string();
let key = rand_string();
let result: Vec<u8> = xxtea::encrypt(&data, &key);
let plain_bytes: Vec<u8> = xxtea::decrypt(&result, &key);
let plain_text = match str::from_utf8(plain_bytes.as_slice()) {
Ok(v) => v,
Err... | let strs: Vec<String> = bytes.iter()
.map(|b| format!("{:02X}", b))
.collect();
| random_line_split |
tests.rs | extern crate rand;
extern crate xxtea;
use std::str;
use rand::Rng;
fn rand_string() -> String {
let num = rand::thread_rng().gen_range(1, 256);
(0..num).map(|_| rand::random::<char>()).collect()
}
pub fn to_hex_string(bytes: &[u8] ) -> String {
let strs: Vec<String> = bytes.iter()
.map(|b| format... | () {
let data = rand_string();
let key = rand_string();
let result: Vec<u8> = xxtea::encrypt(&data, &key);
let plain_bytes: Vec<u8> = xxtea::decrypt(&result, &key);
let plain_text = match str::from_utf8(plain_bytes.as_slice()) {
Ok(v) => v,
Err(e) => panic!("Invalid UTF-8 sequence:... | run_test_case | 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/. */
//! Computed values.
use {Atom, Namespace};
use context::QuirksMode;
use euclid::Size2D;
use font_metrics::{FontM... |
dest.write_str(")")
}
}
/// rect(...) | auto
pub type ClipRectOrAuto = Either<ClipRect, Auto>;
/// The computed value of a grid `<track-breadth>`
pub type TrackBreadth = GenericTrackBreadth<LengthOrPercentage>;
/// The computed value of a grid `<track-size>`
pub type TrackSize = GenericTrackSize<LengthO... | {
dest.write_str("auto")?;
} | 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/. */
//! Computed values.
use {Atom, Namespace};
use context::QuirksMode;
use euclid::Size2D;
use font_metrics::{FontM... | (&self, size: NonNegativeLength) -> NonNegativeLength {
size
}
}
/// An iterator over a slice of computed values
#[derive(Clone)]
pub struct ComputedVecIter<'a, 'cx, 'cx_a: 'cx, S: ToComputedValue + 'a> {
cx: &'cx Context<'cx_a>,
values: &'a [S],
}
impl<'a, 'cx, 'cx_a: 'cx, S: ToComputedValue + 'a... | maybe_zoom_text | 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/. */
//! Computed values.
use {Atom, Namespace};
use context::QuirksMode;
use euclid::Size2D;
use font_metrics::{FontM... | fn to_computed_value(&self, context: &Context) -> Self::ComputedValue;
#[inline]
/// Convert a computed value to specified value form.
///
/// This will be used for recascading during animation.
/// Such from_computed_valued values should recompute to the same value.
fn from_computed_value(... | #[inline] | random_line_split |
cellobject.rs | use libc::c_int;
use pyport::Py_ssize_t;
use object::*;
#[repr(C)]
#[derive(Copy, Clone)]
struct PyCellObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTy... | (*(op as *mut PyCellObject)).ob_ref = obj;
} | #[inline(always)]
pub unsafe fn PyCell_SET(op: *mut PyObject, obj: *mut PyObject) { | random_line_split |
cellobject.rs | use libc::c_int;
use pyport::Py_ssize_t;
use object::*;
#[repr(C)]
#[derive(Copy, Clone)]
struct PyCellObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTy... | (op: *mut PyObject, obj: *mut PyObject) {
(*(op as *mut PyCellObject)).ob_ref = obj;
}
| PyCell_SET | identifier_name |
percentage.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/. */
//! Specified percentages.
use cssparser::{Parser, Token};
use parser::{Parse, ParserContext};
use std::fmt::{sel... | ,
ref t => return Err(location.new_unexpected_token_error(t.clone())),
}
let result = input.parse_nested_block(|i| CalcNode::parse_percentage(context, i))?;
// TODO(emilio): -moz-image-rect is the only thing that uses
// the clamping mode... I guess we could disallow it...
... | {} | conditional_block |
percentage.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/. */
//! Specified percentages.
use cssparser::{Parser, Token};
use parser::{Parse, ParserContext};
use std::fmt::{sel... | }
/// `0%`
#[inline]
pub fn zero() -> Self {
Percentage {
value: 0.,
calc_clamping_mode: None,
}
}
/// `100%`
#[inline]
pub fn hundred() -> Self {
Percentage {
value: 1.,
calc_clamping_mode: None,
}
}
... | Self {
value,
calc_clamping_mode: None,
} | random_line_split |
percentage.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/. */
//! Specified percentages.
use cssparser::{Parser, Token};
use parser::{Parse, ParserContext};
use std::fmt::{sel... |
}
impl Percentage {
/// Creates a percentage from a numeric value.
pub fn new(value: CSSFloat) -> Self {
Self {
value,
calc_clamping_mode: None,
}
}
/// `0%`
#[inline]
pub fn zero() -> Self {
Percentage {
value: 0.,
calc_... | {
if self.calc_clamping_mode.is_some() {
dest.write_str("calc(")?;
}
serialize_percentage(self.value, dest)?;
if self.calc_clamping_mode.is_some() {
dest.write_str(")")?;
}
Ok(())
} | identifier_body |
percentage.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/. */
//! Specified percentages.
use cssparser::{Parser, Token};
use parser::{Parse, ParserContext};
use std::fmt::{sel... | <'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
Self::parse_with_clamping_mode(context, input, AllowedNumericType::All)
}
}
impl ToComputedValue for Percentage {
type ComputedValue = ComputedPercentage;
#[inline]
fn to_comp... | parse | identifier_name |
native.rs | // The MIT License (MIT)
//
// Copyright (c) 2014 Jeremy Letang | // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//... | // | random_line_split |
native.rs | // The MIT License (MIT)
//
// Copyright (c) 2014 Jeremy Letang
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, c... |
} | {} | identifier_body |
native.rs | // The MIT License (MIT)
//
// Copyright (c) 2014 Jeremy Letang
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, c... | (_: T) {}
} | wrap | identifier_name |
main.rs | #![cfg(unix)]
// TODO support for windows
extern crate app_dirs;
#[macro_use]
extern crate clap;
extern crate daemonize;
extern crate libhupa;
extern crate time;
use daemonize::Daemonize;
use libhupa::*;
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::time::Duration;
use std::time::Syst... | get_time_str(),
hupa.get_name(),
e
);
}
}
}
let _ = write!(
file,
"[{}] Waiting ... | "[{}] {} has an error during backup: {}\n", | random_line_split |
main.rs | #![cfg(unix)]
// TODO support for windows
extern crate app_dirs;
#[macro_use]
extern crate clap;
extern crate daemonize;
extern crate libhupa;
extern crate time;
use daemonize::Daemonize;
use libhupa::*;
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::time::Duration;
use std::time::Syst... | ;
if let Some(b) = matches.value_of("interval") {
if let Ok(i) = b.parse() {
config.autobackup_interval = i;
}
}
if let Some(p) = matches.value_of("metadata") {
config.metadata_path = PathBuf::from(p);
}
let config = config;
let mut hupas = match read_metadata... | {
VarsHandler::new(Vec::new())
} | conditional_block |
main.rs | #![cfg(unix)]
// TODO support for windows
extern crate app_dirs;
#[macro_use]
extern crate clap;
extern crate daemonize;
extern crate libhupa;
extern crate time;
use daemonize::Daemonize;
use libhupa::*;
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::time::Duration;
use std::time::Syst... | () {
let matches = clap_app!(hupad =>
(version: crate_version!())
(author: "Bastien Badzioch <fourdotfiveg@gmail.com>")
(about: "Hupa daemon is used as a server or as a backup daemon")
(@arg config: -c --config +takes_value "Set config path")
(@arg metadat... | main | identifier_name |
main.rs | #![cfg(unix)]
// TODO support for windows
extern crate app_dirs;
#[macro_use]
extern crate clap;
extern crate daemonize;
extern crate libhupa;
extern crate time;
use daemonize::Daemonize;
use libhupa::*;
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::time::Duration;
use std::time::Syst... | if let Ok(i) = b.parse() {
config.autobackup_interval = i;
}
}
if let Some(p) = matches.value_of("metadata") {
config.metadata_path = PathBuf::from(p);
}
let config = config;
let mut hupas = match read_metadata_from_config(&config) {
Ok(h) => h,
Er... | {
let matches = clap_app!(hupad =>
(version: crate_version!())
(author: "Bastien Badzioch <fourdotfiveg@gmail.com>")
(about: "Hupa daemon is used as a server or as a backup daemon")
(@arg config: -c --config +takes_value "Set config path")
(@arg metadata: ... | identifier_body |
mesh.rs | use std::u16;
use cgmath::Vector3;
use program::VertexArray;
use world::{Block, World};
/// This has to have C layout since it is read by the OpenGL driver via a pointer passed to it.
#[repr(C)]
#[derive(Clone)]
pub struct Coords {
xyz: [f32; 3],
st: [u16; 2]
}
impl Coords {
pub fn size_bytes() -> u32 {
3... | (&self, x: f32, y: f32, z: f32) -> Coords {
Coords {
xyz: [
self.xyz[0] + x,
self.xyz[1] + y,
self.xyz[2] + z,
],
st: self.st,
}
}
}
/// Each face consists of 2 triangles, 4 vertices total.
pub struct CubeFace {
/// Position and texture coordinates.
pub coords: [... | translate | identifier_name |
mesh.rs | use std::u16;
use cgmath::Vector3;
use program::VertexArray;
use world::{Block, World};
/// This has to have C layout since it is read by the OpenGL driver via a pointer passed to it.
#[repr(C)]
#[derive(Clone)]
pub struct Coords {
xyz: [f32; 3],
st: [u16; 2]
}
impl Coords {
pub fn size_bytes() -> u32 {
3... | {
let x = block.x as f32;
let y = block.y as f32;
let z = block.z as f32;
[
coords[0].translate(x, y, z),
coords[1].translate(x, y, z),
coords[2].translate(x, y, z),
coords[3].translate(x, y, z),
]
} | identifier_body | |
mesh.rs | use std::u16;
use cgmath::Vector3;
use program::VertexArray;
use world::{Block, World};
/// This has to have C layout since it is read by the OpenGL driver via a pointer passed to it.
#[repr(C)]
#[derive(Clone)]
pub struct Coords {
xyz: [f32; 3],
st: [u16; 2]
}
impl Coords {
pub fn size_bytes() -> u32 {
3... |
}
}
vertices
}
/// Accepts vertex and texture coordinates. Translates vertex coordinates only along the vector
// corresponding to the block center position.
fn translate(coords: &[Coords; 4], block: &Block) -> [Coords; 4] {
let x = block.x as f32;
let y = block.y as f32;
let z = block.z as f32;
[
... | {
vertices.add(&translate(&face.coords, block), &INDICES);
} | conditional_block |
mesh.rs | use std::u16;
use cgmath::Vector3;
use program::VertexArray;
use world::{Block, World};
/// This has to have C layout since it is read by the OpenGL driver via a pointer passed to it.
#[repr(C)]
#[derive(Clone)]
pub struct Coords {
xyz: [f32; 3],
st: [u16; 2]
}
impl Coords {
pub fn size_bytes() -> u32 {
3... | coords: [
Coords {
xyz: [-0.5, -0.5, -0.5],
st: [0x0000, 0x7fff],
},
Coords {
xyz: [0.5, -0.5, -0.5],
st: [0x7fff, 0x7fff],
},
Coords {
xyz: [0.5, -0.5, 0.5],
st: [0x7fff, 0x0000],
},
Coords {
... | ],
direction: Vector3::new(1, 0, 0),
},
// Down.
CubeFace { | random_line_split |
core.rs | pub extern crate nalgebra as na;
use std::fmt;
use std::ops::{Add, Sub, Index};
use self::na::DMatrix;
#[derive(Clone, Debug)]
/// A coordinate point in degree, minute, second.
pub struct Coordinate {
pub deg: i8,
pub min: i8,
pub sec: f32,
}
impl Coordinate {
/// Create a new coordinate point from ... | &'a self, _index: DemIndex) -> &'a i16 {
&self.data[_index]
}
}
| <'a>( | identifier_name |
core.rs | pub extern crate nalgebra as na;
use std::fmt;
use std::ops::{Add, Sub, Index};
use self::na::DMatrix;
#[derive(Clone, Debug)]
/// A coordinate point in degree, minute, second.
pub struct Coordinate {
pub deg: i8,
pub min: i8,
pub sec: f32, | let deg = *val as i8;
let min = (60. * (*val - deg as f32)) as i8;
let sec = 3600. * ((*val - deg as f32) - (min as f32) / 60.);
Coordinate {
deg: deg,
min: min,
sec: sec,
}
}
}
impl From<Coordinate> for f32 {
fn from(coord: Coordinate... | }
impl Coordinate {
/// Create a new coordinate point from its decimal representation.
pub fn new(val: &f32) -> Coordinate { | random_line_split |
core.rs | pub extern crate nalgebra as na;
use std::fmt;
use std::ops::{Add, Sub, Index};
use self::na::DMatrix;
#[derive(Clone, Debug)]
/// A coordinate point in degree, minute, second.
pub struct Coordinate {
pub deg: i8,
pub min: i8,
pub sec: f32,
}
impl Coordinate {
/// Create a new coordinate point from ... | &self.data[_index]
}
}
| identifier_body | |
select_path.rs | use http::Method;
use matches::assert_matches;
use ruma_common::api::{
error::IntoHttpError,
select_path,
MatrixVersion::{V1_0, V1_1, V1_2},
Metadata,
};
const BASE: Metadata = Metadata {
description: "",
method: Method::GET,
name: "test_endpoint",
unstable_path: Some("/unstable/path"),... | deprecated: None,
removed: None,
};
const U: &str = "u";
const S: &str = "s";
const R: &str = "r";
// TODO add test that can hook into tracing and verify the deprecation warning is emitted
#[test]
fn select_stable() {
let meta = Metadata { added: Some(V1_1),..BASE };
let res = select_path(&[V1_0, V1... | random_line_split | |
select_path.rs | use http::Method;
use matches::assert_matches;
use ruma_common::api::{
error::IntoHttpError,
select_path,
MatrixVersion::{V1_0, V1_1, V1_2},
Metadata,
};
const BASE: Metadata = Metadata {
description: "",
method: Method::GET,
name: "test_endpoint",
unstable_path: Some("/unstable/path"),... | () {
let meta = Metadata { added: Some(V1_1),..BASE };
let res = select_path(&[V1_0, V1_1], &meta, None, None, Some(format_args!("{}", S)))
.unwrap()
.to_string();
assert_eq!(res, S);
}
#[test]
fn select_unstable() {
let meta = BASE;
let res =
select_path(&[V1_0], &meta, So... | select_stable | identifier_name |
select_path.rs | use http::Method;
use matches::assert_matches;
use ruma_common::api::{
error::IntoHttpError,
select_path,
MatrixVersion::{V1_0, V1_1, V1_2},
Metadata,
};
const BASE: Metadata = Metadata {
description: "",
method: Method::GET,
name: "test_endpoint",
unstable_path: Some("/unstable/path"),... |
#[test]
fn select_removed_err() {
let meta = Metadata { added: Some(V1_0), deprecated: Some(V1_1), removed: Some(V1_2),..BASE };
let res = select_path(
&[V1_2],
&meta,
Some(format_args!("{}", U)),
Some(format_args!("{}", R)),
Some(format_args!("{}", S)),
)
.unwr... | {
let meta = Metadata { added: Some(V1_0), ..BASE };
let res =
select_path(&[V1_0], &meta, None, Some(format_args!("{}", R)), Some(format_args!("{}", S)))
.unwrap()
.to_string();
assert_eq!(res, R);
} | identifier_body |
rna.rs | use bio::dna::DNA;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum RNA {
U, C, A, G
}
pub fn parse_rna(c: char) -> Result<RNA, String> {
match c {
'U' => Ok(RNA::U),
'C' => Ok(RNA::C),
'A' => Ok(RNA::A),
'G' => Ok(RNA::G),
_ => Err(format!("Failed to parse {} as ... | (dna: DNA) -> RNA {
match dna {
DNA::T => RNA::U,
DNA::C => RNA::C,
DNA::A => RNA::A,
DNA::G => RNA::G
}
}
//
// pub struct RNASequence<'a> {
// sequence: &'a [RNA],
// cursor: usize
// }
//
// impl<'a> RNASequence<'a> {
// pub fn new(s: &'a [RNA]) -> RNASequence<'a> ... | transcribe | identifier_name |
rna.rs | use bio::dna::DNA;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum RNA {
U, C, A, G
}
pub fn parse_rna(c: char) -> Result<RNA, String> {
match c {
'U' => Ok(RNA::U),
'C' => Ok(RNA::C),
'A' => Ok(RNA::A),
'G' => Ok(RNA::G),
_ => Err(format!("Failed to parse {} as ... | // return result;
// } else {
// None
// }
// }
// } | // type Item = RNA;
// fn next(&mut self) -> Option<RNA> {
// if self.cursor < self.sequence.len() {
// let result = Some(self.sequence[self.cursor]);
// self.cursor += 1; | random_line_split |
rna.rs | use bio::dna::DNA;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum RNA {
U, C, A, G
}
pub fn parse_rna(c: char) -> Result<RNA, String> {
match c {
'U' => Ok(RNA::U),
'C' => Ok(RNA::C),
'A' => Ok(RNA::A),
'G' => Ok(RNA::G),
_ => Err(format!("Failed to parse {} as ... |
pub fn transcribe(dna: DNA) -> RNA {
match dna {
DNA::T => RNA::U,
DNA::C => RNA::C,
DNA::A => RNA::A,
DNA::G => RNA::G
}
}
//
// pub struct RNASequence<'a> {
// sequence: &'a [RNA],
// cursor: usize
// }
//
// impl<'a> RNASequence<'a> {
// pub fn new(s: &'a [RNA]) ... | {
let mut vec = Vec::new();
for c in s.chars() {
match parse_rna(c) {
Ok(rna) => vec.push(rna),
Err(_) => {}
}
}
vec
} | identifier_body |
dst-trait-tuple.rs | // run-pass
#![allow(type_alias_bounds)]
#![allow(unused_features)]
#![feature(unsized_tuple_coercion)]
type Fat<T:?Sized> = (isize, &'static str, T);
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
struct Bar;
#[derive(Copy, Clone, PartialEq, Eq)]
struct Bar1 {
f: isize
}
trait ToBar {
fn to_bar(&self) -> Ba... | (x: &dyn ToBar) {
assert_eq!(x.to_bar(), Bar);
assert_eq!(x.to_val(), 42);
}
fn baz(x: &Fat<Fat<dyn ToBar>>) {
assert_eq!(x.0, 5);
assert_eq!(x.1, "some str");
assert_eq!((x.2).0, 8);
assert_eq!((x.2).1, "deep str");
assert_eq!((x.2).2.to_bar(), Bar);
assert_eq!((x.2).2.to_val(), 42);
... | bar | identifier_name |
dst-trait-tuple.rs | // run-pass
#![allow(type_alias_bounds)]
#![allow(unused_features)]
#![feature(unsized_tuple_coercion)]
type Fat<T:?Sized> = (isize, &'static str, T);
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
struct Bar;
#[derive(Copy, Clone, PartialEq, Eq)] | fn to_bar(&self) -> Bar;
fn to_val(&self) -> isize;
}
impl ToBar for Bar {
fn to_bar(&self) -> Bar {
*self
}
fn to_val(&self) -> isize {
0
}
}
impl ToBar for Bar1 {
fn to_bar(&self) -> Bar {
Bar
}
fn to_val(&self) -> isize {
self.f
}
}
// x is a ... | struct Bar1 {
f: isize
}
trait ToBar { | random_line_split |
dst-trait-tuple.rs | // run-pass
#![allow(type_alias_bounds)]
#![allow(unused_features)]
#![feature(unsized_tuple_coercion)]
type Fat<T:?Sized> = (isize, &'static str, T);
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
struct Bar;
#[derive(Copy, Clone, PartialEq, Eq)]
struct Bar1 {
f: isize
}
trait ToBar {
fn to_bar(&self) -> Ba... |
fn baz(x: &Fat<Fat<dyn ToBar>>) {
assert_eq!(x.0, 5);
assert_eq!(x.1, "some str");
assert_eq!((x.2).0, 8);
assert_eq!((x.2).1, "deep str");
assert_eq!((x.2).2.to_bar(), Bar);
assert_eq!((x.2).2.to_val(), 42);
let y = &(x.2).2;
assert_eq!(y.to_bar(), Bar);
assert_eq!(y.to_val(), 42... | {
assert_eq!(x.to_bar(), Bar);
assert_eq!(x.to_val(), 42);
} | identifier_body |
switched.rs | use Arg;
#[derive(Debug)]
pub struct Switched<'b> {
pub short: Option<char>,
pub long: Option<&'b str>,
pub aliases: Option<Vec<(&'b str, bool)>>, // (name, visible)
pub disp_ord: usize,
pub unified_ord: usize,
}
impl<'e> Default for Switched<'e> {
fn default() -> Self {
Switched {
... | (a: &'z Arg<'n, 'e>) -> Self {
a.s.clone()
}
}
impl<'e> Clone for Switched<'e> {
fn clone(&self) -> Self {
Switched {
short: self.short,
long: self.long,
aliases: self.aliases.clone(),
disp_ord: self.disp_ord,
unified_ord: self.unified... | from | identifier_name |
switched.rs | use Arg;
#[derive(Debug)]
pub struct Switched<'b> {
pub short: Option<char>,
pub long: Option<&'b str>,
pub aliases: Option<Vec<(&'b str, bool)>>, // (name, visible)
pub disp_ord: usize,
pub unified_ord: usize,
}
impl<'e> Default for Switched<'e> {
fn default() -> Self {
Switched {
... |
impl<'n, 'e, 'z> From<&'z Arg<'n, 'e>> for Switched<'e> {
fn from(a: &'z Arg<'n, 'e>) -> Self {
a.s.clone()
}
}
impl<'e> Clone for Switched<'e> {
fn clone(&self) -> Self {
Switched {
short: self.short,
long: self.long,
aliases: self.aliases.clone(),
... | }
} | random_line_split |
lib.rs | #![allow(unknown_lints)]
#![allow(clippy::identity_op)] // used for vertical alignment
use std::collections::BTreeMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::Cursor;
use std::time::Instant;
use anyhow::{bail, Result};
use curl::easy::{Easy, List};
use percent_encoding::{percent_encode, NON_ALPHANUME... | {
crates: Vec<Crate>,
meta: TotalCrates,
}
impl Registry {
pub fn new(host: String, token: Option<String>) -> Registry {
Registry::new_handle(host, token, Easy::new())
}
pub fn new_handle(host: String, token: Option<String>, handle: Easy) -> Registry {
Registry {
host,
... | Crates | identifier_name |
lib.rs | #![allow(unknown_lints)]
#![allow(clippy::identity_op)] // used for vertical alignment
use std::collections::BTreeMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::Cursor;
use std::time::Instant;
use anyhow::{bail, Result};
use curl::easy::{Easy, List};
use percent_encoding::{percent_encode, NON_ALPHANUME... | 405 => "Method Not Allowed",
406 => "Not Acceptable",
407 => "Proxy Authentication Required",
408 => "Request Timeout",
409 => "Conflict",
410 => "Gone",
411 => "Length Required",
412 => "Precondition Failed",
413 => "Payload Too Large",
41... | 401 => "Unauthorized",
402 => "Payment Required",
403 => "Forbidden",
404 => "Not Found", | random_line_split |
crateresolve5-1.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 ... | () -> int { 10 }
| f | identifier_name |
crateresolve5-1.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 f() -> int { 10 }
| { !nominal_eq(*self, *other) } | identifier_body |
crateresolve5-1.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 f() -> int { 10 } |
impl PartialEq for e {
fn eq(&self, other: &e) -> bool { nominal_eq(*self, *other) }
fn ne(&self, other: &e) -> bool { !nominal_eq(*self, *other) } | random_line_split |
expand.rs | use std::str;
use find_byte::find_byte;
use re_bytes;
use re_unicode;
pub fn expand_str(
caps: &re_unicode::Captures,
mut replacement: &str,
dst: &mut String,
) {
while!replacement.is_empty() {
match find_byte(b'$', replacement.as_bytes()) {
None => break,
Some(i) => {... | (replacement: &[u8]) -> Option<CaptureRef> {
let mut i = 0;
let rep: &[u8] = replacement.as_ref();
if rep.len() <= 1 || rep[0]!= b'$' {
return None;
}
i += 1;
if rep[i] == b'{' {
return find_cap_ref_braced(rep, i + 1);
}
let mut cap_end = i;
while rep.get(cap_end).map... | find_cap_ref | identifier_name |
expand.rs | use std::str;
use find_byte::find_byte;
use re_bytes;
use re_unicode;
pub fn expand_str(
caps: &re_unicode::Captures,
mut replacement: &str,
dst: &mut String,
) {
while!replacement.is_empty() {
match find_byte(b'$', replacement.as_bytes()) {
None => break,
Some(i) => {... | find!(find_cap_ref13, "");
find!(find_cap_ref14, "$1-$2", c!(1, 2));
find!(find_cap_ref15, "$1_$2", c!("1_", 3));
find!(find_cap_ref16, "$x-$y", c!("x", 2));
find!(find_cap_ref17, "$x_$y", c!("x_", 3));
find!(find_cap_ref18, "${#}", c!("#", 4));
find!(find_cap_ref19, "${Z[}", c!("Z[", 5));
} | random_line_split | |
interface.rs | // Copyright 2014 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// 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>,... | {
Quirks,
LimitedQuirks,
NoQuirks,
}
/// Something which can be inserted into the DOM.
///
/// Adjacent sibling text nodes are merged into a single node, so
/// the sink may not want to allocate a `Handle` for each.
pub enum NodeOrText<Handle> {
AppendNode(Handle),
AppendText(StrTendril),
}
/// W... | QuirksMode | identifier_name |
interface.rs | // Copyright 2014 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// 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>,... | /// Append a node as the sibling immediately before the given node. If that node
/// has no parent, do nothing and return Err(new_node).
///
/// The tree builder promises that `sibling` is not a text node. However its
/// old previous sibling, which would become the new node's previous sibling,
... | random_line_split | |
sectriedb.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.... |
/// Get a reference to the underlying raw `TrieDB` struct.
pub fn raw(&self) -> &TrieDB {
&self.raw
}
/// Get a mutable reference to the underlying raw `TrieDB` struct.
pub fn raw_mut(&mut self) -> &mut TrieDB<'db> {
&mut self.raw
}
}
impl<'db> Trie for SecTrieDB<'db> {
fn iter<'a>(&'a self) -> super::Re... | {
Ok(SecTrieDB { raw: try!(TrieDB::new(db, root)) })
} | identifier_body |
sectriedb.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.... | fn root(&self) -> &H256 { self.raw.root() }
fn contains(&self, key: &[u8]) -> super::Result<bool> {
self.raw.contains(&key.sha3())
}
fn get_recorded<'a, 'b, R: 'b>(&'a self, key: &'b [u8], rec: &'b mut R) -> super::Result<Option<&'a [u8]>>
where 'a: 'b, R: Recorder
{
self.raw.get_recorded(&key.sha3(), rec)... | random_line_split | |
sectriedb.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.... | (&self) -> &TrieDB {
&self.raw
}
/// Get a mutable reference to the underlying raw `TrieDB` struct.
pub fn raw_mut(&mut self) -> &mut TrieDB<'db> {
&mut self.raw
}
}
impl<'db> Trie for SecTrieDB<'db> {
fn iter<'a>(&'a self) -> super::Result<Box<Iterator<Item = TrieItem> + 'a>> {
TrieDB::iter(&self.raw)
}
... | raw | identifier_name |
repo.rs | // Copyright 2016 Jeremy Letang.
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to ... | (db: &mut PgConnection, get_github_repo_id: i32, get_user_id: &str) -> Result<Repo, DieselError> {
use diesel::{LoadDsl, FilterDsl, ExpressionMethods};
use db::schemas::repos::dsl::{repos, github_repo_id, user_id};
repos
.filter(user_id.eq(get_user_id))
.filter(github_repo_id.eq(get_github_rep... | get_from_github_repo_id_and_user_id | identifier_name |
repo.rs | // Copyright 2016 Jeremy Letang.
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to ... |
pub fn get(db: &mut PgConnection, get_id: &str) -> Result<Repo, DieselError> {
use diesel::{LoadDsl, FilterDsl, ExpressionMethods};
use db::schemas::repos::dsl::{repos, id};
repos.filter(id.eq(get_id)).first::<Repo>(db)
}
pub fn get_from_github_repo_id_and_user_id(db: &mut PgConnection, get_github_repo_id... | } | random_line_split |
repo.rs | // Copyright 2016 Jeremy Letang.
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to ... | {
use diesel::{LoadDsl, FilterDsl, ExpressionMethods};
use db::schemas::repos::dsl::{repos, id};
use diesel::pg::expression::dsl::any;
repos.filter(id.eq(any(ids)))
.load::<Repo>(db)
} | identifier_body | |
instr_packusdw.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; | use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn packusdw_1() {
run_test(&Instruction { mnemonic: Mnemonic::PACKUSDW, operand1: Some(Direct(XMM2)), operand2: Some(Direct(XMM0)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: ... | use ::RegType::*;
use ::instruction_def::*; | random_line_split |
instr_packusdw.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn | () {
run_test(&Instruction { mnemonic: Mnemonic::PACKUSDW, operand1: Some(Direct(XMM2)), operand2: Some(Direct(XMM0)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 43, 208], OperandSize::Dword)
}
#[test]
fn packusdw_2(... | packusdw_1 | identifier_name |
instr_packusdw.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn packusdw_1() {
run_test(&Instruction { mnemonic: Mnemonic::PACKUSDW, operand1: Some(Direc... |
#[test]
fn packusdw_3() {
run_test(&Instruction { mnemonic: Mnemonic::PACKUSDW, operand1: Some(Direct(XMM4)), operand2: Some(Direct(XMM4)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 56, 43, 228], OperandSize::Qword)
}
... | {
run_test(&Instruction { mnemonic: Mnemonic::PACKUSDW, operand1: Some(Direct(XMM6)), operand2: Some(IndirectScaledDisplaced(EBX, Two, 1054303909, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102,... | identifier_body |
mod.rs | mod sip;
use std::default::Default;
use std::hash::{BuildHasher, Hash, Hasher};
use std::rc::Rc;
struct MyHasher {
hash: u64,
}
impl Default for MyHasher {
fn default() -> MyHasher {
MyHasher { hash: 0 }
}
}
impl Hasher for MyHasher {
fn write(&mut self, buf: &[u8]) {
for byte in buf... | {
use std::collections::hash_map::{DefaultHasher, RandomState};
let _: &dyn BuildHasher<Hasher = DefaultHasher> = &RandomState::new();
} | identifier_body | |
mod.rs | mod sip;
use std::default::Default;
use std::hash::{BuildHasher, Hash, Hasher};
use std::rc::Rc;
struct MyHasher {
hash: u64,
}
impl Default for MyHasher {
fn default() -> MyHasher {
MyHasher { hash: 0 }
}
}
impl Hasher for MyHasher {
fn write(&mut self, buf: &[u8]) {
for byte in buf... | }
struct Custom {
hash: u64,
}
struct CustomHasher {
output: u64,
}
impl Hasher for CustomHasher {
fn finish(&self) -> u64 {
self.output
}
fn write(&mut self, _: &[u8]) {
panic!()
}
fn write_u64(&mut self, data: u64) {
self.output = data;
}
}
impl Default for C... | assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64); | random_line_split |
mod.rs | mod sip;
use std::default::Default;
use std::hash::{BuildHasher, Hash, Hasher};
use std::rc::Rc;
struct MyHasher {
hash: u64,
}
impl Default for MyHasher {
fn default() -> MyHasher {
MyHasher { hash: 0 }
}
}
impl Hasher for MyHasher {
fn write(&mut self, buf: &[u8]) {
for byte in buf... | (&self) -> u64 {
self.hash
}
}
#[test]
fn test_writer_hasher() {
fn hash<T: Hash>(t: &T) -> u64 {
let mut s = MyHasher { hash: 0 };
t.hash(&mut s);
s.finish()
}
assert_eq!(hash(&()), 0);
assert_eq!(hash(&5_u8), 5);
assert_eq!(hash(&5_u16), 5);
assert_eq!(ha... | finish | identifier_name |
mod.rs | mod sip;
use std::default::Default;
use std::hash::{BuildHasher, Hash, Hasher};
use std::rc::Rc;
struct MyHasher {
hash: u64,
}
impl Default for MyHasher {
fn default() -> MyHasher {
MyHasher { hash: 0 }
}
}
impl Hasher for MyHasher {
fn write(&mut self, buf: &[u8]) {
for byte in buf... |
let cs: &mut [u8] = &mut [1, 2, 3];
let ptr = cs.as_ptr();
let slice_ptr = cs as *const [u8];
assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64);
let slice_ptr = cs as *mut [u8];
assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64);
}
struct Custom {
hash: u64,
}
struct Cus... | {
// Miri cannot hash pointers
return;
} | conditional_block |
test-ignore-cfg.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... | () {
}
#[test]
fn checktests() {
// Pull the tests out of the secreturn test module
let tests = __test::TESTS;
assert!(
tests.iter().any(|t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore));
assert!(
tests.iter().any(|t| t.desc.name.to_str() == ~"shouldnotignore" &&!t.desc.i... | shouldnotignore | identifier_name |
test-ignore-cfg.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... | // Pull the tests out of the secreturn test module
let tests = __test::TESTS;
assert!(
tests.iter().any(|t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore));
assert!(
tests.iter().any(|t| t.desc.name.to_str() == ~"shouldnotignore" &&!t.desc.ignore));
} |
#[test]
fn checktests() { | random_line_split |
test-ignore-cfg.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... |
#[test]
#[ignore(cfg(noignorecfg))]
fn shouldnotignore() {
}
#[test]
fn checktests() {
// Pull the tests out of the secreturn test module
let tests = __test::TESTS;
assert!(
tests.iter().any(|t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore));
assert!(
tests.iter().any(|t... | {
} | identifier_body |
borrowck-unary-move-2.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 finalize(&self) {
error!("dropped");
}
}
fn noncopyable() -> noncopyable {
noncopyable {
i: ()
}
}
struct wrapper(noncopyable);
fn main() {
let x1 = wrapper(noncopyable());
let _x2 = *x1; //~ ERROR moving out of anonymous field
} | struct noncopyable {
i: (),
}
impl Drop for noncopyable { | random_line_split |
borrowck-unary-move-2.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 ... | {
i: (),
}
impl Drop for noncopyable {
fn finalize(&self) {
error!("dropped");
}
}
fn noncopyable() -> noncopyable {
noncopyable {
i: ()
}
}
struct wrapper(noncopyable);
fn main() {
let x1 = wrapper(noncopyable());
let _x2 = *x1; //~ ERROR moving out of anonymous field
}... | noncopyable | identifier_name |
queue.rs | //
//
//
//!
use kernel::prelude::*;
use interface::Interface;
use core::sync::atomic::{AtomicUsize,Ordering};
pub struct Queue {
idx: usize,
size: usize,
buffer: ::kernel::memory::virt::AllocHandle,
descriptors_lock: ::kernel::sync::Mutex<()>,
avail_ring_lock: ::kernel::sync::Mutex<()>,
last_seen_used: AtomicU... | //log_debug!("AvailRing = {:?}", self);
}
}
impl UsedRing {
//pub fn used_event(&self) -> &u16 {
//}
}
struct LockedDescriptors<'a> {
_lh: ::kernel::sync::mutex::HeldMutex<'a, ()>,
slice: *mut [VRingDesc],
}
impl<'a> ::core::ops::Deref for LockedDescriptors<'a> {
type Target = [VRingDesc];
// SAFE: Uniquely ... | impl AvailRing {
fn push(&mut self, val: u16) {
let count = self.ents.len();
self.ents[self.idx as usize % count] = val;
self.idx += 1; | random_line_split |
queue.rs | //
//
//
//!
use kernel::prelude::*;
use interface::Interface;
use core::sync::atomic::{AtomicUsize,Ordering};
pub struct Queue {
idx: usize,
size: usize,
buffer: ::kernel::memory::virt::AllocHandle,
descriptors_lock: ::kernel::sync::Mutex<()>,
avail_ring_lock: ::kernel::sync::Mutex<()>,
last_seen_used: AtomicU... | else { 0 });
desc.next = match next { Some(v) => v.idx, None => 0 };
return DescriptorHandle { pd: ::core::marker::PhantomData, idx: idx as u16 };
}
}
todo!("allocate_descriptor - out of descriptors");
}
fn dispatch_descriptor<'a, I: Interface>(&'a self, interface: &I, handle: DescriptorHandle<'a>) ->... | { VRING_DESC_F_WRITE } | conditional_block |
queue.rs | //
//
//
//!
use kernel::prelude::*;
use interface::Interface;
use core::sync::atomic::{AtomicUsize,Ordering};
pub struct Queue {
idx: usize,
size: usize,
buffer: ::kernel::memory::virt::AllocHandle,
descriptors_lock: ::kernel::sync::Mutex<()>,
avail_ring_lock: ::kernel::sync::Mutex<()>,
last_seen_used: AtomicU... | (idx: usize, count: usize) -> Queue
{
let n_pages = Self::get_alloc_size(count) / ::kernel::PAGE_SIZE;
assert!(n_pages > 0);
Queue {
idx: idx,
size: count,
buffer: ::kernel::memory::virt::alloc_dma(32+12, n_pages, "VirtIO").expect("TODO: Handle alloc failure VirtIO queue"),
descriptors_lock: Default:... | new | identifier_name |
mock.rs | use std::fmt;
use std::ascii::AsciiExt;
use std::io::{self, Read, Write, Cursor};
use std::cell::RefCell;
use std::net::SocketAddr;
use std::sync::{Arc, Mutex};
use solicit::http::HttpScheme;
use solicit::http::transport::TransportStream;
use solicit::http::frame::{SettingsFrame, Frame};
use solicit::http::connection:... | ;
impl NetworkConnector for MockConnector {
type Stream = MockStream;
fn connect(&self, _host: &str, _port: u16, _scheme: &str) -> ::Result<MockStream> {
Ok(MockStream::new())
}
}
/// new connectors must be created if you wish to intercept requests.
macro_rules! mock_connector (
($name:ident ... | MockConnector | identifier_name |
mock.rs | use std::fmt;
use std::ascii::AsciiExt;
use std::io::{self, Read, Write, Cursor};
use std::cell::RefCell;
use std::net::SocketAddr;
use std::sync::{Arc, Mutex};
use solicit::http::HttpScheme;
use solicit::http::transport::TransportStream;
use solicit::http::frame::{SettingsFrame, Frame};
use solicit::http::connection:... |
}
impl NetworkStream for CloneableMockStream {
fn peer_addr(&mut self) -> io::Result<SocketAddr> {
self.inner.lock().unwrap().peer_addr()
}
}
impl CloneableMockStream {
pub fn with_stream(stream: MockStream) -> CloneableMockStream {
CloneableMockStream {
inner: Arc::new(Mutex:... | {
Ok(())
} | identifier_body |
mock.rs | use std::fmt;
use std::ascii::AsciiExt;
use std::io::{self, Read, Write, Cursor};
use std::cell::RefCell;
use std::net::SocketAddr;
use std::sync::{Arc, Mutex};
use solicit::http::HttpScheme;
use solicit::http::transport::TransportStream;
use solicit::http::frame::{SettingsFrame, Frame};
use solicit::http::connection:... | MockHttp2Connector {
streams: RefCell::new(Vec::new()),
}
}
/// Adds a new `CloneableMockStream` to the end of the connector's stream queue.
///
/// Streams are returned in a FIFO manner.
pub fn add_stream(&mut self, stream: CloneableMockStream) {
self.streams.bo... | /// Creates a new `MockHttp2Connector` with no streams.
pub fn new() -> MockHttp2Connector { | random_line_split |
mock.rs | use std::fmt;
use std::ascii::AsciiExt;
use std::io::{self, Read, Write, Cursor};
use std::cell::RefCell;
use std::net::SocketAddr;
use std::sync::{Arc, Mutex};
use solicit::http::HttpScheme;
use solicit::http::transport::TransportStream;
use solicit::http::frame::{SettingsFrame, Frame};
use solicit::http::connection:... | ;
conn.send_headers(resp_headers, 1, end).unwrap();
if body.is_some() {
let chunk = DataChunk::new_borrowed(&body.as_ref().unwrap()[..], 1, EndStream::Yes);
conn.send_data(chunk).unwrap();
}
conn.sender.write
}
/// A mock connector that produces `MockStream`s that are set to return HTT... | {
EndStream::No
} | conditional_block |
command.rs | use crate::direction::*;
use crate::position::*;
type Slot = u8;
/// Anything the user can ask the back end to do.
#[derive(Debug, Clone)]
pub enum Command {
/// Do not do anything. This exists solely to eliminate the need of using Option<Command>.
Nothing,
Movement(Movement),
LevelManagement(LevelMa... | _ => unreachable!(),
}
}
}
/// Did the player try to move a crate?
#[derive(Clone, Debug)]
pub struct WithCrate(pub bool);
/// What blacked a movement?
#[derive(Clone, Debug)]
#[cfg_attr(test, derive(PartialEq))]
pub enum Obstacle {
Wall,
Crate,
// TODO multiple workers might bloc... | use crate::Command::*;
use crate::Macro::*;
use crate::Movement::*;
match *self {
Movement(ref m) => match *m {
Step { direction } => direction.to_string(),
// TODO Find different formats for the next two cases
PushTillObstacle... | identifier_body |
command.rs | use crate::direction::*;
use crate::position::*;
type Slot = u8;
/// Anything the user can ask the back end to do.
#[derive(Debug, Clone)]
pub enum Command {
/// Do not do anything. This exists solely to eliminate the need of using Option<Command>.
Nothing,
Movement(Movement),
LevelManagement(LevelMa... |
/// Start recording a macro to the given slot.
Record(Slot),
/// Stop recording a macro and store the result.
Store,
/// Execute the macro stored in the given slon.
Execute(Slot),
}
impl Command {
/// Does this command change the collection of macros, i.e. cannot be safely recorded in a
... | cro { | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.