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 |
|---|---|---|---|---|
mod.rs | ,
sockaddr_in,
sockaddr_in6,
sockaddr_un,
sa_family_t,
};
pub use self::multicast::{
ip_mreq,
ipv6_mreq,
};
pub use self::consts::*;
pub use libc::sockaddr_storage;
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[repr(i32)]
pub enum SockType {
Stream = consts::SOCK_STREAM,
Datagram = c... | cmsg_len: self.len() as type_of_cmsg_len,
cmsg_level: SOL_SOCKET,
cmsg_type: SCM_RIGHTS,
cmsg_data: [],
};
copy_bytes(&cmsg, buf);
let padlen = cmsg_align(mem::size_of_val(&cmsg)) -
... | let cmsg = cmsghdr { | random_line_split |
multi-byte-chars.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... |
let x = C { θ: 0 };
(|c: C| c.θ )(x);
}
| identifier_body | |
multi-byte-chars.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... | // See also issue #18791.
struct C { θ: u8 }
fn main() {
let x = C { θ: 0 };
(|c: C| c.θ )(x);
} | // This test checks whether debuginfo generation can handle multi-byte UTF-8
// characters at the end of a block. There's no need to do anything in the
// debugger -- just make sure that the compiler doesn't crash. | random_line_split |
multi-byte-chars.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... | ) {
let x = C { θ: 0 };
(|c: C| c.θ )(x);
}
| ain( | identifier_name |
htmlheadingelement.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 crate::dom::bindings::codegen::Bindings::HTMLHeadingElementBinding;
use crate::dom::bindings::root::DomRoot;
u... | (
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
level: HeadingLevel,
) -> HTMLHeadingElement {
HTMLHeadingElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
level: level,
}
}
#[allow(... | new_inherited | identifier_name |
htmlheadingelement.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 crate::dom::bindings::codegen::Bindings::HTMLHeadingElementBinding;
use crate::dom::bindings::root::DomRoot;
u... | #[derive(JSTraceable, MallocSizeOf)]
pub enum HeadingLevel {
Heading1,
Heading2,
Heading3,
Heading4,
Heading5,
Heading6,
}
#[dom_struct]
pub struct HTMLHeadingElement {
htmlelement: HTMLElement,
level: HeadingLevel,
}
impl HTMLHeadingElement {
fn new_inherited(
local_name: ... | use crate::dom::htmlelement::HTMLElement;
use crate::dom::node::Node;
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
| random_line_split |
mod.rs | use na::{DMatrix};
use std::collections::{HashMap, HashSet};
use std::num::*;
use itertools::Itertools;
use std::cell::RefCell;
use std::rc::Rc;
use petgraph::{Graph};
use petgraph::graph::NodeIndex;
use petgraph::algo::*;
use rand;
pub fn do_stuff() | }
}
| {
let d = 7; //dimensions
let bin_width = 0.2; //bin size (assuming bins are squares
let bin_range_start = -100.0; //bin values cover -100
let bin_range_end = 100.0; //to 100
let bin_range = rand::distributions::Range::new(bin_range_start, bin_range_end);
let gap_time = 5; //time steps to run be... | identifier_body |
mod.rs | use na::{DMatrix};
use std::collections::{HashMap, HashSet};
use std::num::*;
use itertools::Itertools;
use std::cell::RefCell;
use std::rc::Rc;
use petgraph::{Graph};
use petgraph::graph::NodeIndex;
use petgraph::algo::*;
use rand;
pub fn do_stuff() {
let d = 7; //dimensions
let bin_width = 0.2; //bin size (... | let mut rng = rand::thread_rng();
for t in 0..11 {
let rand_vec = rand::sample(&mut rng, -100..100, d);
println!("{:?}", rand_vec);
}
} | let c_l = 0.8;
let lambda = 0.998;
let beta = 0.3;
| random_line_split |
mod.rs | use na::{DMatrix};
use std::collections::{HashMap, HashSet};
use std::num::*;
use itertools::Itertools;
use std::cell::RefCell;
use std::rc::Rc;
use petgraph::{Graph};
use petgraph::graph::NodeIndex;
use petgraph::algo::*;
use rand;
pub fn | () {
let d = 7; //dimensions
let bin_width = 0.2; //bin size (assuming bins are squares
let bin_range_start = -100.0; //bin values cover -100
let bin_range_end = 100.0; //to 100
let bin_range = rand::distributions::Range::new(bin_range_start, bin_range_end);
let gap_time = 5; //time steps to run... | do_stuff | identifier_name |
lub-if.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 ... | "(none)"
} else {
let s: &'a str = *maybestr.get_ref();
s
}
}
pub fn opt_str3<'a>(maybestr: &'a Option<~str>) -> &'static str {
if maybestr.is_some() { //~ ERROR mismatched types
let s: &'a str = *maybestr.get_ref();
s
} else {
"(none)"
}
}
fn main... | }
pub fn opt_str2<'a>(maybestr: &'a Option<~str>) -> &'static str {
if maybestr.is_none() { //~ ERROR mismatched types | random_line_split |
lub-if.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 opt_str1<'a>(maybestr: &'a Option<~str>) -> &'a str {
if maybestr.is_some() {
let s: &'a str = *maybestr.get_ref();
s
} else {
"(none)"
}
}
pub fn opt_str2<'a>(maybestr: &'a Option<~str>) -> &'static str {
if maybestr.is_none() { //~ ERROR mismatched types
"(non... | {
if maybestr.is_none() {
"(none)"
} else {
let s: &'a str = *maybestr.get_ref();
s
}
} | identifier_body |
lub-if.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 ... | () {}
| main | identifier_name |
lub-if.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 {
let s: &'a str = *maybestr.get_ref();
s
}
}
pub fn opt_str1<'a>(maybestr: &'a Option<~str>) -> &'a str {
if maybestr.is_some() {
let s: &'a str = *maybestr.get_ref();
s
} else {
"(none)"
}
}
pub fn opt_str2<'a>(maybestr: &'a Option<~str>) -> &'static str... | {
"(none)"
} | conditional_block |
logfwd.rs | use libc::c_char;
use std::sync::Once;
use crate::raw;
/// Manually initialize logging.
///
/// It is optional to call this function, and safe to do so more than once.
pub fn | () {
static mut INIT: Once = Once::new();
unsafe {
INIT.call_once(|| {
init_impl();
});
}
}
#[cfg(feature = "log")]
fn init_impl() {
use log::LevelFilter;
// trace to our callback
unsafe {
raw::rs_trace_to(trace);
}
// determine log level
// th... | init | identifier_name |
logfwd.rs | use libc::c_char;
use std::sync::Once;
use crate::raw; | /// Manually initialize logging.
///
/// It is optional to call this function, and safe to do so more than once.
pub fn init() {
static mut INIT: Once = Once::new();
unsafe {
INIT.call_once(|| {
init_impl();
});
}
}
#[cfg(feature = "log")]
fn init_impl() {
use log::LevelFil... | random_line_split | |
logfwd.rs | use libc::c_char;
use std::sync::Once;
use crate::raw;
/// Manually initialize logging.
///
/// It is optional to call this function, and safe to do so more than once.
pub fn init() {
static mut INIT: Once = Once::new();
unsafe {
INIT.call_once(|| {
init_impl();
});
}
}
#[cfg... |
}
| {} | identifier_body |
gigasecond.rs | use time::PrimitiveDateTime as DateTime;
/// Create a datetime from the given numeric point in time.
///
/// Panics if any field is invalid.
fn dt(year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8) -> DateTime {
use time::{Date, Time};
DateTime::new(
Date::from_calendar_date(year, month.... | {
let start_date = dt(2015, 1, 24, 23, 59, 59);
assert_eq!(gigasecond::after(start_date), dt(2046, 10, 3, 1, 46, 39));
} | identifier_body | |
gigasecond.rs | use time::PrimitiveDateTime as DateTime;
/// Create a datetime from the given numeric point in time.
///
/// Panics if any field is invalid.
fn dt(year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8) -> DateTime {
use time::{Date, Time};
DateTime::new(
Date::from_calendar_date(year, month.... | let start_date = dt(1977, 6, 13, 0, 0, 0);
assert_eq!(gigasecond::after(start_date), dt(2009, 2, 19, 1, 46, 40));
}
#[test]
#[ignore]
fn test_third_date() {
let start_date = dt(1959, 7, 19, 0, 0, 0);
assert_eq!(gigasecond::after(start_date), dt(1991, 3, 27, 1, 46, 40));
}
#[test]
#[ignore]
fn test_d... | fn test_another_date() { | random_line_split |
gigasecond.rs | use time::PrimitiveDateTime as DateTime;
/// Create a datetime from the given numeric point in time.
///
/// Panics if any field is invalid.
fn dt(year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8) -> DateTime {
use time::{Date, Time};
DateTime::new(
Date::from_calendar_date(year, month.... | () {
let start_date = dt(1977, 6, 13, 0, 0, 0);
assert_eq!(gigasecond::after(start_date), dt(2009, 2, 19, 1, 46, 40));
}
#[test]
#[ignore]
fn test_third_date() {
let start_date = dt(1959, 7, 19, 0, 0, 0);
assert_eq!(gigasecond::after(start_date), dt(1991, 3, 27, 1, 46, 40));
}
#[test]
#[ignore]
fn t... | test_another_date | identifier_name |
toast.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use crate::{components::font_awesome_outline, extensions::NodeExt, generated::css_classes::C};
use seed::{prelude::*, *};
#[derive(Clone, Copy, Debug)]
pub enum | {
Close,
}
pub enum Model {
Success(String),
Warn(String),
Error(String),
}
pub fn view(model: &Model) -> Node<Msg> {
let (toast_bg, toast_status_bg, icon, status_txt, x) = match model {
Model::Success(x) => (C.bg_green_600, C.bg_green_500, "check-circle", "Success", x),
Model::Wa... | Msg | identifier_name |
toast.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use crate::{components::font_awesome_outline, extensions::NodeExt, generated::css_classes::C};
use seed::{prelude::*, *};
#[derive(Clone, Copy, Debug)]
pub enum Msg {... | class![
C.flex,
C.items_center,
C.rounded_full,
toast_status_bg,
C.px_2,
C.py_1,
C.text_xs,
C.font_bold,
C.mr_3,
],
font_awesome_outline(cla... | C.rounded_full,
C.flex,
C.inline_flex,
],
span![ | random_line_split |
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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... | tnode.debug_id(),
tnode.flow_debug_id());
}
}
// Reset the layout damage in this node. It's been propagated to the
// flow by the flow constructor.
tnode.set_restyle_damage(RestyleDamage::empty());
}
unsafe {
nod... | random_line_split | |
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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... | <'a>(shared: &'a Self::SharedContext, root: OpaqueNode) -> Self {
// FIXME(bholley): This transmutation from &'a to &'lc is very unfortunate, but I haven't
// found a way to avoid it despite spending several days on it (and consulting Manishearth,
// brson, and nmatsakis).
//
// ... | new | 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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... |
}
#[derive(Copy, Clone)]
pub struct ComputeAbsolutePositions<'a> {
pub layout_context: &'a LayoutContext<'a>,
}
impl<'a> PreorderFlowTraversal for ComputeAbsolutePositions<'a> {
#[inline]
fn process(&self, flow: &mut Flow) {
flow.compute_absolute_position(self.layout_context);
}
}
pub struct... | {
let base = flow::base(flow);
base.restyle_damage.intersects(REFLOW_OUT_OF_FLOW | REFLOW) &&
// The fragmentation countainer is responsible for calling Flow::fragment recursively
!base.flags.contains(CAN_BE_FRAGMENTED)
} | 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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... |
for kid in flow::child_iter_mut(flow) {
self.traverse(kid);
}
}
#[inline]
fn should_process(&self) -> bool {
true
}
}
| {
self.state.push_stacking_context_id(flow::base(flow).stacking_context_id);
flow.build_display_list(&mut self.state);
flow::mut_base(flow).restyle_damage.remove(REPAINT);
self.state.pop_stacking_context_id();
} | conditional_block |
lib.rs | extern crate diesel;
extern crate diesel_dynamic_schema;
use diesel::sql_types::*;
use diesel::*;
use diesel_dynamic_schema::{schema, table};
mod dynamic_values;
mod connection_setup;
use connection_setup::{create_user_table, establish_connection};
#[cfg(feature = "postgres")]
type Backend = diesel::pg::Pg;
#[cfg(... |
#[test]
fn providing_custom_schema_name() {
let table = schema("information_schema").table("users");
let sql = debug_query::<Backend, _>(&table);
#[cfg(feature = "postgres")]
assert_eq!(
r#""information_schema"."users" -- binds: []"#,
sql.to_string()
);
#[cfg(not(feature = "p... | {
let conn = establish_connection();
create_user_table(&conn);
sql_query("INSERT INTO users (name) VALUES ('Sean'), ('Tess')")
.execute(&conn)
.unwrap();
let users = table("users");
let name = users.column::<Text, _>("name");
let users = users
.select(name)
.filt... | identifier_body |
lib.rs | extern crate diesel;
extern crate diesel_dynamic_schema;
use diesel::sql_types::*;
use diesel::*;
use diesel_dynamic_schema::{schema, table};
mod dynamic_values;
mod connection_setup;
use connection_setup::{create_user_table, establish_connection};
#[cfg(feature = "postgres")]
type Backend = diesel::pg::Pg;
#[cfg(... | () {
let conn = establish_connection();
create_user_table(&conn);
sql_query("INSERT INTO users(name) VALUES ('Sean')")
.execute(&conn)
.unwrap();
let users = table("users");
let name = users.column::<Text, _>("name");
let names = users.select(name).load::<String>(&conn);
asser... | querying_basic_schemas | identifier_name |
lib.rs | extern crate diesel;
extern crate diesel_dynamic_schema; |
use diesel::sql_types::*;
use diesel::*;
use diesel_dynamic_schema::{schema, table};
mod dynamic_values;
mod connection_setup;
use connection_setup::{create_user_table, establish_connection};
#[cfg(feature = "postgres")]
type Backend = diesel::pg::Pg;
#[cfg(feature = "mysql")]
type Backend = diesel::mysql::Mysql;
... | random_line_split | |
lib.rs | //! Keep track of all the git repositories on your machine.
//!
//! This crate houses the binary and library for the git-global subcommand, a
//! way to find, query statuses, and gain other insights about all the git repos
//! on your machine. The binary can be installed with cargo: `cargo install
//! git-global`.
//!
... | pub use errors::{GitGlobalError, Result};
pub use repo::Repo;
pub use report::Report; | pub use config::Config; | random_line_split |
geom.rs | //! Geometry-related types.
use std::cmp::{max, min};
use std::ops::Range;
/// A rectangle.
///
/// TODO: Maybe merge with `vobsub::Coords`? Or find a third-party library
/// for this?
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Rect {
left: usize,
top: usize,
width: usize,
height: usize,
}
//... |
/// Does this rectangle have area zero?
pub fn is_empty(&self) -> bool {
self.width == 0 || self.height == 0
}
/// Is the specified point in this rectangle?
pub fn contains(&self, x: usize, y: usize) -> bool {
self.left <= x && x < self.right() &&
self.top <= y && y < ... | {
self.height
} | identifier_body |
geom.rs | //! Geometry-related types.
use std::cmp::{max, min};
use std::ops::Range;
/// A rectangle.
///
/// TODO: Maybe merge with `vobsub::Coords`? Or find a third-party library
/// for this?
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Rect {
left: usize,
top: usize,
width: usize,
height: usize,
}
//... | (&self) -> bool {
self.width == 0 || self.height == 0
}
/// Is the specified point in this rectangle?
pub fn contains(&self, x: usize, y: usize) -> bool {
self.left <= x && x < self.right() &&
self.top <= y && y < self.bottom()
}
/// Return a rectangle including all the... | is_empty | identifier_name |
geom.rs | //! Geometry-related types.
use std::cmp::{max, min};
use std::ops::Range;
/// A rectangle.
///
/// TODO: Maybe merge with `vobsub::Coords`? Or find a third-party library
/// for this?
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Rect {
left: usize,
top: usize,
width: usize,
height: usize,
}
//... | width: r.checked_sub(l).expect("rectangle has negative width"),
height: b.checked_sub(t).expect("rectangle has negative height"),
}
}
/// The left-most edge of the rectangle (inclusive).
pub fn left(&self) -> usize {
self.left
}
/// The top-most edge of the ... | Rect {
left: l,
top: t, | random_line_split |
instr_blendpd.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*; | use ::test::run_test;
#[test]
fn blendpd_1() {
run_test(&Instruction { mnemonic: Mnemonic::BLENDPD, operand1: Some(Direct(XMM3)), operand2: Some(Direct(XMM3)), operand3: Some(Literal8(2)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 58, ... | use ::Operand::*;
use ::Reg::*;
use ::RegScale::*; | random_line_split |
instr_blendpd.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 blendpd_1() {
run_test(&Instruction { mnemonic: Mnemonic::BLENDPD, operand1: Some(Direct(... | () {
run_test(&Instruction { mnemonic: Mnemonic::BLENDPD, operand1: Some(Direct(XMM6)), operand2: Some(Direct(XMM7)), operand3: Some(Literal8(8)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 58, 13, 247, 8], OperandSize::Qword)
}
#[test]... | blendpd_3 | identifier_name |
instr_blendpd.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 blendpd_1() {
run_test(&Instruction { mnemonic: Mnemonic::BLENDPD, operand1: Some(Direct(... | {
run_test(&Instruction { mnemonic: Mnemonic::BLENDPD, operand1: Some(Direct(XMM6)), operand2: Some(IndirectScaledIndexedDisplaced(RAX, RAX, Eight, 536446275, Some(OperandSize::Xmmword), None)), operand3: Some(Literal8(94)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None,... | identifier_body | |
singlebyte.rs | // This is a part of rust-encoding.
// Copyright (c) 2013-2015, Kang Seonghoon.
// See README.md and LICENSE.txt for details.
//! Common codec implementation for single-byte encodings.
use libtww::std::convert::Into;
use util::{as_char, StrCharIndex};
use types::*;
/// A common framework for single-byte encodings ba... |
}
(input.len(), None)
}
fn raw_finish(&mut self, _output: &mut ByteWriter) -> Option<CodecError> {
None
}
}
/// A decoder for single-byte encodings based on ASCII.
#[derive(Clone, Copy)]
pub struct SingleByteDecoder {
index_forward: fn(u8) -> u16,
}
impl SingleByteDecoder {
... | {
let index = (self.index_backward)(ch as u32);
if index != 0 {
output.write_byte(index);
} else {
return (i,
Some(CodecError {
upto: j as isize,
cause: "un... | conditional_block |
singlebyte.rs | // This is a part of rust-encoding.
// Copyright (c) 2013-2015, Kang Seonghoon.
// See README.md and LICENSE.txt for details.
//! Common codec implementation for single-byte encodings.
use libtww::std::convert::Into;
use util::{as_char, StrCharIndex};
use types::*;
/// A common framework for single-byte encodings ba... | (&mut self, input: &[u8], output: &mut StringWriter) -> (usize, Option<CodecError>) {
output.writer_hint(input.len());
let mut i = 0;
let len = input.len();
while i < len {
if input[i] <= 0x7f {
output.write_char(input[i] as char);
} else {
... | raw_feed | identifier_name |
singlebyte.rs | // This is a part of rust-encoding.
// Copyright (c) 2013-2015, Kang Seonghoon.
// See README.md and LICENSE.txt for details.
//! Common codec implementation for single-byte encodings.
use libtww::std::convert::Into;
use util::{as_char, StrCharIndex};
use types::*;
/// A common framework for single-byte encodings ba... | }
} | assert_feed_err!(e, "A", "\u{10000}", "B", [0x41]); | random_line_split |
singlebyte.rs | // This is a part of rust-encoding.
// Copyright (c) 2013-2015, Kang Seonghoon.
// See README.md and LICENSE.txt for details.
//! Common codec implementation for single-byte encodings.
use libtww::std::convert::Into;
use util::{as_char, StrCharIndex};
use types::*;
/// A common framework for single-byte encodings ba... |
fn raw_encoder(&self) -> Box<RawEncoder> {
SingleByteEncoder::new(self.index_backward)
}
fn raw_decoder(&self) -> Box<RawDecoder> {
SingleByteDecoder::new(self.index_forward)
}
}
/// An encoder for single-byte encodings based on ASCII.
#[derive(Clone, Copy)]
pub struct SingleByteEncode... | {
self.whatwg_name
} | identifier_body |
coherence-blanket-conflicts-with-specific-multidispatch.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 ... | () { }
| main | identifier_name |
coherence-blanket-conflicts-with-specific-multidispatch.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 | // except according to those terms.
use std::fmt::Show;
use std::default::Default;
// Test that a blank impl for all T conflicts with an impl for some
// specific T, even when there are multiple type parameters involved.
trait MyTrait<T> {
fn get(&self) -> T;
}
impl<T> MyTrait<T> for T { //~ ERROR E0119
fn ... | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed | random_line_split |
predicate.rs | // Copyright 2016 Mozilla
//
// 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... | () {
let mut cc = ConjoiningClauses::default();
let mut schema = Schema::default();
associate_ident(&mut schema, Keyword::namespaced("foo", "bar"), 99);
associate_ident(&mut schema, Keyword::namespaced("foo", "roz"), 98);
add_attribute(&mut schema, 99, Attribute {
va... | test_apply_conflict_with_numeric_range | identifier_name |
predicate.rs | // Copyright 2016 Mozilla
//
// 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... | }
// Go from arguments -- parser output -- to columns or values.
// Any variables that aren't bound by this point in the linear processing of clauses will
// cause the application of the predicate to fail.
let mut args = predicate.args.into_iter();
let left = args.next()... | /// - Ensures that the predicate functions name a known operator.
/// - Accumulates an `Inequality` constraint into the `wheres` list.
pub(crate) fn apply_inequality(&mut self, known: Known, comparison: Inequality, predicate: Predicate) -> Result<()> {
if predicate.args.len() != 2 {
bail... | random_line_split |
predicate.rs | // Copyright 2016 Mozilla
//
// 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... |
/// This function:
/// - Resolves variables and converts types to those more amenable to SQL.
/// - Ensures that the predicate functions name a known operator.
/// - Accumulates an `Inequality` constraint into the `wheres` list.
pub(crate) fn apply_inequality(&mut self, known: Known, comparison: I... | {
match ValueType::from_keyword(&anno.value_type) {
Some(value_type) => self.add_type_requirement(anno.variable.clone(), ValueTypeSet::of_one(value_type)),
None => bail!(AlgebrizerError::InvalidArgumentType(PlainSymbol::plain("type"), ValueTypeSet::any(), 2)),
}
Ok(())
... | identifier_body |
predicate.rs | // Copyright 2016 Mozilla
//
// 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... | else {
bail!(AlgebrizerError::InvalidArgumentType(predicate.operator.clone(), supported_types, 0));
}
// These arguments must be variables or instant/numeric constants.
// TODO: static evaluation. #383.
let constraint = comparison.to_constraint(left_v, right_v);
sel... | {
left_v = self.resolve_ref_argument(known.schema, &predicate.operator, 0, left)?;
right_v = self.resolve_ref_argument(known.schema, &predicate.operator, 1, right)?;
} | conditional_block |
message.rs | use ascii_canvas::AsciiView;
use grammar::parse_tree::Span;
use message::Content;
use std::cmp;
use std::fmt::{Debug, Error, Formatter};
use style::Style;
use tls::Tls;
/// The top-level message display like this:
///
/// ```
/// <span>: <heading>
///
/// <body>
/// ```
///
/// This is equivalent to a
///
/// ```
/// ... | span: span,
heading: heading,
body: body,
}
}
}
impl Content for Message {
fn min_width(&self) -> usize {
let file_text = Tls::file_text();
let span = file_text.span_str(self.span).chars().count();
let heading = self.heading.min_width();
... | impl Message {
pub fn new(span: Span, heading: Box<Content>, body: Box<Content>) -> Self {
Message { | random_line_split |
message.rs | use ascii_canvas::AsciiView;
use grammar::parse_tree::Span;
use message::Content;
use std::cmp;
use std::fmt::{Debug, Error, Formatter};
use style::Style;
use tls::Tls;
/// The top-level message display like this:
///
/// ```
/// <span>: <heading>
///
/// <body>
/// ```
///
/// This is equivalent to a
///
/// ```
/// ... | (&self, fmt: &mut Formatter) -> Result<(), Error> {
fmt.debug_struct("Message")
.field("span", &self.span)
.field("heading", &self.heading)
.field("body", &self.body)
.finish()
}
}
| fmt | identifier_name |
message.rs | use ascii_canvas::AsciiView;
use grammar::parse_tree::Span;
use message::Content;
use std::cmp;
use std::fmt::{Debug, Error, Formatter};
use style::Style;
use tls::Tls;
/// The top-level message display like this:
///
/// ```
/// <span>: <heading>
///
/// <body>
/// ```
///
/// This is equivalent to a
///
/// ```
/// ... |
fn into_wrap_items(self: Box<Self>, wrap_items: &mut Vec<Box<Content>>) {
wrap_items.push(self);
}
}
impl Debug for Message {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
fmt.debug_struct("Message")
.field("span", &self.span)
.field("heading", &self.head... | {
let session = Tls::session();
let file_text = Tls::file_text();
let span = file_text.span_str(self.span);
view.write_chars(0, 0, span.chars(), Style::new());
let count = span.chars().count();
view.write_chars(0, count, ":".chars(), Style::new());
let (row, _) ... | identifier_body |
transfer.rs | use params::{List, Metadata, Timestamp};
use resources::Currency;
/// The resource representing a Stripe transfer reversal.
///
/// For more details see https://stripe.com/docs/api#transfer_reversal_object.
#[derive(Debug, Deserialize, Serialize)]
pub struct TransferReversal {
pub id: String,
pub object: Strin... | /// For more details see https://stripe.com/docs/api#transfer_object.
#[derive(Debug, Deserialize, Serialize)]
pub struct Transfer {
pub id: String,
pub object: String,
pub amount: u64,
pub amount_reversed: u64,
pub balance_transaction: String,
pub created: Timestamp,
pub currency: Currency,... | /// The resource representing a Stripe transfer.
/// | random_line_split |
transfer.rs | use params::{List, Metadata, Timestamp};
use resources::Currency;
/// The resource representing a Stripe transfer reversal.
///
/// For more details see https://stripe.com/docs/api#transfer_reversal_object.
#[derive(Debug, Deserialize, Serialize)]
pub struct TransferReversal {
pub id: String,
pub object: Strin... | {
pub id: String,
pub object: String,
pub amount: u64,
pub amount_reversed: u64,
pub balance_transaction: String,
pub created: Timestamp,
pub currency: Currency,
pub description: Option<String>,
pub destination: String,
pub destination_payment: String,
pub livemode: bool,
... | Transfer | identifier_name |
negative_iterator.rs | use std::iter::*;
pub trait NegativeIterator {
type Item;
type IntoIter : Iterator;
fn neg_iter(&self) -> Self::IntoIter;
}
impl<T> NegativeIterator for Option<T> {
type Item = ();
type IntoIter = <Option<()> as IntoIterator>::IntoIter;
fn neg_iter(&self) -> Self::IntoIter {
match *s... |
#[test]
fn result_ok() {
let result: Result<i32, i32> = Ok(5);
for _ in (&result).neg_iter() {
panic!("Should not iterate");
}
}
#[test]
fn result_err() {
let mut iterations = 0;
let result: Result<i32, i32> = Err(5);
for x in (&result).... | {
let mut iterations = 0;
let option: Option<i32> = None;
for _ in option.neg_iter() {
iterations += 1;
}
assert_eq!(1, iterations);
} | identifier_body |
negative_iterator.rs | use std::iter::*;
pub trait NegativeIterator {
type Item;
type IntoIter : Iterator;
fn neg_iter(&self) -> Self::IntoIter;
}
impl<T> NegativeIterator for Option<T> {
type Item = ();
type IntoIter = <Option<()> as IntoIterator>::IntoIter;
fn neg_iter(&self) -> Self::IntoIter {
match *s... | }.into_iter()
}
}
impl<'a, T, I, II> NegativeIterator for &'a T
where
II: Iterator,
T: NegativeIterator<Item=I, IntoIter=II>,
{
type Item = I;
type IntoIter = II;
fn neg_iter(&self) -> Self::IntoIter {
NegativeIterator::neg_iter(*self)
}
}
// TODO impl for Vec<_> that chec... | match **self {
Ok(_) => None,
Err(ref err) => Some(err) | random_line_split |
negative_iterator.rs | use std::iter::*;
pub trait NegativeIterator {
type Item;
type IntoIter : Iterator;
fn neg_iter(&self) -> Self::IntoIter;
}
impl<T> NegativeIterator for Option<T> {
type Item = ();
type IntoIter = <Option<()> as IntoIterator>::IntoIter;
fn neg_iter(&self) -> Self::IntoIter {
match *s... | () {
let mut iterations = 0;
let option: Option<i32> = None;
for _ in option.neg_iter() {
iterations += 1;
}
assert_eq!(1, iterations);
}
#[test]
fn result_ok() {
let result: Result<i32, i32> = Ok(5);
for _ in (&result).neg_iter() {
... | option_none | identifier_name |
mod.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>,... | a>(&'a mut self) -> &'a mut Sink {
&mut self.sink
}
/// Call the `Tracer`'s `trace_handle` method on every `Handle` in the tree builder's
/// internal state. This is intended to support garbage-collected DOMs.
pub fn trace_handles(&self, tracer: &Tracer<Handle=Handle>) {
tracer.trace_h... | nk_mut<' | identifier_name |
mod.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>,... |
impl<Handle, Sink> TokenSink
for TreeBuilder<Handle, Sink>
where Handle: Clone,
Sink: TreeSink<Handle=Handle>,
{
fn process_token(&mut self, token: tokenizer::Token) {
let ignore_lf = replace(&mut self.ignore_lf, false);
// Handle `ParseError` and `DoctypeToken`; convert everythi... | }
}
} | random_line_split |
mod.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>,... | self.next_tokenizer_state.take()
}
} | identifier_body | |
mime.rs | use std::{error::Error as StdError, io::Write};
use diesel::{backend::Backend, deserialize, serialize, sql_types::Text};
use mime::Mime as OrigMime;
#[derive(AsExpression, Debug, FromSqlRow)]
#[sql_type = "Text"]
pub struct Mime(pub OrigMime);
impl<DB> serialize::ToSql<Text, DB> for Mime
where
DB: Backend,
{
... |
}
| {
Mime(u)
} | identifier_body |
mime.rs | use std::{error::Error as StdError, io::Write};
use diesel::{backend::Backend, deserialize, serialize, sql_types::Text};
use mime::Mime as OrigMime;
#[derive(AsExpression, Debug, FromSqlRow)]
#[sql_type = "Text"]
pub struct Mime(pub OrigMime);
impl<DB> serialize::ToSql<Text, DB> for Mime
where
DB: Backend,
{
... | })
}
}
impl From<OrigMime> for Mime {
fn from(u: OrigMime) -> Self {
Mime(u)
}
} | fn from_sql(bytes: Option<&DB::RawValue>) -> deserialize::Result<Self> {
deserialize::FromSql::<Text, DB>::from_sql(bytes).and_then(|s: String| {
s.parse()
.map(Mime)
.map_err(|e| Box::new(e) as Box<StdError + Send + Sync>) | random_line_split |
mime.rs | use std::{error::Error as StdError, io::Write};
use diesel::{backend::Backend, deserialize, serialize, sql_types::Text};
use mime::Mime as OrigMime;
#[derive(AsExpression, Debug, FromSqlRow)]
#[sql_type = "Text"]
pub struct Mime(pub OrigMime);
impl<DB> serialize::ToSql<Text, DB> for Mime
where
DB: Backend,
{
... | <W: Write>(&self, out: &mut serialize::Output<W, DB>) -> serialize::Result {
serialize::ToSql::<Text, DB>::to_sql(self.0.as_ref(), out)
}
}
impl<DB> deserialize::FromSql<Text, DB> for Mime
where
DB: Backend<RawValue = [u8]>,
{
fn from_sql(bytes: Option<&DB::RawValue>) -> deserialize::Result<Self> {... | to_sql | identifier_name |
pagetransitionevent.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/. */
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindi... | type_: DOMString,
init: &PageTransitionEventBinding::PageTransitionEventInit,
) -> Fallible<DomRoot<PageTransitionEvent>> {
Ok(PageTransitionEvent::new(
window,
Atom::from(type_),
init.parent.bubbles,
init.parent.cancelable,
init.pe... | window: &Window, | random_line_split |
pagetransitionevent.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/. */
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindi... | (&self) -> bool {
self.event.IsTrusted()
}
}
| IsTrusted | identifier_name |
pagetransitionevent.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/. */
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindi... |
}
impl PageTransitionEventMethods for PageTransitionEvent {
// https://html.spec.whatwg.org/multipage/#dom-pagetransitionevent-persisted
fn Persisted(&self) -> bool {
self.persisted.get()
}
// https://dom.spec.whatwg.org/#dom-event-istrusted
fn IsTrusted(&self) -> bool {
self.even... | {
Ok(PageTransitionEvent::new(
window,
Atom::from(type_),
init.parent.bubbles,
init.parent.cancelable,
init.persisted,
))
} | identifier_body |
exec.rs | use std::{env,
ffi::OsString,
io,
path::PathBuf};
use crate::hcore::{fs::{find_command,
FS_ROOT_PATH},
os::process,
package::{PackageIdent,
PackageInstall}};
use crate::error::{Error,
... | for (key, value) in cmd_env.into_iter() {
debug!("Setting: {}='{}'", key, value);
env::set_var(key, value);
}
let command = match find_command(&command) {
Some(path) => path,
None => return Err(Error::ExecCommandNotFound(command)),
};
let mut display_args = command.to... | {
let command = command.into();
let pkg_install = PackageInstall::load(&ident, Some(&*FS_ROOT_PATH))?;
let mut cmd_env = pkg_install.environment_for_command()?;
if let Some(path) = cmd_env.get(PATH_KEY) {
if let Some(val) = env::var_os(PATH_KEY) {
let mut paths: Vec<PathBuf> = env::... | identifier_body |
exec.rs | use std::{env,
ffi::OsString,
io,
path::PathBuf};
use crate::hcore::{fs::{find_command,
FS_ROOT_PATH},
os::process,
package::{PackageIdent,
PackageInstall}};
use crate::error::{Error,
... |
for (key, value) in cmd_env.into_iter() {
debug!("Setting: {}='{}'", key, value);
env::set_var(key, value);
}
let command = match find_command(&command) {
Some(path) => path,
None => return Err(Error::ExecCommandNotFound(command)),
};
let mut display_args = command.... | {
if let Some(val) = env::var_os(PATH_KEY) {
let mut paths: Vec<PathBuf> = env::split_paths(&path).collect();
let mut os_paths = env::split_paths(&val).collect();
paths.append(&mut os_paths);
let joined = env::join_paths(paths)?;
let path_str =
... | conditional_block |
exec.rs | use std::{env,
ffi::OsString,
io,
path::PathBuf};
use crate::hcore::{fs::{find_command,
FS_ROOT_PATH},
os::process,
package::{PackageIdent,
PackageInstall}};
use crate::error::{Error,
... | let mut paths: Vec<PathBuf> = env::split_paths(&path).collect();
let mut os_paths = env::split_paths(&val).collect();
paths.append(&mut os_paths);
let joined = env::join_paths(paths)?;
let path_str =
joined.into_string()
.m... | if let Some(path) = cmd_env.get(PATH_KEY) {
if let Some(val) = env::var_os(PATH_KEY) { | random_line_split |
exec.rs | use std::{env,
ffi::OsString,
io,
path::PathBuf};
use crate::hcore::{fs::{find_command,
FS_ROOT_PATH},
os::process,
package::{PackageIdent,
PackageInstall}};
use crate::error::{Error,
... | <T>(ident: &PackageIdent, command: T, args: &[OsString]) -> Result<()>
where T: Into<PathBuf>
{
let command = command.into();
let pkg_install = PackageInstall::load(&ident, Some(&*FS_ROOT_PATH))?;
let mut cmd_env = pkg_install.environment_for_command()?;
if let Some(path) = cmd_env.get(PATH_KEY) {
... | start | identifier_name |
pact_support.rs | use http::{HeaderMap, Uri, Error};
use http::header::{ACCESS_CONTROL_ALLOW_ORIGIN, CONTENT_TYPE};
use http::header::HeaderValue;
use http::request::Parts;
use hyper::{Body, Response as HyperResponse};
use pact_matching::models::{HttpPart, OptionalBody, Request, Response};
use pact_matching::models::parse_query_string;
... |
match &response.body {
OptionalBody::Present(ref body, content_type) => {
let content_type_header = CONTENT_TYPE;
if!response.has_header(content_type_header.as_str()) {
let content_type = content_type.clone()
.unwrap_or_else(|| response.content_type().unwrap_or_else(|| TEXT.clone())... | {
res = res.header(allow_origin, "*");
} | conditional_block |
pact_support.rs | use http::{HeaderMap, Uri, Error};
use http::header::{ACCESS_CONTROL_ALLOW_ORIGIN, CONTENT_TYPE};
use http::header::HeaderValue;
use http::request::Parts;
use hyper::{Body, Response as HyperResponse};
use pact_matching::models::{HttpPart, OptionalBody, Request, Response};
use pact_matching::models::parse_query_string;
... | (req: Parts, body: OptionalBody) -> Request {
Request {
method: req.method.to_string(),
path: req.uri.path().to_string(),
query: extract_query_string(&req.uri),
headers: extract_headers(&req.headers),
body,
.. Request::default()
}
}
pub fn pact_response_to_hyper_r... | hyper_request_to_pact_request | identifier_name |
pact_support.rs | use http::{HeaderMap, Uri, Error};
use http::header::{ACCESS_CONTROL_ALLOW_ORIGIN, CONTENT_TYPE};
use http::header::HeaderValue;
use http::request::Parts;
use hyper::{Body, Response as HyperResponse};
use pact_matching::models::{HttpPart, OptionalBody, Request, Response};
use pact_matching::models::parse_query_string;
... |
#[test]
fn only_add_a_cors_origin_header_if_one_has_not_already_been_provided() {
let response = Response {
headers: Some(hashmap! { s!("Access-Control-Allow-Origin") => vec![s!("dodgy.com")] }),
.. Response::default()
};
let hyper_response = pact_response_to_hype... | let hyper_response = pact_response_to_hyper_response(&response).unwrap();
expect!(hyper_response.headers().is_empty()).to(be_false());
expect!(hyper_response.headers().get("content-type")).to(be_some().value(HeaderValue::from_static("application/json")));
} | random_line_split |
pact_support.rs | use http::{HeaderMap, Uri, Error};
use http::header::{ACCESS_CONTROL_ALLOW_ORIGIN, CONTENT_TYPE};
use http::header::HeaderValue;
use http::request::Parts;
use hyper::{Body, Response as HyperResponse};
use pact_matching::models::{HttpPart, OptionalBody, Request, Response};
use pact_matching::models::parse_query_string;
... |
}
| {
let response = Response {
headers: Some(hashmap! { s!("Access-Control-Allow-Origin") => vec![s!("dodgy.com")] }),
.. Response::default()
};
let hyper_response = pact_response_to_hyper_response(&response).unwrap();
expect!(hyper_response.headers().len()).to(be_e... | identifier_body |
var_dir_ind_reg.rs | use std::collections::HashMap;
use pest::Error;
use var_instr::variable::{Variable, AsComplete, LabelNotFound};
use var_instr::variable::FromPair;
use machine::instruction::mem_size::MemSize;
use machine::instruction::parameter::{Direct, Indirect, Register, DirIndReg};
use label::Label;
#[derive(Debug)]
pub enum VarDi... | (&self, offset: usize, label_offsets: &HashMap<Label, usize>) -> Result<DirIndReg, LabelNotFound> {
use self::VarDirIndReg::*;
match *self {
Direct(ref direct) => Ok(DirIndReg::Direct(direct.as_complete(offset, label_offsets)?)),
Indirect(ref indirect) => Ok(DirIndReg::Indirect(i... | as_complete | identifier_name |
var_dir_ind_reg.rs | use std::collections::HashMap;
use pest::Error;
use var_instr::variable::{Variable, AsComplete, LabelNotFound};
use var_instr::variable::FromPair;
use machine::instruction::mem_size::MemSize;
use machine::instruction::parameter::{Direct, Indirect, Register, DirIndReg};
use label::Label;
#[derive(Debug)]
pub enum VarDi... | VarDirIndReg::Register(register) => register.mem_size(),
}
}
}
impl FromPair for VarDirIndReg {
fn from_pair(pair: ::AsmPair) -> Result<Self, ::AsmError> {
match pair.as_rule() {
::Rule::direct => Ok(VarDirIndReg::Direct(Variable::from_pair(pair)?)),
::Rule::... | impl MemSize for VarDirIndReg {
fn mem_size(&self) -> usize {
match *self {
VarDirIndReg::Direct(ref direct) => direct.mem_size(),
VarDirIndReg::Indirect(ref indirect) => indirect.mem_size(), | random_line_split |
main.rs | extern crate clap;
#[macro_use]
extern crate structopt_derive;
extern crate structopt;
extern crate bytes;
extern crate futures;
extern crate tokio_core;
extern crate tokio_io;
extern crate net2;
extern crate num_cpus;
extern crate resolve;
use std::net::SocketAddr;
use std::time::{self, Duration, SystemTime};
use ne... |
}
}
})
.last();
Ok(())
});
handle.spawn(server.map_err(|_| ()));
}
}
... | {
ERR_COUNTER.fetch_add(1, Ordering::Relaxed);
} | conditional_block |
main.rs | extern crate clap;
#[macro_use]
extern crate structopt_derive;
extern crate structopt;
extern crate bytes;
extern crate futures;
extern crate tokio_core;
extern crate tokio_io;
extern crate net2;
extern crate num_cpus;
extern crate resolve;
use std::net::SocketAddr;
use std::time::{self, Duration, SystemTime};
use ne... | stats_prefix: String,
#[structopt(short = "S", long = "stats", help = "Graphite plaintext format compatible address:port to send metrics to")]
stats: Option<String>,
}
fn main() {
let mut opts = Options::from_args();
if opts.nthreads == 0 {
opts.nthreads = num_cpus::get();
}
if o... | random_line_split | |
main.rs | extern crate clap;
#[macro_use]
extern crate structopt_derive;
extern crate structopt;
extern crate bytes;
extern crate futures;
extern crate tokio_core;
extern crate tokio_io;
extern crate net2;
extern crate num_cpus;
extern crate resolve;
use std::net::SocketAddr;
use std::time::{self, Duration, SystemTime};
use ne... | {
addr: SocketAddr,
}
impl DgramCodec {
pub fn new(addr: SocketAddr) -> Self {
DgramCodec { addr: addr }
}
}
impl UdpCodec for DgramCodec {
type In = Bytes;
type Out = Bytes;
fn decode(&mut self,
_src: &SocketAddr,
buf: &[u8])
-> ::std::result::Res... | DgramCodec | identifier_name |
issue-33174-restricted-type-in-public-interface.rs | // Copyright 2018 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 ... | ;
//~^ NOTE `Tortoise` declared as private
pub struct Shell<T> {
pub(crate) creature: T,
}
pub type Helix_pomatia = Shell<Snail>;
//~^ ERROR crate-visible type `Snail` in public interface
//~| NOTE can't leak crate-visible type
pub type Dermochelys_coriacea = Shell<sea::Turtle>;
//~^ ERROR restricted type `sea::T... | Tortoise | identifier_name |
issue-33174-restricted-type-in-public-interface.rs | // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | // 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_camel_case_types)] // genus is always capitalized
pub(crate) struct Snail... | // http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | random_line_split |
euler11.rs | #[cfg_attr(rustfmt, rustfmt_skip)]
#[allow(zero_prefixed_literal)]
const GRID: [[u32; 20]; 20] = [
[08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08],
[49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00],
[81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65],
[52,70,95,23,04... | let mut max = 0;
for i in 0..20 {
for j in 0..20 {
if j < 17 {
let p = product(&GRID[i][j..j + 4]);
if p > max {
max = p
}
}
if i < 17 {
let p = product(&[GRID[i][j], GRID[i + 1][j], G... | pub fn main() {
let product = |slice: &[u32]| slice.iter().fold(1, |prod, i| prod * i); | random_line_split |
euler11.rs | #[cfg_attr(rustfmt, rustfmt_skip)]
#[allow(zero_prefixed_literal)]
const GRID: [[u32; 20]; 20] = [
[08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08],
[49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00],
[81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65],
[52,70,95,23,04... | GRID[i + 2][j + 2],
GRID[i + 3][j + 3]]);
if p > max {
max = p
}
}
if i > 2 && j < 17 {
let p = product(&[GRID[i][j],
GRID[i -... | {
let product = |slice: &[u32]| slice.iter().fold(1, |prod, i| prod * i);
let mut max = 0;
for i in 0..20 {
for j in 0..20 {
if j < 17 {
let p = product(&GRID[i][j..j + 4]);
if p > max {
max = p
}
}
... | identifier_body |
euler11.rs | #[cfg_attr(rustfmt, rustfmt_skip)]
#[allow(zero_prefixed_literal)]
const GRID: [[u32; 20]; 20] = [
[08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08],
[49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00],
[81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65],
[52,70,95,23,04... | () {
let product = |slice: &[u32]| slice.iter().fold(1, |prod, i| prod * i);
let mut max = 0;
for i in 0..20 {
for j in 0..20 {
if j < 17 {
let p = product(&GRID[i][j..j + 4]);
if p > max {
max = p
}
}
... | main | identifier_name |
euler11.rs | #[cfg_attr(rustfmt, rustfmt_skip)]
#[allow(zero_prefixed_literal)]
const GRID: [[u32; 20]; 20] = [
[08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08],
[49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00],
[81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65],
[52,70,95,23,04... |
if i < 17 {
let p = product(&[GRID[i][j], GRID[i + 1][j], GRID[i + 2][j], GRID[i + 3][j]]);
if p > max {
max = p
}
}
if i < 17 && j < 17 {
let p = product(&[GRID[i][j],
... | {
let p = product(&GRID[i][j..j + 4]);
if p > max {
max = p
}
} | 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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... |
/// Traverses the tree in-order.
fn traverse(&mut self, flow: &mut Flow, level: u32) {
if!self.should_process_subtree(flow) {
return;
}
self.process(flow, level);
for kid in flow.mut_base().child_iter_mut() {
self.traverse(kid, level + 1);
}
... | {
true
} | 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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... | <'a> {
pub layout_context: &'a LayoutContext<'a>,
}
impl<'a> PreorderFlowTraversal for AssignISizes<'a> {
#[inline]
fn process(&self, flow: &mut Flow) {
flow.assign_inline_sizes(self.layout_context);
}
#[inline]
fn should_process(&self, flow: &mut Flow) -> bool {
flow.base().re... | AssignISizes | 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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... |
for descendant_link in flow.mut_base().abs_descendants.iter() {
self.traverse_absolute_flows(descendant_link)
}
}
}
/// A bottom-up traversal, with a optional in-order pass.
pub trait PostorderFlowTraversal {
/// The operation to perform. Return true to continue or false to stop.
... | {
self.process(flow);
} | 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/. */
//! Traversals over the DOM and flow trees, running the layout computations.
use construct::FlowConstructor;
use ... | flow.mut_base().restyle_damage.remove(ServoRestyleDamage::BUBBLE_ISIZES);
}
#[inline]
fn should_process(&self, flow: &mut Flow) -> bool {
flow.base().restyle_damage.contains(ServoRestyleDamage::BUBBLE_ISIZES)
}
}
/// The assign-inline-sizes traversal. In Gecko this corresponds to `Refl... | flow.bubble_inline_sizes(); | random_line_split |
protocol.rs | use std::convert::{From, Into};
use std::fmt;
use self::OpCode::*;
/// Operation codes as part of rfc6455.
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
pub enum OpCode {
/// Indicates a continuation frame of a fragmented message.
Continue,
/// Indicates a text data frame.
Text,
/// Indicates a bina... | (byte: u8) -> OpCode {
match byte {
0 => Continue,
1 => Text,
2 => Binary,
8 => Close,
9 => Ping,
10 => Pong,
_ => Bad,
}
}
}
use self::CloseCode::*;
/// Status code used to indicate why an endpoint is closing the W... | from | identifier_name |
protocol.rs | use std::convert::{From, Into};
use std::fmt;
use self::OpCode::*;
/// Operation codes as part of rfc6455.
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
pub enum OpCode {
/// Indicates a continuation frame of a fragmented message.
Continue,
/// Indicates a text data frame.
Text,
/// Indicates a bina... | }
impl Into<u16> for CloseCode {
fn into(self) -> u16 {
match self {
Normal => 1000,
Away => 1001,
Protocol => 1002,
Unsupported => 1003,
Status => 1005,
Abnormal => 1006,
Invalid => 1007,
Policy => 1008,
... | Other(u16), | random_line_split |
protocol.rs | use std::convert::{From, Into};
use std::fmt;
use self::OpCode::*;
/// Operation codes as part of rfc6455.
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
pub enum OpCode {
/// Indicates a continuation frame of a fragmented message.
Continue,
/// Indicates a text data frame.
Text,
/// Indicates a bina... |
}
impl From<u8> for OpCode {
fn from(byte: u8) -> OpCode {
match byte {
0 => Continue,
1 => Text,
2 => Binary,
8 => Close,
9 => Ping,
10 => Pong,
_ => Bad,
}
}
}
use self::CloseCode::*;
/// Status code used to... | {
match self {
Continue => 0,
Text => 1,
Binary => 2,
Close => 8,
Ping => 9,
Pong => 10,
Bad => {
debug_assert!(
false,
"Attempted to convert invalid opcode to u8. This is ... | identifier_body |
mod.rs | //! Access to open sqlite3 database by filename.
//!
//! The `core` module requires explicit authority to access files and such,
//! following the principle of least authority.
//!
//! This module provides the privileged functions to create such authorities.
//!
//! *TODO: move `mod access` to its own crate so that lin... | ByFilename {
filename: filename,
flags: flags.unwrap_or_default()
})
}
/// Access to a database by filename
pub struct ByFilename<'a> {
/// Filename or sqlite3 style URI.
pub filename: &'a str,
/// Flags for additional control over the new database connection.
pu... | DatabaseConnection::new( | random_line_split |
mod.rs | //! Access to open sqlite3 database by filename.
//!
//! The `core` module requires explicit authority to access files and such,
//! following the principle of least authority.
//!
//! This module provides the privileged functions to create such authorities.
//!
//! *TODO: move `mod access` to its own crate so that lin... | (filename: &str, flags: Option<OpenFlags>) -> SqliteResult<DatabaseConnection> {
DatabaseConnection::new(
ByFilename {
filename: filename,
flags: flags.unwrap_or_default()
})
}
/// Access to a database by filename
pub struct ByFilename<'a> {
/// Filename or sqlite3 style... | open | identifier_name |
lib.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/. */
#![feature(box_syntax)]
#![feature(core_intrinsics)]
#![feature(link_args)]
#![feature(plugin)]
#![feature(unicode... | extern crate log;
extern crate servo;
extern crate compositing;
extern crate euclid;
extern crate gfx_traits;
extern crate gleam;
extern crate glutin_app;
extern crate rustc_unicode;
extern crate script_traits;
extern crate servo_url;
extern crate style_traits;
extern crate net_traits;
extern crate msg;
extern crate... | random_line_split | |
neon.rs | use std::process;
use crate::{Config, NeonGenesisNode, BurnchainController,
BitcoinRegtestController, Keychain};
use stacks::chainstate::burn::db::burndb::BurnDB;
use stacks::burnchains::bitcoin::address::BitcoinAddress;
use stacks::burnchains::Address;
use stacks::burnchains::bitcoin::{BitcoinNetworkType,... | }
}
// now, let's tell the miner to try and mine.
if!node.relayer_issue_tenure() {
// relayer hung up, exit.
error!("Block relayer and miner hung up, exiting.");
process::exit(1);
}
block_height ... | process::exit(1); | random_line_split |
neon.rs | use std::process;
use crate::{Config, NeonGenesisNode, BurnchainController,
BitcoinRegtestController, Keychain};
use stacks::chainstate::burn::db::burndb::BurnDB;
use stacks::burnchains::bitcoin::address::BitcoinAddress;
use stacks::burnchains::Address;
use stacks::burnchains::bitcoin::{BitcoinNetworkType,... |
// first, let's process all blocks in (block_height, next_height]
for block_to_process in (block_height+1)..(next_height+1) {
let block = {
let ic = burnchain.burndb_ref().index_conn();
BurnDB::get_ancestor_snapshot(
... | {
warn!("burnchain.sync() did not progress block height");
continue;
} | conditional_block |
neon.rs | use std::process;
use crate::{Config, NeonGenesisNode, BurnchainController,
BitcoinRegtestController, Keychain};
use stacks::chainstate::burn::db::burndb::BurnDB;
use stacks::burnchains::bitcoin::address::BitcoinAddress;
use stacks::burnchains::Address;
use stacks::burnchains::bitcoin::{BitcoinNetworkType,... | (&self) -> std::sync::Arc<std::sync::atomic::AtomicU64> {
self.blocks_processed.clone()
}
#[cfg(not(test))]
fn get_blocks_processed_arc(&self) {
}
#[cfg(test)]
fn bump_blocks_processed(&self) {
self.blocks_processed.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
}
... | get_blocks_processed_arc | identifier_name |
neon.rs | use std::process;
use crate::{Config, NeonGenesisNode, BurnchainController,
BitcoinRegtestController, Keychain};
use stacks::chainstate::burn::db::burndb::BurnDB;
use stacks::burnchains::bitcoin::address::BitcoinAddress;
use stacks::burnchains::Address;
use stacks::burnchains::bitcoin::{BitcoinNetworkType,... |
#[cfg(test)]
pub fn new(config: Config) -> Self {
Self {
config,
callbacks: RunLoopCallbacks::new(),
blocks_processed: std::sync::Arc::new(std::sync::atomic::AtomicU64::new(0)),
}
}
#[cfg(test)]
pub fn get_blocks_processed_arc(&self) -> std::syn... | {
Self {
config,
callbacks: RunLoopCallbacks::new(),
}
} | identifier_body |
main.rs | extern crate time;
use std::fs::{File, create_dir, OpenOptions, remove_file};
use std::io::{Seek, SeekFrom, BufReader, BufRead, Lines, Write};
use std::io;
use std::path::{Path, PathBuf};
use std::env::{args, home_dir};
use std::fmt;
use std::process::exit;
use time::{Duration, now_utc, Tm, empty_tm, strptime};
fn ma... | print_time_worked(&time_worked_today, ¤t_day);
}
Ok(())
}
// aux. methods
fn set_current_working_state(&mut self, currently_working: bool) {
self.currently_working = currently_working;
if currently_working {
File::create(&self.state_path).unwr... | {
try!(self.timesheet.seek(SeekFrom::Start(0)));
let buf = BufReader::new(try!(File::open(&self.timesheet_path)));
let mut current_day = empty_tm();
let mut time_worked_today = Duration::zero();
for interval in IntervalIter::from_lines(buf.lines()) {
let (start, end)... | identifier_body |
main.rs | extern crate time;
use std::fs::{File, create_dir, OpenOptions, remove_file};
use std::io::{Seek, SeekFrom, BufReader, BufRead, Lines, Write};
use std::io;
use std::path::{Path, PathBuf};
use std::env::{args, home_dir};
use std::fmt;
use std::process::exit;
use time::{Duration, now_utc, Tm, empty_tm, strptime};
fn ma... | .create(true).open(×heet_path));
Ok(TimeClock {
timesheet: timesheet,
timesheet_path: timesheet_path,
currently_working: path_exists(&working_state_path),
state_path: working_state_path,
now: now
})
}
//... | random_line_split | |
main.rs | extern crate time;
use std::fs::{File, create_dir, OpenOptions, remove_file};
use std::io::{Seek, SeekFrom, BufReader, BufRead, Lines, Write};
use std::io;
use std::path::{Path, PathBuf};
use std::env::{args, home_dir};
use std::fmt;
use std::process::exit;
use time::{Duration, now_utc, Tm, empty_tm, strptime};
fn ma... | (&mut self, currently_working: bool) {
self.currently_working = currently_working;
if currently_working {
File::create(&self.state_path).unwrap();
} else {
remove_file(&self.state_path).unwrap();
}
}
}
struct IntervalIter {
lines: Lines<BufReader<File>>
}... | set_current_working_state | identifier_name |
lib.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... |
pub mod parse;
pub mod crateid;
pub mod print {
pub mod pp;
pub mod pprust;
}
pub mod ext {
pub mod asm;
pub mod base;
pub mod expand;
pub mod quote;
pub mod deriving;
pub mod build;
pub mod tt {
pub mod transcribe;
pub mod macro_parser;
pub mod macro_r... | pub mod ast_util;
pub mod ast_map;
pub mod visit;
pub mod fold;
| random_line_split |
modify.rs | use std::collections::HashSet;
use std::convert::AsRef;
use std::hash::Hash;
use std::io;
use lber::structures::{Tag, Enumerated, Sequence, Set, OctetString};
use lber::common::TagClass;
use futures::{future, Future};
use tokio_service::Service;
use ldap::{Ldap, LdapOp, next_req_controls};
use result::LdapResult;
/... | <S: AsRef<[u8]> + Eq + Hash> {
/// Add an attribute, with at least one value.
Add(S, HashSet<S>),
/// Delete the entire attribute, or the given values of an attribute.
Delete(S, HashSet<S>),
/// Replace an existing attribute, setting its values to those in the set, or delete it if no values are give... | Mod | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.