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 |
|---|---|---|---|---|
htmllielement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLLIElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLLIElemen... | (&self) -> bool {
*self.type_id() ==
EventTargetTypeId::Node(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLIElement)))
}
}
impl HTMLLIElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLLIEle... | is_htmllielement | identifier_name |
yubi.rs | use yubico::config::{Command, Config, Mode, Slot};
use yubico::configure::DeviceModeConfig;
use yubico::hmacmode::HmacKey;
use yubico::Yubico;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use hex;
use std::ops::Deref;
pub fn setup_secret() -> Result<(), String> {
let mut yubi = Yubico::new... | }
pub fn retrieve_secret(token: [u8; 20]) -> Option<String> {
let mut yubi = Yubico::new();
if let Ok(device) = yubi.find_yubikey() {
let config = Config::default()
.set_vendor_id(device.vendor_id)
.set_product_id(device.product_id)
.set_variable_size(true)
... | random_line_split | |
yubi.rs | use yubico::config::{Command, Config, Mode, Slot};
use yubico::configure::DeviceModeConfig;
use yubico::hmacmode::HmacKey;
use yubico::Yubico;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use hex;
use std::ops::Deref;
pub fn setup_secret() -> Result<(), String> {
let mut yubi = Yubico::new... |
}
| {
return None;
} | conditional_block |
yubi.rs | use yubico::config::{Command, Config, Mode, Slot};
use yubico::configure::DeviceModeConfig;
use yubico::hmacmode::HmacKey;
use yubico::Yubico;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use hex;
use std::ops::Deref;
pub fn setup_secret() -> Result<(), String> | } else {
return Ok(());
}
}
Err("Yubikey not found".into())
}
pub fn retrieve_secret(token: [u8; 20]) -> Option<String> {
let mut yubi = Yubico::new();
if let Ok(device) = yubi.find_yubikey() {
let config = Config::default()
.set_vendor_id(device.vendor... | {
let mut yubi = Yubico::new();
// We assume the first device
if let Ok(device) = yubi.find_yubikey() {
let config = Config::default()
.set_vendor_id(device.vendor_id)
.set_product_id(device.product_id)
.set_command(Command::Configuration2);
let mut rng ... | identifier_body |
yubi.rs | use yubico::config::{Command, Config, Mode, Slot};
use yubico::configure::DeviceModeConfig;
use yubico::hmacmode::HmacKey;
use yubico::Yubico;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use hex;
use std::ops::Deref;
pub fn | () -> Result<(), String> {
let mut yubi = Yubico::new();
// We assume the first device
if let Ok(device) = yubi.find_yubikey() {
let config = Config::default()
.set_vendor_id(device.vendor_id)
.set_product_id(device.product_id)
.set_command(Command::Configuration2);... | setup_secret | identifier_name |
phantom.rs | /*
* Copyright 2017 Sreejith Krishnan R
*
* 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... | (&mut self, context: &Context, width_mode: &MeasureMode, height_mode: &MeasureMode) {
if let Some(ref mut wrapped) = self.wrapped {
wrapped.calculate(context, width_mode, height_mode);
self.bounding_box = wrapped.bounding_box().clone();
} else {
self.bounding_box = Bo... | calculate | identifier_name |
phantom.rs | /*
* Copyright 2017 Sreejith Krishnan R
*
* 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... | else {
self.bounding_box = BoundingBox::default()
}
}
fn bounding_box(&self) -> &BoundingBox {
&self.bounding_box
}
} | {
wrapped.calculate(context, width_mode, height_mode);
self.bounding_box = wrapped.bounding_box().clone();
} | conditional_block |
phantom.rs | /*
* Copyright 2017 Sreejith Krishnan R | * 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 ... | *
* 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
* | random_line_split |
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 dom::bindings::codegen::Bindings::HTMLHeadingElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLHea... | (&self) -> bool {
*self.type_id() ==
EventTargetTypeId::Node(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLHeadingElement)))
}
}
impl HTMLHeadingElement {
fn new_inherited(localName: DOMString,
prefix: Option<DOMString>,
... | is_htmlheadingelement | 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 dom::bindings::codegen::Bindings::HTMLHeadingElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLHea... |
}
| {
let element = HTMLHeadingElement::new_inherited(localName, prefix, document, level);
Node::reflect_node(box element, document, HTMLHeadingElementBinding::Wrap)
} | identifier_body |
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 dom::bindings::codegen::Bindings::HTMLHeadingElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLHea... | pub struct HTMLHeadingElement {
htmlelement: HTMLElement,
level: HeadingLevel,
}
impl HTMLHeadingElementDerived for EventTarget {
fn is_htmlheadingelement(&self) -> bool {
*self.type_id() ==
EventTargetTypeId::Node(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElem... | Heading6,
}
#[dom_struct] | random_line_split |
recursion_limit_macro.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
recurse!(0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9);
}
| main | identifier_name |
recursion_limit_macro.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
// | // except according to those terms.
// Test that the recursion limit can be changed and that the compiler
// suggests a fix. In this case, we have a recursing macro that will
// overflow if the number of arguments surpasses the recursion limit.
#![allow(dead_code)]
#![recursion_limit="10"]
macro_rules! recurse {
... | // 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 | random_line_split |
recursion_limit_macro.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
recurse!(0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9);
} | identifier_body | |
trait-static-method-generic-inference.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (&self) { }
}
pub struct Foo {
dummy: (),
}
impl HasNew<Foo> for Foo {
fn new() -> Foo {
Foo { dummy: () }
}
}
}
pub fn foo() {
let _f: base::Foo = base::HasNew::new();
//~^ ERROR type annotations required
}
fn main() { }
| dummy | identifier_name |
trait-static-method-generic-inference.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn main() { } | } | random_line_split |
class-implement-trait-cross-crate.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... | how_hungry : int,
name : String,
}
impl cat {
pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
println!("OM NOM NOM");
self.how_hungry -= 2;
return true;
}
else {
println!("Not hungry!");
return false;
}
}
}... | struct cat {
meows: uint,
| random_line_split |
class-implement-trait-cross-crate.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
}
}
impl noisy for cat {
fn speak(&mut self) { self.meow(); }
}
impl cat {
fn meow(&mut self) {
println!("Meow");
self.meows += 1u;
if self.meows % 5u == 0u {
self.how_hungry += 1;
}
}
}
fn cat(in_x : uint, in_y : int, in_name: String) -> cat {
cat {
... | {
println!("Not hungry!");
return false;
} | conditional_block |
class-implement-trait-cross-crate.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... | {
meows: uint,
how_hungry : int,
name : String,
}
impl cat {
pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
println!("OM NOM NOM");
self.how_hungry -= 2;
return true;
}
else {
println!("Not hungry!");
return false... | cat | identifier_name |
class-implement-trait-cross-crate.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... | {
let mut nyan = cat(0u, 2, "nyan".to_string());
nyan.eat();
assert!((!nyan.eat()));
for _ in 1u..10u { nyan.speak(); };
assert!((nyan.eat()));
} | identifier_body | |
mod.rs | // Copyright 2015-2017 Intecture Developers.
//
// Licensed under the Mozilla Public License 2.0 <LICENSE or
// https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied,
// modified, or distributed except according to those terms.
//! Manages the connection between the API and a server.
pub mod local;
pub mo... | (&self, request: Request) ->
Box<Future<Item = Message<Response, Body<Vec<u8>, io::Error>>, Error = Error>>
{
self.request_msg(Message::WithoutBody(request))
}
#[doc(hidden)]
fn request_msg(&self, Message<Request, Body<Vec<u8>, io::Error>>) ->
Box<Future<Item = Message<Response, ... | request | identifier_name |
mod.rs | // Copyright 2015-2017 Intecture Developers.
//
// Licensed under the Mozilla Public License 2.0 <LICENSE or
// https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied,
// modified, or distributed except according to those terms.
//! Manages the connection between the API and a server.
pub mod local;
pub mo... | use tokio_core::reactor::Handle;
use tokio_proto::streaming::{Body, Message};
/// Trait for local and remote host types.
pub trait Host: Clone {
/// Get `Telemetry` for this host.
fn telemetry(&self) -> &Telemetry;
/// Get `Handle` to Tokio reactor.
fn handle(&self) -> &Handle;
#[doc(hidden)]
f... | use futures::Future;
use remote::{Request, Response};
use std::io;
use telemetry::Telemetry; | random_line_split |
mod.rs | // Copyright 2015-2017 Intecture Developers.
//
// Licensed under the Mozilla Public License 2.0 <LICENSE or
// https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied,
// modified, or distributed except according to those terms.
//! Manages the connection between the API and a server.
pub mod local;
pub mo... |
#[doc(hidden)]
fn request_msg(&self, Message<Request, Body<Vec<u8>, io::Error>>) ->
Box<Future<Item = Message<Response, Body<Vec<u8>, io::Error>>, Error = Error>>;
}
| {
self.request_msg(Message::WithoutBody(request))
} | identifier_body |
ui.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... |
.subcommand(SubCommand::with_name("import")
.about("Import contacts")
.version("0.1")
.arg(Arg::with_name("path")
.index(1)
.takes_value(true)
.required(true)
.multip... | {
app
.subcommand(SubCommand::with_name("list")
.about("List contacts")
.version("0.1")
.arg(Arg::with_name("filter")
.index(1)
.takes_value(true)
.required(false)
... | identifier_body |
ui.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... | .value_name("FORMAT")
.help("Format to format the contact when printing it"))
)
.subcommand(SubCommand::with_name("create")
.about("Create a contact file (.vcf) and track it in imag.")
.version("0.1")
... | .takes_value(true)
.required(false)
.multiple(false) | random_line_split |
ui.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... | <'a>(app: App<'a, 'a>) -> App<'a, 'a> {
app
.subcommand(SubCommand::with_name("list")
.about("List contacts")
.version("0.1")
.arg(Arg::with_name("filter")
.index(1)
.takes_value(true)
.... | build_ui | identifier_name |
css.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 cssparser::{Parser, serialize_identifier};
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding:... | (_: &Window, ident: DOMString) -> Fallible<DOMString> {
let mut escaped = String::new();
serialize_identifier(&ident, &mut escaped).unwrap();
Ok(DOMString::from(escaped))
}
/// https://drafts.csswg.org/css-conditional/#dom-css-supports
pub fn Supports(win: &Window, property: DOMStri... | Escape | identifier_name |
css.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 cssparser::{Parser, serialize_identifier};
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding:... | else {
false
}
}
}
| {
let url = win.Document().url();
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports),
PARSING_MODE_DEFAULT,
QuirksMode::NoQuirks);
... | conditional_block |
css.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 cssparser::{Parser, serialize_identifier};
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding:... | pub fn Supports_(win: &Window, condition: DOMString) -> bool {
let mut input = Parser::new(&condition);
let cond = parse_condition_or_declaration(&mut input);
if let Ok(cond) = cond {
let url = win.Document().url();
let context = ParserContext::new_for_cssom(&url, win... | /// https://drafts.csswg.org/css-conditional/#dom-css-supports | random_line_split |
title.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// 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... | glfw::KeyEvent(glfw::KeyEscape, _, glfw::Press, _) => {
window.set_should_close(true)
}
_ => {}
}
}
| identifier_body | |
title.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// 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... | }
}
| set_should_close(true)
}
_ => {}
| conditional_block |
title.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// 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... | // 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.
extern crate native;
extern crate glfw;
use glfw::Context;
#[start]
fn start(argc: int, argv: *const *const u8) -> int {
native::sta... | //
// 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, | random_line_split |
title.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// 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... | (argc: int, argv: *const *const u8) -> int {
native::start(argc, argv, main)
}
fn main() {
let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
let (window, events) = glfw.create_window(400, 400, "English 日本語 русский язык 官話", glfw::Windowed)
.expect("Failed to create GLFW window.");
window.s... | start | identifier_name |
font.rs | 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 app_units::Au;
use euclid::{Point2D, Rect, Size2D};
use font_context::{FontContext, FontSource};
use font_template::FontTemplateDescriptor;
use orde... | else { "Didn't find" };
debug!("{} font table[{}] with family={}, face={}",
status, tag.tag_to_str(),
self.handle.family_name(), self.handle.face_name().unwrap_or("unavailable".to_owned()));
result
}
#[inline]
pub fn glyph_index(&self, codepoint: char) -> Op... | { "Found" } | conditional_block |
font.rs | 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 app_units::Au;
use euclid::{Point2D, Rect, Size2D};
use font_context::{FontContext, FontSource};
use font_template::FontTemplateDescriptor;
use orde... |
/// The scope within which we will look for a font.
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum FontSearchScope {
/// All fonts will be searched, including those specified via `@font-face` rules.
Any,
/// Only local system fonts will be searched.
Local,
}
/// A font... | {
let value = TEXT_SHAPING_PERFORMANCE_COUNTER.load(Ordering::SeqCst);
TEXT_SHAPING_PERFORMANCE_COUNTER.store(0, Ordering::SeqCst);
value
} | identifier_body |
font.rs | 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 app_units::Au;
use euclid::{Point2D, Rect, Size2D};
use font_context::{FontContext, FontSource};
use font_template::FontTemplateDescriptor;
use orde... | (&self, codepoint: char) -> Option<GlyphId> {
let codepoint = match self.descriptor.variant {
font_variant_caps::T::SmallCaps => codepoint.to_uppercase().next().unwrap(), //FIXME: #5938
font_variant_caps::T::Normal => codepoint,
};
self.handle.glyph_index(codepoint)
}... | glyph_index | identifier_name |
font.rs | 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 app_units::Au;
use euclid::{Point2D, Rect, Size2D};
use font_context::{FontContext, FontSource};
use font_template::FontTemplateDescripto... | (($t1 as u32) << 24) | (($t2 as u32) << 16) | (($t3 as u32) << 8) | ($t4 as u32)
);
}
pub const GPOS: u32 = ot_tag!('G', 'P', 'O', 'S');
pub const GSUB: u32 = ot_tag!('G', 'S', 'U', 'B');
pub const KERN: u32 = ot_tag!('k', 'e', 'r', 'n');
static TEXT_SHAPING_PERFORMANCE_COUNTER: AtomicUsize = ATOMIC_USIZE... | macro_rules! ot_tag {
($t1:expr, $t2:expr, $t3:expr, $t4:expr) => ( | random_line_split |
event.rs | use std::io::Write;
use termion::event::Key;
use Editor;
pub type EventHandler<'a, W> = FnMut(Event<W>) + 'a;
pub struct Event<'a, 'out: 'a, W: Write + 'a> {
pub editor: &'a mut Editor<'out, W>, | pub fn new(editor: &'a mut Editor<'out, W>, kind: EventKind) -> Self {
Event {
editor: editor,
kind: kind,
}
}
}
#[derive(Debug)]
pub enum EventKind {
/// Sent before handling a keypress.
BeforeKey(Key),
/// Sent after handling a keypress.
AfterKey(Key),
... | pub kind: EventKind,
}
impl<'a, 'out: 'a, W: Write + 'a> Event<'a, 'out, W> { | random_line_split |
event.rs | use std::io::Write;
use termion::event::Key;
use Editor;
pub type EventHandler<'a, W> = FnMut(Event<W>) + 'a;
pub struct Event<'a, 'out: 'a, W: Write + 'a> {
pub editor: &'a mut Editor<'out, W>,
pub kind: EventKind,
}
impl<'a, 'out: 'a, W: Write + 'a> Event<'a, 'out, W> {
pub fn new(editor: &'a mut Edito... |
}
#[derive(Debug)]
pub enum EventKind {
/// Sent before handling a keypress.
BeforeKey(Key),
/// Sent after handling a keypress.
AfterKey(Key),
/// Sent in `Editor.complete()`, before processing the completion.
BeforeComplete,
}
| {
Event {
editor: editor,
kind: kind,
}
} | identifier_body |
event.rs | use std::io::Write;
use termion::event::Key;
use Editor;
pub type EventHandler<'a, W> = FnMut(Event<W>) + 'a;
pub struct | <'a, 'out: 'a, W: Write + 'a> {
pub editor: &'a mut Editor<'out, W>,
pub kind: EventKind,
}
impl<'a, 'out: 'a, W: Write + 'a> Event<'a, 'out, W> {
pub fn new(editor: &'a mut Editor<'out, W>, kind: EventKind) -> Self {
Event {
editor: editor,
kind: kind,
}
}
}
#[... | Event | identifier_name |
lib.rs | #![recursion_limit = "1024"] // for error_chain!
extern crate rand;
extern crate scopeguard;
#[macro_use]
extern crate error_chain;
extern crate rustc_serialize;
extern crate sha2;
extern crate url;
extern crate toml;
extern crate download;
extern crate semver;
#[cfg(windows)]
extern crate winapi;
#[cfg(windows)]
ext... | pub use errors::*;
pub use notifications::{Notification};
pub mod notify; | random_line_split | |
core_application.rs | include_generated!();
/// A struct providing valid `argc` and `argv` values for Qt application
/// objects.
///
/// Constructors of `qt_core::core_application::CoreApplication`,
/// `qt_gui::gui_application::GuiApplication` and `qt_widgets::application::Application`
/// require `argc` and `argv` values that are availa... |
#[cfg(windows)]
/// Creates an object representing real arguments of the application.
/// On Windows, this function uses empty argument list for performance reasons because
/// Qt doesn't use `argc` and `argv` on Windows at all.
pub fn from_real() -> CoreApplicationArgs {
// Qt doesn't use argc and argv ... | {
use std::os::unix::ffi::OsStringExt;
let args = ::std::env::args_os().map(|arg| arg.into_vec()).collect();
CoreApplicationArgs::from(args)
} | identifier_body |
core_application.rs | include_generated!();
/// A struct providing valid `argc` and `argv` values for Qt application
/// objects. | /// `qt_gui::gui_application::GuiApplication` and `qt_widgets::application::Application`
/// require `argc` and `argv` values that are available in C++'s `main` function but
/// not available in Rust. More importantly, `argc` and `argv` must be valid for the entire
/// life of the application. This struct stores list o... | ///
/// Constructors of `qt_core::core_application::CoreApplication`, | random_line_split |
core_application.rs | include_generated!();
/// A struct providing valid `argc` and `argv` values for Qt application
/// objects.
///
/// Constructors of `qt_core::core_application::CoreApplication`,
/// `qt_gui::gui_application::GuiApplication` and `qt_widgets::application::Application`
/// require `argc` and `argv` values that are availa... | (&mut self) -> (&mut ::libc::c_int, *mut *mut ::libc::c_char) {
(self.argc.as_mut(), self.argv.as_mut_ptr())
}
#[cfg(unix)]
/// Creates an object representing real arguments of the application.
/// On Windows, this function uses empty argument list for performance reasons because
/// Qt doesn't use `argc... | get | identifier_name |
core_application.rs | include_generated!();
/// A struct providing valid `argc` and `argv` values for Qt application
/// objects.
///
/// Constructors of `qt_core::core_application::CoreApplication`,
/// `qt_gui::gui_application::GuiApplication` and `qt_widgets::application::Application`
/// require `argc` and `argv` values that are availa... |
}
CoreApplicationArgs {
argc: Box::new(args.len() as ::libc::c_int),
argv: args
.iter_mut()
.map(|x| x.as_mut_ptr() as *mut ::libc::c_char)
.collect(),
_values: args,
}
}
/// Creates an object containing empty list of arguments.
/// Although this is the cheapest... | {
arg.push(0);
} | conditional_block |
main.rs | extern crate dialoguer;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate quote;
use dialoguer::Input;
use std::path::PathBuf;
use std::{
fs::{self, File},
io::Write,
path::Path,
};
mod api_generator;
mod error;
mod rest_spec;
fn main() {
// This must be run from the src root directo... |
}
}
| {
// delete existing generated files if the exist
if generated_dir.exists() {
fs::remove_dir_all(&generated_dir).unwrap();
}
fs::create_dir_all(&generated_dir).unwrap();
api_generator::generate(&branch, &download_dir, &generated_dir).unwrap()... | conditional_block |
main.rs | extern crate dialoguer;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate quote;
use dialoguer::Input;
use std::path::PathBuf;
use std::{
fs::{self, File},
io::Write,
path::Path,
};
mod api_generator;
mod error;
mod rest_spec;
fn main() {
// This must be run from the src root directo... | }
// only offer to generate if there are downloaded specs
if download_dir
.read_dir()
.map(|mut r| r.next().is_some())
.unwrap_or(false)
{
let mut generate_code = true;
answer = String::new();
while answer!= "y" && answer!= "n" {
answer = Input::... | File::create(last_downloaded_version)
.expect("failed to create last_downloaded_version file")
.write_all(branch.as_bytes())
.expect("unable to write branch to last_downloaded_version file"); | random_line_split |
main.rs | extern crate dialoguer;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate quote;
use dialoguer::Input;
use std::path::PathBuf;
use std::{
fs::{self, File},
io::Write,
path::Path,
};
mod api_generator;
mod error;
mod rest_spec;
fn main() | .interact()
.unwrap()
.to_lowercase();
download_specs = answer == "y";
}
if download_specs {
branch = Input::new()
.default(default_branch.clone())
.show_default(false)
.with_prompt(
format!(
"... | {
// This must be run from the src root directory, with cargo run -p api_generator
let download_dir = fs::canonicalize(PathBuf::from("./api_generator/rest_specs")).unwrap();
let generated_dir = fs::canonicalize(PathBuf::from("./elasticsearch/src/generated")).unwrap();
let last_downloaded_version = "./ap... | identifier_body |
main.rs | extern crate dialoguer;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate quote;
use dialoguer::Input;
use std::path::PathBuf;
use std::{
fs::{self, File},
io::Write,
path::Path,
};
mod api_generator;
mod error;
mod rest_spec;
fn | () {
// This must be run from the src root directory, with cargo run -p api_generator
let download_dir = fs::canonicalize(PathBuf::from("./api_generator/rest_specs")).unwrap();
let generated_dir = fs::canonicalize(PathBuf::from("./elasticsearch/src/generated")).unwrap();
let last_downloaded_version = ".... | main | identifier_name |
benches.rs | #![feature(test)]
extern crate blake2b;
extern crate blake2_rfc;
extern crate test;
use test::{Bencher, black_box};
const DATA: &'static [u8] = include_bytes!("data");
#[bench]
fn blake2b_32kib(bencher: &mut Bencher) {
bencher.bytes = DATA.len() as u64;
bencher.iter(|| black_box(blake2b::blake2b(64, DATA)));
}
#... | (bencher: &mut Bencher) {
bencher.bytes = 128;
bencher.iter(|| black_box(blake2b::unbuffered::Blake2b::default().finish(&[0x5555555555555555; 16], 128)));
}
#[bench]
fn blake2_single_block_raw(bencher: &mut Bencher) {
bencher.bytes = 128;
bencher.iter(|| black_box(blake2b::compress(&[0x5555555555555555; 16], &mut ... | blake2_single_block_unbuffered | identifier_name |
benches.rs | #![feature(test)]
extern crate blake2b;
extern crate blake2_rfc;
extern crate test;
| use test::{Bencher, black_box};
const DATA: &'static [u8] = include_bytes!("data");
#[bench]
fn blake2b_32kib(bencher: &mut Bencher) {
bencher.bytes = DATA.len() as u64;
bencher.iter(|| black_box(blake2b::blake2b(64, DATA)));
}
#[bench]
fn blake2_rfc_32kib(bencher: &mut Bencher) {
bencher.bytes = DATA.len() as u6... | random_line_split | |
benches.rs | #![feature(test)]
extern crate blake2b;
extern crate blake2_rfc;
extern crate test;
use test::{Bencher, black_box};
const DATA: &'static [u8] = include_bytes!("data");
#[bench]
fn blake2b_32kib(bencher: &mut Bencher) {
bencher.bytes = DATA.len() as u64;
bencher.iter(|| black_box(blake2b::blake2b(64, DATA)));
}
#... |
#[bench]
fn blake2_single_block_raw(bencher: &mut Bencher) {
bencher.bytes = 128;
bencher.iter(|| black_box(blake2b::compress(&[0x5555555555555555; 16], &mut blake2b::ParameterBlock::new().set_digest_len(64).set_fanout(1).set_max_depth(1).xor_with_iv().0, (128, 0), (!0, 0))));
}
| {
bencher.bytes = 128;
bencher.iter(|| black_box(blake2b::unbuffered::Blake2b::default().finish(&[0x5555555555555555; 16], 128)));
} | identifier_body |
bitvec.rs | //! Defines basic operations defined under FixedSizeBitVectors theory in SMTLIB2.
use std::fmt;
use crate::backends::backend::SMTNode;
#[macro_export]
macro_rules! bv_const {
($solver: ident, $i: expr, $n: expr) => { $solver.new_const(bitvec::OpCodes::Const($i, $n)) }
}
#[derive(Clone, Debug)]
pub enum OpCodes... | BvNeg,
BvAdd,
BvMul,
BvUDiv,
BvURem,
BvShl,
BvLShr,
BvULt,
BvNand,
BvNor,
BvXor,
BvXnor,
BvComp,
BvSub,
BvSDiv,
BvSRem,
BvSMod,
BvAShr,
// parameterized functions
Repeat(u64),
ZeroExtend(u64),
SignExtend(u64),
RotateLeft(u64),
... | Concat,
Extract(u64, u64),
BvNot,
BvAnd,
BvOr, | random_line_split |
bitvec.rs | //! Defines basic operations defined under FixedSizeBitVectors theory in SMTLIB2.
use std::fmt;
use crate::backends::backend::SMTNode;
#[macro_export]
macro_rules! bv_const {
($solver: ident, $i: expr, $n: expr) => { $solver.new_const(bitvec::OpCodes::Const($i, $n)) }
}
#[derive(Clone, Debug)]
pub enum OpCodes... | {
BitVector(usize),
}
impl fmt::Display for Sorts {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let s = match *self {
Sorts::BitVector(ref n) => format!("(_ BitVec {})", n),
};
write!(f, "{}", s)
}
}
| Sorts | identifier_name |
inner.rs | use crate::types::*;
use ndarray::*;
/// Inner Product
///
/// Differenct from `Dot` trait, this take complex conjugate of `self` elements
///
pub trait InnerProduct {
type Elem: Scalar;
/// Inner product `(self.conjugate, rhs)
fn inner<S>(&self, rhs: &ArrayBase<S, Ix1>) -> Self::Elem
where
S:... | <St: Data<Elem = A>>(&self, rhs: &ArrayBase<St, Ix1>) -> A {
assert_eq!(self.len(), rhs.len());
Zip::from(self)
.and(rhs)
.fold_while(A::zero(), |acc, s, r| {
FoldWhile::Continue(acc + s.conj() * *r)
})
.into_inner()
}
}
| inner | identifier_name |
inner.rs | use crate::types::*;
use ndarray::*;
/// Inner Product
///
/// Differenct from `Dot` trait, this take complex conjugate of `self` elements
///
pub trait InnerProduct {
type Elem: Scalar;
/// Inner product `(self.conjugate, rhs)
fn inner<S>(&self, rhs: &ArrayBase<S, Ix1>) -> Self::Elem
where
S:... |
}
| {
assert_eq!(self.len(), rhs.len());
Zip::from(self)
.and(rhs)
.fold_while(A::zero(), |acc, s, r| {
FoldWhile::Continue(acc + s.conj() * *r)
})
.into_inner()
} | identifier_body |
inner.rs | use crate::types::*;
use ndarray::*;
/// Inner Product
///
/// Differenct from `Dot` trait, this take complex conjugate of `self` elements
///
pub trait InnerProduct {
type Elem: Scalar;
/// Inner product `(self.conjugate, rhs)
fn inner<S>(&self, rhs: &ArrayBase<S, Ix1>) -> Self::Elem
where
S:... | S: Data<Elem = A>,
{
type Elem = A;
fn inner<St: Data<Elem = A>>(&self, rhs: &ArrayBase<St, Ix1>) -> A {
assert_eq!(self.len(), rhs.len());
Zip::from(self)
.and(rhs)
.fold_while(A::zero(), |acc, s, r| {
FoldWhile::Continue(acc + s.conj() * *r)
... | impl<A, S> InnerProduct for ArrayBase<S, Ix1>
where
A: Scalar, | random_line_split |
mod.rs | //! A module for grouping things that handle serial data
pub mod command;
pub use self::command::*;
use std::io::Write;
use csv::Writer;
use setup;
use protocol::Message;
use config::DataRecordingConfig;
/// A struct to handle serial data
pub struct SerialHandler {
data_records: Writer<Box<Write>>,
}
impl Serial... | (config: &DataRecordingConfig) -> Self {
SerialHandler { data_records: setup::data_recording(config) }
}
pub fn handle(&mut self, message: Message) {
match message {
Message::Command(command) => command::CommandHandler::handle(command),
Message::Data(data) => {
... | new | identifier_name |
mod.rs | //! A module for grouping things that handle serial data
pub mod command;
pub use self::command::*;
use std::io::Write;
use csv::Writer;
use setup;
use protocol::Message;
use config::DataRecordingConfig;
/// A struct to handle serial data
pub struct SerialHandler {
data_records: Writer<Box<Write>>,
}
impl Serial... |
}
| {
match message {
Message::Command(command) => command::CommandHandler::handle(command),
Message::Data(data) => {
if let Err(error) = self.data_records.serialize(data) {
error!(
"Error serializing data to write to records: \"{:?... | identifier_body |
mod.rs | //! A module for grouping things that handle serial data
pub mod command;
pub use self::command::*;
use std::io::Write;
use csv::Writer;
use setup;
use protocol::Message;
use config::DataRecordingConfig;
/// A struct to handle serial data
pub struct SerialHandler {
data_records: Writer<Box<Write>>,
}
impl Serial... |
}
}
}
| {
if let Err(error) = self.data_records.serialize(data) {
error!(
"Error serializing data to write to records: \"{:?}\"",
error
);
} else if let Err(error) = self.data_records.flush() {
... | conditional_block |
mod.rs | //! A module for grouping things that handle serial data
pub mod command;
pub use self::command::*;
| use setup;
use protocol::Message;
use config::DataRecordingConfig;
/// A struct to handle serial data
pub struct SerialHandler {
data_records: Writer<Box<Write>>,
}
impl SerialHandler {
pub fn new(config: &DataRecordingConfig) -> Self {
SerialHandler { data_records: setup::data_recording(config) }
... | use std::io::Write;
use csv::Writer; | random_line_split |
application_window.rs | // This file was generated by gir (b7f5189) from gir-files (71d73f0)
// DO NOT EDIT
use Application;
use Bin;
use Container;
#[cfg(feature = "v3_20")]
use ShortcutsWindow;
use Widget;
use Window;
use ffi;
use gio;
use gio_ffi;
use glib::object::Downcast;
use glib::translate::*;
glib_wrapper! {
pub struct Applicat... |
}
| {
unsafe {
ffi::gtk_application_window_set_show_menubar(self.to_glib_none().0, show_menubar.to_glib());
}
} | identifier_body |
application_window.rs | // This file was generated by gir (b7f5189) from gir-files (71d73f0)
// DO NOT EDIT
use Application;
use Bin;
use Container;
#[cfg(feature = "v3_20")]
use ShortcutsWindow;
use Widget;
use Window;
use ffi;
use gio;
use gio_ffi;
use glib::object::Downcast;
use glib::translate::*;
glib_wrapper! {
pub struct Applicat... | (&self) -> Option<ShortcutsWindow> {
unsafe {
from_glib_none(ffi::gtk_application_window_get_help_overlay(self.to_glib_none().0))
}
}
#[cfg(feature = "v3_6")]
pub fn get_id(&self) -> u32 {
unsafe {
ffi::gtk_application_window_get_id(self.to_glib_none().0)
... | get_help_overlay | identifier_name |
application_window.rs | // This file was generated by gir (b7f5189) from gir-files (71d73f0)
// DO NOT EDIT
use Application;
use Bin;
use Container;
#[cfg(feature = "v3_20")]
use ShortcutsWindow;
use Widget;
use Window;
use ffi;
use gio;
use gio_ffi;
use glib::object::Downcast;
use glib::translate::*;
glib_wrapper! { | Widget,
gio::ActionGroup => gio_ffi::GActionGroup,
gio::ActionMap => gio_ffi::GActionMap,
];
match fn {
get_type => || ffi::gtk_application_window_get_type(),
}
}
impl ApplicationWindow {
pub fn new(application: &Application) -> ApplicationWindow {
skip_assert_i... | pub struct ApplicationWindow(Object<ffi::GtkApplicationWindow>): [
Window,
Bin,
Container, | 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 ... | <F>(&self, traversal_data: &PerLevelTraversalData,
context: &mut StyleContext<E>, node: E::ConcreteNode,
note_child: F)
where F: FnMut(E::ConcreteNode)
{
// FIXME(pcwalton): Stop allocating here. Ideally this should just be
// done by the... | process_preorder | 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 ... |
flow.assign_block_size(self.layout_context);
}
#[inline]
fn should_process(&self, flow: &mut Flow) -> bool {
let base = flow::base(flow);
base.restyle_damage.intersects(ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW) &&
// The fragmentation countainer ... | {
return
} | 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 ... | #[inline]
fn process(&self, flow: &mut Flow) {
flow.bubble_inline_sizes();
flow::mut_base(flow).restyle_damage.remove(ServoRestyleDamage::BUBBLE_ISIZES);
}
#[inline]
fn should_process(&self, flow: &mut Flow) -> bool {
flow::base(flow).restyle_damage.contains(ServoRestyleDama... |
impl<'a> PostorderFlowTraversal for BubbleISizes<'a> { | random_line_split |
lib.rs | extern crate pcap;
use pcap::{Active, Activated, Offline, Capture};
use std::path::Path;
#[test]
fn read_packet_with_full_data() { | #[test]
fn read_packet_with_truncated_data() {
let mut capture = capture_from_test_file("packet_snaplen_20.pcap");
assert_eq!(capture.next().unwrap().len(), 20);
}
fn capture_from_test_file(file_name: &str) -> Capture<Offline> {
let path = Path::new("tests/data/").join(file_name);
Capture::from_file(pa... | let mut capture = capture_from_test_file("packet_snaplen_65535.pcap");
assert_eq!(capture.next().unwrap().len(), 98);
}
| random_line_split |
lib.rs | extern crate pcap;
use pcap::{Active, Activated, Offline, Capture};
use std::path::Path;
#[test]
fn read_packet_with_full_data() {
let mut capture = capture_from_test_file("packet_snaplen_65535.pcap");
assert_eq!(capture.next().unwrap().len(), 98);
}
#[test]
fn read_packet_with_truncated_data() {
let mut... | (file_name: &str) -> Capture<Offline> {
let path = Path::new("tests/data/").join(file_name);
Capture::from_file(path).unwrap()
}
#[test]
fn unify_activated() {
#![allow(dead_code)]
fn test1() -> Capture<Active> {
loop{}
}
fn test2() -> Capture<Offline> {
loop{}
}
fn maybe(a: bool) -> Capture<Activ... | capture_from_test_file | identifier_name |
lib.rs | extern crate pcap;
use pcap::{Active, Activated, Offline, Capture};
use std::path::Path;
#[test]
fn read_packet_with_full_data() {
let mut capture = capture_from_test_file("packet_snaplen_65535.pcap");
assert_eq!(capture.next().unwrap().len(), 98);
}
#[test]
fn read_packet_with_truncated_data() {
let mut... | else {
test2().into()
}
}
fn also_maybe(a: &mut Capture<Activated>) {
a.filter("whatever filter string, this won't be run anyway").unwrap();
}
} | {
test1().into()
} | conditional_block |
lib.rs | extern crate pcap;
use pcap::{Active, Activated, Offline, Capture};
use std::path::Path;
#[test]
fn read_packet_with_full_data() {
let mut capture = capture_from_test_file("packet_snaplen_65535.pcap");
assert_eq!(capture.next().unwrap().len(), 98);
}
#[test]
fn read_packet_with_truncated_data() {
let mut... |
#[test]
fn unify_activated() {
#![allow(dead_code)]
fn test1() -> Capture<Active> {
loop{}
}
fn test2() -> Capture<Offline> {
loop{}
}
fn maybe(a: bool) -> Capture<Activated> {
if a {
test1().into()
} else {
test2().into()
}
}
fn also_maybe(a: &mut Capture<Activated>) {
a.filter("whateve... | {
let path = Path::new("tests/data/").join(file_name);
Capture::from_file(path).unwrap()
} | identifier_body |
unique-vec-res.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct r {
i: @mu... | // http://rust-lang.org/COPYRIGHT.
// | random_line_split |
unique-vec-res.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 f<T>(_i: ~[T], _j: ~[T]) {
}
fn main() {
let i1 = @mut 0;
let i2 = @mut 1;
let r1 = ~[~r { i: i1 }];
let r2 = ~[~r { i: i2 }];
f(copy r1, copy r2);
//~^ ERROR copying a value of non-copyable type
//~^^ ERROR copying a value of non-copyable type
info!((r2, *i1));
info!((r1, *i... | {
unsafe {
*(self.i) = *(self.i) + 1;
}
} | identifier_body |
unique-vec-res.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (&self) {
unsafe {
*(self.i) = *(self.i) + 1;
}
}
}
fn f<T>(_i: ~[T], _j: ~[T]) {
}
fn main() {
let i1 = @mut 0;
let i2 = @mut 1;
let r1 = ~[~r { i: i1 }];
let r2 = ~[~r { i: i2 }];
f(copy r1, copy r2);
//~^ ERROR copying a value of non-copyable type
//~^^ E... | drop | identifier_name |
number.rs | // Copyright 2013 The Servo 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>, at ... | }
}
/// A convenience function to create CFNumbers.
pub fn number(value: i64) -> CFNumber {
FromPrimitive::from_i64(value).unwrap()
}
#[link(name = "CoreFoundation", kind = "framework")]
extern {
/*
* CFNumber.h
*/
fn CFNumberCreate(allocator: CFAllocatorRef, theType: CFNumberType, valuePt... | kCFNumberFloat64Type,
mem::transmute(&value));
Some(TCFType::wrap_under_create_rule(number_ref))
} | random_line_split |
number.rs | // Copyright 2013 The Servo 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>, at ... | (obj: CFNumberRef) -> CFNumber {
CFNumber {
obj: obj,
}
}
#[inline]
fn type_id(_: Option<CFNumber>) -> CFTypeID {
unsafe {
CFNumberGetTypeID()
}
}
}
// TODO(pcwalton): Floating point.
impl ToPrimitive for CFNumber {
#[inline]
fn to_i64(&s... | wrap_under_create_rule | identifier_name |
number.rs | // Copyright 2013 The Servo 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>, at ... |
}
/// A convenience function to create CFNumbers.
pub fn number(value: i64) -> CFNumber {
FromPrimitive::from_i64(value).unwrap()
}
#[link(name = "CoreFoundation", kind = "framework")]
extern {
/*
* CFNumber.h
*/
fn CFNumberCreate(allocator: CFAllocatorRef, theType: CFNumberType, valuePtr: *c... | {
unsafe {
let number_ref = CFNumberCreate(kCFAllocatorDefault,
kCFNumberFloat64Type,
mem::transmute(&value));
Some(TCFType::wrap_under_create_rule(number_ref))
}
} | identifier_body |
windows.rs | use winapi::um::processenv::GetStdHandle;
use winapi::um::winbase::STD_OUTPUT_HANDLE;
use winapi::um::wincon::GetConsoleScreenBufferInfo;
use winapi::um::wincon::{CONSOLE_SCREEN_BUFFER_INFO, COORD, SMALL_RECT};
/// Query the current processes's output, returning its width and height as a
/// number of characters.
///... |
}
/// Query the current processes's output, returning its width and height as a
/// number of characters. Returns `None` if the output isn't to a terminal.
///
/// # Errors
///
/// Returns `None` if the output isn't to a terminal.
///
/// # Example
///
/// To get the dimensions of your terminal window, simply use ... | {
None
} | conditional_block |
windows.rs | use winapi::um::processenv::GetStdHandle;
use winapi::um::winbase::STD_OUTPUT_HANDLE;
use winapi::um::wincon::GetConsoleScreenBufferInfo;
use winapi::um::wincon::{CONSOLE_SCREEN_BUFFER_INFO, COORD, SMALL_RECT};
/// Query the current processes's output, returning its width and height as a
/// number of characters.
///... | srWindow: null_smallrect,
dwMaximumWindowSize: null_coord,
};
if unsafe { GetConsoleScreenBufferInfo(stdout_h, &mut console_data) }!= 0 {
Some(((console_data.srWindow.Right - console_data.srWindow.Left) as usize,
(console_data.srWindow.Bottom - console_data.srWindow.Top)... | dwCursorPosition: null_coord,
wAttributes: 0, | random_line_split |
windows.rs | use winapi::um::processenv::GetStdHandle;
use winapi::um::winbase::STD_OUTPUT_HANDLE;
use winapi::um::wincon::GetConsoleScreenBufferInfo;
use winapi::um::wincon::{CONSOLE_SCREEN_BUFFER_INFO, COORD, SMALL_RECT};
/// Query the current processes's output, returning its width and height as a
/// number of characters.
///... | () -> Option<(usize, usize)> { dimensions() }
/// This isn't implemented for Windows
///
/// # Panics
///
/// This function `panic!`s unconditionally with the `unimplemented!`
/// macro
pub fn dimensions_stdin() -> Option<(usize, usize)> { unimplemented!() }
/// This isn't implemented for Windows
///
/// # Panics
... | dimensions_stdout | identifier_name |
windows.rs | use winapi::um::processenv::GetStdHandle;
use winapi::um::winbase::STD_OUTPUT_HANDLE;
use winapi::um::wincon::GetConsoleScreenBufferInfo;
use winapi::um::wincon::{CONSOLE_SCREEN_BUFFER_INFO, COORD, SMALL_RECT};
/// Query the current processes's output, returning its width and height as a
/// number of characters.
///... | { unimplemented!() } | identifier_body | |
local_sched.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let scheduler = ~UvEventLoop::new_scheduler();
put(scheduler);
let _scheduler = take();
let scheduler = ~UvEventLoop::new_scheduler();
put(scheduler);
let _scheduler = take();
}
#[test]
fn borrow_smoke_test() {
let scheduler = ~UvEventLoop::new_scheduler();
put(scheduler);
unsa... | thread_local_scheduler_two_instances | identifier_name |
local_sched.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
/// Borrow a mutable reference to the thread-local Scheduler
///
/// # Safety Note
///
/// Because this leaves the Scheduler in thread-local storage it is possible
/// For the Scheduler pointer to be aliased
pub unsafe fn unsafe_borrow() -> &mut Scheduler {
let key = tls_key();
let mut void_sched: *mut c_void... | {
let mut sched = take();
f(sched);
put(sched);
} | identifier_body |
local_sched.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | }
}
/// Take ownership of the Scheduler from thread-local storage
pub fn take() -> ~Scheduler {
unsafe {
let key = tls_key();
let void_sched: *mut c_void = tls::get(key);
assert!(void_sched.is_not_null());
let sched = transmute::<*mut c_void, ~Scheduler>(void_sched);
tls... | let key = tls_key();
let void_sched: *mut c_void = transmute::<~Scheduler, *mut c_void>(sched);
tls::set(key, void_sched); | random_line_split |
local_sched.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
}
extern {
fn rust_get_sched_tls_key() -> *mut c_void;
}
#[test]
fn thread_local_scheduler_smoke_test() {
let scheduler = ~UvEventLoop::new_scheduler();
put(scheduler);
let _scheduler = take();
}
#[test]
fn thread_local_scheduler_two_instances() {
let scheduler = ~UvEventLoop::new_schedule... | {
return None;
} | conditional_block |
remote_info.rs | use helpers;
use regex::Regex;
use slog::Logger;
use std::io;
use std::process::Command;
pub struct RemoteInfo {
pub is_remote: bool,
pub path: String,
pub user: String,
pub host: String,
pub port: String,
}
impl RemoteInfo {
pub fn build(remote_dir: &str, port: Option<&str>) -> Self {
... |
pub fn full_path(&self) -> String {
if self.is_remote {
format!("{}@{}:{}", self.user, self.host, self.path)
} else {
self.path.clone()
}
}
pub fn full_path_trailing_slash(&self) -> String {
format!("{}/", self.full_path())
}
pub fn check_cm... | random_line_split | |
remote_info.rs | use helpers;
use regex::Regex;
use slog::Logger;
use std::io;
use std::process::Command;
pub struct RemoteInfo {
pub is_remote: bool,
pub path: String,
pub user: String,
pub host: String,
pub port: String,
}
impl RemoteInfo {
pub fn build(remote_dir: &str, port: Option<&str>) -> Self {
... |
}
}
pub fn get_cmd_output(&self, cmd: &str) -> Result<String, io::Error> {
let output = self.generate_command(&mut self.base_command(cmd), cmd)
.output()?;
Ok(String::from_utf8_lossy(&output.stdout).trim().to_owned())
}
pub fn run_cmd(&self, cmd: &str) -> bool {
... | {
helpers::log_error_and_exit(log, &format!("Failed to run '{}' on remote: {}", cmd, e));
panic!(); // For compilation
} | conditional_block |
remote_info.rs | use helpers;
use regex::Regex;
use slog::Logger;
use std::io;
use std::process::Command;
pub struct RemoteInfo {
pub is_remote: bool,
pub path: String,
pub user: String,
pub host: String,
pub port: String,
}
impl RemoteInfo {
pub fn build(remote_dir: &str, port: Option<&str>) -> Self {
... | <'a>(&self, command: &'a mut Command, cmd: &str) -> &'a mut Command {
if self.is_remote {
command
.arg("-q")
.arg(format!("{}@{}", self.user, self.host))
.arg("-p")
.arg(&self.port)
.arg("-C")
.arg(cmd)
... | generate_command | identifier_name |
loader.rs | self.find_library_crate()
}
pub fn load_library_crate(&mut self) -> Library {
match self.find_library_crate() {
Some(t) => t,
None => {
self.report_load_errs();
unreachable!()
}
}
}
pub fn report_load_errs(&mut... | let start = time::precise_time_ns();
let ret = get_metadata_section_imp(os, filename);
info!("reading {} => {}ms", filename.filename_display(),
(time::precise_time_ns() - start) / 1000000);
return ret;
}
fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, StrBuf> {
... | // Just a small wrapper to time how long reading metadata takes.
fn get_metadata_section(os: Os, filename: &Path) -> Result<MetadataBlob, StrBuf> { | random_line_split |
loader.rs | self.find_library_crate()
}
pub fn load_library_crate(&mut self) -> Library {
match self.find_library_crate() {
Some(t) => t,
None => {
self.report_load_errs();
unreachable!()
}
}
}
pub fn report_load_errs(&mut s... |
impl ArchiveMetadata {
fn new(ar: ArchiveRO) -> Option<ArchiveMetadata> {
let data: &'static [u8] = {
let data = match ar.read(METADATA_FILENAME) {
Some(data) => data,
None => {
debug!("didn't find '{}' in the archive", METADATA_FILENAME);
... | {
diag.handler().note(format!("crate_id: {}", crateid.to_str()));
} | identifier_body |
loader.rs | self.find_library_crate()
}
pub fn load_library_crate(&mut self) -> Library {
match self.find_library_crate() {
Some(t) => t,
None => {
self.report_load_errs();
unreachable!()
}
}
}
pub fn report_load_errs(&mut s... | else {
FileDoesntMatch
}
});
// We have now collected all known libraries into a set of candidates
// keyed of the filename hash listed. For each filename, we also have a
// list of rlibs/dylibs that apply. Here, we map each of these lists
// (per ha... | {
info!("dylib candidate: {}", path.display());
match self.try_match(file, dylib_prefix, dysuffix) {
Some(hash) => {
info!("dylib accepted, hash: {}", hash);
let slot = candidates.find_or_insert_with(hash, |_| {
... | conditional_block |
loader.rs | }
None => {
info!("rlib rejected");
FileDoesntMatch
}
}
} else if file.starts_with(dylib_prefix) && file.ends_with(dysuffix){
info!("dylib candidate: {}", path.display());
... | meta_section_name | identifier_name | |
conf.rs | // Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//! Schema for configuration files, exact encoding json/xml to be worked out.
use crate::io::gpio::{PinMode, PullMode};
use serde::Deserialize;
/// Configuration of a... | {
/// Optional specification of transport backend, for which this
/// configuration applies (to be implemented).
pub interface: Option<String>,
/// List of names of other configuration files to include recursively.
#[serde(default)]
pub includes: Vec<String>,
/// List of GPIO pin configurat... | ConfigurationFile | identifier_name |
conf.rs | // Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//! Schema for configuration files, exact encoding json/xml to be worked out.
use crate::io::gpio::{PinMode, PullMode};
use serde::Deserialize;
/// Configuration of a... | pub struct StrappingConfiguration {
/// The user-visible name of the strapping combination.
pub name: String,
/// List of GPIO pin configurations (the alias_of) field should not be used in these.
#[serde(default)]
pub pins: Vec<PinConfiguration>,
}
/// Parity configuration for UART communication.
#... |
/// Configuration of a particular GPIO pin.
#[derive(Deserialize, Clone, Debug)] | random_line_split |
util.rs | use std::fs::File;
use std::io::{self, Read};
use std::path::Path;
use std::process::{Command, Stdio};
pub trait SplitEOL {
fn split_eol(&self) -> Vec<String>;
}
impl SplitEOL for String {
fn split_eol(&self) -> Vec<String> {
if self.trim() == "" {
Vec::new()
} else {
self.split("\n").map(ToOw... | .stdout(Stdio::piped())
.stderr(Stdio::piped())
.output()?;
let stdout = String::from_utf8_lossy(&output.stdout).into_owned();
let stderr = String::from_utf8_lossy(&output.stdout).into_owned();
let status = output.status
.code()
.ok_or(io::Error::new(io::ErrorKind::Other,
... | let output = Command::new(name).args(args)
.stdin(Stdio::null()) | random_line_split |
util.rs | use std::fs::File;
use std::io::{self, Read};
use std::path::Path;
use std::process::{Command, Stdio};
pub trait SplitEOL {
fn split_eol(&self) -> Vec<String>;
}
impl SplitEOL for String {
fn split_eol(&self) -> Vec<String> {
if self.trim() == "" {
Vec::new()
} else {
self.split("\n").map(ToOw... | (name: &str, args: &[&str]) -> Result<(String, String, i32), io::Error> {
use std::process::*;
let output = Command::new(name).args(args)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.output()?;
let stdout = String::from_utf8_lossy(&output.stdout).into_owned();
let stderr =... | communicate | identifier_name |
util.rs | use std::fs::File;
use std::io::{self, Read};
use std::path::Path;
use std::process::{Command, Stdio};
pub trait SplitEOL {
fn split_eol(&self) -> Vec<String>;
}
impl SplitEOL for String {
fn split_eol(&self) -> Vec<String> {
if self.trim() == "" {
Vec::new()
} else {
self.split("\n").map(ToOw... |
pub fn get_lines(name: &str, args: &[&str]) -> Result<Vec<String>, io::Error> {
communicate(name, args).map(|(stdout, _, _)| stdout.split_eol())
}
pub fn read_content<P: AsRef<Path>>(path: P) -> io::Result<String> {
let mut buf = String::new();
File::open(path)
.and_then(|mut f| f.read_to_string(&mut buf))
... | {
use std::process::*;
let output = Command::new(name).args(args)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.output()?;
let stdout = String::from_utf8_lossy(&output.stdout).into_owned();
let stderr = String::from_utf8_lossy(&output.stdout).into_owned();
let status ... | identifier_body |
util.rs | use std::fs::File;
use std::io::{self, Read};
use std::path::Path;
use std::process::{Command, Stdio};
pub trait SplitEOL {
fn split_eol(&self) -> Vec<String>;
}
impl SplitEOL for String {
fn split_eol(&self) -> Vec<String> {
if self.trim() == "" | else {
self.split("\n").map(ToOwned::to_owned).collect()
}
}
}
pub fn communicate(name: &str, args: &[&str]) -> Result<(String, String, i32), io::Error> {
use std::process::*;
let output = Command::new(name).args(args)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
... | {
Vec::new()
} | conditional_block |
packed-struct-with-destructor.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... | {
x: i64,
y: i32,
z: i16
}
impl Drop for Unpacked {
fn drop(&mut self) {}
}
#[packed]
struct UnpackedInPacked {
a: i16,
b: Unpacked,
c: Unpacked,
d: i64
}
#[packed]
struct PackedInPackedWithDrop {
a: i32,
b: Packed,
c: i64,
d: Packed
}
impl Drop for PackedInPackedWit... | Unpacked | identifier_name |
packed-struct-with-destructor.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 |
// ignore-tidy-linelength
// ignore-android: FIXME(#10381)
// compile-flags:-g
// debugger:set print pretty off
// debugger:rbreak zzz
// debugger:run
// debugger:finish
// debugger:print packed
// check:$1 = {x = 123, y = 234, z = 345}
// debugger:print packedInPacked
// check:$2 = {a = 1111, b = {x = 2222, y = 33... | // <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. | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.