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
lib.rs
#[macro_use] extern crate lazy_static; extern crate rustc_serialize; use rustc_serialize::json::Json; use std::error::Error; use std::path::Path; use std::fs::File; use std::io::Read; pub mod common; pub mod install; pub mod scanner; pub mod connection; pub mod message; pub mod runner; pub fn plugin_json() -> Json {...
{ let json = plugin_json(); let ver = json.find_path(&["version"]).unwrap(); ver.to_string() }
identifier_body
lib.rs
#[macro_use] extern crate lazy_static; extern crate rustc_serialize; use rustc_serialize::json::Json; use std::error::Error; use std::path::Path; use std::fs::File; use std::io::Read; pub mod common; pub mod install; pub mod scanner; pub mod connection; pub mod message; pub mod runner; pub fn plugin_json() -> Json {...
() -> String { let json = plugin_json(); let ver = json.find_path(&["version"]).unwrap(); ver.to_string() }
version
identifier_name
lib.rs
#[macro_use] extern crate lazy_static; extern crate rustc_serialize; use rustc_serialize::json::Json; use std::error::Error; use std::path::Path; use std::fs::File; use std::io::Read; pub mod common; pub mod install; pub mod scanner; pub mod connection; pub mod message; pub mod runner; pub fn plugin_json() -> Json {...
match Json::from_str(&s) { Err(why) => panic!("Couldn't parse plugin JSON: {}", Error::description(&why)), Ok(jsoncontent) => jsoncontent, } } pub fn version() -> String { let json = plugin_json(); let ver = json.find_path(&["version"]).unwrap(); ver.to_string() }
Err(why) => panic!("Couldn't read plugin meta file {}: {}", file_path.display(), Error::description(&why)), Ok(content) => content, };
random_line_split
twitter_eggmode.rs
extern crate egg_mode; extern crate tokio; use super::notifier::Error; use super::NotifierStrategy; use super::Message; use self::tokio::runtime::current_thread::block_on_all; use std::string::ToString; pub struct TwitterEggMode { token: egg_mode::Token, } impl TwitterEggMode { pub fn new(consumer_key: &str,...
} }
Ok(())
random_line_split
twitter_eggmode.rs
extern crate egg_mode; extern crate tokio; use super::notifier::Error; use super::NotifierStrategy; use super::Message; use self::tokio::runtime::current_thread::block_on_all; use std::string::ToString; pub struct TwitterEggMode { token: egg_mode::Token, } impl TwitterEggMode { pub fn new(consumer_key: &str,...
}
{ let truncated = message.truncate(140); block_on_all( egg_mode::tweet::DraftTweet::new(truncated.body()) .send(&self.token) ).map_err(|e| Error::FailedToPostMessage(e.to_string()))?; Ok(()) }
identifier_body
twitter_eggmode.rs
extern crate egg_mode; extern crate tokio; use super::notifier::Error; use super::NotifierStrategy; use super::Message; use self::tokio::runtime::current_thread::block_on_all; use std::string::ToString; pub struct TwitterEggMode { token: egg_mode::Token, } impl TwitterEggMode { pub fn
(consumer_key: &str, consumer_secret: &str, access_key: &str, access_secret: &str) -> Self { // create twitter client let consumer = egg_mode::KeyPair::new(consumer_key.to_owned(), consumer_secret.to_owned()); let access = egg_mode::KeyPair::new(access_key.to_owned(), access_secret.to_owned())...
new
identifier_name
dict.rs
use std::rc::Rc; /// Структура описывающая граммему. /// /// Список всех граммем можно [посмотреть](http://opencorpora.org/dict.php?act=gram) /// на сайте [opencorpora.org](http://opencorpora.org). #[derive(Clone, Default, Debug)] pub struct Grammeme { /// Имя родительской граммемы (значение `None` индицирует, что...
pub to: Rc<Lemma>, /// Типа связи pub kind: Rc<LinkKind>, } /// Структура содержащая данные словаря. #[derive(Default, Debug)] pub struct Dict { /// Версия словаря pub version: String, /// Номер ревизии pub revision: usize, /// Множество граммем pub grammemes: Vec<Rc<Grammeme>>, ...
/// Лексема с конечной стороны связи
random_line_split
dict.rs
use std::rc::Rc; /// Структура описывающая граммему. /// /// Список всех граммем можно [посмотреть](http://opencorpora.org/dict.php?act=gram) /// на сайте [opencorpora.org](http://opencorpora.org). #[derive(Clone, Default, Debug)] pub struct Grammeme { /// Имя родительской граммемы (значение `None` индиц
то это граммема верхнего уровня) pub parent: Option<String>, /// Имя граммемы на латинице pub name: String, /// Имя граммемы на кириллице pub alias: String, /// Подробное описание граммемы pub description: String, } /// Тип ограничения на использование граммемы. #[derive(Clone, Copy, Deb...
ирует, ч
identifier_name
test_thread.rs
use rustler::thread; use rustler::types::atom; use rustler::{Atom, Encoder, Env}; #[rustler::nif] pub fn threaded_fac(env: Env, n: u64) -> Atom { // Multiply two numbers; panic on overflow. In Rust, the `*` operator wraps (rather than // panicking) in release builds. A test depends on this panicking, so we mak...
let result = (1..=n).fold(1, mul); result.encode(thread_env) }); atom::ok() } #[rustler::nif] pub fn threaded_sleep(env: Env, msec: u64) -> Atom { let q = msec / 1000; let r = (msec % 1000) as u32; thread::spawn::<thread::ThreadSpawner, _>(env, move |thread_env| { std::thre...
thread::spawn::<thread::ThreadSpawner, _>(env, move |thread_env| {
random_line_split
test_thread.rs
use rustler::thread; use rustler::types::atom; use rustler::{Atom, Encoder, Env}; #[rustler::nif] pub fn threaded_fac(env: Env, n: u64) -> Atom
#[rustler::nif] pub fn threaded_sleep(env: Env, msec: u64) -> Atom { let q = msec / 1000; let r = (msec % 1000) as u32; thread::spawn::<thread::ThreadSpawner, _>(env, move |thread_env| { std::thread::sleep(std::time::Duration::new(q as u64, r * 1_000_000)); msec.encode(thread_env) }); ...
{ // Multiply two numbers; panic on overflow. In Rust, the `*` operator wraps (rather than // panicking) in release builds. A test depends on this panicking, so we make sure it panics in // all builds. The test also checks the panic message. fn mul(a: u64, b: u64) -> u64 { a.checked_mul(b).expec...
identifier_body
test_thread.rs
use rustler::thread; use rustler::types::atom; use rustler::{Atom, Encoder, Env}; #[rustler::nif] pub fn threaded_fac(env: Env, n: u64) -> Atom { // Multiply two numbers; panic on overflow. In Rust, the `*` operator wraps (rather than // panicking) in release builds. A test depends on this panicking, so we mak...
(env: Env, msec: u64) -> Atom { let q = msec / 1000; let r = (msec % 1000) as u32; thread::spawn::<thread::ThreadSpawner, _>(env, move |thread_env| { std::thread::sleep(std::time::Duration::new(q as u64, r * 1_000_000)); msec.encode(thread_env) }); atom::ok() }
threaded_sleep
identifier_name
net.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
fn peer_count(&self) -> Result<String, Error>; /// Returns true if client is actively listening for network connections. /// Otherwise false. #[rpc(name = "net_listening")] fn is_listening(&self) -> Result<bool, Error>; } }
/// Returns number of peers connected to node. #[rpc(name = "net_peerCount")]
random_line_split
cleanup.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use crate::storage::mvcc::{ metrics::{MVCC_CONFLICT_COUNTER, MVCC_DUPLICATE_CMD_COUNTER_VEC}, ErrorInner, Key, MvccTxn, ReleasedLock, Result as MvccResult, SnapshotReader, TimeStamp, }; use crate::storage::txn::actions::check_txn_status::{ ...
<E: Engine>( engine: &E, key: &[u8], start_ts: impl Into<TimeStamp>, current_ts: impl Into<TimeStamp>, ) { let ctx = Context::default(); let snapshot = engine.snapshot(Default::default()).unwrap(); let current_ts = current_ts.into(); let cm = Concurren...
must_succeed
identifier_name
cleanup.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use crate::storage::mvcc::{ metrics::{MVCC_CONFLICT_COUNTER, MVCC_DUPLICATE_CMD_COUNTER_VEC}, ErrorInner, Key, MvccTxn, ReleasedLock, Result as MvccResult, SnapshotReader, TimeStamp, }; use crate::storage::txn::actions::check_txn_status::{ ...
must_succeed(&engine, k, ts(13, 1), ts(120, 0)); must_get_rollback_protected(&engine, k, ts(13, 1), true); } }
must_succeed(&engine, k, ts(11, 1), ts(120, 0)); must_get_rollback_protected(&engine, k, ts(11, 1), true); must_acquire_pessimistic_lock(&engine, k, k, ts(13, 1), ts(14, 1)); must_pessimistic_prewrite_put(&engine, k, v, k, ts(13, 1), ts(14, 1), true);
random_line_split
cleanup.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use crate::storage::mvcc::{ metrics::{MVCC_CONFLICT_COUNTER, MVCC_DUPLICATE_CMD_COUNTER_VEC}, ErrorInner, Key, MvccTxn, ReleasedLock, Result as MvccResult, SnapshotReader, TimeStamp, }; use crate::storage::txn::actions::check_txn_status::{ ...
lock, is_pessimistic_txn, !protect_rollback, ) } l => match check_txn_status_missing_lock( txn, reader, key.clone(), l, MissingLockAction::rollback_protect(protect_rollback), ...
{ fail_point!("cleanup", |err| Err( crate::storage::mvcc::txn::make_txn_error(err, &key, reader.start_ts).into() )); match reader.load_lock(&key)? { Some(ref lock) if lock.ts == reader.start_ts => { // If current_ts is not 0, check the Lock's TTL. // If the lock is n...
identifier_body
generic-object.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 x = @S { x: 1 }; let y = x as @Foo<int>; assert!(y.get() == 1); }
main
identifier_name
generic-object.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} pub fn main() { let x = @S { x: 1 }; let y = x as @Foo<int>; assert!(y.get() == 1); }
{ self.x }
identifier_body
macros.rs
/// Shortcut to generate an ESC-prefixed CSI sequence macro_rules! csi { ($( $l:expr ),*) => { concat!("\x1b[", $( $l ),*) }; } /// Generates an empty struct that prints as a CSI sequence macro_rules! generate_csi_struct { ($name:ident, $value:expr) => { pub struct $name; impl Disp...
() { assert_eq!(csi!("123"), "\x1b[123"); } }
csi
identifier_name
macros.rs
/// Shortcut to generate an ESC-prefixed CSI sequence macro_rules! csi { ($( $l:expr ),*) => { concat!("\x1b[", $( $l ),*) }; } /// Generates an empty struct that prints as a CSI sequence macro_rules! generate_csi_struct { ($name:ident, $value:expr) => { pub struct $name; impl Disp...
}
{ assert_eq!(csi!("123"), "\x1b[123"); }
identifier_body
macros.rs
/// Shortcut to generate an ESC-prefixed CSI sequence macro_rules! csi { ($( $l:expr ),*) => { concat!("\x1b[", $( $l ),*) }; } /// Generates an empty struct that prints as a CSI sequence macro_rules! generate_csi_struct { ($name:ident, $value:expr) => { pub struct $name; impl Disp...
#[cfg(test)] mod tests { #[test] fn csi() { assert_eq!(csi!("123"), "\x1b[123"); } }
} } }; }
random_line_split
path.rs
use anyhow::Result; use once_cell::sync::Lazy; use std::fs; use std::path::{Path, PathBuf}; #[derive(Copy, Clone)] pub enum FilePath { LocalData, } impl FilePath { fn path(self) -> PathBuf { static LOCAL_DATA_PATH: Lazy<PathBuf> = Lazy::new(|| { let mut dir = dirs_next::dat...
<P>(self, subdir: P) -> Result<PathBuf> where P: AsRef<Path>, { let mut dir = self.path(); dir.push(subdir); validate_dir(&dir)?; Ok(dir) } } pub fn validate_dir<P>(dir: P) -> Result<()> where P: AsRef<Path>, { let dir = dir.as_ref(); if!dir.exists() { ...
validated_subdir
identifier_name
path.rs
use anyhow::Result; use once_cell::sync::Lazy; use std::fs; use std::path::{Path, PathBuf}; #[derive(Copy, Clone)]
fn path(self) -> PathBuf { static LOCAL_DATA_PATH: Lazy<PathBuf> = Lazy::new(|| { let mut dir = dirs_next::data_local_dir().unwrap_or_else(|| PathBuf::from("~/.local/share/")); dir.push(env!("CARGO_PKG_NAME")); dir }); match self { ...
pub enum FilePath { LocalData, } impl FilePath {
random_line_split
nul-characters.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 http://opensource.org/licenses/MIT>, at your // option. This file...
random_line_split
nul-characters.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 ...
assert_eq!(c1,c2); } } // testing equality between explicit character literals assert_eq!('\0', '\x00'); assert_eq!('\u{0}', '\x00'); assert_eq!('\u{0}', '\u{0}'); // NUL characters should make a difference assert!("Hello World"!= "Hello \0World"); assert!("Hello Wo...
{ let all_nuls1 = "\0\x00\u{0}\u{0}"; let all_nuls2 = "\u{0}\u{0}\x00\0"; let all_nuls3 = "\u{0}\u{0}\x00\0"; let all_nuls4 = "\x00\u{0}\0\u{0}"; // sizes for two should suffice assert_eq!(all_nuls1.len(), 4); assert_eq!(all_nuls2.len(), 4); // string equality should pass between the s...
identifier_body
nul-characters.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 all_nuls1 = "\0\x00\u{0}\u{0}"; let all_nuls2 = "\u{0}\u{0}\x00\0"; let all_nuls3 = "\u{0}\u{0}\x00\0"; let all_nuls4 = "\x00\u{0}\0\u{0}"; // sizes for two should suffice assert_eq!(all_nuls1.len(), 4); assert_eq!(all_nuls2.len(), 4); // string equality should pass between th...
main
identifier_name
win.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...
} impl<T: Writer> WinConsole<T> { fn apply(&mut self) { let _unused = self.buf.flush(); let mut accum: libc::WORD = 0; accum |= color_to_bits(self.foreground); accum |= color_to_bits(self.background) << 4; unsafe { // Magic -11 means stdout, from // ...
}
random_line_split
win.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...
} impl<T: Writer> Terminal<T> for WinConsole<T> { fn new(out: T) -> Option<WinConsole<T>> { Some(WinConsole { buf: out, foreground: color::WHITE, background: color::BLACK }) } fn fg(&mut self, color: color::Color) -> IoResult<bool> { self.foreground = color; self.apply(); ...
{ self.buf.flush() }
identifier_body
win.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...
(&mut self) { let _unused = self.buf.flush(); let mut accum: libc::WORD = 0; accum |= color_to_bits(self.foreground); accum |= color_to_bits(self.background) << 4; unsafe { // Magic -11 means stdout, from // http://msdn.microsoft.com/en-us/library/windows...
apply
identifier_name
22-code.rs
fn
() { let x = 5u8; let y = "Cold".to_string(); call_method(x); call_method(y); // dynamit dispatch let x1: u8 = 1; let y1: String = "Cool".to_string(); let x1obj = TraitObj { data: &x1, vtable: &F1_for_u8_vtable }; let y1obj = TraitObj { data: &y1, ...
main
identifier_name
22-code.rs
fn main() { let x = 5u8; let y = "Cold".to_string(); call_method(x); call_method(y); // dynamit dispatch let x1: u8 = 1; let y1: String = "Cool".to_string(); let x1obj = TraitObj { data: &x1, vtable: &F1_for_u8_vtable }; let y1obj = TraitObj { data: &y1...
_vtable: F1Vtable = F1Vtable { destructor: /* */, size: 1, align: 1, method: call_method_on_u8 as fn(*const ()) -> String, } fn call_method_on_String(x: *const ()) -> String { let string: &String = unsafe { &*(x as *const String) }; string.method() } static F1_for_String_vtable: F1Vtable = F1...
8 = unsafe { &*(x as *const u8) }; byte.method() } static F1_for_u8
identifier_body
22-code.rs
fn main() { let x = 5u8; let y = "Cold".to_string(); call_method(x); call_method(y); // dynamit dispatch let x1: u8 = 1; let y1: String = "Cool".to_string(); let x1obj = TraitObj { data: &x1, vtable: &F1_for_u8_vtable }; let y1obj = TraitObj { data: &y1...
fn call_method<T:F1>(x: T) { println!("{}", x.method()); } // dynamic dispatch pub struct TraitObj { // two pointer pub data: *mut (), // addresses the data of type T pub vtable: *mut (), // vtable(virtual method table) Foo 在 T 上的实现 // a struct of function pointers, pointing to the concrete pie...
impl F1 for String { fn method(&self) -> String { format!("string : {}", *self) } }
random_line_split
context.rs
use alloc::arc::Arc; use alloc::boxed::Box; use collections::{BTreeMap, Vec}; use spin::Mutex; use arch; use context::file::File; use context::memory::{Grant, Memory, SharedMemory, Tls}; use syscall::data::Event; use sync::{WaitMap, WaitQueue}; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Status { Runnab...
/// Remove a file // TODO: adjust files vector to smaller size if possible pub fn remove_file(&self, i: usize) -> Option<File> { let mut files = self.files.lock(); if i < files.len() { files[i].take() } else { None } } }
None } }
random_line_split
context.rs
use alloc::arc::Arc; use alloc::boxed::Box; use collections::{BTreeMap, Vec}; use spin::Mutex; use arch; use context::file::File; use context::memory::{Grant, Memory, SharedMemory, Tls}; use syscall::data::Event; use sync::{WaitMap, WaitQueue}; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum
{ Runnable, Blocked, Exited(usize) } /// A context, which identifies either a process or a thread #[derive(Debug)] pub struct Context { /// The ID of this context pub id: usize, /// The ID of the parent context pub ppid: usize, /// The real user id pub ruid: u32, /// The real g...
Status
identifier_name
context.rs
use alloc::arc::Arc; use alloc::boxed::Box; use collections::{BTreeMap, Vec}; use spin::Mutex; use arch; use context::file::File; use context::memory::{Grant, Memory, SharedMemory, Tls}; use syscall::data::Event; use sync::{WaitMap, WaitQueue}; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Status { Runnab...
} /// Add a file to the lowest available slot. /// Return the file descriptor number or None if no slot was found pub fn add_file(&self, file: File) -> Option<usize> { let mut files = self.files.lock(); for (i, mut file_option) in files.iter_mut().enumerate() { if file_opti...
{ false }
conditional_block
build_gecko.rs
} #[cfg(feature = "bindgen")] mod bindings { use bindgen::{Builder, CodegenConfig}; use bindgen::callbacks::{EnumVariantCustomBehavior, EnumVariantValue, ParseCallbacks}; use regex::{Regex, RegexSet}; use std::cmp; use std::collections::{HashSet, HashMap}; use std::env; use std::fs::{self,...
{ let to = to.as_ref(); for entry in from.as_ref().read_dir()? { let entry = entry?; let path = entry.path(); callback(&path); fs::copy(&path, to.join(entry.file_name()))?; } Ok(()) }
identifier_body
build_gecko.rs
} }; for dir in SEARCH_PATHS.iter() { builder = builder.clang_arg("-I").clang_arg(dir.to_str().unwrap()); } builder = builder.include(add_include("mozilla-config.h")); if env::var("CARGO_FEATURE_GECKO_DEBUG").is_ok() { bu...
use std::thread; macro_rules! run_tasks { ($($task:expr,)+) => {
random_line_split
build_gecko.rs
); } } result }; static ref INCLUDE_RE: Regex = Regex::new(r#"#include\s*"(.+?)""#).unwrap(); static ref DISTDIR_PATH: PathBuf = { let path = PathBuf::from(env::var_os("MOZ_DIST").unwrap()); if!path.is_absolute() ||!path.is_dir() { ...
, }; for fixup in fixups.iter() { result = Regex::new(&fixup.pat).unwrap().replace_all(&result, &*fixup.rep) .into_owned().into(); } let bytes = result.into_bytes(); File::create(&out_file).unwrap().write_all(&bytes).expect("Unable to write output"); ...
{ panic!("Failed to generate bindings, flags: {:?}", command_line_opts); }
conditional_block
build_gecko.rs
builder.rustfmt_bindings(env::var_os("STYLO_RUSTFMT_BINDINGS").is_some()) } }; for dir in SEARCH_PATHS.iter() { builder = builder.clang_arg("-I").clang_arg(dir.to_str().unwrap()); } builder = builder.include(add_include("mozi...
generate
identifier_name
root.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/. */ /// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/d...
{ from: String, applicationType: String, traits: ActorTraits, } pub struct RootActor { pub tabs: Vec<String>, } impl Actor for RootActor { fn name(&self) -> String { "root".to_string() } fn handle_message(&self, registry: &ActorRegistry, ...
RootActorMsg
identifier_name
root.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/. */ /// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/d...
/// that perform more specific actions (tabs, addons, browser chrome, etc.) use actor::{Actor, ActorRegistry}; use actors::tab::{TabActor, TabActorMsg}; use protocol::JsonPacketStream; use serialize::json; use std::io::TcpStream; #[deriving(Encodable)] struct ActorTraits { sources: bool, highlightable: bool,...
/// Connection point for all new remote devtools interactions, providing lists of know actors
random_line_split
trait-inheritance-num0.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-M...
() {}
main
identifier_name
trait-inheritance-num0.rs
// Copyright 2012-2014 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. // Extending Num an...
// http://rust-lang.org/COPYRIGHT. //
random_line_split
trait-inheritance-num0.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-M...
pub fn main() {}
{ n.gt(&NumCast::from(1i).unwrap()) }
identifier_body
struct_visibility.rs
/* * MIT License * * Copyright (c) 2016 Johnathan Fercher * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy...
{ // pub for made the struct accessible pub i: u8, // pub for made the field accessible j: u8, // inaccessible } impl Test { pub fn new() -> Test { // accessible Test { i: 0, j: 0, ...
Test
identifier_name
struct_visibility.rs
/* * MIT License * * Copyright (c) 2016 Johnathan Fercher * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy...
fn test() { // inaccessible } } } use my::Test; // removes the necessite to call Test like my::Test fn main() { let test: Test = Test::new(); }
{ // accessible Test { i: 0, j: 0, } }
identifier_body
struct_visibility.rs
/* * MIT License * * Copyright (c) 2016 Johnathan Fercher * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy...
} } fn test() { // inaccessible } } } use my::Test; // removes the necessite to call Test like my::Test fn main() { let test: Test = Test::new(); }
pub fn new() -> Test { // accessible Test { i: 0, j: 0,
random_line_split
mod.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 ...
unnormalized_env); let predicates: Vec<_> = util::elaborate_predicates(tcx, unnormalized_env.caller_bounds.clone()) .filter(|p|!p.is_global()) // (*) .collect(); // (*) Any predicate like `i32: Trait<u32>` or whatever doesn't // need to be in the *environment* to be proven...
let span = cause.span; let body_id = cause.body_id; debug!("normalize_param_env_or_error(unnormalized_env={:?})",
random_line_split
mod.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 ...
(span: Span, body_id: ast::NodeId) -> ObligationCause<'tcx> { ObligationCause { span: span, body_id: body_id, code: MiscObligation } } pub fn dummy() -> ObligationCause<'tcx> { ObligationCause { span: DUMMY_SP, body_id: 0, code: MiscObligation } } } impl<'tcx, N> Vtable<'tcx, N> { pub ...
misc
identifier_name
mod.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 ...
ty, bound); true } Err(e) => { debug!("type_known_to_meet_builtin_bound: ty={:?} bound={:?} errors={:?}", ty, bound, e); false } } } // FIXME: this is gonna ne...
{ debug!("type_known_to_meet_builtin_bound(ty={:?}, bound={:?})", ty, bound); let mut fulfill_cx = FulfillmentContext::new(false); // We can use a dummy node-id here because we won't pay any mind // to region obligations that arise (there shouldn't really be any // anyhow). ...
identifier_body
constellation_msg.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/. */ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling...
write!(fmt, "({},{})", namespace_id, index.get()) } } thread_local!(pub static TOP_LEVEL_BROWSING_CONTEXT_ID: Cell<Option<TopLevelBrowsingContextId>> = Cell::new(None)); #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)] pub struct TopLevelBrowsingCon...
impl fmt::Display for BrowsingContextId { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let PipelineNamespaceId(namespace_id) = self.namespace_id; let BrowsingContextIndex(index) = self.index;
random_line_split
constellation_msg.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/. */ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling...
} impl fmt::Display for BrowsingContextId { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let PipelineNamespaceId(namespace_id) = self.namespace_id; let BrowsingContextIndex(index) = self.index; write!(fmt, "({},{})", namespace_id, index.get()) } } thread_local!(pub static ...
{ PIPELINE_NAMESPACE.with(|tls| { let mut namespace = tls.get().expect("No namespace set for this thread!"); let new_browsing_context_id = namespace.next_browsing_context_id(); tls.set(Some(namespace)); new_browsing_context_id }) }
identifier_body
constellation_msg.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/. */ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling...
(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let PipelineNamespaceId(namespace_id) = self.namespace_id; let BrowsingContextIndex(index) = self.index; write!(fmt, "({},{})", namespace_id, index.get()) } } thread_local!(pub static TOP_LEVEL_BROWSING_CONTEXT_ID: Cell<Option<TopLevelBrows...
fmt
identifier_name
cave-4.rs
use std::io::BufRead; // Meet-in-the-middle algorithm using binary search. fn read_int() -> usize { let stdin = std::io::stdin(); let line = stdin.lock().lines().next().unwrap().unwrap(); line.parse::<usize>().unwrap() } fn read_weight() -> usize { let stdin = std::io::stdin(); let line = stdin.l...
} weights[lo] } fn main() { // read input let backpack = read_weight(); let n = read_int(); let nuggets: Vec<usize> = (0..n).map(|_| read_weight()).collect(); // split nuggets into two sets A and B let (a, b) = nuggets.split_at(n as usize / 2); // compute weights for all subsets ...
{ hi = mid; }
conditional_block
cave-4.rs
use std::io::BufRead; // Meet-in-the-middle algorithm using binary search. fn read_int() -> usize
fn read_weight() -> usize { let stdin = std::io::stdin(); let line = stdin.lock().lines().next().unwrap(); let numbers: Vec<usize> = line.unwrap().split('.').map(|n| n.parse().unwrap()).collect(); 10_000_000 * numbers[0] + numbers[1] } fn print_weight(w: usize) { println!("{}.{:07}", w / ...
{ let stdin = std::io::stdin(); let line = stdin.lock().lines().next().unwrap().unwrap(); line.parse::<usize>().unwrap() }
identifier_body
cave-4.rs
use std::io::BufRead; // Meet-in-the-middle algorithm using binary search. fn read_int() -> usize { let stdin = std::io::stdin(); let line = stdin.lock().lines().next().unwrap().unwrap(); line.parse::<usize>().unwrap() } fn read_weight() -> usize { let stdin = std::io::stdin(); let line = stdin.l...
best = (wb.0 << a.len() | wa.0, combined_weight); } } // print results print_weight(best.1); for i in 0..n { if 1 << i & best.0!= 0 { print_weight(nuggets[i as usize]); } } }
let wb = find_closest(backpack - wa.1, &weights_b); let combined_weight = wa.1 + wb.1; if combined_weight > best.1 {
random_line_split
cave-4.rs
use std::io::BufRead; // Meet-in-the-middle algorithm using binary search. fn read_int() -> usize { let stdin = std::io::stdin(); let line = stdin.lock().lines().next().unwrap().unwrap(); line.parse::<usize>().unwrap() } fn read_weight() -> usize { let stdin = std::io::stdin(); let line = stdin.l...
(w: usize) { println!("{}.{:07}", w / 10_000_000, w % 10_000_000); } // Compute the weight of every possible combination of nuggets. fn compute_weights(nuggets: &[usize]) -> Vec<(usize, usize)> { let n = nuggets.len(); let mut weights = Vec::with_capacity(1 << n); weights.push(...
print_weight
identifier_name
rust_base64.rs
extern crate base64; use errors::prelude::*; use failure::ResultExt; pub fn encode(doc: &[u8]) -> String { base64::encode(doc) } pub fn decode(doc: &str) -> Result<Vec<u8>, IndyError> { base64::decode(doc) .context("Invalid base64 sequence") .context(IndyErrorKind::InvalidStructure) .map...
(doc: &[u8]) -> String { base64::encode_config(doc, base64::URL_SAFE) } pub fn decode_urlsafe(doc: &str) -> Result<Vec<u8>, IndyError> { base64::decode_config(doc, base64::URL_SAFE) .context("Invalid base64URL_SAFE sequence") .context(IndyErrorKind::InvalidStructure) .map_err(|err| err.int...
encode_urlsafe
identifier_name
rust_base64.rs
extern crate base64; use errors::prelude::*; use failure::ResultExt; pub fn encode(doc: &[u8]) -> String { base64::encode(doc) } pub fn decode(doc: &str) -> Result<Vec<u8>, IndyError> { base64::decode(doc) .context("Invalid base64 sequence") .context(IndyErrorKind::InvalidStructure) .map...
} #[test] fn decode_urlsafe_works() { let result = decode_urlsafe("AQID"); assert!(result.is_ok(), "Got error"); assert_eq!(&[1, 2, 3], &result.unwrap()[..]); } }
fn encode_urlsafe_works() { let result = encode_urlsafe(&[1, 2, 3]); assert_eq!("AQID", &result);
random_line_split
rust_base64.rs
extern crate base64; use errors::prelude::*; use failure::ResultExt; pub fn encode(doc: &[u8]) -> String { base64::encode(doc) } pub fn decode(doc: &str) -> Result<Vec<u8>, IndyError> { base64::decode(doc) .context("Invalid base64 sequence") .context(IndyErrorKind::InvalidStructure) .map...
}
{ let result = decode_urlsafe("AQID"); assert!(result.is_ok(), "Got error"); assert_eq!(&[1, 2, 3], &result.unwrap()[..]); }
identifier_body
main.rs
use std::str; use std::u32; use std::fmt::Write; extern crate crypto; use crypto::md5::Md5; use crypto::digest::Digest; // It takes two hex digits to make a byte, so check // the first 2.5 bytes for zero values fn first_five_hex_zero(input: &[u8; 16]) -> bool { let sum = (input[0] as u32) + (input[1] as u32) + (i...
if index < 8 { if password_part2_bytes[index as usize] == 0 { password_part2_bytes[index as usize] = next_char as u8; set_characters += 1; } } } } if set_characters == tar...
let next_char = get_seventh_hex_char(&hash_output); if let Some(index) = next_pos.to_digit(10) {
random_line_split
main.rs
use std::str; use std::u32; use std::fmt::Write; extern crate crypto; use crypto::md5::Md5; use crypto::digest::Digest; // It takes two hex digits to make a byte, so check // the first 2.5 bytes for zero values fn first_five_hex_zero(input: &[u8; 16]) -> bool { let sum = (input[0] as u32) + (input[1] as u32) + (...
fn get_seventh_hex_char(input: &[u8; 16]) -> char { let mut buff = String::new(); let _ = write!(buff,"{:x}", input[3] >> 4); buff.as_bytes()[0] as char } fn main() { // Puzzle input let door_id = "reyedfim"; let mut hasher = Md5::new(); let mut password = "".to_owned(); let target_...
{ let mut buff = String::new(); let _ = write!(buff,"{:x}", input[2]); buff.as_bytes()[0] as char }
identifier_body
main.rs
use std::str; use std::u32; use std::fmt::Write; extern crate crypto; use crypto::md5::Md5; use crypto::digest::Digest; // It takes two hex digits to make a byte, so check // the first 2.5 bytes for zero values fn first_five_hex_zero(input: &[u8; 16]) -> bool { let sum = (input[0] as u32) + (input[1] as u32) + (...
() { // Puzzle input let door_id = "reyedfim"; let mut hasher = Md5::new(); let mut password = "".to_owned(); let target_password_length = 8; // Static buffer to hold the result let mut hash_output = [0u8; 16]; // Loop through door_id + [0..max] to find hashes that // start with ...
main
identifier_name
main.rs
use std::str; use std::u32; use std::fmt::Write; extern crate crypto; use crypto::md5::Md5; use crypto::digest::Digest; // It takes two hex digits to make a byte, so check // the first 2.5 bytes for zero values fn first_five_hex_zero(input: &[u8; 16]) -> bool { let sum = (input[0] as u32) + (input[1] as u32) + (...
} println!("Part 1: password = '{}'", password); assert!(password == "f97c354d"); // Part 2 let mut password_part2_bytes = [0u8; 8]; //" ".as_bytes(); let mut set_characters = 0; // Loop through door_id + [0..max] to find hashes that // start with five zeros for i in 0..u32:...
{ break; }
conditional_block
compaction_filter.rs
//! `CompactionFilter` allows an application to modify/delete a key-value at //! the time of compaction. use std::os::raw::{c_char, c_int}; use rocks_sys as ll; #[repr(C)] #[derive(Debug, PartialEq, PartialOrd, Eq, Ord, Copy, Clone)] pub enum ValueType { Value = 0, MergeOperand = 1, } #[derive(Debug)] pub e...
mod tests { use crate::rocksdb::*; use super::*; use lazy_static::lazy_static; pub struct MyCompactionFilter; impl CompactionFilter for MyCompactionFilter { fn filter(&mut self, level: i32, key: &[u8], value_type: ValueType, existing_value: &[u8]) -> Decision { assert_eq!(value...
} #[cfg(test)]
random_line_split
compaction_filter.rs
//! `CompactionFilter` allows an application to modify/delete a key-value at //! the time of compaction. use std::os::raw::{c_char, c_int}; use rocks_sys as ll; #[repr(C)] #[derive(Debug, PartialEq, PartialOrd, Eq, Ord, Copy, Clone)] pub enum ValueType { Value = 0, MergeOperand = 1, } #[derive(Debug)] pub e...
(&self) -> bool { true } /// Returns a name that identifies this compaction filter. /// The name will be printed to LOG file on start up for diagnosis. fn name(&self) -> &str { "RustCompactionFilterV2\0" } } /// Each compaction will create a new `CompactionFilter` allowing the /// ...
ignore_snapshots
identifier_name
dataflow.rs
use rustc_data_structures::fx::FxHashMap; use rustc_index::bit_set::BitSet; use rustc_middle::mir::{self, BasicBlock, Body, Location, Place}; use rustc_middle::ty::RegionVid; use rustc_middle::ty::TyCtxt; use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces}; use rustc_mir_dataflow::ResultsVi...
fn call_return_effect( &self, _trans: &mut impl GenKill<Self::Idx>, _block: mir::BasicBlock, _func: &mir::Operand<'tcx>, _args: &[mir::Operand<'tcx>], _dest_place: mir::Place<'tcx>, ) { } } impl DebugWithContext<Borrows<'_, '_>> for BorrowIndex { fn fmt...
{ if let mir::TerminatorKind::InlineAsm { operands, .. } = &teminator.kind { for op in operands { if let mir::InlineAsmOperand::Out { place: Some(place), .. } | mir::InlineAsmOperand::InOut { out_place: Some(place), .. } = *op { sel...
identifier_body
dataflow.rs
use rustc_data_structures::fx::FxHashMap; use rustc_index::bit_set::BitSet; use rustc_middle::mir::{self, BasicBlock, Body, Location, Place}; use rustc_middle::ty::RegionVid; use rustc_middle::ty::TyCtxt; use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces}; use rustc_mir_dataflow::ResultsVi...
trans.gen(index); } // Make sure there are no remaining borrows for variables // that are assigned over. self.kill_borrows_on_place(trans, lhs); } mir::StatementKind::StorageDead(local) => { //...
} let index = self.borrow_set.get_index_of(&location).unwrap_or_else(|| { panic!("could not find BorrowIndex for location {:?}", location); });
random_line_split
dataflow.rs
use rustc_data_structures::fx::FxHashMap; use rustc_index::bit_set::BitSet; use rustc_middle::mir::{self, BasicBlock, Body, Location, Place}; use rustc_middle::ty::RegionVid; use rustc_middle::ty::TyCtxt; use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces}; use rustc_mir_dataflow::ResultsVi...
mir::StatementKind::LlvmInlineAsm(ref asm) => { for (output, kind) in iter::zip(&*asm.outputs, &asm.asm.outputs) { if!kind.is_indirect &&!kind.is_rw { self.kill_borrows_on_place(trans, *output); } } ...
{ // Make sure there are no remaining borrows for locals that // are gone out of scope. self.kill_borrows_on_place(trans, Place::from(local)); }
conditional_block
dataflow.rs
use rustc_data_structures::fx::FxHashMap; use rustc_index::bit_set::BitSet; use rustc_middle::mir::{self, BasicBlock, Body, Location, Place}; use rustc_middle::ty::RegionVid; use rustc_middle::ty::TyCtxt; use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces}; use rustc_mir_dataflow::ResultsVi...
<B, U, E> { pub borrows: B, pub uninits: U, pub ever_inits: E, } /// The results of the dataflow analyses used by the borrow checker. pub type BorrowckResults<'mir, 'tcx> = BorrowckAnalyses< Results<'tcx, Borrows<'mir, 'tcx>>, Results<'tcx, MaybeUninitializedPlaces<'mir, 'tcx>>, Results<'tcx, E...
BorrowckAnalyses
identifier_name
overflowing-rsh-4.rs
// build-fail // compile-flags: -C debug-assertions // This function is checking that our (type-based) automatic // truncation does not sidestep the overflow checking. #![deny(arithmetic_overflow, const_err)] fn main() { // this signals overflow when checking is on let x = 2_i8 >> 17; //~^ ERROR: this ar...
// produce the error expected above). assert_eq!(x, 1_i8); }
// overflow checking is turned off, then this assertion will pass // (and the compiletest driver will report that the test did not
random_line_split
overflowing-rsh-4.rs
// build-fail // compile-flags: -C debug-assertions // This function is checking that our (type-based) automatic // truncation does not sidestep the overflow checking. #![deny(arithmetic_overflow, const_err)] fn main()
{ // this signals overflow when checking is on let x = 2_i8 >> 17; //~^ ERROR: this arithmetic operation will overflow // ... but when checking is off, the fallback will truncate the // input to its lower three bits (= 1). Note that this is *not* // the behavior of the x86 processor for 8- and ...
identifier_body
overflowing-rsh-4.rs
// build-fail // compile-flags: -C debug-assertions // This function is checking that our (type-based) automatic // truncation does not sidestep the overflow checking. #![deny(arithmetic_overflow, const_err)] fn
() { // this signals overflow when checking is on let x = 2_i8 >> 17; //~^ ERROR: this arithmetic operation will overflow //... but when checking is off, the fallback will truncate the // input to its lower three bits (= 1). Note that this is *not* // the behavior of the x86 processor for 8- an...
main
identifier_name
macros.rs
codespan_reporting::diagnostic::Diagnostic, downcast_rs::{impl_downcast, Downcast}, futures::{prelude::*, task::Spawn}, }; use gluon_codegen::Trace; use crate::base::{ ast::{self, Expr, MutVisitor, SpannedExpr}, error::{AsDiagnostic, Errors as BaseErrors, Salvage, SalvageResult}, fnv::FnvMap, ...
} impl<'ast, F> From<F> for LazyMacroResult<'ast> where for<'a> F: FnOnce() -> Pin<Box<dyn Future<Output = SalvageMacroResult<'ast>> + Send + 'ast>> + Send + 'ast, { fn from(r: F) -> Self { Self::Lazy(Box::new(r)) } } pub type MacroFuture<'r, 'ast> = Pin<Box<dyn Future<Output ...
{ Self::Done(r) }
identifier_body
macros.rs
codespan_reporting::diagnostic::Diagnostic, downcast_rs::{impl_downcast, Downcast}, futures::{prelude::*, task::Spawn}, }; use gluon_codegen::Trace; use crate::base::{ ast::{self, Expr, MutVisitor, SpannedExpr}, error::{AsDiagnostic, Errors as BaseErrors, Salvage, SalvageResult}, fnv::FnvMap, ...
(&self, other: &Self) -> bool { self.0.eq_error(&*other.0) } } impl std::hash::Hash for Error { fn hash<H>(&self, state: &mut H) where H: std::hash::Hasher, { self.0.hash_error(state) } } impl Error { pub fn new<E>(err: E) -> Self where E: MacroError, { ...
eq
identifier_name
macros.rs
codespan_reporting::diagnostic::Diagnostic, downcast_rs::{impl_downcast, Downcast}, futures::{prelude::*, task::Spawn}, }; use gluon_codegen::Trace; use crate::base::{ ast::{self, Expr, MutVisitor, SpannedExpr}, error::{AsDiagnostic, Errors as BaseErrors, Salvage, SalvageResult}, fnv::FnvMap, ...
} fn replace_expr<'ast>( arena: &ast::OwnedArena<'ast, Symbol>, expr: &mut SpannedExpr<'ast, Symbol>, new: Expr<'ast, Symbol>, ) { let expr_span = expr.span; let original = mem::replace(expr, pos::spanned(expr_span, Expr::Error(None))); *expr = pos::spanned( expr.span, Expr::Mac...
.extend(unordered_errors.into_iter().map(|(_, err)| err)); }
random_line_split
wl_data_source.rs
// Copyright 2014 Jonathan Eyolfson use libc::{c_char, c_int, c_void, uint32_t}; use raw; use raw::types::listeners; use raw::types::objects; pub const WL_DATA_SOURCE_OFFER: uint32_t = 0; pub const WL_DATA_SOURCE_DESTROY: uint32_t = 1; #[inline(always)] pub unsafe fn wl_data_source_add_listener( wl_data_source:...
pub unsafe fn wl_data_source_set_user_data( wl_data_source: *mut objects::wl_data_source, user_data: *mut c_void ) { raw::wl_proxy_set_user_data( wl_data_source as *mut objects::wl_proxy, user_data ) } #[inline(always)] pub unsafe fn wl_data_source_get_user_data( wl_data_source: *mu...
#[inline(always)]
random_line_split
wl_data_source.rs
// Copyright 2014 Jonathan Eyolfson use libc::{c_char, c_int, c_void, uint32_t}; use raw; use raw::types::listeners; use raw::types::objects; pub const WL_DATA_SOURCE_OFFER: uint32_t = 0; pub const WL_DATA_SOURCE_DESTROY: uint32_t = 1; #[inline(always)] pub unsafe fn wl_data_source_add_listener( wl_data_source:...
( wl_data_source: *mut objects::wl_data_source ) -> *mut c_void { raw::wl_proxy_get_user_data(wl_data_source as *mut objects::wl_proxy) } #[inline(always)] pub unsafe fn wl_data_source_offer( wl_data_source: *mut objects::wl_data_source, mime_type: *const c_char ) { raw::wl_proxy_marshal( w...
wl_data_source_get_user_data
identifier_name
wl_data_source.rs
// Copyright 2014 Jonathan Eyolfson use libc::{c_char, c_int, c_void, uint32_t}; use raw; use raw::types::listeners; use raw::types::objects; pub const WL_DATA_SOURCE_OFFER: uint32_t = 0; pub const WL_DATA_SOURCE_DESTROY: uint32_t = 1; #[inline(always)] pub unsafe fn wl_data_source_add_listener( wl_data_source:...
#[inline(always)] pub unsafe fn wl_data_source_offer( wl_data_source: *mut objects::wl_data_source, mime_type: *const c_char ) { raw::wl_proxy_marshal( wl_data_source as *mut objects::wl_proxy, WL_DATA_SOURCE_OFFER, mime_type ) } #[inline(always)] pub unsafe fn wl_data_source_...
{ raw::wl_proxy_get_user_data(wl_data_source as *mut objects::wl_proxy) }
identifier_body
associated-types-cc.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 ...
extern crate associated_types_cc_lib as bar; use bar::Bar; fn foo<B:Bar>(b: B) -> <B as Bar>::T { Bar::get(None::<B>) } fn main() { println!("{}", foo(3)); }
random_line_split
associated-types-cc.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 ...
{ println!("{}", foo(3)); }
identifier_body
associated-types-cc.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 ...
() { println!("{}", foo(3)); }
main
identifier_name
object-method-numbering.rs
// Copyright 2015 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 ...
<T:SomeTrait<SomeType=i32>+?Sized>(x: &T) -> i32 { x.get() } impl SomeTrait for i32 { type SomeType = i32; fn get(&self) -> i32 { *self } } fn main() { let x = 22; let x1: &SomeTrait<SomeType=i32> = &x; let y = get_int(x1); assert_eq!(x, y); }
get_int
identifier_name
object-method-numbering.rs
// Copyright 2015 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 x = 22; let x1: &SomeTrait<SomeType=i32> = &x; let y = get_int(x1); assert_eq!(x, y); }
identifier_body
object-method-numbering.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT.
// 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. // Test for using an object with an associated type binding as the // instantiation for ...
// // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
random_line_split
over_nano.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
#[test] fn can_create_client() { let client = nanoipc::init_duplex_client::<ServiceClient<_>>("ipc:///tmp/parity-nano-test10.ipc"); assert!(client.is_ok()); } #[test] fn can_create_renamed_client() { let client = nanoipc::init_duplex_client::<PrettyNamedClient<_>>("ipc:///tmp/parity-nano-test10.ipc"); a...
{ let mut worker = nanoipc::Worker::<Service>::new(&Arc::new(Service::new())); worker.add_duplex(addr).unwrap(); worker }
identifier_body
over_nano.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
(addr: &str) -> nanoipc::Worker<Service> { let mut worker = nanoipc::Worker::<Service>::new(&Arc::new(Service::new())); worker.add_duplex(addr).unwrap(); worker } #[test] fn can_create_client() { let client = nanoipc::init_duplex_client::<ServiceClient<_>>("ipc:///tmp/parity-nano-test10.ipc"); assert!(cli...
init_worker
identifier_name
over_nano.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
fn init_worker(addr: &str) -> nanoipc::Worker<Service> { let mut worker = nanoipc::Worker::<Service>::new(&Arc::new(Service::new())); worker.add_duplex(addr).unwrap(); worker } #[test] fn can_create_client() { let client = nanoipc::init_duplex_client::<ServiceClient<_>>("ipc:///tmp/parity-nano-test10.ipc"...
random_line_split
ext.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use syn::{Data, DataEnum, DataStruct, DataUnion, Field, Fields, Type}; pub trait DataExt { fn nested_types(&self) -> Vec<&Type>; } impl DataExt for D...
} impl DataExt for DataUnion { fn nested_types(&self) -> Vec<&Type> { field_iter_to_types(&self.fields.named) } } fn fields_to_types(fields: &Fields) -> Vec<&Type> { match fields { Fields::Named(named) => field_iter_to_types(&named.named), Fields::Unnamed(unnamed) => field_iter_to...
{ self.nested_types().is_empty() }
identifier_body
ext.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use syn::{Data, DataEnum, DataStruct, DataUnion, Field, Fields, Type}; pub trait DataExt { fn nested_types(&self) -> Vec<&Type>; } impl DataExt for D...
(&self) -> bool { self.nested_types().is_empty() } } impl DataExt for DataUnion { fn nested_types(&self) -> Vec<&Type> { field_iter_to_types(&self.fields.named) } } fn fields_to_types(fields: &Fields) -> Vec<&Type> { match fields { Fields::Named(named) => field_iter_to_types(&n...
is_c_like
identifier_name
ext.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use syn::{Data, DataEnum, DataStruct, DataUnion, Field, Fields, Type}; pub trait DataExt { fn nested_types(&self) -> Vec<&Type>; } impl DataExt for D...
impl DataExt for DataEnum { fn nested_types(&self) -> Vec<&Type> { self.variants.iter().map(|var| fields_to_types(&var.fields)).fold(Vec::new(), |mut a, b| { a.extend(b); a }) } } pub trait EnumExt { fn is_c_like(&self) -> bool; } impl EnumExt for DataEnum { fn ...
} }
random_line_split
serial.rs
//! contains class Serial - singleton for writing symbols to serial port. use ::fmt; use ::ioports::*; use ::utility::*; const PORT: u16 = 0x3f8; static mut PORT_0: IOPort<(), u8> = IOPort::new(PORT + 0); static mut PORT_1: IOPort<(), u8> = IOPort::new(PORT + 1); // static mut PORT_2: IOPort<(), u8> = IOPort::new(PO...
pub fn get() -> &'static mut Self { static mut INIT: bool = false; unsafe { if!INIT { // Disable all interrupts PORT_1.write(0b0000_0000); // Enable DLAB (set baud rate divisor) PORT_3.write(0b1000_0000); //...
pub struct Serial; static mut OBJECT: Serial = Serial { }; impl Serial {
random_line_split
serial.rs
//! contains class Serial - singleton for writing symbols to serial port. use ::fmt; use ::ioports::*; use ::utility::*; const PORT: u16 = 0x3f8; static mut PORT_0: IOPort<(), u8> = IOPort::new(PORT + 0); static mut PORT_1: IOPort<(), u8> = IOPort::new(PORT + 1); // static mut PORT_2: IOPort<(), u8> = IOPort::new(PO...
} unsafe { &mut OBJECT } } } impl fmt::Write for Serial { fn write_char(&mut self, c: char) -> fmt::Result { loop { let free = unsafe { get_bit(PORT_5.read(), 5) }; if free { unsafe { PORT_0.write(c as u8) }; break; }...
{ // Disable all interrupts PORT_1.write(0b0000_0000); // Enable DLAB (set baud rate divisor) PORT_3.write(0b1000_0000); // Set divisor to 3 (lo byte) 38400 baud PORT_0.write(0b0000_0011); // ...
conditional_block
serial.rs
//! contains class Serial - singleton for writing symbols to serial port. use ::fmt; use ::ioports::*; use ::utility::*; const PORT: u16 = 0x3f8; static mut PORT_0: IOPort<(), u8> = IOPort::new(PORT + 0); static mut PORT_1: IOPort<(), u8> = IOPort::new(PORT + 1); // static mut PORT_2: IOPort<(), u8> = IOPort::new(PO...
fn write_str(&mut self, s: &str) -> fmt::Result { for char in s.chars() { try!(self.write_char(char)); } Ok(()) } }
{ loop { let free = unsafe { get_bit(PORT_5.read(), 5) }; if free { unsafe { PORT_0.write(c as u8) }; break; } } Ok(()) }
identifier_body
serial.rs
//! contains class Serial - singleton for writing symbols to serial port. use ::fmt; use ::ioports::*; use ::utility::*; const PORT: u16 = 0x3f8; static mut PORT_0: IOPort<(), u8> = IOPort::new(PORT + 0); static mut PORT_1: IOPort<(), u8> = IOPort::new(PORT + 1); // static mut PORT_2: IOPort<(), u8> = IOPort::new(PO...
; static mut OBJECT: Serial = Serial { }; impl Serial { pub fn get() -> &'static mut Self { static mut INIT: bool = false; unsafe { if!INIT { // Disable all interrupts PORT_1.write(0b0000_0000); // Enable DLAB (set baud rate divisor) ...
Serial
identifier_name
alt-borrowed_str.rs
// xfail-test // xfail-fast // -*- rust -*- fn f1(ref_string: &str) { match ref_string { "a" => io::println("found a"), "b" => io::println("found b"), _ => io::println("not found") } } fn f2(ref_string: &str) { match ref_string { "a" => io::println("found a"), "b" =>...
() { f1(@"a"); f1(~"b"); f1(&"c"); f1("d"); f2(@"a"); f2(~"b"); f2(&"c"); f2("d"); g1(@"a", @"b"); g1(~"b", ~"c"); g1(&"c", &"d"); g1("d", "e"); g2(@"a", @"b"); g2(~"b", ~"c"); g2(&"c", &"d"); g2("d", "e"); }
main
identifier_name
alt-borrowed_str.rs
// xfail-test // xfail-fast // -*- rust -*- fn f1(ref_string: &str) { match ref_string { "a" => io::println("found a"), "b" => io::println("found b"), _ => io::println("not found") } } fn f2(ref_string: &str)
fn g1(ref_1: &str, ref_2: &str) { match (ref_1, ref_2) { ("a", "b") => io::println("found a,b"), ("b", "c") => io::println("found b,c"), _ => io::println("not found") } } fn g2(ref_1: &str, ref_2: &str) { match (ref_1, ref_2) { ("a", "b") => io::println("found a,b"), ...
{ match ref_string { "a" => io::println("found a"), "b" => io::println("found b"), s => io::println(fmt!("not found (%s)", s)) } }
identifier_body
alt-borrowed_str.rs
// xfail-test // xfail-fast // -*- rust -*- fn f1(ref_string: &str) { match ref_string { "a" => io::println("found a"), "b" => io::println("found b"), _ => io::println("not found") } } fn f2(ref_string: &str) { match ref_string { "a" => io::println("found a"), "b" =>...
f1("d"); f2(@"a"); f2(~"b"); f2(&"c"); f2("d"); g1(@"a", @"b"); g1(~"b", ~"c"); g1(&"c", &"d"); g1("d", "e"); g2(@"a", @"b"); g2(~"b", ~"c"); g2(&"c", &"d"); g2("d", "e"); }
f1(&"c");
random_line_split
rust_string.rs
extern crate tor_util; extern crate libc; use std::ffi::CString; use tor_util::RustString; #[test] fn rust_string_conversions_preserve_c_string() { let s = CString::new("asdf foo").unwrap(); let r = RustString::from(s.clone()); let r2 = RustString::from(s.clone()); let c = r2.as_ptr(); assert_eq!(...
() { let s = CString::new("").unwrap(); let r = RustString::from(s.clone()); let c = r.as_ptr(); assert_eq!(unsafe { libc::strlen(c) }, 0); let c_str = r.into(); assert_eq!(s, c_str); } #[test] fn c_string_with_unicode() { // The euro sign is three bytes let s = CString::new("asd€asd")....
empty_string
identifier_name
rust_string.rs
extern crate tor_util; extern crate libc; use std::ffi::CString; use tor_util::RustString; #[test] fn rust_string_conversions_preserve_c_string()
#[test] fn empty_string() { let s = CString::new("").unwrap(); let r = RustString::from(s.clone()); let c = r.as_ptr(); assert_eq!(unsafe { libc::strlen(c) }, 0); let c_str = r.into(); assert_eq!(s, c_str); } #[test] fn c_string_with_unicode() { // The euro sign is three bytes let s =...
{ let s = CString::new("asdf foo").unwrap(); let r = RustString::from(s.clone()); let r2 = RustString::from(s.clone()); let c = r2.as_ptr(); assert_eq!(unsafe { libc::strlen(c) }, 8); let c_str = r.into(); assert_eq!(s, c_str); }
identifier_body
rust_string.rs
extern crate tor_util; extern crate libc;
let s = CString::new("asdf foo").unwrap(); let r = RustString::from(s.clone()); let r2 = RustString::from(s.clone()); let c = r2.as_ptr(); assert_eq!(unsafe { libc::strlen(c) }, 8); let c_str = r.into(); assert_eq!(s, c_str); } #[test] fn empty_string() { let s = CString::new("").unwrap...
use std::ffi::CString; use tor_util::RustString; #[test] fn rust_string_conversions_preserve_c_string() {
random_line_split