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 |
|---|---|---|---|---|
glyph.rs | u8 = 0x0;
static BREAK_TYPE_NORMAL: u8 = 0x1;
static BREAK_TYPE_HYPHEN: u8 = 0x2;
fn break_flag_to_enum(flag: u8) -> BreakType {
if (flag & BREAK_TYPE_NORMAL)!= 0 {
BreakType::Normal
} else if (flag & BREAK_TYPE_HYPHEN)!= 0 {
BreakType::Hyphen
} else {
BreakType::None
}
}
fn ... |
#[inline(always)]
fn adapt_character_flags_of_entry(&self, other: GlyphEntry) -> GlyphEntry {
GlyphEntry { value: self.value | other.value }
}
}
// Stores data for a detailed glyph, in the case that several glyphs
// correspond to one character, or the glyph's data couldn't be packed.
#[derive(Cl... | {
(self.value & flag) != 0
} | identifier_body |
glyph.rs | u8 = 0x0;
static BREAK_TYPE_NORMAL: u8 = 0x1;
static BREAK_TYPE_HYPHEN: u8 = 0x2;
fn break_flag_to_enum(flag: u8) -> BreakType {
if (flag & BREAK_TYPE_NORMAL)!= 0 {
BreakType::Normal
} else if (flag & BREAK_TYPE_HYPHEN)!= 0 {
BreakType::Hyphen
} else {
BreakType::None
}
}
fn... | // Rather than eagerly assembling and copying glyph data, it only retrieves
// values as they are needed from the GlyphStore, using provided offsets.
#[derive(Copy)]
pub enum GlyphInfo<'a> {
Simple(&'a GlyphStore, CharIndex),
Detail(&'a GlyphStore, CharIndex, u16),
}
impl<'a> GlyphInfo<'a> {
pub fn id(self... | }
}
// This enum is a proxy that's provided to GlyphStore clients when iterating
// through glyphs (either for a particular TextRun offset, or all glyphs). | random_line_split |
htmlfontelement.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::attr::{Attr, AttrHelpers};
use dom::bindings::codegen::Bindings::HTMLFontElementBinding;
use dom::binding... | {
htmlelement: HTMLElement,
color: Cell<Option<RGBA>>,
}
impl HTMLFontElementDerived for EventTarget {
fn is_htmlfontelement(&self) -> bool {
*self.type_id() ==
EventTargetTypeId::Node(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFontElement)))... | HTMLFontElement | identifier_name |
htmlfontelement.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::attr::{Attr, AttrHelpers};
use dom::bindings::codegen::Bindings::HTMLFontElementBinding;
use dom::binding... | self.color.set(str::parse_legacy_color(&attr.value()).ok())
}
_ => {}
}
}
fn before_remove_attr(&self, attr: JSRef<Attr>) {
if let Some(ref s) = self.super_type() {
s.before_remove_attr(attr);
}
match attr.local_name() {
... | match attr.local_name() {
&atom!("color") => { | random_line_split |
htmlfontelement.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::attr::{Attr, AttrHelpers};
use dom::bindings::codegen::Bindings::HTMLFontElementBinding;
use dom::binding... |
}
impl HTMLFontElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLFontElement {
HTMLFontElement {
htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLFontElement, localName, prefix, document),
color: Cell::new(No... | {
*self.type_id() ==
EventTargetTypeId::Node(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFontElement)))
} | identifier_body |
lexical-scope-in-for-loop.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 ... | () {()}
| sentinel | identifier_name |
lexical-scope-in-for-loop.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 ... |
// AFTER LOOP
// debugger:finish
// debugger:print x
// check:$7 = 1000000
// debugger:continue
fn main() {
let range = [1, 2, 3];
let x = 1000000; // wan meeeljen doollaars!
for &x in range.iter() {
zzz();
sentinel();
let x = -1 * x;
zzz();
sentinel();
}
... | // debugger:finish
// debugger:print x
// check:$6 = -3
// debugger:continue | random_line_split |
lexical-scope-in-for-loop.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 ... |
fn sentinel() {()}
| {()} | identifier_body |
bench.rs | extern crate env_logger;
extern crate time;
extern crate url;
/// A simple, but immature, benchmark client for destroying other WebSocket frameworks and proving
/// WS-RS's performance excellence. ;)
/// Make sure you allow for enough connections in your OS (e.g. ulimit -Sn 10000).
extern crate ws;
// Try this against... |
Ok(())
}
}
let mut ws = Builder::new()
.with_settings(Settings {
max_connections: CONNECTIONS,
..Settings::default()
})
.build(|out| Connection {
out,
count: 0,
time: 0,
total: 0,
})
... | {
self.out.send(MESSAGE)?;
let time = time::precise_time_ns();
// println!("time {}", time -self.time);
self.total += time - self.time;
self.count += 1;
self.time = time;
} | conditional_block |
bench.rs | extern crate env_logger;
extern crate time;
extern crate url;
/// A simple, but immature, benchmark client for destroying other WebSocket frameworks and proving
/// WS-RS's performance excellence. ;)
/// Make sure you allow for enough connections in your OS (e.g. ulimit -Sn 10000).
extern crate ws;
// Try this against... |
fn on_message(&mut self, msg: Message) -> Result<()> {
assert_eq!(msg.as_text().unwrap(), MESSAGE);
if self.count > MESSAGES {
self.out.close(CloseCode::Normal)?;
} else {
self.out.send(MESSAGE)?;
let time = time::precise_time... | {
self.out.send(MESSAGE)?;
self.count += 1;
self.time = time::precise_time_ns();
Ok(())
} | identifier_body |
bench.rs | extern crate env_logger;
extern crate time;
extern crate url;
/// A simple, but immature, benchmark client for destroying other WebSocket frameworks and proving
/// WS-RS's performance excellence. ;)
/// Make sure you allow for enough connections in your OS (e.g. ulimit -Sn 10000).
extern crate ws;
// Try this against... |
impl Handler for Connection {
fn on_open(&mut self, _: Handshake) -> Result<()> {
self.out.send(MESSAGE)?;
self.count += 1;
self.time = time::precise_time_ns();
Ok(())
}
fn on_message(&mut self, msg: Message) -> Result<()> {
asser... | random_line_split | |
bench.rs | extern crate env_logger;
extern crate time;
extern crate url;
/// A simple, but immature, benchmark client for destroying other WebSocket frameworks and proving
/// WS-RS's performance excellence. ;)
/// Make sure you allow for enough connections in your OS (e.g. ulimit -Sn 10000).
extern crate ws;
// Try this against... | () {
env_logger::init();
let url = url::Url::parse("ws://127.0.0.1:3012").unwrap();
struct Connection {
out: Sender,
count: u32,
time: u64,
total: u64,
}
impl Handler for Connection {
fn on_open(&mut self, _: Handshake) -> Result<()> {
self.out.... | main | identifier_name |
issue-18400.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() {
let bits: &[_] = &[0, 1];
0.contains(bits);
//~^ ERROR the trait `Set<_>` is not implemented for the type `_`
}
| {
for &bit in bits.iter() {
self.set(bit)
}
} | identifier_body |
issue-18400.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let bits: &[_] = &[0, 1];
0.contains(bits);
//~^ ERROR the trait `Set<_>` is not implemented for the type `_`
}
| main | identifier_name |
issue-18400.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() {
let bits: &[_] = &[0, 1];
0.contains(bits);
//~^ ERROR the trait `Set<_>` is not implemented for the type `_`
} | } | random_line_split |
error.rs | use alloc::boxed::Box;
use collections::string::String;
use core::fmt::{self, Debug, Display};
use core::marker::{Send, Sync, Reflect};
/// Base functionality for all errors in Rust.
//#[stable(feature = "rust1", since = "1.0.0")]
pub trait Error: Debug + Display + Reflect {
/// A short description of the error.
... | (err: E) -> Box<Error + Send + Sync + 'a> {
Box::new(err)
}
}
//#[stable(feature = "rust1", since = "1.0.0")]
impl From<String> for Box<Error + Send + Sync> {
fn from(err: String) -> Box<Error + Send + Sync> {
#[derive(Debug)]
struct StringError(String);
impl Error for StringEr... | from | identifier_name |
error.rs | use alloc::boxed::Box;
use collections::string::String;
use core::fmt::{self, Debug, Display};
use core::marker::{Send, Sync, Reflect};
/// Base functionality for all errors in Rust.
//#[stable(feature = "rust1", since = "1.0.0")]
pub trait Error: Debug + Display + Reflect {
/// A short description of the error.
... |
}
//#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<Error + Send + Sync + 'a> {
fn from(err: E) -> Box<Error + Send + Sync + 'a> {
Box::new(err)
}
}
//#[stable(feature = "rust1", since = "1.0.0")]
impl From<String> for Box<Error + Send + Sync> {
... | {
Box::new(err)
} | identifier_body |
error.rs | use alloc::boxed::Box;
use collections::string::String;
use core::fmt::{self, Debug, Display};
use core::marker::{Send, Sync, Reflect};
/// Base functionality for all errors in Rust.
//#[stable(feature = "rust1", since = "1.0.0")]
pub trait Error: Debug + Display + Reflect {
/// A short description of the error.
... |
//#[stable(feature = "rust1", since = "1.0.0")]
impl From<String> for Box<Error + Send + Sync> {
fn from(err: String) -> Box<Error + Send + Sync> {
#[derive(Debug)]
struct StringError(String);
impl Error for StringError {
fn description(&self) -> &str { &self.0 }
}
... | fn from(err: E) -> Box<Error + Send + Sync + 'a> {
Box::new(err)
}
} | random_line_split |
lib.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 ... | sig: ty::Binder(ty::FnSig {
inputs: vec!(
tcx.types.isize,
tcx.mk_imm_ptr(tcx.mk_imm_ptr(tcx.types.u8))
),
output: ty::FnConverging(tcx.types.isize),
variadic: false,
... |
let se_ty = tcx.mk_fn(Some(local_def(start_id)), tcx.mk_bare_fn(ty::BareFnTy {
unsafety: ast::Unsafety::Normal,
abi: abi::Rust, | random_line_split |
lib.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 require_c_abi_if_variadic(tcx: &ty::ctxt,
decl: &ast::FnDecl,
abi: abi::Abi,
span: Span) {
if decl.variadic && abi!= abi::C {
span_err!(tcx.sess, span, E0045,
"variadic function must have C calling ... | {
match tcx.def_map.borrow().get(&id) {
Some(x) => x.full_def(),
None => {
span_fatal!(tcx.sess, sp, E0242, "internal error looking up a definition")
}
}
} | identifier_body |
lib.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 ... | (ccx: &CrateCtxt,
start_id: ast::NodeId,
start_span: Span) {
let tcx = ccx.tcx;
let start_t = tcx.node_id_to_type(start_id);
match start_t.sty {
ty::TyBareFn(..) => {
match tcx.map.find(start_id) {
Some(ast_map::NodeItem(it)) => {... | check_start_fn_ty | identifier_name |
engine.rs | use std::str::FromStr;
use crate::parsers::lang::{Lang, LangType};
use crate::parsers::planner;
use crate::parsers::sql::Sql;
use crate::parsers::value::PqlValue;
pub fn evaluate(sql: &str, input: &str, from: &str, to: &str) -> anyhow::Result<String> {
let from_lang_type = LangType::from_str(&from)?;
let to_l... |
pub fn query_evaluate(data: PqlValue, sql: &str) -> anyhow::Result<PqlValue> {
let sql = Sql::from_str(&sql)?;
let data = PqlValue::from(data);
let value = planner::evaluate(sql, data);
Ok(value)
}
| {
let to_lang_type = LangType::from_str(&to)?;
let mut lang = Lang::default();
lang.data = data;
lang.to = to_lang_type;
let output = lang.to_string(true)?;
Ok(output)
} | identifier_body |
engine.rs | use std::str::FromStr;
use crate::parsers::lang::{Lang, LangType};
use crate::parsers::planner;
use crate::parsers::sql::Sql;
use crate::parsers::value::PqlValue;
pub fn evaluate(sql: &str, input: &str, from: &str, to: &str) -> anyhow::Result<String> {
let from_lang_type = LangType::from_str(&from)?;
let to_l... | lang.data = result;
let output = lang.to_string(true)?;
Ok(output)
}
pub fn loads(input: &str, from: &str) -> anyhow::Result<PqlValue> {
let from_lang_type = LangType::from_str(&from)?;
let lang = Lang::from_as(&input, from_lang_type)?;
let value = lang.data;
Ok(value)
}
pub fn dumps(data... | let sql = Sql::from_str(&sql)?;
let result = planner::evaluate(sql, lang.data);
lang.to = to_lang_type; | random_line_split |
engine.rs | use std::str::FromStr;
use crate::parsers::lang::{Lang, LangType};
use crate::parsers::planner;
use crate::parsers::sql::Sql;
use crate::parsers::value::PqlValue;
pub fn evaluate(sql: &str, input: &str, from: &str, to: &str) -> anyhow::Result<String> {
let from_lang_type = LangType::from_str(&from)?;
let to_l... | (data: PqlValue, to: &str) -> anyhow::Result<String> {
let to_lang_type = LangType::from_str(&to)?;
let mut lang = Lang::default();
lang.data = data;
lang.to = to_lang_type;
let output = lang.to_string(true)?;
Ok(output)
}
pub fn query_evaluate(data: PqlValue, sql: &str) -> anyhow::Result<PqlVa... | dumps | identifier_name |
delete-version.rs | // Purge all references to a crate's version from the database.
//
// Please be super sure you want to do this before running this.
//
// Usage:
// cargo run --bin delete-version crate-name version-number
#![deny(warnings)]
extern crate cargo_registry;
extern crate postgres;
extern crate time;
extern crate semve... |
fn main() {
let conn = postgres::Connection::connect(&env("DATABASE_URL")[..],
&postgres::SslMode::None).unwrap();
{
let tx = conn.transaction().unwrap();
delete(&tx);
tx.set_commit();
tx.finish().unwrap();
}
}
fn env(s: &str) ->... |
use cargo_registry::{Crate, Version}; | random_line_split |
delete-version.rs | // Purge all references to a crate's version from the database.
//
// Please be super sure you want to do this before running this.
//
// Usage:
// cargo run --bin delete-version crate-name version-number
#![deny(warnings)]
extern crate cargo_registry;
extern crate postgres;
extern crate time;
extern crate semve... |
fn delete(tx: &postgres::Transaction) {
let name = match env::args().nth(1) {
None => { println!("needs a crate-name argument"); return }
Some(s) => s,
};
let version = match env::args().nth(2) {
None => { println!("needs a version argument"); return }
Some(s) => s,
};
... | {
match env::var(s).ok() {
Some(s) => s,
None => panic!("must have `{}` defined", s),
}
} | identifier_body |
delete-version.rs | // Purge all references to a crate's version from the database.
//
// Please be super sure you want to do this before running this.
//
// Usage:
// cargo run --bin delete-version crate-name version-number
#![deny(warnings)]
extern crate cargo_registry;
extern crate postgres;
extern crate time;
extern crate semve... | (tx: &postgres::Transaction) {
let name = match env::args().nth(1) {
None => { println!("needs a crate-name argument"); return }
Some(s) => s,
};
let version = match env::args().nth(2) {
None => { println!("needs a version argument"); return }
Some(s) => s,
};
let ver... | delete | identifier_name |
borrowck-lend-flow.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | let _w = &v;
borrow_mut(&mut *v); //~ ERROR cannot borrow
}
fn post_freeze() {
// In this instance, the const alias starts after the borrow.
let mut v = box 3;
borrow_mut(&mut *v);
let _w = &v;
}
fn main() {} |
let mut v = box 3; | random_line_split |
borrowck-lend-flow.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 ... | <F>(_f: F) where F: FnOnce() -> bool { panic!() }
fn produce<T>() -> T { panic!(); }
fn inc(v: &mut Box<int>) {
*v = box() (**v + 1);
}
fn pre_freeze() {
// In this instance, the freeze starts before the mut borrow.
let mut v = box 3;
let _w = &v;
borrow_mut(&mut *v); //~ ERROR cannot borrow
}
f... | for_func | identifier_name |
borrowck-lend-flow.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 for_func<F>(_f: F) where F: FnOnce() -> bool { panic!() }
fn produce<T>() -> T { panic!(); }
fn inc(v: &mut Box<int>) {
*v = box() (**v + 1);
}
fn pre_freeze() {
// In this instance, the freeze starts before the mut borrow.
let mut v = box 3;
let _w = &v;
borrow_mut(&mut *v); //~ ERROR cannot... | { panic!() } | identifier_body |
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/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | {
/// A new touch point came in contact with the screen.
Down,
/// An existing touch point changed location.
Move,
/// A touch point was removed from the screen.
Up,
/// The system stopped tracking a touch point.
Cancel,
}
/// An opaque identifier for a touch point.
///
/// http://w3c.... | TouchEventType | 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/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | /// An existing touch point changed location.
Move,
/// A touch point was removed from the screen.
Up,
/// The system stopped tracking a touch point.
Cancel,
}
/// An opaque identifier for a touch point.
///
/// http://w3c.github.io/touch-events/#widl-Touch-identifier
#[derive(Clone, Copy, Debu... | pub enum TouchEventType {
/// A new touch point came in contact with the screen.
Down, | random_line_split |
stub_activity.rs | // Copyright (C) 2011 The Android Open Source Project
//
// 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 applic... | int root(void) {
// Clear the background color
rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// Tell the runtime what the font color should be
rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
// Introuduce ourselves to the world
rsgDrawText("Hello World!", 50, 50);
// Return value tells RS roughly how often... | #pragma rs java_package_name(android.renderscriptgraphics.cts)
// Built-in header with graphics API's
#include "rs_graphics.rsh"
| random_line_split |
aml.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// arch/amd64/acpi/aml.rs
//! ACPI Machine Language parser (VM)
use prelude::*;
struct Error;
struct AmlStream<'a>(&'a [u8],usize);
#[derive(Debug)]
enum FieldElement<'a>
{
Named(&'a str, usize),
}
impl<'a> AmlStream<'a>
{
pub fn new(s: &[u8]) -> AmlStream ... | }
let ignore_last = match base[len]
{
0x00 => { len += 1; true },
// TODO: Handle these with a custom format string that understands the decomposition
//0x2E => { len += 8; false },
//0x2F => {
// len += 1;
// if len >= base.len() { return Err( Error ); }
// let c = base[len];
// len +... | else {
while base[len] == b'^' {
len += 1;
if len >= base.len() { return Err( Error ); }
} | random_line_split |
aml.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// arch/amd64/acpi/aml.rs
//! ACPI Machine Language parser (VM)
use prelude::*;
struct Error;
struct AmlStream<'a>(&'a [u8],usize);
#[derive(Debug)]
enum FieldElement<'a>
{
Named(&'a str, usize),
}
impl<'a> AmlStream<'a>
{
pub fn new(s: &[u8]) -> AmlStream ... | (&mut self) -> Result<u8,Error> {
Ok( try!(self.slice(1))[0] )
}
fn read_pkglength(&mut self) -> Result<usize,Error> {
let lead = try!(self.read_byte());
match lead >> 6
{
0 => Ok(lead as usize),
count @ 1... 3 => {
let mut rv = (lead as usize & 0xF);
for ofs in (0.. count) {
let b = try!(self.r... | read_byte | identifier_name |
aml.rs | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// arch/amd64/acpi/aml.rs
//! ACPI Machine Language parser (VM)
use prelude::*;
struct Error;
struct AmlStream<'a>(&'a [u8],usize);
#[derive(Debug)]
enum FieldElement<'a>
{
Named(&'a str, usize),
}
impl<'a> AmlStream<'a>
{
pub fn new(s: &[u8]) -> AmlStream ... |
}
fn dump_aml_termobj(data: &mut AmlStream) -> Result<usize,Error>
{
match try!(data.read_byte())
{
// TermObj
// -> NameSpaceModifierObj
// -> DefAlias
0x06 => {
let dst = try!(data.read_namestring());
let src = try!(data.read_namestring());
log_trace!("DefAlias {} {}", dst, src);
},
// -> DefName
... | {
unimplemented!();
} | identifier_body |
main.rs | #![feature(asm)]
#![feature(box_syntax)]
mod bitboard;
mod color;
mod constants;
mod _move;
mod piece;
mod piece_type;
mod position;
mod search;
mod square;
mod zobrist;
fn | () {
use std::collections::HashMap;
use std::io;
use constants;
use _move;
use position::{Position, perft};
use search::Searcher;
use zobrist;
// Initialize various constants, including magic bitboards
constants::init();
// Initialize zobrist keys
zobrist::init();
let ... | main | identifier_name |
main.rs | #![feature(asm)]
#![feature(box_syntax)]
mod bitboard;
mod color;
mod constants;
mod _move;
mod piece;
mod piece_type;
mod position;
mod search;
mod square;
mod zobrist;
fn main() |
loop {
let mut user_move;
let available_moves = searcher.pos.gen_moves(false);
println!("Available Moves: {:?}", available_moves);
let mut move_map = HashMap::new();
for _move in available_moves.iter() {
move_map.insert(_move::to_int(*_move) & 0xfff, _move);
... | {
use std::collections::HashMap;
use std::io;
use constants;
use _move;
use position::{Position, perft};
use search::Searcher;
use zobrist;
// Initialize various constants, including magic bitboards
constants::init();
// Initialize zobrist keys
zobrist::init();
let boa... | identifier_body |
main.rs | #![feature(asm)]
#![feature(box_syntax)]
mod bitboard;
mod color;
mod constants;
mod _move;
mod piece;
mod piece_type; | mod position;
mod search;
mod square;
mod zobrist;
fn main() {
use std::collections::HashMap;
use std::io;
use constants;
use _move;
use position::{Position, perft};
use search::Searcher;
use zobrist;
// Initialize various constants, including magic bitboards
constants::init();
... | random_line_split | |
day_8.rs | use std::rc::Rc;
use std::cell::RefCell;
const SEGMENT_SIZE: usize = 16;
type SegmentLink = Rc<RefCell<Segment>>;
#[derive(PartialEq)]
struct Segment {
head: usize,
tail: usize,
items: [i32; SEGMENT_SIZE],
next: Option<SegmentLink>
}
impl Segment {
fn new() -> SegmentLink {
Rc::new(RefCe... | Ok(()) => (),
Err(last) => self.last = Some(last.clone())
}
}
fn insert(&mut self, item: i32) -> Result<(), SegmentLink> {
let segment = self.last.get_or_insert(Segment::new());
if self.first.as_ref().map_or(true, |first| first == segment) {
self.firs... |
pub fn enqueue(&mut self, item: i32) {
match self.insert(item) { | random_line_split |
day_8.rs | use std::rc::Rc;
use std::cell::RefCell;
const SEGMENT_SIZE: usize = 16;
type SegmentLink = Rc<RefCell<Segment>>;
#[derive(PartialEq)]
struct Segment {
head: usize,
tail: usize,
items: [i32; SEGMENT_SIZE],
next: Option<SegmentLink>
}
impl Segment {
fn new() -> SegmentLink {
Rc::new(RefCe... | (&mut self, item: i32) -> Result<(), SegmentLink> {
let segment = self.last.get_or_insert(Segment::new());
if self.first.as_ref().map_or(true, |first| first == segment) {
self.first = Some(segment.clone());
}
segment.borrow_mut().add(item)
}
}
impl Default for ArrayLinke... | insert | identifier_name |
day_8.rs | use std::rc::Rc;
use std::cell::RefCell;
const SEGMENT_SIZE: usize = 16;
type SegmentLink = Rc<RefCell<Segment>>;
#[derive(PartialEq)]
struct Segment {
head: usize,
tail: usize,
items: [i32; SEGMENT_SIZE],
next: Option<SegmentLink>
}
impl Segment {
fn new() -> SegmentLink {
Rc::new(RefCe... |
}
impl Default for ArrayLinkedQueue {
fn default() -> Self {
ArrayLinkedQueue { first: None, last: None }
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn enqueue_dequeue_many_items() {
let mut queue = ArrayLinkedQueue::default();
queue.enqueue(1);
queue.enq... | {
let segment = self.last.get_or_insert(Segment::new());
if self.first.as_ref().map_or(true, |first| first == segment) {
self.first = Some(segment.clone());
}
segment.borrow_mut().add(item)
} | identifier_body |
issue-16822.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 ... | {
i: isize
}
impl lib::Update for App {
fn update(&mut self) {
self.i += 1;
}
}
fn main(){
let app = App { i: 5 };
let window = lib::Window { data: RefCell::new(app) };
window.update(1);
}
| App | identifier_name |
issue-16822.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 ... | window.update(1);
} | random_line_split | |
issue-16822.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let app = App { i: 5 };
let window = lib::Window { data: RefCell::new(app) };
window.update(1);
} | identifier_body | |
lib.rs | #![crate_type = "dylib"]
#[macro_export]
macro_rules! world {
($space:ident ($param:ty), $($name:ident : $component:ty,)*) => {
/// A collection of pointers to components
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Entity {
$(
pub $name: Option<$space::Id<$comp... | self.entity.$name = Some(id);
self
}
)*
}
impl Components {
pub fn new() -> Components {
Components {
$(
$name: $space::Array::new(),
)*
}
... | pub fn $name(mut self, value: $component) -> Adder<'d> {
debug_assert!(self.entity.$name.is_none());
let id = self.data.$name.add(value); | random_line_split |
fixed.rs | // Copyright 2013-2015, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
//! A container which allows you to position widgets at fixed coordinates
use libc::c_int;
... | // FIXME: search a new name
pub fn move_<T: ::WidgetTrait>(&self,
widget: &T,
x: i32,
y: i32) -> () {
unsafe {
ffi::gtk_fixed_move(GTK_FIXED(self.pointer), widget.unwrap_widget(), x as c_int, y as c_int... | unsafe {
ffi::gtk_fixed_put(GTK_FIXED(self.pointer), widget.unwrap_widget(), x as c_int, y as c_int);
}
}
| identifier_body |
fixed.rs | // Copyright 2013-2015, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
//! A container which allows you to position widgets at fixed coordinates
use libc::c_int;
... | : ::WidgetTrait>(&self,
widget: &T,
x: i32,
y: i32) -> () {
unsafe {
ffi::gtk_fixed_move(GTK_FIXED(self.pointer), widget.unwrap_widget(), x as c_int, y as c_int);
}
}
}
impl_drop!(Fixed);
impl_Trai... | ve_<T | identifier_name |
fixed.rs | // Copyright 2013-2015, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
//! A container which allows you to position widgets at fixed coordinates
use libc::c_int;
... | ffi::gtk_fixed_move(GTK_FIXED(self.pointer), widget.unwrap_widget(), x as c_int, y as c_int);
}
}
}
impl_drop!(Fixed);
impl_TraitWidget!(Fixed);
impl ::ContainerTrait for Fixed {} | y: i32) -> () {
unsafe { | random_line_split |
shootout-ackermann.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 ... | (m: int, n: int) -> int {
if m == 0 {
return n + 1
} else {
if n == 0 {
return ack(m - 1, 1);
} else {
return ack(m - 1, ack(m, n - 1));
}
}
}
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
~[~"",... | ack | identifier_name |
shootout-ackermann.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"12"]
} else if args.len() <= 1u {
~[~"", ~"8"]
} else {
args
};
let n = from_str::<int>(args[1]).unwrap();
printfln!("Ack(3,%d): %d\n", n, ack(3, n));
} | identifier_body | |
shootout-ackermann.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | };
let n = from_str::<int>(args[1]).unwrap();
printfln!("Ack(3,%d): %d\n", n, ack(3, n));
} | random_line_split | |
shootout-ackermann.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 {
args
};
let n = from_str::<int>(args[1]).unwrap();
printfln!("Ack(3,%d): %d\n", n, ack(3, n));
}
| {
~[~"", ~"8"]
} | conditional_block |
move_error.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 ... |
}
debug!("found a new move from location");
grouped_errors.push(GroupedMoveErrors {
move_from: error.move_from.clone(),
move_to_places: move_to
})
}
}
fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
... | {
debug!("appending move_to to list");
ge.move_to_places.extend(move_to.into_iter());
return
} | conditional_block |
move_error.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 ... | move_to_places: Vec<MoveSpanAndPath>
}
fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
errors: &Vec<MoveError<'tcx>>) {
let grouped_errors = group_errors_with_same_origin(errors);
for error in grouped_errors.iter() {
report_cannot_move_out_of(bccx, err... | }
pub struct GroupedMoveErrors<'tcx> {
move_from: mc::cmt<'tcx>, | random_line_split |
move_error.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 ... | (move_from: mc::cmt<'tcx>,
move_to: Option<MoveSpanAndPath>)
-> MoveError<'tcx> {
MoveError {
move_from: move_from,
move_to: move_to,
}
}
}
#[derive(Clone)]
pub struct MoveSpanAndPath {
pub span: codemap::Span,
pub ... | with_move_info | identifier_name |
move_error.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 ... |
}
pub struct MoveError<'tcx> {
move_from: mc::cmt<'tcx>,
move_to: Option<MoveSpanAndPath>
}
impl<'tcx> MoveError<'tcx> {
pub fn with_move_info(move_from: mc::cmt<'tcx>,
move_to: Option<MoveSpanAndPath>)
-> MoveError<'tcx> {
MoveError {
... | {
report_move_errors(bccx, &*self.errors.borrow())
} | identifier_body |
fragment.rs | // Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except accordin... | macro_rules! quote_expr {
($($tt:tt)*) => {
$crate::fragment::Fragment::Expr(quote!($($tt)*))
}
}
macro_rules! quote_block {
($($tt:tt)*) => {
$crate::fragment::Fragment::Block(quote!($($tt)*))
}
}
/// Interpolate a fragment in place of an expression. This involves surrounding
/// Bloc... | random_line_split | |
fragment.rs | // Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except accordin... |
}
}
}
/// Interpolate a fragment as the statements of a block.
pub struct Stmts(pub Fragment);
impl ToTokens for Stmts {
fn to_tokens(&self, out: &mut Tokens) {
match self.0 {
Fragment::Expr(ref expr) => expr.to_tokens(out),
Fragment::Block(ref block) => block.to_tokens... | {
token::Brace::default().surround(out, |out| block.to_tokens(out));
} | conditional_block |
fragment.rs | // Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except accordin... |
}
impl AsRef<Tokens> for Fragment {
fn as_ref(&self) -> &Tokens {
match *self {
Fragment::Expr(ref expr) => expr,
Fragment::Block(ref block) => block,
}
}
}
| {
match self.0 {
Fragment::Expr(ref expr) => {
expr.to_tokens(out);
<Token![,]>::default().to_tokens(out);
}
Fragment::Block(ref block) => {
token::Brace::default().surround(out, |out| block.to_tokens(out));
}
... | identifier_body |
fragment.rs | // Copyright 2017 Serde Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except accordin... | (&self, out: &mut Tokens) {
match self.0 {
Fragment::Expr(ref expr) => expr.to_tokens(out),
Fragment::Block(ref block) => {
token::Brace::default().surround(out, |out| block.to_tokens(out));
}
}
}
}
/// Interpolate a fragment as the statements of ... | to_tokens | identifier_name |
singleton.rs | ::collections::HashMap;
use std::thread;
use uuid::Uuid;
#[derive(PartialEq,Eq,Clone,Debug,Hash)]
pub struct VarName {
pub name: Cow<'static, str>,
pub subscript: usize,
}
#[derive(Clone,Debug)]
pub struct AbstractInterpretation {
pub input: HashMap<VarName, Kset>,
pub output: HashMap<VarName, Kset>,
... | let mut proj = Project::new("(none)".to_string(), region.clone());
let mut prog = Program::new("(none");
for f in self.functions.iter() {
prog.insert(f.1.clone());
}
proj.code.push(prog);
proj.snapshot(&Path::new(&path))?;
... | } else if let Some(ref region) = self.region { | random_line_split |
singleton.rs | collections::HashMap;
use std::thread;
use uuid::Uuid;
#[derive(PartialEq,Eq,Clone,Debug,Hash)]
pub struct VarName {
pub name: Cow<'static, str>,
pub subscript: usize,
}
#[derive(Clone,Debug)]
pub struct AbstractInterpretation {
pub input: HashMap<VarName, Kset>,
pub output: HashMap<VarName, Kset>,
}
... | (&mut self, path: String) -> Result<()> {
use std::path::Path;
use panopticon_core::{CallTarget, Machine};
use panopticon_amd64 as amd64;
use panopticon_avr as avr;
use panopticon_analysis::pipeline;
use futures::Stream;
use std::ffi::CString;
debug!("ope... | open_program | identifier_name |
singleton.rs | collections::HashMap;
use std::thread;
use uuid::Uuid;
#[derive(PartialEq,Eq,Clone,Debug,Hash)]
pub struct VarName {
pub name: Cow<'static, str>,
pub subscript: usize,
}
#[derive(Clone,Debug)]
pub struct AbstractInterpretation {
pub input: HashMap<VarName, Kset>,
pub output: HashMap<VarName, Kset>,
}
... |
}
}
let entry = func.start();
// my addr
let pairs_owned = self.unresolved_calls.remove(&Some(entry)).unwrap_or(vec![]).into_iter();
let pairs_ref = self.unresolved_calls.get_vec(&None).cloned().unwrap_or(vec![]).into_iter();
sel... | {
match rv {
&Rvalue::Constant { value, .. } => {
// their addr
let maybe_callee = self.by_entry.get(&value);
if let Some(callee) = maybe_callee {
... | conditional_block |
singleton.rs | collections::HashMap;
use std::thread;
use uuid::Uuid;
#[derive(PartialEq,Eq,Clone,Debug,Hash)]
pub struct VarName {
pub name: Cow<'static, str>,
pub subscript: usize,
}
#[derive(Clone,Debug)]
pub struct AbstractInterpretation {
pub input: HashMap<VarName, Kset>,
pub output: HashMap<VarName, Kset>,
}
... |
if!qt::SUBSCRIBED_FUNCTIONS.lock().contains(uuid) {
return Ok(());
}
let bbls: Vec<_> = self.get_function_nodes(uuid.clone().to_string())
.unwrap()
.into_iter()
.filter_map(
|bbl| if bbl.4.is_empty() || ids.is_empty() || ids.iter().a... | {
use std::ffi::CString;
use panopticon_glue::{CBasicBlockLine, CBasicBlockOperand};
debug!(
"update_control_flow_nodes() func={}, addrs={:?}",
uuid,
addrs
);
let ids = if let Some(ref mut cfl) = self.control_flow_layouts.get_mut(uuid) {
... | identifier_body |
uart.rs | use Core;
use Addon;
use io;
pub struct |
{
/// The baud rate (bits/second)
pub baud: u64,
/// The number of CPU ticks in a single second (ticks/second)
pub cpu_frequency: u64,
/// Number of ticks between each bit.
ticks_between_bits: u64,
ticks_until_next_bit: u64,
_tx: io::Port,
_rx: io::Port,
_processed_bits: Vec<... | Uart | identifier_name |
uart.rs | use Core;
use Addon;
use io;
pub struct Uart
{
/// The baud rate (bits/second)
pub baud: u64,
/// The number of CPU ticks in a single second (ticks/second)
pub cpu_frequency: u64,
/// Number of ticks between each bit.
ticks_between_bits: u64,
ticks_until_next_bit: u64,
_tx: io::Port,
... | pub fn new(cpu_frequency: u64, baud: u64, tx: io::Port, rx: io::Port) -> Self {
let ticks_between_bits = cpu_frequency / baud;
Uart {
cpu_frequency: cpu_frequency,
baud: baud,
_tx: tx,
_rx: rx,
ticks_between_bits: ticks_between_bits, // T... | random_line_split | |
uart.rs | use Core;
use Addon;
use io;
pub struct Uart
{
/// The baud rate (bits/second)
pub baud: u64,
/// The number of CPU ticks in a single second (ticks/second)
pub cpu_frequency: u64,
/// Number of ticks between each bit.
ticks_between_bits: u64,
ticks_until_next_bit: u64,
_tx: io::Port,
... |
}
}
| {
self.process_bit(core);
self.ticks_until_next_bit = self.ticks_between_bits;
} | conditional_block |
uart.rs | use Core;
use Addon;
use io;
pub struct Uart
{
/// The baud rate (bits/second)
pub baud: u64,
/// The number of CPU ticks in a single second (ticks/second)
pub cpu_frequency: u64,
/// Number of ticks between each bit.
ticks_between_bits: u64,
ticks_until_next_bit: u64,
_tx: io::Port,
... |
fn process_bit(&mut self, _core: &mut Core) {
println!("tick");
}
}
impl Addon for Uart
{
fn tick(&mut self, core: &mut Core) {
self.ticks_until_next_bit -= 1;
if self.ticks_until_next_bit == 0 {
self.process_bit(core);
self.ticks_until_next_bit = self.tic... | {
let ticks_between_bits = cpu_frequency / baud;
Uart {
cpu_frequency: cpu_frequency,
baud: baud,
_tx: tx,
_rx: rx,
ticks_between_bits: ticks_between_bits, // TODO: set this variable
ticks_until_next_bit: ticks_between_bits,
... | identifier_body |
default_writer.rs | extern crate rust_base58;
use std::fs;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use serde_json;
use errors::prelude::*;
use utils::environment;
use super::{WritableBlob, Writer, WriterType};
use self::rust_base58::ToBase58;
#[allow(dead_code)]
pub struct DefaultWriter {
base_dir: PathBuf... | (id: i32) -> PathBuf {
environment::tmp_file_path(&format!("def_storage_tmp_{}", id))
}
pub struct DefaultWriterType {}
impl DefaultWriterType {
pub fn new() -> Self {
DefaultWriterType {}
}
}
| tmp_storage_file | identifier_name |
default_writer.rs | extern crate rust_base58;
use std::fs;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use serde_json;
use errors::prelude::*;
use utils::environment;
use super::{WritableBlob, Writer, WriterType};
use self::rust_base58::ToBase58;
#[allow(dead_code)]
pub struct DefaultWriter {
base_dir: PathBuf... |
fs::remove_file(&tmp_storage_file(self.id))
.map_err(map_err_trace!())?;
let res = path.to_str().unwrap().to_owned();
trace!("finalize <<< {}", res);
Ok(res)
}
}
fn tmp_storage_file(id: i32) -> PathBuf {
environment::tmp_file_path(&format!("def_storage_tmp_{}", id)... | .map_err(map_err_trace!(format!("path: {:?}", path)))?;
fs::copy(&tmp_storage_file(self.id), &path)
.map_err(map_err_trace!())?; //FIXME | random_line_split |
default_writer.rs | extern crate rust_base58;
use std::fs;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use serde_json;
use errors::prelude::*;
use utils::environment;
use super::{WritableBlob, Writer, WriterType};
use self::rust_base58::ToBase58;
#[allow(dead_code)]
pub struct DefaultWriter {
base_dir: PathBuf... |
}
impl WritableBlob for DefaultWriter {
fn append(&mut self, bytes: &[u8]) -> IndyResult<usize> {
trace!("append >>>");
let res = self.file.write(bytes)
.map_err(map_err_trace!())?;
trace!("append <<< {}", res);
Ok(res)
}
fn finalize(&mut self, hash: &[u8]) ->... | {
let path = PathBuf::from(&self.base_dir);
fs::DirBuilder::new()
.recursive(true)
.create(tmp_storage_file(id).parent().unwrap())?;
let file = File::create(tmp_storage_file(id))
.map_err(map_err_trace!())?;
Ok(Box::new(DefaultWriter {
b... | identifier_body |
gpr1.rs | #[doc = "Register `GPR1` reader"]
pub struct R(crate::R<GPR1_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<GPR1_SPEC>;
#[inline(always)]
fn | (&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<GPR1_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R<GPR1_SPEC>) -> Self {
R(reader)
}
}
#[doc = "Register `GPR1` writer"]
pub struct W(crate::W<GPR1_SPEC>);
impl core::ops::Deref for W {
type Target = crate::W<GPR1_... | deref | identifier_name |
gpr1.rs | #[doc = "Register `GPR1` reader"]
pub struct R(crate::R<GPR1_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<GPR1_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<GPR1_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R<GPR1_SP... | }
#[doc = "Register `GPR1` writer"]
pub struct W(crate::W<GPR1_SPEC>);
impl core::ops::Deref for W {
type Target = crate::W<GPR1_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl core::ops::DerefMut for W {
#[inline(always)]
fn deref_mut(&mut self) -> &mut Self... | R(reader)
} | random_line_split |
gpr1.rs | #[doc = "Register `GPR1` reader"]
pub struct R(crate::R<GPR1_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<GPR1_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<GPR1_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R<GPR1_SP... |
}
impl R {
#[doc = "Bits 0:31 - User Data"]
#[inline(always)]
pub fn dat(&self) -> DAT_R {
DAT_R::new((self.bits & 0xffff_ffff) as u32)
}
}
impl W {
#[doc = "Bits 0:31 - User Data"]
#[inline(always)]
pub fn dat(&mut self) -> DAT_W {
DAT_W { w: self }
}
#[doc = "Write... | {
self.w.bits = (self.w.bits & !0xffff_ffff) | (value as u32 & 0xffff_ffff);
self.w
} | identifier_body |
main.rs | /* Aurélien DESBRIÈRES
aurelien(at)hackers(dot)camp
License GNU GPL latest */
// Rust experimentations
// HOF - Higher Order Functions in Rust
fn is_odd(n: u32) -> bool {
n % 2 == 1
}
fn main() {
println!("Find the sum of all the squared odd numbers under 1000");
let upper = 1000;
// Imperative appr... | } else if is_odd(n_squared) {
// Accumulate value, if it's odd
acc += n_squared;
}
}
println!("imperative style: {}", acc);
// Functional approach
let sum_of_squared_odd_numbers: u32 =
(0..).map(|n| n * n) // All natural numbers squared
.tak... |
if n_squared >= upper {
// Break loop if exceeded the upper limit
break; | random_line_split |
main.rs | /* Aurélien DESBRIÈRES
aurelien(at)hackers(dot)camp
License GNU GPL latest */
// Rust experimentations
// HOF - Higher Order Functions in Rust
fn is_odd(n: u32) -> bool {
n % 2 == 1
}
fn main() {
|
// Functional approach
let sum_of_squared_odd_numbers: u32 =
(0..).map(|n| n * n) // All natural numbers squared
.take_while(|&n| n < upper) // Below upper limit
.filter(|&n| is_odd(n)) // That are odd
.fold(0, |sum, i| sum + i); // Sum them
println!("functional styl... | println!("Find the sum of all the squared odd numbers under 1000");
let upper = 1000;
// Imperative approach
// Declare accumulator varialbe
let mut acc = 0;
// Iterate: 0, 1, 2, ... to infinity
for n in 0.. {
// Square the number
let n_squared = n * n;
if n_squared... | identifier_body |
main.rs | /* Aurélien DESBRIÈRES
aurelien(at)hackers(dot)camp
License GNU GPL latest */
// Rust experimentations
// HOF - Higher Order Functions in Rust
fn is_odd(n: u32) -> bool {
n % 2 == 1
}
fn ma | {
println!("Find the sum of all the squared odd numbers under 1000");
let upper = 1000;
// Imperative approach
// Declare accumulator varialbe
let mut acc = 0;
// Iterate: 0, 1, 2,... to infinity
for n in 0.. {
// Square the number
let n_squared = n * n;
if n_squar... | in() | identifier_name |
modules.rs | use parking_lot::RwLock;
use std::sync::Arc;
use crate::language::ty::SourceType;
use crate::size::InstanceSize;
use crate::utils::GrowableVec;
use crate::vm::{
namespace_path, replace_type_param, Candidate, FctDefinitionId, Field, FieldDef, FileId,
NamespaceId, TraitDefinitionId, VM,
};
use crate::vtable::VT... | (&self, vm: &VM) -> String {
namespace_path(vm, self.namespace_id, self.name)
}
}
pub fn find_methods_in_module(vm: &VM, object_type: SourceType, name: Name) -> Vec<Candidate> {
let mut ignores = HashSet::new();
let mut module_type = object_type;
loop {
let module_id = module_type.mod... | name | identifier_name |
modules.rs | use parking_lot::RwLock;
use std::sync::Arc;
use crate::language::ty::SourceType;
use crate::size::InstanceSize;
use crate::utils::GrowableVec;
use crate::vm::{
namespace_path, replace_type_param, Candidate, FctDefinitionId, Field, FieldDef, FileId,
NamespaceId, TraitDefinitionId, VM,
};
use crate::vtable::VT... |
if!ignores.contains(&method.id) {
return vec![Candidate {
object_type: module_type.clone(),
container_type_params: module_type.type_params(),
fct_id: method.id,
}];
}
... | {
ignores.insert(overrides);
} | conditional_block |
modules.rs | use parking_lot::RwLock;
use std::sync::Arc;
use crate::language::ty::SourceType;
use crate::size::InstanceSize;
use crate::utils::GrowableVec;
use crate::vm::{
namespace_path, replace_type_param, Candidate, FctDefinitionId, Field, FieldDef, FileId,
NamespaceId, TraitDefinitionId, VM,
};
use crate::vtable::VT... | }];
}
}
}
if let Some(parent_class) = module.parent_class.clone() {
let type_list = module_type.type_params();
module_type = replace_type_param(vm, parent_class, &type_list, None);
} else {
break;
}
... | container_type_params: module_type.type_params(),
fct_id: method.id, | random_line_split |
modules.rs | use parking_lot::RwLock;
use std::sync::Arc;
use crate::language::ty::SourceType;
use crate::size::InstanceSize;
use crate::utils::GrowableVec;
use crate::vm::{
namespace_path, replace_type_param, Candidate, FctDefinitionId, Field, FieldDef, FileId,
NamespaceId, TraitDefinitionId, VM,
};
use crate::vtable::VT... |
}
pub fn find_methods_in_module(vm: &VM, object_type: SourceType, name: Name) -> Vec<Candidate> {
let mut ignores = HashSet::new();
let mut module_type = object_type;
loop {
let module_id = module_type.module_id().expect("no module");
let module = vm.modules.idx(module_id);
let m... | {
namespace_path(vm, self.namespace_id, self.name)
} | identifier_body |
lib.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 ... | { } | identifier_body | |
lib.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
};
let mut val = 0u32;
for codepoint in s.get().chars().take(4) {
let byte = if codepoint as u32 > 0xFF {
cx.span_err(expr.span, "fourcc! literal character out of range 0-255");
0u8
} else {
codepoint as u8
};
val = if little {
... | {
cx.span_err(expr.span, "non-literal in fourcc!");
return MRExpr(cx.expr_lit(sp, ast::LitUint(0u64, ast::TyU32)));
} | conditional_block |
lib.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 ... | // FIXME (10872): This is required to prevent an LLVM assert on Windows
#[test]
fn dummy_test() { } | ast::LitStr(InternedString::new("little"), ast::CookedStr));
contains(cx.cfg().as_slice(), meta)
}
| random_line_split |
lib.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 ... | {
ident: ast::Ident,
span: Span
}
fn parse_tts(cx: &ExtCtxt, tts: &[ast::TokenTree]) -> (@ast::Expr, Option<Ident>) {
let p = &mut parse::new_parser_from_tts(cx.parse_sess(),
cx.cfg(),
tts.iter()
... | Ident | identifier_name |
slack.rs | use std::sync::{Arc, Mutex};
use log::{debug, error, info};
use serde_derive::{Deserialize, Serialize};
use crate::util;
use crate::worker;
use octobot_lib::errors::*;
use octobot_lib::http_client::HTTPClient;
use octobot_lib::metrics::Metrics;
#[derive(Serialize, Clone, PartialEq, Eq, Debug)]
pub struct SlackAttach... | }
impl SlackAttachment {
pub fn new(text: &str) -> SlackAttachment {
SlackAttachment {
text: text.to_string(),
title: None,
title_link: None,
color: None,
mrkdwn_in: None,
}
}
}
pub struct SlackAttachmentBuilder {
attachment: Slac... |
#[derive(Deserialize)]
struct SlackResponse {
ok: bool,
error: Option<String>, | random_line_split |
slack.rs | use std::sync::{Arc, Mutex};
use log::{debug, error, info};
use serde_derive::{Deserialize, Serialize};
use crate::util;
use crate::worker;
use octobot_lib::errors::*;
use octobot_lib::http_client::HTTPClient;
use octobot_lib::metrics::Metrics;
#[derive(Serialize, Clone, PartialEq, Eq, Debug)]
pub struct SlackAttach... |
debug!("Sending message to #{}", channel);
let res: Result<SlackResponse> = self.client.post("/chat.postMessage", &slack_msg).await;
match res {
Ok(r) => {
if r.ok {
info!("Successfully sent slack message to {}", channel)
} else ... | {
info!("Skipping duplicate message to {}", channel);
return;
} | conditional_block |
slack.rs | use std::sync::{Arc, Mutex};
use log::{debug, error, info};
use serde_derive::{Deserialize, Serialize};
use crate::util;
use crate::worker;
use octobot_lib::errors::*;
use octobot_lib::http_client::HTTPClient;
use octobot_lib::metrics::Metrics;
#[derive(Serialize, Clone, PartialEq, Eq, Debug)]
pub struct | {
pub text: String,
pub title: Option<String>,
pub title_link: Option<String>,
pub color: Option<String>,
pub mrkdwn_in: Option<Vec<String>>,
}
#[derive(Deserialize)]
struct SlackResponse {
ok: bool,
error: Option<String>,
}
impl SlackAttachment {
pub fn new(text: &str) -> SlackAttach... | SlackAttachment | identifier_name |
utils.rs | use brotli;
use byteorder::{BigEndian, ReadBytesExt};
use chrono::Local;
use env_logger::Builder;
use log::{LevelFilter, Record};
use rocket::http::{ContentType, Status};
use rocket::response::{self, Responder};
use rocket::{fairing, Data, Request, Response};
use serde_json;
use std::env;
use std::io::{self, BufRead, ... | for _ in vector.len()..=pos {
vector.push(default);
}
vector[pos] = value;
}
/// Wraps a JSON value and implements a responder for it, with support for brotli compression.
#[allow(dead_code)]
pub struct CompressedJSON(pub serde_json::Value);
impl Responder<'static> for CompressedJSON {
fn resp... | pub fn insert_at<T: Copy>(vector: &mut Vec<T>, pos: usize, value: T, default: T) { | random_line_split |
utils.rs | use brotli;
use byteorder::{BigEndian, ReadBytesExt};
use chrono::Local;
use env_logger::Builder;
use log::{LevelFilter, Record};
use rocket::http::{ContentType, Status};
use rocket::response::{self, Responder};
use rocket::{fairing, Data, Request, Response};
use serde_json;
use std::env;
use std::io::{self, BufRead, ... |
}
| {
let uri = request.uri().path();
if !uri.starts_with("/api") && !uri.starts_with("/public") {
info!("User request: {}", uri);
}
} | identifier_body |
utils.rs | use brotli;
use byteorder::{BigEndian, ReadBytesExt};
use chrono::Local;
use env_logger::Builder;
use log::{LevelFilter, Record};
use rocket::http::{ContentType, Status};
use rocket::response::{self, Responder};
use rocket::{fairing, Data, Request, Response};
use serde_json;
use std::env;
use std::io::{self, BufRead, ... | (&self, request: &mut Request, _: &Data) {
let uri = request.uri().path();
if!uri.starts_with("/api") &&!uri.starts_with("/public") {
info!("User request: {}", uri);
}
}
}
| on_request | identifier_name |
utils.rs | use brotli;
use byteorder::{BigEndian, ReadBytesExt};
use chrono::Local;
use env_logger::Builder;
use log::{LevelFilter, Record};
use rocket::http::{ContentType, Status};
use rocket::response::{self, Responder};
use rocket::{fairing, Data, Request, Response};
use serde_json;
use std::env;
use std::io::{self, BufRead, ... | else {
Ok(Response::build()
.status(Status::Ok)
.header(ContentType::JSON)
.streamed_body(reader)
.finalize())
}
}
}
pub fn read_str<'a>(rdr: &'a mut Cursor<&[u8]>) -> Result<&'a str> {
let len = (rdr.read_i16::<BigEndian>()).chai... | {
Ok(Response::build()
.status(Status::Ok)
.header(ContentType::JSON)
.raw_header("Content-Encoding", "br")
.streamed_body(brotli::CompressorReader::new(reader, 4096, 3, 20))
.finalize())
} | conditional_block |
command.rs | use std::fmt::{Debug, Formatter, Error};
use std::path::{PathBuf, Path};
use std::process::{Command, Output};
use std::{env, str};
pub struct TestCommand {
cwd: PathBuf,
args: Vec<String>,
env_vars: Vec<(String, String)>,
}
impl TestCommand {
pub fn new(cwd: &Path, subcommand: &str) -> Self {
... | () -> PathBuf {
env::current_exe().unwrap()
.parent().unwrap()
.join("diesel")
}
impl Debug for CommandResult {
fn fmt(&self, out: &mut Formatter) -> Result<(), Error> {
write!(out, "stdout: {}\nstderr: {}", self.stdout(), self.stderr())
}
}
| path_to_diesel_cli | identifier_name |
command.rs | use std::fmt::{Debug, Formatter, Error};
use std::path::{PathBuf, Path};
use std::process::{Command, Output};
use std::{env, str};
pub struct TestCommand {
cwd: PathBuf,
args: Vec<String>,
env_vars: Vec<(String, String)>,
}
impl TestCommand {
pub fn new(cwd: &Path, subcommand: &str) -> Self {
... | CommandResult {
output: output,
}
}
fn build_command(&self) -> Command {
let mut command = Command::new(path_to_diesel_cli());
command.args(&self.args)
.current_dir(&self.cwd);
for &(ref k, ref v) in self.env_vars.iter() {
command.env(&... | let output = self.build_command().output().unwrap(); | random_line_split |
command.rs | use std::fmt::{Debug, Formatter, Error};
use std::path::{PathBuf, Path};
use std::process::{Command, Output};
use std::{env, str};
pub struct TestCommand {
cwd: PathBuf,
args: Vec<String>,
env_vars: Vec<(String, String)>,
}
impl TestCommand {
pub fn new(cwd: &Path, subcommand: &str) -> Self {
... |
fn build_command(&self) -> Command {
let mut command = Command::new(path_to_diesel_cli());
command.args(&self.args)
.current_dir(&self.cwd);
for &(ref k, ref v) in self.env_vars.iter() {
command.env(&k, &v);
}
command
}
}
pub struct CommandResult... | {
let output = self.build_command().output().unwrap();
CommandResult {
output: output,
}
} | identifier_body |
layout_debug.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/. */
//! Supports writing a trace file created during each layout scope
//! that can be viewed by an external tool to m... |
}
});
}
}
/// Generate a unique ID. This is used for items such as Fragment
/// which are often reallocated but represent essentially the
/// same data.
pub fn generate_unique_debug_id() -> u16 {
DEBUG_ID_COUNTER.fetch_add(1, Ordering::SeqCst) as u16
}
/// Begin a layout debug trace. If t... | {} | conditional_block |
layout_debug.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/. */
//! Supports writing a trace file created during each layout scope
//! that can be viewed by an external tool to m... | let mut file = File::create("layout_trace.json").unwrap();
file.write_all(result.as_bytes()).unwrap();
} |
let result = json::encode(&root_scope).unwrap(); | random_line_split |
layout_debug.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/. */
//! Supports writing a trace file created during each layout scope
//! that can be viewed by an external tool to m... | () {
let mut task_state = STATE_KEY.with(|ref r| r.borrow_mut().take().unwrap());
assert!(task_state.scope_stack.len() == 1);
let mut root_scope = task_state.scope_stack.pop().unwrap();
root_scope.post = json::encode(&flow::base(&*task_state.flow_root)).unwrap();
let result = json::encode(&root_sco... | end_trace | identifier_name |
variablenbindung.rs | fn main() | println!("f = {}", f);
}
| {
// let - Variablenbindung erstellen, Standard: immutable (Wert ist unveränderbar)
let a = 1;
println!("a = {}", a);
// Muster sind bei einer Variablenbindung möglich, z.B.
let (b, c, d) = (2, 3, 4);
println!("b = {}, c = {}, d = {}", b, c, d);
// Variablenbindung mit Typangabe
/... | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.