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 |
|---|---|---|---|---|
handler.rs | use Reset;
use epoll::*;
use error::*; |
#[derive(Debug)]
pub struct SyncMux<'m, H, P, R> {
epfd: EpollFd,
handlers: Slab<H, usize>,
resources: Vec<R>,
factory: P,
interests: EpollEventKind,
_marker: ::std::marker::PhantomData<&'m ()>,
}
impl<'m, H, P, R> SyncMux<'m, H, P, R>
where H: Handler<MuxEvent<'m, R>, MuxCmd> + EpollHandler,
P:... | use handler::*;
use nix::sys::socket::*;
use slab::Slab;
use super::*;
use super::action::*; | random_line_split |
handler.rs | use Reset;
use epoll::*;
use error::*;
use handler::*;
use nix::sys::socket::*;
use slab::Slab;
use super::*;
use super::action::*;
#[derive(Debug)]
pub struct SyncMux<'m, H, P, R> {
epfd: EpollFd,
handlers: Slab<H, usize>,
resources: Vec<R>,
factory: P,
interests: EpollEventKind,
_marker: ::std::marker::P... | (&self) -> Self {
SyncMux {
epfd: self.epfd,
handlers: Slab::with_capacity(self.handlers.capacity()),
resources: vec!(self.factory.new_resource(); self.handlers.capacity()),
factory: self.factory.clone(),
interests: self.interests,
_marker: ::std::marker::PhantomData {},
}
... | clone | identifier_name |
handler.rs | use Reset;
use epoll::*;
use error::*;
use handler::*;
use nix::sys::socket::*;
use slab::Slab;
use super::*;
use super::action::*;
#[derive(Debug)]
pub struct SyncMux<'m, H, P, R> {
epfd: EpollFd,
handlers: Slab<H, usize>,
resources: Vec<R>,
factory: P,
interests: EpollEventKind,
_marker: ::std::marker::P... |
}
macro_rules! some {
($cmd:expr) => {{
match $cmd {
None => {
return;
},
Some(res) => res,
}
}}
}
impl<'m, H, P, R> Handler<EpollEvent, EpollCmd> for SyncMux<'m, H, P, R>
where H: Handler<MuxEvent<'m, R>, MuxCmd> + EpollHandler,
P: HandlerFactory<'m, H, R> +'m,
... | {
SyncMux {
epfd: epfd,
handlers: Slab::with_capacity(max_handlers),
resources: vec!(factory.new_resource(); max_handlers),
factory: factory,
interests: H::interests(),
_marker: ::std::marker::PhantomData {},
}
} | identifier_body |
lib.rs | extern crate coinaddress;
use coinaddress::{validate_base58_hash,validate_btc_address,validate_ltc_address,ValidationError};
#[test]
fn test_validate_hash() {
assert_eq!(validate_base58_hash("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"), Ok(0));
assert_eq!(validate_base58_hash("mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn"), ... | {
assert_eq!(validate_ltc_address("LRELGDJyeCPRDXz4Dh1kWorMN9hTBB7CEz"), Ok(48));
assert_eq!(validate_ltc_address("muen9zszN6rVwXaFw48xh6YkdUSjJcfzek"), Ok(111));
assert_eq!(validate_ltc_address("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"), Err(ValidationError::NotLitecoin));
} | identifier_body | |
lib.rs | extern crate coinaddress;
use coinaddress::{validate_base58_hash,validate_btc_address,validate_ltc_address,ValidationError};
#[test]
fn | () {
assert_eq!(validate_base58_hash("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"), Ok(0));
assert_eq!(validate_base58_hash("mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn"), Ok(111));
assert_eq!(validate_base58_hash("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYheX"), Err(ValidationError::HashMismatch));
assert_eq!(validate_base58_hash... | test_validate_hash | identifier_name |
lib.rs | extern crate coinaddress;
use coinaddress::{validate_base58_hash,validate_btc_address,validate_ltc_address,ValidationError};
#[test]
fn test_validate_hash() {
assert_eq!(validate_base58_hash("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"), Ok(0));
assert_eq!(validate_base58_hash("mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn"), ... | assert_eq!(validate_btc_address("mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn"), Ok(111));
assert_eq!(validate_btc_address("LRELGDJyeCPRDXz4Dh1kWorMN9hTBB7CEz"), Err(ValidationError::NotBitcoin));
}
#[test]
fn test_validate_ltc_address() {
assert_eq!(validate_ltc_address("LRELGDJyeCPRDXz4Dh1kWorMN9hTBB7CEz"), Ok(48)... | #[test]
fn test_validate_btc_address() {
assert_eq!(validate_btc_address("17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"), Ok(0));
assert_eq!(validate_btc_address("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX"), Ok(5)); | random_line_split |
document_state.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/. */
//! An invalidation processor for style changes due to document state changes.
use dom::TElement;
use element_sta... | (
&mut self,
_element: E,
self_invalidations: &mut InvalidationVector<'a>,
_descendant_invalidations: &mut DescendantInvalidationLists<'a>,
_sibling_invalidations: &mut InvalidationVector<'a>,
) -> bool {
for cascade_data in &mut self.rules {
let map = cas... | collect_invalidations | identifier_name |
document_state.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/. */
//! An invalidation processor for style changes due to document state changes.
use dom::TElement;
use element_sta... | }
/// An invalidation processor for style changes due to state and attribute
/// changes.
pub struct DocumentStateInvalidationProcessor<'a, E: TElement, I> {
// TODO(emilio): We might want to just run everything for every possible
// binding along with the document data, or just apply the XBL stuff to the
... | } | random_line_split |
document_state.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/. */
//! An invalidation processor for style changes due to document state changes.
use dom::TElement;
use element_sta... |
}
/// An invalidation processor for style changes due to state and attribute
/// changes.
pub struct DocumentStateInvalidationProcessor<'a, E: TElement, I> {
// TODO(emilio): We might want to just run everything for every possible
// binding along with the document data, or just apply the XBL stuff to the
... | {
Self {
document_state: DocumentState::empty(),
}
} | identifier_body |
map-types.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 ... | } | random_line_split | |
map-types.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: Box<HashMap<int, int>> = box HashMap::new();
let x: Box<Map<int, int>> = x;
let y: Box<Map<uint, int>> = box x;
//~^ ERROR failed to find an implementation of trait core::container::Map<uint,int>
// for ~core::container::Map<int,int>:Send
} | identifier_body | |
map-types.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: Box<HashMap<int, int>> = box HashMap::new();
let x: Box<Map<int, int>> = x;
let y: Box<Map<uint, int>> = box x;
//~^ ERROR failed to find an implementation of trait core::container::Map<uint,int>
// for ~core::container::Map<int,int>:Send
}
| main | identifier_name |
windows_base.rs | // 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 may not be copied, modified, or distributed
// except accordin... | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | random_line_split | |
windows_base.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 ... | () -> TargetOptions {
TargetOptions {
// FIXME(#13846) this should be enabled for windows
function_sections: false,
linker: "gcc".to_string(),
dynamic_linking: true,
executables: true,
dll_prefix: "".to_string(),
dll_suffix: ".dll".to_string(),
exe_suf... | opts | identifier_name |
windows_base.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 ... | // but COFF (at least according to LLVM). COFF doesn't officially allow
// for section names over 8 characters, apparently. Our metadata
// section, ".note.rustc", you'll note is over 8 characters.
//
// On more recent versions of gcc on mingw, apparently the ... | {
TargetOptions {
// FIXME(#13846) this should be enabled for windows
function_sections: false,
linker: "gcc".to_string(),
dynamic_linking: true,
executables: true,
dll_prefix: "".to_string(),
dll_suffix: ".dll".to_string(),
exe_suffix: ".exe".to_strin... | identifier_body |
mod.rs | //! Platform-specific extensions to `std` for Windows.
//!
//! Provides access to platform-level information for Windows, and exposes
//! Windows-specific idioms that would otherwise be inappropriate as part
//! the core `std` library. These extensions allow developers to use
//! `std` types and idioms with Windows in ... | pub mod process;
pub mod raw;
pub mod thread;
/// A prelude for conveniently writing platform-specific code.
///
/// Includes all extension traits, and some important type definitions.
#[stable(feature = "rust1", since = "1.0.0")]
pub mod prelude {
#[doc(no_inline)]
#[stable(feature = "rust1", since = "1.0.0")... | random_line_split | |
issue-7673-cast-generically-implemented-trait.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 owned3<T:'static>(a: ~T) { ~a as ~A:; }
fn managed1<T:'static>(a: T) { @a as @A; }
fn managed2<T:'static>(a: @T) { a as @A; }
fn managed3<T:'static>(a: @T) { @a as @A; }
| { a as ~A:; } | identifier_body |
issue-7673-cast-generically-implemented-trait.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 ... | */
pub fn main() {}
trait A {}
impl<T:'static> A for T {}
fn owned1<T:'static>(a: T) { ~a as ~A:; } /* note `:` */
fn owned2<T:'static>(a: ~T) { a as ~A:; }
fn owned3<T:'static>(a: ~T) { ~a as ~A:; }
fn managed1<T:'static>(a: T) { @a as @A; }
fn managed2<T:'static>(a: @T) { a as @A; }
fn managed3<T:'static>(a: @T) ... | random_line_split | |
issue-7673-cast-generically-implemented-trait.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 ... | <T:'static>(a: ~T) { a as ~A:; }
fn owned3<T:'static>(a: ~T) { ~a as ~A:; }
fn managed1<T:'static>(a: T) { @a as @A; }
fn managed2<T:'static>(a: @T) { a as @A; }
fn managed3<T:'static>(a: @T) { @a as @A; }
| owned2 | identifier_name |
state_helper.rs | use std::collections::BTreeMap;
use std::fs;
use std::path::{Path, PathBuf};
use std::sync::MutexGuard;
use std::time::SystemTime;
use anyhow::{Context, Result};
use chrono::prelude::*;
use log::{debug, info};
use pueue_lib::state::{Group, GroupStatus, State, PUEUE_DEFAULT_GROUP};
use pueue_lib::task::{TaskResult, Ta... |
// Handle crash during editing of the task command.
if task.status == TaskStatus::Locked {
task.status = TaskStatus::Stashed { enqueue_at: None };
}
// Go trough all tasks and set all groups that are no longer
// listed in the configuration file to the default.
... | {
info!(
"Setting task {} with previous status {:?} to new status {:?}",
task.id,
task.status,
TaskResult::Killed
);
task.status = TaskStatus::Done(TaskResult::Killed);
} | conditional_block |
state_helper.rs | use std::collections::BTreeMap;
use std::fs;
use std::path::{Path, PathBuf};
use std::sync::MutexGuard;
use std::time::SystemTime;
use anyhow::{Context, Result};
use chrono::prelude::*;
use log::{debug, info};
use pueue_lib::state::{Group, GroupStatus, State, PUEUE_DEFAULT_GROUP};
use pueue_lib::task::{TaskResult, Ta... | (state: &LockedState) -> Result<()> {
let path = state.settings.shared.pueue_directory().join("log");
// Get all log files in the directory with their respective system time.
let mut entries: BTreeMap<SystemTime, PathBuf> = BTreeMap::new();
let mut directory_list = fs::read_dir(path)?;
while let So... | rotate_state | identifier_name |
state_helper.rs | use std::collections::BTreeMap;
use std::fs;
use std::path::{Path, PathBuf};
use std::sync::MutexGuard;
use std::time::SystemTime;
use anyhow::{Context, Result};
use chrono::prelude::*;
use log::{debug, info};
use pueue_lib::state::{Group, GroupStatus, State, PUEUE_DEFAULT_GROUP};
use pueue_lib::task::{TaskResult, Ta... | task.status = TaskStatus::Stashed { enqueue_at: None };
}
// Go trough all tasks and set all groups that are no longer
// listed in the configuration file to the default.
let group = match state.groups.get_mut(&task.group) {
Some(group) => group,
None... | }
// Handle crash during editing of the task command.
if task.status == TaskStatus::Locked { | random_line_split |
state_helper.rs | use std::collections::BTreeMap;
use std::fs;
use std::path::{Path, PathBuf};
use std::sync::MutexGuard;
use std::time::SystemTime;
use anyhow::{Context, Result};
use chrono::prelude::*;
use log::{debug, info};
use pueue_lib::state::{Group, GroupStatus, State, PUEUE_DEFAULT_GROUP};
use pueue_lib::task::{TaskResult, Ta... | fs::remove_file(path)?;
number_entries -= 1;
}
}
Ok(())
}
| {
let path = state.settings.shared.pueue_directory().join("log");
// Get all log files in the directory with their respective system time.
let mut entries: BTreeMap<SystemTime, PathBuf> = BTreeMap::new();
let mut directory_list = fs::read_dir(path)?;
while let Some(Ok(entry)) = directory_list.next(... | identifier_body |
associated-types-in-inherent-method.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 ... | <T:Get>(x: &T) -> &<T as Get>::Value {
x.get()
}
}
fn main() {
let s = Struct {
x: 100,
};
assert_eq!(*Struct::grab(&s), 100);
}
| grab | identifier_name |
associated-types-in-inherent-method.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait Get {
... | random_line_split | |
lib.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 ... | factory: factory,
task_state: state,
tasks_done: p,
};
// Create a work queue for each scheduler, ntimes. Create an extra
// for the main thread if that flag is set. We won't steal from it.
let mut workers = Vec::with_capacity(nscheds);
let mu... | {
static mut POOL_ID: AtomicUint = INIT_ATOMIC_UINT;
let PoolConfig {
threads: nscheds,
event_loop_factory: factory
} = config;
assert!(nscheds > 0);
// The pool of schedulers that will be returned from this function
let (p, state) = TaskState::n... | identifier_body |
lib.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 ... | /// down. The entire pool (and this function) will only return once
/// all child tasks have finished executing.
///
/// # Return value
///
/// The return value is used as the process return code. 0 on success, 101 on
/// error.
pub fn start(argc: int, argv: *const *const u8,
event_lo... | /// by os::args.
/// * `main` - The initial procedure to run inside of the M:N scheduling pool.
/// Once this procedure exits, the scheduling pool will begin to shut | random_line_split |
lib.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 ... | {
cnt: Arc<AtomicUint>,
done: Sender<()>,
}
impl SchedPool {
/// Execute the main function in a pool of M:N schedulers.
///
/// This will configure the pool according to the `config` parameter, and
/// initially run `main` inside the pool of schedulers.
pub fn new(config: PoolConfig) -> Sc... | TaskState | identifier_name |
reporter.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::{Parser, SourcePosition};
use log;
use style_traits::ParseErrorReporter;
#[derive(JSTraceable, Hea... | let location = input.source_location(position);
// TODO eventually this will got into a "web console" or something.
info!("{}:{} {}", location.line, location.column, message)
}
}
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
let error_repo... | random_line_split | |
reporter.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::{Parser, SourcePosition};
use log;
use style_traits::ParseErrorReporter;
#[derive(JSTraceable, Hea... |
}
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
let error_reporter = box CSSErrorReporter;
return error_reporter;
}
}
| {
let location = input.source_location(position);
// TODO eventually this will got into a "web console" or something.
info!("{}:{} {}", location.line, location.column, message)
} | conditional_block |
reporter.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::{Parser, SourcePosition};
use log;
use style_traits::ParseErrorReporter;
#[derive(JSTraceable, Hea... | (&self) -> Box<ParseErrorReporter + Send + Sync> {
let error_reporter = box CSSErrorReporter;
return error_reporter;
}
}
| clone | identifier_name |
optimizer.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/. */
//! Transforms a display list to produce a visually-equivalent, but cheaper-to-paint, one.
use display_list::{Dis... | (visible_rect: &Rect<f32>) -> DisplayListOptimizer {
DisplayListOptimizer {
visible_rect: geometry::f32_rect_to_au_rect(*visible_rect),
}
}
/// Optimizes the given display list, returning an equivalent, but cheaper-to-paint, one.
pub fn optimize(self, display_list: &DisplayList)... | new | identifier_name |
optimizer.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/. */
//! Transforms a display list to produce a visually-equivalent, but cheaper-to-paint, one.
use display_list::{Dis... |
}
}
}
| {
result_list.push_back((*stacking_context).clone())
} | conditional_block |
optimizer.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/. */
//! Transforms a display list to produce a visually-equivalent, but cheaper-to-paint, one.
use display_list::{Dis... | fn add_in_bounds_display_items<'a,I>(&self,
result_list: &mut LinkedList<DisplayItem>,
display_items: I)
where I: Iterator<Item=&'a DisplayItem> {
for display_item in display_items {
... | }
/// Adds display items that intersect the visible rect to `result_list`. | random_line_split |
main.rs | #[macro_use]
extern crate futures;
extern crate tokio_io;
extern crate tokio_core;
extern crate bytes;
| extern crate rpassword;
#[macro_use]
extern crate serde_derive;
extern crate docopt;
extern crate toml;
#[macro_use]
extern crate log;
use std::{io, str};
use futures::{future, stream, Future, Stream, Sink};
use tokio_core::reactor::{Core, Handle};
use tokio_core::net::TcpStream;
use tokio_io::AsyncRead;
pub mod a... | extern crate time; | random_line_split |
main.rs |
#[macro_use]
extern crate futures;
extern crate tokio_io;
extern crate tokio_core;
extern crate bytes;
extern crate time;
extern crate rpassword;
#[macro_use]
extern crate serde_derive;
extern crate docopt;
extern crate toml;
#[macro_use]
extern crate log;
use std::{io, str};
use futures::{future, stream, Future,... | /*
let conn_msg: Vec<Result<Line, io::Error>> = vec![
Ok(Line::from_str("USER a b c d")),
Ok(Line::from_str("NICK qjkxk")),
Ok(Line::from_str("JOIN #test")),
];
let mut logs = Logs::new("/tmp/irc_logs");
let mut core = Core::new().unwrap();
//let addr = "irc.freenode.org... | {
// TODO: clap/docopt CLI args for logging verbosity|output / config file
let config_file = "config2.toml";
/*
let dec = slog_term::TermDecorator::new().build();
let drain = slog_term::FullFormat::new(dec).build().fuse();
let async_drain = slog_async::Async::new(drain).build().fuse();
let ... | identifier_body |
main.rs |
#[macro_use]
extern crate futures;
extern crate tokio_io;
extern crate tokio_core;
extern crate bytes;
extern crate time;
extern crate rpassword;
#[macro_use]
extern crate serde_derive;
extern crate docopt;
extern crate toml;
#[macro_use]
extern crate log;
use std::{io, str};
use futures::{future, stream, Future,... |
future::ok(())
})
})
}).map_err(|_| ());
handle.spawn(listen);
}
fn main() {
info!("Parsing arguments");
let args: args::Args = docopt::Docopt::new(args::USAGE)
.and_then(|d| d.deserialize())
.unwrap_or_else(|e| e.exit());
println!("ARG... | {
logs.write(name,&text).unwrap();
} | conditional_block |
main.rs |
#[macro_use]
extern crate futures;
extern crate tokio_io;
extern crate tokio_core;
extern crate bytes;
extern crate time;
extern crate rpassword;
#[macro_use]
extern crate serde_derive;
extern crate docopt;
extern crate toml;
#[macro_use]
extern crate log;
use std::{io, str};
use futures::{future, stream, Future,... | (srv_name: String, srv: Server, log_path: &str, handle: Handle) {
// TODO: make sure someone's nick can't contains directory traversal
// `NICK../../../../dev/sda1`
// TODO: stop passwords from leaking into log files (don't long conn msg)
let mut logs = Logs::new(log_path);
//let conn_msg: Vec<_> = ... | _server | identifier_name |
buffer.rs | pub struct | {
line: u32,
column: u32
}
pub enum Cursor {
Simple(Position),
Range(Position, Position),
Block(Position, Position)
}
pub trait StrLike {
type Bytes: Iterator;
type Chars: Iterator;
type Lines: Iterator;
/// Return number of bytes in this object
fn len(&self) -> usize;
//... | Position | identifier_name |
buffer.rs | pub struct Position {
line: u32,
column: u32
}
pub enum Cursor {
Simple(Position),
Range(Position, Position),
Block(Position, Position)
}
pub trait StrLike {
type Bytes: Iterator; | /// Return number of unicode characters in this object
fn char_count(&self) -> usize;
/// Return number of lines in this object
fn line_count(&self) -> usize;
fn bytes(&self) -> Bytes;
fn chars(&self) -> Chars;
fn lines(&self) -> Lines;
// TODO: strchr or some such. Bytes or chars base... | type Chars: Iterator;
type Lines: Iterator;
/// Return number of bytes in this object
fn len(&self) -> usize; | random_line_split |
documenttype.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::DocumentTypeBinding::DocumentTypeMethods;
use crate::dom::bindings::... | (&self) -> &DOMString {
&self.public_id
}
#[inline]
pub fn system_id(&self) -> &DOMString {
&self.system_id
}
}
impl DocumentTypeMethods for DocumentType {
// https://dom.spec.whatwg.org/#dom-documenttype-name
fn Name(&self) -> DOMString {
self.name.clone()
}
/... | public_id | identifier_name |
documenttype.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::DocumentTypeBinding::DocumentTypeMethods;
use crate::dom::bindings::... |
// https://dom.spec.whatwg.org/#dom-childnode-after
fn After(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
self.upcast::<Node>().after(nodes)
}
// https://dom.spec.whatwg.org/#dom-childnode-replacewith
fn ReplaceWith(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
self.upcas... | {
self.upcast::<Node>().before(nodes)
} | identifier_body |
documenttype.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::DocumentTypeBinding::DocumentTypeMethods;
use crate::dom::bindings::... | )
}
#[inline]
pub fn name(&self) -> &DOMString {
&self.name
}
#[inline]
pub fn public_id(&self) -> &DOMString {
&self.public_id
}
#[inline]
pub fn system_id(&self) -> &DOMString {
&self.system_id
}
}
impl DocumentTypeMethods for DocumentType {
... | random_line_split | |
color.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Computed color values.
use cssparser::{Color as CSSParserColor, RGBA};
use std::fmt;
use style_traits::ToCss;... | let fg_ratio = self.foreground_ratio;
if self.color.alpha == fg_color.alpha {
let r = blend_color_component(self.color.red, fg_color.red, fg_ratio);
let g = blend_color_component(self.color.green, fg_color.green, fg_ratio);
let b = blend_color_component(self.color.blu... | }
// Common case that alpha channel is equal (usually both are opaque). | random_line_split |
color.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Computed color values.
use cssparser::{Color as CSSParserColor, RGBA};
use std::fmt;
use style_traits::ToCss;... |
/// Returns a complex color value representing transparent.
pub fn transparent() -> Color {
Color::rgba(RGBA::transparent())
}
/// Returns a complex color value representing currentcolor.
pub fn currentcolor() -> Color {
Color {
color: RGBA::transparent(),
... | {
Color {
color: rgba,
foreground_ratio: 0,
}
} | identifier_body |
color.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Computed color values.
use cssparser::{Color as CSSParserColor, RGBA};
use std::fmt;
use style_traits::ToCss;... | {
/// RGBA color.
pub color: RGBA,
/// The ratio of currentcolor in complex color.
pub foreground_ratio: u8,
}
fn blend_color_component(bg: u8, fg: u8, fg_alpha: u8) -> u8 {
let bg_ratio = (u8::max_value() - fg_alpha) as u32;
let fg_ratio = fg_alpha as u32;
let color = bg as u32 * bg_ratio... | Color | identifier_name |
color.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Computed color values.
use cssparser::{Color as CSSParserColor, RGBA};
use std::fmt;
use style_traits::ToCss;... |
}
}
/// Computed value type for the specified RGBAColor.
pub type RGBAColor = RGBA;
| {
Ok(())
} | conditional_block |
test_select.rs | use nix::sys::select::*;
use nix::unistd::{pipe, write};
use nix::sys::signal::SigSet;
use nix::sys::time::{TimeSpec, TimeValLike};
#[test]
pub fn test_pselect() {
let _mtx = ::SIGNAL_MTX
.lock()
.expect("Mutex got poisoned by another test");
let (r1, w1) = pipe().unwrap();
write(w1, b"hi!")... | } | random_line_split | |
test_select.rs | use nix::sys::select::*;
use nix::unistd::{pipe, write};
use nix::sys::signal::SigSet;
use nix::sys::time::{TimeSpec, TimeValLike};
#[test]
pub fn test_pselect() {
let _mtx = ::SIGNAL_MTX
.lock()
.expect("Mutex got poisoned by another test");
let (r1, w1) = pipe().unwrap();
write(w1, b"hi!")... | );
assert!(fd_set.contains(r1));
assert!(!fd_set.contains(r2));
}
| {
let (r1, w1) = pipe().unwrap();
write(w1, b"hi!").unwrap();
let (r2, _w2) = pipe().unwrap();
let mut fd_set = FdSet::new();
fd_set.insert(r1);
fd_set.insert(r2);
let timeout = TimeSpec::seconds(10);
assert_eq!(
1,
pselect(
::std::cmp::max(r1, r2) + 1,
... | identifier_body |
test_select.rs | use nix::sys::select::*;
use nix::unistd::{pipe, write};
use nix::sys::signal::SigSet;
use nix::sys::time::{TimeSpec, TimeValLike};
#[test]
pub fn test_pselect() {
let _mtx = ::SIGNAL_MTX
.lock()
.expect("Mutex got poisoned by another test");
let (r1, w1) = pipe().unwrap();
write(w1, b"hi!")... | () {
let (r1, w1) = pipe().unwrap();
write(w1, b"hi!").unwrap();
let (r2, _w2) = pipe().unwrap();
let mut fd_set = FdSet::new();
fd_set.insert(r1);
fd_set.insert(r2);
let timeout = TimeSpec::seconds(10);
assert_eq!(
1,
pselect(
::std::cmp::max(r1, r2) + 1,
... | test_pselect_nfds2 | identifier_name |
registry.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
}
| {
self.lint_groups.insert(name, to.into_iter().map(|x| LintId::of(x)).collect());
} | identifier_body |
registry.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | ///
/// A plugin registrar function takes an `&mut Registry` and should call
/// methods to register its plugins.
///
/// This struct has public fields and other methods for use by `rustc`
/// itself. They are not documented here, and plugin authors should
/// not use them.
pub struct Registry {
#[doc(hidden)]
... |
use std::collections::HashMap;
/// Structure used to register plugins. | random_line_split |
registry.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (&mut self, lint_pass: LintPassObject) {
self.lint_passes.push(lint_pass);
}
/// Register a lint group.
pub fn register_lint_group(&mut self, name: &'static str, to: Vec<&'static Lint>) {
self.lint_groups.insert(name, to.into_iter().map(|x| LintId::of(x)).collect());
}
}
| register_lint_pass | identifier_name |
fs.rs | use io::{Read, Result, Write, Seek, SeekFrom};
use path::PathBuf;
use str;
use string::{String, ToString};
use vec::Vec;
use system::syscall::{sys_open, sys_dup, sys_close, sys_fpath, sys_ftruncate, sys_read,
sys_write, sys_lseek, sys_fsync, sys_mkdir, sys_rmdir, sys_unlink};
use system::syscall::{O_RDWR... | (path: &str) -> Result<()> {
let path_c = path.to_string() + "\0";
unsafe {
sys_mkdir(path_c.as_ptr(), 755).and(Ok(()))
}
}
pub fn read_dir(path: &str) -> Result<ReadDir> {
let file_result = if path.is_empty() || path.ends_with('/') {
File::open(path)
} else {
File::open(&(p... | create_dir | identifier_name |
fs.rs | use io::{Read, Result, Write, Seek, SeekFrom};
use path::PathBuf;
use str;
use string::{String, ToString};
use vec::Vec;
use system::syscall::{sys_open, sys_dup, sys_close, sys_fpath, sys_ftruncate, sys_read,
sys_write, sys_lseek, sys_fsync, sys_mkdir, sys_rmdir, sys_unlink};
use system::syscall::{O_RDWR... |
impl Iterator for ReadDir {
type Item = Result<DirEntry>;
fn next(&mut self) -> Option<Result<DirEntry>> {
let mut path = String::new();
let mut buf: [u8; 1] = [0; 1];
loop {
match self.file.read(&mut buf) {
Ok(0) => break,
Ok(count) => {
... | file: File,
} | random_line_split |
asm-out-assign-imm.rs | // Copyright 2012-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 | // except according to those terms.
// ignore-fast #[feature] doesn't work with check-fast
#![feature(asm)]
fn foo(x: int) { println!("{}", x); }
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "x86_64")]
#[cfg(target_arch = "arm")]
pub fn main() {
let x: int;
x = 1; //~ NOTE prior assignment occurs here
... | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed | random_line_split |
asm-out-assign-imm.rs | // Copyright 2012-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
// <LICEN... | (x: int) { println!("{}", x); }
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "x86_64")]
#[cfg(target_arch = "arm")]
pub fn main() {
let x: int;
x = 1; //~ NOTE prior assignment occurs here
foo(x);
unsafe {
asm!("mov $1, $0" : "=r"(x) : "r"(5u)); //~ ERROR re-assignment of immutable variable ... | foo | identifier_name |
asm-out-assign-imm.rs | // Copyright 2012-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
// <LICEN... | {} | identifier_body | |
lock.rs | /* Copyright 2013 Leon Sixt
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in wr... |
fn unlock(&self, id: &T) {
debug!("unlocking ptr: {}", id.to_str());
/*do self.mutex.lock_cond |cond| {
unsafe {
let mut_set = cast::transmute_mut(&self.set);
mut_set.remove(id);
cond.signal();
}
}*/
}
}
| {
debug!("locking ptr: {}", id.to_str());
/* do self.mutex.lock_cond |cond| {
while self.set.contains(&id) {
cond.wait();
}
unsafe {
let mut_set = cast::transmute_mut(&self.set);
mut_set.insert(id.clone());
}
... | identifier_body |
lock.rs | /* Copyright 2013 Leon Sixt
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in wr... | (&self, id: &T) {
debug!("unlocking ptr: {}", id.to_str());
/*do self.mutex.lock_cond |cond| {
unsafe {
let mut_set = cast::transmute_mut(&self.set);
mut_set.remove(id);
cond.signal();
}
}*/
}
}
| unlock | identifier_name |
lock.rs | /* Copyright 2013 Leon Sixt
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in wr... | cond.wait();
}
unsafe {
let mut_set = cast::transmute_mut(&self.set);
mut_set.insert(id.clone());
}
}*/
}
fn unlock(&self, id: &T) {
debug!("unlocking ptr: {}", id.to_str());
/*do self.mutex.lock_cond |co... | impl<T: Hash + Eq + Clone + Freeze + ToStr> LockManager<T> for SimpleLockManager<T> {
fn lock(&self, id: T) {
debug!("locking ptr: {}", id.to_str());
/* do self.mutex.lock_cond |cond| {
while self.set.contains(&id) { | random_line_split |
cloudwatch.rs | #![cfg(feature = "cloudwatch")]
extern crate rusoto;
use rusoto::cloudwatch::{CloudWatch, CloudWatchClient, PutMetricDataInput, Dimension, MetricDatum};
use rusoto::{DefaultCredentialsProvider, Region};
use rusoto::default_tls_client;
#[test]
fn should_put_metric_data() |
let response = client.put_metric_data(&request).unwrap();
println!("{:#?}", response);
}
| {
let client = CloudWatchClient::new(default_tls_client().unwrap(),
DefaultCredentialsProvider::new().unwrap(),
Region::UsEast1);
let metric_data = vec![MetricDatum {
dimensions: Some(vec![Dimension {
... | identifier_body |
cloudwatch.rs | #![cfg(feature = "cloudwatch")]
extern crate rusoto;
use rusoto::cloudwatch::{CloudWatch, CloudWatchClient, PutMetricDataInput, Dimension, MetricDatum};
use rusoto::{DefaultCredentialsProvider, Region};
use rusoto::default_tls_client;
#[test]
fn | () {
let client = CloudWatchClient::new(default_tls_client().unwrap(),
DefaultCredentialsProvider::new().unwrap(),
Region::UsEast1);
let metric_data = vec![MetricDatum {
dimensions: Some(vec![Dimension ... | should_put_metric_data | identifier_name |
cloudwatch.rs | #![cfg(feature = "cloudwatch")]
extern crate rusoto;
use rusoto::cloudwatch::{CloudWatch, CloudWatchClient, PutMetricDataInput, Dimension, MetricDatum};
use rusoto::{DefaultCredentialsProvider, Region};
use rusoto::default_tls_client;
#[test]
fn should_put_metric_data() {
let client = CloudWatchClient::new(defau... | }];
let request = PutMetricDataInput {
namespace: "TestNamespace".to_string(),
metric_data: metric_data,
};
let response = client.put_metric_data(&request).unwrap();
println!("{:#?}", response);
} | value: Some(1.0), | random_line_split |
receiver.rs | use std::io::Cursor;
use std::sync::Arc;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst;
use rotor_redis;
use rotor_redis::Message;
use cbor::Encoder;
use inner::{MANAGER, SockId};
pub struct Receiver(SockId, usize, Arc<AtomicUsize>);
impl Receiver {
pub fn new(id: SockId) -> Receiv... |
impl Receiver {
pub fn next_id(&mut self) -> usize {
self.2.fetch_add(1, SeqCst)
}
}
impl rotor_redis::Receiver for Receiver {
fn receive(&mut self, msg: &Message) {
let mut enc = Encoder::new(Cursor::new(Vec::new()));
enc.u64(self.1 as u64).unwrap();
write_message(&mut en... | {
use rotor_redis::Message::*;
match *msg {
Simple(s) => enc.text(s).unwrap(),
Error(kind, text) => {
enc.object(2).unwrap();
enc.text("error_kind").unwrap();
enc.text(kind).unwrap();
enc.text("error_text").unwrap();
enc.text(text).unwr... | identifier_body |
receiver.rs | use std::io::Cursor;
use std::sync::Arc;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst; | use cbor::Encoder;
use inner::{MANAGER, SockId};
pub struct Receiver(SockId, usize, Arc<AtomicUsize>);
impl Receiver {
pub fn new(id: SockId) -> Receiver {
Receiver(id, 0, Arc::new(AtomicUsize::new(0)))
}
}
impl Clone for Receiver {
fn clone(&self) -> Receiver {
Receiver(self.0, self.2.l... |
use rotor_redis;
use rotor_redis::Message; | random_line_split |
receiver.rs | use std::io::Cursor;
use std::sync::Arc;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst;
use rotor_redis;
use rotor_redis::Message;
use cbor::Encoder;
use inner::{MANAGER, SockId};
pub struct Receiver(SockId, usize, Arc<AtomicUsize>);
impl Receiver {
pub fn new(id: SockId) -> Receiv... | (&self) -> Receiver {
Receiver(self.0, self.2.load(SeqCst), self.2.clone())
}
}
fn write_message(enc: &mut Encoder<Cursor<Vec<u8>>>, msg: &Message) {
use rotor_redis::Message::*;
match *msg {
Simple(s) => enc.text(s).unwrap(),
Error(kind, text) => {
enc.object(2).unwrap(... | clone | identifier_name |
properties.rs | //! Parse server.properties files
use std::fs::File;
use std::io::prelude::*;
use std::io::{self, BufReader, BufWriter, Error, ErrorKind};
use std::num::ParseIntError;
use std::path::Path;
use std::str::ParseBoolError;
macro_rules! parse {
($value:ident, String) => {
$value.to_string()
};
($value:... | },
Err(err) => {
panic!("Failed to load server.properties file with error: {}", err);
}
}
fs::remove_file(&dir).unwrap();
}
#[test]
fn custom_save_load() {
... | match Properties::load(&dir) {
Ok(props) => {
assert_eq!(props, default_props); | random_line_split |
options.rs | #[feature(convert)]
use std::convert::AsRef;
use std::collections;
use std::fmt;
use syntax::ast;
use syntax::ext::base;
use super::super::utils::string;
//use super::super::utils::attrs::{Attrs,AttrError};
use super::columns::options;
use ::models::model::Model;
/*
ModelOptionsError
error
*/
#[derive(Debug)]
pub ... | (ann:&base::Annotatable) -> Result<Vec<String>, ModelOptionsError> {
let mut results:Vec<String> = vec![];
let mut name = "".to_string();
let mut db_name = "".to_string();
let mut primary_key = "".to_string();
let mut columns:Vec<String> = vec![];
let mut column_options:Vec<String> = vec![];
let mut column_inits... | generate_model_options_impls | identifier_name |
options.rs | #[feature(convert)]
use std::convert::AsRef;
use std::collections;
use std::fmt;
use syntax::ast;
use syntax::ext::base;
use super::super::utils::string;
//use super::super::utils::attrs::{Attrs,AttrError};
use super::columns::options;
use ::models::model::Model;
/*
ModelOptionsError
error
*/
#[derive(Debug)]
pub ... |
fn get_column_options(ann:&base::Annotatable) -> Result<(Vec<(String, String)>), ModelOptionsError> {
let mut result = vec![];
let nserr = Err(ModelOptionsError::NotStruct);
if let &base::Annotatable::Item(ref item) = ann {
if let ast::Item_::ItemStruct(ref sd, _) = item.node {
match options::get_columns(sd) ... | } | random_line_split |
options.rs | #[feature(convert)]
use std::convert::AsRef;
use std::collections;
use std::fmt;
use syntax::ast;
use syntax::ext::base;
use super::super::utils::string;
//use super::super::utils::attrs::{Attrs,AttrError};
use super::columns::options;
use ::models::model::Model;
/*
ModelOptionsError
error
*/
#[derive(Debug)]
pub ... | {
let mut result = vec![];
let nserr = Err(ModelOptionsError::NotStruct);
if let &base::Annotatable::Item(ref item) = ann {
if let ast::Item_::ItemStruct(ref sd, _) = item.node {
match options::get_columns(sd) {
Ok(cols) => {
for (k, v) in cols {
result.push((k.clone(), format!(r#"{}"#, v)))
... | identifier_body | |
deriving-clone-struct.rs | // Copyright 2013 The Rust Project Developers. See the 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 may not be copied, modified, or distributed
// except according to those terms.
// pretty-expanded ... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
// | random_line_split |
deriving-clone-struct.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 ... | () {}
| main | identifier_name |
class-impl-very-parameterized-trait.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (&self, k: &int) -> bool { *k <= self.meows }
fn find(&self, k: &int) -> Option<&T> {
if *k <= self.meows {
Some(&self.name)
} else {
None
}
}
}
impl<T> MutableMap<int, T> for cat<T> {
fn insert(&mut self, k: int, _: T) -> bool {
self.meows += k;
... | contains_key | identifier_name |
class-impl-very-parameterized-trait.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
}
}
pub fn new(in_x: int, in_y: int, in_name: T) -> cat<T> {
cat{meows: in_x, how_hungry: in_y, name: in_name }
}
}
impl<T> cat<T> {
fn meow(&mut self) {
self.meows += 1;
println!("Meow {}", self.meows);
if self.meows % 5 == 0 {
self.how_hungry += 1... | { fail!("epic fail"); } | conditional_block |
class-impl-very-parameterized-trait.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {
let mut nyan: cat<String> = cat::new(0, 2, "nyan".to_string());
for _ in range(1u, 5) { nyan.speak(); }
assert!(*nyan.find(&1).unwrap() == "nyan".to_string());
assert_eq!(nyan.find(&10), None);
let mut spotty: cat<cat_type> = cat::new(2, 57, tuxedo);
for _ in range(0u, 6) { spotty.speak(); }
... | identifier_body | |
class-impl-very-parameterized-trait.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
impl cmp::PartialEq for cat_type {
fn eq(&self, other: &cat_type) -> bool {
((*self) as uint) == ((*other) as uint)
}
fn ne(&self, other: &cat_type) -> bool {!(*self).eq(other) }
}
// Very silly -- this just returns the value of the name field
// for any int value that's less than the meows field
... | #[deriving(Show)]
enum cat_type { tuxedo, tabby, tortoiseshell } | random_line_split |
mod.rs | use std::io::Write;
pub mod export;
pub mod import;
pub fn print_progress(noun: &str, start_time: ::time::Timespec, done: usize, total: usize) {
let remaining_jobs = total - done;
let progress: f64 = 100f64 * done as f64 / total as f64;
let current_time = ::time::get_time().sec;
let time_per_job = (cu... | use std::iter::repeat; | random_line_split | |
mod.rs | use std::iter::repeat;
use std::io::Write;
pub mod export;
pub mod import;
pub fn | (noun: &str, start_time: ::time::Timespec, done: usize, total: usize) {
let remaining_jobs = total - done;
let progress: f64 = 100f64 * done as f64 / total as f64;
let current_time = ::time::get_time().sec;
let time_per_job = (current_time - start_time.sec) as f64 / done as f64;
let remaining_time =... | print_progress | identifier_name |
mod.rs | use std::iter::repeat;
use std::io::Write;
pub mod export;
pub mod import;
pub fn print_progress(noun: &str, start_time: ::time::Timespec, done: usize, total: usize) |
fn make_progress_bar(ratio: f64, length: usize) -> String {
let filled = (ratio * length as f64).round() as usize;
let mut bar: String = repeat('|').take(filled).collect();
for _ in 0..(length - filled) {
bar.push('-');
}
bar
}
| {
let remaining_jobs = total - done;
let progress: f64 = 100f64 * done as f64 / total as f64;
let current_time = ::time::get_time().sec;
let time_per_job = (current_time - start_time.sec) as f64 / done as f64;
let remaining_time = time_per_job * remaining_jobs as f64;
print!("\r{} {}/{} complet... | identifier_body |
mod.rs | use std::iter::repeat;
use std::io::Write;
pub mod export;
pub mod import;
pub fn print_progress(noun: &str, start_time: ::time::Timespec, done: usize, total: usize) {
let remaining_jobs = total - done;
let progress: f64 = 100f64 * done as f64 / total as f64;
let current_time = ::time::get_time().sec;
... |
}
fn make_progress_bar(ratio: f64, length: usize) -> String {
let filled = (ratio * length as f64).round() as usize;
let mut bar: String = repeat('|').take(filled).collect();
for _ in 0..(length - filled) {
bar.push('-');
}
bar
}
| {
print!(" ETA {:.2} min ", remaining_time / 60.0);
::std::io::stdout().flush().ok().expect("failed to flush io");
} | 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 ... | //! approximate a square root to arbitrary precision:
//!
//! ```
//! extern crate num;
//!
//! use num::bigint::BigInt;
//! use num::rational::{Ratio, BigRational};
//!
//! fn approx_sqrt(number: u64, iterations: uint) -> BigRational {
//! let start: Ratio<BigInt> = Ratio::from_integer(FromPrimitive::from_u64(numb... | //!
//! ## Example
//!
//! This example uses the BigRational type and [Newton's method][newt] to | 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 maybe_yield(self: Box<Self>, cur_task: Box<Task>);
fn deschedule(self: Box<Self>,
times: uint,
cur_task: Box<Task>,
f: |BlockedTask| -> Result<(), BlockedTask>);
fn reawaken(self: Box<Self>, to_wake: Box<Task>);
// Miscellaneous calls which are v... | 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 ... |
// FIXME: these probably shouldn't be public...
#[doc(hidden)]
pub mod shouldnt_be_public {
#[cfg(not(test))]
pub use super::local_ptr::native::maybe_tls_key;
#[cfg(all(not(windows), not(target_os = "android"), not(target_os = "ios")))]
pub use super::local_ptr::compiled::RT_TLS_PTR;
}
#[cfg(not(test... | {
bookkeeping::wait_for_other_tasks();
at_exit_imp::run();
args::cleanup();
thread::cleanup();
local_ptr::cleanup();
} | 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 ... | () {
bookkeeping::wait_for_other_tasks();
at_exit_imp::run();
args::cleanup();
thread::cleanup();
local_ptr::cleanup();
}
// FIXME: these probably shouldn't be public...
#[doc(hidden)]
pub mod shouldnt_be_public {
#[cfg(not(test))]
pub use super::local_ptr::native::maybe_tls_key;
#[cfg(... | cleanup | identifier_name |
walkState.rs | # order is:
# Heading
# Position
# Orientation
# Velocity
# AngularVelocity
# Relative Orientation
# Relative Angular Velocity
#----------------
# Heading
0
# Root(body)
0 0.562244 0
0.999554 0.029849 -0.000000 -0.000152
0.249120 0.375816 0.866547
0.257640 0.100468 0.388803
# body_neck
0.971329... |
# tail_1
0.997887 0.059312 0.026492 -0.001575
-0.944952 -0.316730 0.050275
# neck_head
0.978705 -0.204796 -0.013719 0.002532
-0.816336 -0.004197 0.002574
# lKnee
0.821044 0.570865 -0.000000 0.000000
-2.636854 -0.000040 0.000011
# rKnee
0.835187 0.549966 -0.000001 -0.000001
-2.321718 -0.000044 -0.0010... | random_line_split | |
main.rs | struct Counter {
count: u32,
}
impl Counter {
fn | () -> Counter {
Counter { count: 0 }
}
}
// define the iterator functionality
impl Iterator for Counter {
type Item = u32;
fn next(&mut self) -> Option<Self::Item> {
if self.count < 5 {
self.count += 1;
Some(self.count)
} else {
None
}
... | new | identifier_name |
main.rs | struct Counter {
count: u32,
}
impl Counter {
fn new() -> Counter {
Counter { count: 0 }
}
}
// define the iterator functionality
impl Iterator for Counter {
type Item = u32;
fn next(&mut self) -> Option<Self::Item> {
if self.count < 5 {
self.count += 1;
So... |
}
}
fn main() {
let v1 = vec![1, 2, 3];
let v1_iter = v1.iter();
// use an iterator - this consumes the iterator
// v1_iter so v1_iter cannot be used again
for val in v1_iter {
println!("Value is: {}", val);
}
// after the sum() call, you can no longer use v2_iter
// beca... | {
None
} | conditional_block |
main.rs | struct Counter {
count: u32,
}
impl Counter {
fn new() -> Counter {
Counter { count: 0 }
}
}
// define the iterator functionality
impl Iterator for Counter {
type Item = u32;
fn next(&mut self) -> Option<Self::Item> {
if self.count < 5 {
self.count += 1;
So... | // after the sum() call, you can no longer use v2_iter
// because sum() consumes the iterator
let v2_iter = v1.iter();
let total: i32 = v2_iter.sum();
if total == 6 {
println!("Found total!");
} else {
println!("Something went wrong!");
}
// map() is lazy evaluated and d... | random_line_split | |
main.rs | struct Counter {
count: u32,
}
impl Counter {
fn new() -> Counter |
}
// define the iterator functionality
impl Iterator for Counter {
type Item = u32;
fn next(&mut self) -> Option<Self::Item> {
if self.count < 5 {
self.count += 1;
Some(self.count)
} else {
None
}
}
}
fn main() {
let v1 = vec![1, 2, 3];
... | {
Counter { count: 0 }
} | identifier_body |
htmltitleelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLTitleElementBinding;
use dom::bindings::codegen::Bindings::HTMLTitleElem... |
}
| {
let node = NodeCast::from_ref(*self);
if is_in_doc {
let document = node.owner_doc();
document.r().title_changed();
}
} | identifier_body |
htmltitleelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLTitleElementBinding;
use dom::bindings::codegen::Bindings::HTMLTitleElem... | <'b>(&'b self) -> Option<&'b VirtualMethods> {
let htmlelement: &&HTMLElement = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods)
}
fn children_changed(&self, mutation: &ChildrenMutation) {
if let Some(ref s) = self.super_type() {
s.children_chan... | super_type | identifier_name |
htmltitleelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLTitleElementBinding;
use dom::bindings::codegen::Bindings::HTMLTitleElem... |
let node = NodeCast::from_ref(*self);
if node.is_in_doc() {
node.owner_doc().title_changed();
}
}
fn bind_to_tree(&self, is_in_doc: bool) {
let node = NodeCast::from_ref(*self);
if is_in_doc {
let document = node.owner_doc();
document... | {
s.children_changed(mutation);
} | conditional_block |
htmltitleelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLTitleElementBinding;
use dom::bindings::codegen::Bindings::HTMLTitleElem... | let node = NodeCast::from_ref(*self);
if is_in_doc {
let document = node.owner_doc();
document.r().title_changed();
}
}
} | }
}
fn bind_to_tree(&self, is_in_doc: bool) { | random_line_split |
local.rs | // Copyright (c) 2013-2017 Sandstorm Development Group, Inc. and contributors
//
// 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 right... |
}
struct Results {
message: Option<message::Builder<message::HeapAllocator>>,
cap_table: Vec<Option<Box<dyn ClientHook>>>,
results_done_fulfiller: Option<oneshot::Sender<Box<dyn ResultsDoneHook>>>,
}
impl Results {
fn new(fulfiller: oneshot::Sender<Box<dyn ResultsDoneHook>>) -> Results {
Resu... | {
let mut result: any_pointer::Reader = self.request.get_root_as_reader()?;
result.imbue(&self.cap_table);
Ok(result)
} | identifier_body |
local.rs | // Copyright (c) 2013-2017 Sandstorm Development Group, Inc. and contributors
//
// 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 right... | {
message: Option<message::Builder<message::HeapAllocator>>,
cap_table: Vec<Option<Box<dyn ClientHook>>>,
results_done_fulfiller: Option<oneshot::Sender<Box<dyn ResultsDoneHook>>>,
}
impl Results {
fn new(fulfiller: oneshot::Sender<Box<dyn ResultsDoneHook>>) -> Results {
Results {
... | Results | identifier_name |
local.rs | // Copyright (c) 2013-2017 Sandstorm Development Group, Inc. and contributors
//
// 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 right... | }
}
}
impl Clone for Pipeline {
fn clone(&self) -> Pipeline {
Pipeline { inner: self.inner.clone() }
}
}
impl PipelineHook for Pipeline {
fn add_ref(&self) -> Box<dyn PipelineHook> {
Box::new(self.clone())
}
fn get_pipelined_cap(&self, ops: &[PipelineOp]) -> Box<dyn Cli... | random_line_split | |
local.rs | // Copyright (c) 2013-2017 Sandstorm Development Group, Inc. and contributors
//
// 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 right... | else {
unreachable!()
}
}
}
impl ResultsHook for Results {
fn get<'a>(&'a mut self) -> ::capnp::Result<any_pointer::Builder<'a>> {
match *self {
Results { message: Some(ref mut message), ref mut cap_table,.. } => {
let mut result: any_pointer::Builder = ... | {
let cap_table = mem::replace(&mut self.cap_table, Vec::new());
let _ = fulfiller.send(Box::new(ResultsDone::new(message, cap_table)));
} | conditional_block |
cargo_clean.rs | use crate::core::InternedString;
use std::collections::HashMap;
use std::fs;
use std::path::Path;
use crate::core::compiler::unit_dependencies;
use crate::core::compiler::{BuildConfig, BuildContext, CompileKind, CompileMode, Context};
use crate::core::compiler::{RustcTargetData, UnitInterner};
use crate::core::profile... |
// If we have a spec, then we need to delete some packages, otherwise, just
// remove the whole target directory and be done with it!
//
// Note that we don't bother grabbing a lock here as we're just going to
// blow it all away anyway.
if opts.spec.is_empty() {
return rm_rf(&target_d... | {
// After parsing profiles we know the dir-name of the profile, if a profile
// was passed from the command line. If so, delete only the directory of
// that profile.
let dir_name = profiles.get_dir_name();
target_dir = target_dir.join(dir_name);
} | conditional_block |
cargo_clean.rs | use crate::core::InternedString;
use std::collections::HashMap;
use std::fs;
use std::path::Path;
use crate::core::compiler::unit_dependencies;
use crate::core::compiler::{BuildConfig, BuildContext, CompileKind, CompileMode, Context};
use crate::core::compiler::{RustcTargetData, UnitInterner};
use crate::core::profile... | {
let m = fs::metadata(path);
if m.as_ref().map(|s| s.is_dir()).unwrap_or(false) {
config
.shell()
.verbose(|shell| shell.status("Removing", path.display()))?;
paths::remove_dir_all(path)
.chain_err(|| anyhow::format_err!("could not remove build directory"))?;... | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.