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 |
|---|---|---|---|---|
main.rs | // Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos.
//
// Serkr 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 later ver... | () {
let matches = clap::App::new("Serkr")
.version(crate_version!())
.author("Mikko Aarnos <mikko.aarnos@gmail.com>")
.about("An automated theorem prover for first order logic with equality")
.args_from_usage("<INPUT> 'The TPTP fil... | main | identifier_name |
main.rs | // Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos.
//
// Serkr is free software: you can redistribute it and/or modify | // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Serkr is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Pub... | // it under the terms of the GNU General Public License as published by | random_line_split |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Calculate [specified][specified] and [computed values][computed] from a
//! tree of DOM nodes and a set of sty... | <W, T>(dest: &mut W,
list: &[T])
-> fmt::Result
where W: fmt::Write,
T: ToCss,
{
if list.is_empty() {
return Ok(());
}
list[0].to_css(dest)?;
for item in list.iter().skip(1) {
dest.wri... | serialize_comma_separated_list | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Calculate [specified][specified] and [computed values][computed] from a
//! tree of DOM nodes and a set of sty... | pub mod dom_apis;
pub mod driver;
pub mod element_state;
#[cfg(feature = "servo")] mod encoding_support;
pub mod error_reporting;
pub mod font_face;
pub mod font_metrics;
#[cfg(feature = "gecko")] #[allow(unsafe_code)] pub mod gecko;
#[cfg(feature = "gecko")] #[allow(unsafe_code)] pub mod gecko_bindings;
pub mod hash;
... | pub mod dom; | random_line_split |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Calculate [specified][specified] and [computed values][computed] from a
//! tree of DOM nodes and a set of sty... |
list[0].to_css(dest)?;
for item in list.iter().skip(1) {
dest.write_str(", ")?;
item.to_css(dest)?;
}
Ok(())
}
#[cfg(feature = "gecko")] use gecko_string_cache::WeakAtom;
#[cfg(feature = "servo")] use servo_atoms::Atom as WeakAtom;
/// Extension methods for selectors::attr::CaseSen... | {
return Ok(());
} | conditional_block |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Calculate [specified][specified] and [computed values][computed] from a
//! tree of DOM nodes and a set of sty... |
#[cfg(feature = "gecko")] use gecko_string_cache::WeakAtom;
#[cfg(feature = "servo")] use servo_atoms::Atom as WeakAtom;
/// Extension methods for selectors::attr::CaseSensitivity
pub trait CaseSensitivityExt {
/// Return whether two atoms compare equal according to this case sensitivity.
fn eq_atom(self, a:... | {
if list.is_empty() {
return Ok(());
}
list[0].to_css(dest)?;
for item in list.iter().skip(1) {
dest.write_str(", ")?;
item.to_css(dest)?;
}
Ok(())
} | identifier_body |
line.rs | use std::string::ToString;
use std::borrow::Cow;
use time;
#[derive(Debug)]
pub enum Line {
// PMs are logged sometimes trigger alerts (and are sent to client(s))
PrivMsg { src: String, dst: String, text: String, orig: String },
// Metadata is not logged (but is sent to client(s))
Meta { orig: String }... | (&self, srv_name: &str) -> Option<(Cow<str>,String)> {
// (name,msg)
// if this message was in a public channel, `name` should be that channel
// if it was a private message from another user, it should be their nick
if let &Line::PrivMsg{ ref src, ref dst, ref text,.. } = self {
... | format_privmsg | identifier_name |
line.rs | use std::string::ToString;
use std::borrow::Cow;
use time;
#[derive(Debug)]
pub enum Line {
// PMs are logged sometimes trigger alerts (and are sent to client(s))
PrivMsg { src: String, dst: String, text: String, orig: String },
// Metadata is not logged (but is sent to client(s))
Meta { orig: String }... | Ping { orig: String },
}
impl Line {
pub fn new_meta(s: &str) -> Self {
Line::Meta{ orig: s.to_string() }
}
pub fn new_ping(s: &str) -> Self {
Line::Ping{ orig: s.to_string() }
}
pub fn new_pm(src: &str, dst: &str, text: &str, orig: &str) -> Self {
Line::PrivMsg{
... | random_line_split | |
line.rs | use std::string::ToString;
use std::borrow::Cow;
use time;
#[derive(Debug)]
pub enum Line {
// PMs are logged sometimes trigger alerts (and are sent to client(s))
PrivMsg { src: String, dst: String, text: String, orig: String },
// Metadata is not logged (but is sent to client(s))
Meta { orig: String }... |
pub fn pong_from_ping(p: &str) -> Line {
let s = p.replacen("PING ", "PONG ", 1);
Line::Ping { orig: s }
}
pub fn format_privmsg(&self, srv_name: &str) -> Option<(Cow<str>,String)> {
// (name,msg)
// if this message was in a public channel, `name` should be that channel
... | {
Line::PrivMsg{
src: src.to_string(),
dst: dst.to_string(),
text: text.to_string(),
orig: orig.to_string(),
}
} | identifier_body |
state_db.rs | // CITA
// Copyright 2016-2017 Cryptape Technologies LLC.
// This program 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
// later version.
// Th... | (&self) -> StateDB {
StateDB { db: self.db.boxed_clone() }
}
/// Journal all recent operations under the given era and ID.
pub fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, id: &H256) -> Result<u32, UtilError> {
self.db.journal_under(batch, now, id)
}
/// Returns... | boxed_clone | identifier_name |
state_db.rs | // CITA
// Copyright 2016-2017 Cryptape Technologies LLC.
// This program 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
// later version.
// Th... | /// Returns underlying `JournalDB`.
pub fn journal_db(&self) -> &JournalDB {
&*self.db
}
}
impl Backend for StateDB {
fn as_hashdb(&self) -> &HashDB {
self.db.as_hashdb()
}
fn as_hashdb_mut(&mut self) -> &mut HashDB {
self.db.as_hashdb_mut()
}
} | random_line_split | |
state_db.rs | // CITA
// Copyright 2016-2017 Cryptape Technologies LLC.
// This program 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
// later version.
// Th... |
}
| {
self.db.as_hashdb_mut()
} | identifier_body |
thunk.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub struct Thunk<'a, A=(),R=()> {
invoke: Box<Invoke<A,R>+Send + 'a>,
}
impl<'a, R> Thunk<'a,(),R> {
pub fn new<F>(func: F) -> Thunk<'a,(),R>
where F : FnOnce() -> R, F : Send + 'a
{
Thunk::with_arg(move|()| func())
}
}
impl<'a,A,R> Thunk<'a,A,R> {
pub fn with_arg<F>(func: F) -> T... | use core::marker::Send;
use core::ops::FnOnce; | random_line_split |
thunk.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 ... | <'a, A=(),R=()> {
invoke: Box<Invoke<A,R>+Send + 'a>,
}
impl<'a, R> Thunk<'a,(),R> {
pub fn new<F>(func: F) -> Thunk<'a,(),R>
where F : FnOnce() -> R, F : Send + 'a
{
Thunk::with_arg(move|()| func())
}
}
impl<'a,A,R> Thunk<'a,A,R> {
pub fn with_arg<F>(func: F) -> Thunk<'a,A,R>
... | Thunk | identifier_name |
issue-14901.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
pub fn main() {}
| {
Wrapper::WrapReader(self as &'a mut Reader)
} | identifier_body |
issue-14901.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (self) -> Wrapper<'a> {
Wrapper::WrapReader(self as &'a mut Reader)
}
}
pub fn main() {}
| wrap | identifier_name |
issue-14901.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | pub trait Reader {}
enum Wrapper<'a> {
WrapReader(&'a (Reader + 'a))
}
trait Wrap<'a> {
fn wrap(self) -> Wrapper<'a>;
}
impl<'a, R: Reader> Wrap<'a> for &'a mut R {
fn wrap(self) -> Wrapper<'a> {
Wrapper::WrapReader(self as &'a mut Reader)
}
}
pub fn main() {} | random_line_split | |
logistic_reg.rs | //! Logistic Regression module
//!
//! Contains implemention of logistic regression using
//! gradient descent optimization.
//!
//! The regressor will automatically add the intercept term
//! so you do not need to format the input matrices yourself.
//!
//! # Usage
//!
//! ```
//! use rusty_machine::learning::logistic... | else {
panic!("Model has not been trained.");
}
}
}
/// The Base Logistic Regression model.
///
/// This struct cannot be instantianated and is used internally only.
#[derive(Debug)]
pub struct BaseLogisticRegressor {
parameters: Option<Vector<f64>>,
}
impl BaseLogisticRegressor {
///... | {
let ones = Matrix::<f64>::ones(inputs.rows(), 1);
let full_inputs = ones.hcat(inputs);
(full_inputs * v).apply(&Sigmoid::func)
} | conditional_block |
logistic_reg.rs | //! Logistic Regression module
//!
//! Contains implemention of logistic regression using
//! gradient descent optimization.
//!
//! The regressor will automatically add the intercept term
//! so you do not need to format the input matrices yourself.
//!
//! # Usage
//!
//! ```
//! use rusty_machine::learning::logistic... | (&self) -> Option<&Vector<f64>> {
self.base.parameters()
}
}
impl<A> SupModel<Matrix<f64>, Vector<f64>> for LogisticRegressor<A>
where A: OptimAlgorithm<BaseLogisticRegressor>
{
/// Train the logistic regression model.
///
/// Takes training data and output values as input.
///
/// ... | parameters | identifier_name |
logistic_reg.rs | //! Logistic Regression module
//!
//! Contains implemention of logistic regression using
//! gradient descent optimization.
//!
//! The regressor will automatically add the intercept term
//! so you do not need to format the input matrices yourself.
//!
//! # Usage
//!
//! ```
//! use rusty_machine::learning::logistic... | pub struct BaseLogisticRegressor {
parameters: Option<Vector<f64>>,
}
impl BaseLogisticRegressor {
/// Construct a new BaseLogisticRegressor
/// with parameters set to None.
fn new() -> BaseLogisticRegressor {
BaseLogisticRegressor { parameters: None }
}
}
impl BaseLogisticRegressor {
... | random_line_split | |
macros.rs | #![crate_id = "oxidize_macros#0.2-pre"]
#![comment = "Macros for oxidize"]
#![license = "MIT"]
#![crate_type = "dylib"]
#![feature(macro_rules, plugin_registrar, managed_boxes, quote, phase)]
#![feature(trace_macros)]
/**
router! is a macro that is intended to ease the implementation of App for your App Struct
The g... |
// (04:53:50 PM) jroweboy: but I'm just asking about the outer impl block right now. Is that considered a block? Or maybe the mysterious trait_ref? I actually have no clue haha
// (04:53:58 PM) huon: jroweboy: an Item
// (04:54:05 PM) huon: jroweboy: however you can probably use a quote macro
// (04:54:19 PM) huon: ... | {
let expander = box BasicMacroExpander{expander: expand_router, span: None};
register(token::intern("router"), NormalTT(expander, None));
} | identifier_body |
macros.rs | #![crate_id = "oxidize_macros#0.2-pre"]
#![comment = "Macros for oxidize"]
#![license = "MIT"]
#![crate_type = "dylib"]
#![feature(macro_rules, plugin_registrar, managed_boxes, quote, phase)]
#![feature(trace_macros)]
/**
router! is a macro that is intended to ease the implementation of App for your App Struct
The g... | captured variable and pass it to the function as a `uint` otherwise it will 404. Maybe it should Bad Request
instead, but thats easy enough to change in the future.
**/
extern crate syntax;
#[allow(unused_imports)]
use std::path::BytesContainer;
#[allow(unused_imports)]
use syntax::{ast, codemap};
#[allow(unused_im... | }
```
Additionally, it should support variable binding, such that <userid:uint> should attempt to bind the | random_line_split |
macros.rs | #![crate_id = "oxidize_macros#0.2-pre"]
#![comment = "Macros for oxidize"]
#![license = "MIT"]
#![crate_type = "dylib"]
#![feature(macro_rules, plugin_registrar, managed_boxes, quote, phase)]
#![feature(trace_macros)]
/**
router! is a macro that is intended to ease the implementation of App for your App Struct
The g... | (cx: &mut ExtCtxt, sp: codemap::Span, tts: &[ast::TokenTree]) -> Box<MacResult> {
// fn parse_str(&mut self) -> (InternedString, StrStyle)
// ItemImpl for the Impl
// Trait as an Ident
// Type as a Type
// methods as a Vec of Methods?fn item_fn?
// make a parser for router! {
// trace_mac... | expand_router | identifier_name |
panic.rs | use std::any::Any;
use std::cell::RefCell;
thread_local!(static LAST_ERROR: RefCell<Option<Box<Any + Send>>> = {
RefCell::new(None)
});
#[cfg(feature = "unstable")]
pub fn wrap<T, F: FnOnce() -> T + ::std::panic::UnwindSafe>(f: F) -> Option<T> {
use std::panic;
if LAST_ERROR.with(|slot| slot.borrow().is_s... | }
}
}
#[cfg(not(feature = "unstable"))]
pub fn wrap<T, F: FnOnce() -> T>(f: F) -> Option<T> {
struct Bomb {
enabled: bool,
}
impl Drop for Bomb {
fn drop(&mut self) {
if!self.enabled {
return
}
panic!("callback has panicked, an... | Err(e) => {
LAST_ERROR.with(move |slot| {
*slot.borrow_mut() = Some(e);
});
None | random_line_split |
panic.rs | use std::any::Any;
use std::cell::RefCell;
thread_local!(static LAST_ERROR: RefCell<Option<Box<Any + Send>>> = {
RefCell::new(None)
});
#[cfg(feature = "unstable")]
pub fn wrap<T, F: FnOnce() -> T + ::std::panic::UnwindSafe>(f: F) -> Option<T> {
use std::panic;
if LAST_ERROR.with(|slot| slot.borrow().is_s... |
panic!("callback has panicked, and continuing to unwind into C \
is not safe, so aborting the process");
}
}
let mut bomb = Bomb { enabled: true };
let ret = Some(f());
bomb.enabled = false;
return ret;
}
pub fn check() {
let err = LAST_ERROR.with(|slot... | {
return
} | conditional_block |
panic.rs | use std::any::Any;
use std::cell::RefCell;
thread_local!(static LAST_ERROR: RefCell<Option<Box<Any + Send>>> = {
RefCell::new(None)
});
#[cfg(feature = "unstable")]
pub fn wrap<T, F: FnOnce() -> T + ::std::panic::UnwindSafe>(f: F) -> Option<T> {
use std::panic;
if LAST_ERROR.with(|slot| slot.borrow().is_s... | {
enabled: bool,
}
impl Drop for Bomb {
fn drop(&mut self) {
if!self.enabled {
return
}
panic!("callback has panicked, and continuing to unwind into C \
is not safe, so aborting the process");
}
}
let mut b... | Bomb | identifier_name |
panic.rs | use std::any::Any;
use std::cell::RefCell;
thread_local!(static LAST_ERROR: RefCell<Option<Box<Any + Send>>> = {
RefCell::new(None)
});
#[cfg(feature = "unstable")]
pub fn wrap<T, F: FnOnce() -> T + ::std::panic::UnwindSafe>(f: F) -> Option<T> {
use std::panic;
if LAST_ERROR.with(|slot| slot.borrow().is_s... |
pub fn panicked() -> bool {
LAST_ERROR.with(|slot| slot.borrow().is_some())
}
| {
let err = LAST_ERROR.with(|slot| slot.borrow_mut().take());
if let Some(err) = err {
panic!(err)
}
} | identifier_body |
outlives_suggestion.rs | //! Contains utilities for generating suggestions for borrowck errors related to unsatisfied
//! outlives constraints.
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::DiagnosticBuilder;
use rustc_middle::ty::RegionVid;
use smallvec::SmallVec;
use std::collections::BTreeMap;
use tracing::debug;
use crate::... | SuggestedConstraint::Outlives(a, bs) => {
let bs: SmallVec<[String; 2]> =
bs.iter().map(|r| format!("{}", r)).collect();
diag.help(&format!("add bound `{}: {}`", a, bs.join(" + ")));
}
... | // Add suggestions.
for constraint in suggested {
match constraint { | random_line_split |
outlives_suggestion.rs | //! Contains utilities for generating suggestions for borrowck errors related to unsatisfied
//! outlives constraints.
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::DiagnosticBuilder;
use rustc_middle::ty::RegionVid;
use smallvec::SmallVec;
use std::collections::BTreeMap;
use tracing::debug;
use crate::... |
/// Emit an intermediate note on the given `Diagnostic` if the involved regions are
/// suggestable.
crate fn intermediate_suggestion(
&mut self,
mbcx: &MirBorrowckCtxt<'_, '_>,
errci: &ErrorConstraintInfo,
diag: &mut DiagnosticBuilder<'_>,
) {
// Emit an interm... | {
debug!("Collected {:?}: {:?}", fr, outlived_fr);
// Add to set of constraints for final help note.
self.constraints_to_add.entry(fr).or_default().push(outlived_fr);
} | identifier_body |
outlives_suggestion.rs | //! Contains utilities for generating suggestions for borrowck errors related to unsatisfied
//! outlives constraints.
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::DiagnosticBuilder;
use rustc_middle::ty::RegionVid;
use smallvec::SmallVec;
use std::collections::BTreeMap;
use tracing::debug;
use crate::... |
SuggestedConstraint::Static(a) => format!("replace `{}` with `'static`", a),
})
} else {
// Create a new diagnostic.
let mut diag = mbcx
.infcx
.tcx
.sess
.diagnostic()
.struct_help("t... | {
format!("`{}` and `{}` must be the same: replace one with the other", a, b)
} | conditional_block |
outlives_suggestion.rs | //! Contains utilities for generating suggestions for borrowck errors related to unsatisfied
//! outlives constraints.
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::DiagnosticBuilder;
use rustc_middle::ty::RegionVid;
use smallvec::SmallVec;
use std::collections::BTreeMap;
use tracing::debug;
use crate::... | (
&mut self,
mbcx: &MirBorrowckCtxt<'_, '_>,
errci: &ErrorConstraintInfo,
diag: &mut DiagnosticBuilder<'_>,
) {
// Emit an intermediate note.
let fr_name = self.region_vid_to_name(mbcx, errci.fr);
let outlived_fr_name = self.region_vid_to_name(mbcx, errci.outl... | intermediate_suggestion | identifier_name |
hashchangeevent.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::EventBinding::EventMethods;
use dom::bindings::codegen::Bindings::HashChange... | {
event: Event,
old_url: String,
new_url: String,
}
impl HashChangeEvent {
fn new_inherited(old_url: String, new_url: String) -> HashChangeEvent {
HashChangeEvent {
event: Event::new_inherited(),
old_url: old_url,
new_url: new_url,
}
}
pub f... | HashChangeEvent | identifier_name |
hashchangeevent.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::EventBinding::EventMethods;
use dom::bindings::codegen::Bindings::HashChange... | old_url: String,
new_url: String,
}
impl HashChangeEvent {
fn new_inherited(old_url: String, new_url: String) -> HashChangeEvent {
HashChangeEvent {
event: Event::new_inherited(),
old_url: old_url,
new_url: new_url,
}
}
pub fn new_uninitialized(w... |
// https://html.spec.whatwg.org/multipage/#hashchangeevent
#[dom_struct]
pub struct HashChangeEvent {
event: Event, | random_line_split |
hashchangeevent.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::EventBinding::EventMethods;
use dom::bindings::codegen::Bindings::HashChange... |
}
impl HashChangeEventMethods for HashChangeEvent {
// https://html.spec.whatwg.org/multipage/#dom-hashchangeevent-oldurl
fn OldURL(&self) -> USVString {
USVString(self.old_url.clone())
}
// https://html.spec.whatwg.org/multipage/#dom-hashchangeevent-newurl
fn NewURL(&self) -> USVString {... | {
Ok(HashChangeEvent::new(
window,
Atom::from(type_),
init.parent.bubbles,
init.parent.cancelable,
init.oldURL.0.clone(),
init.newURL.0.clone(),
))
} | identifier_body |
mouse.rs | use std::ptr;
use get_error;
use SdlResult;
use surface::SurfaceRef;
use video;
use sys::mouse as ll;
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[repr(u32)]
pub enum SystemCursor {
Arrow = ll::SDL_SYSTEM_CURSOR_ARROW,
IBeam = ll::SDL_SYSTEM_CURSOR_IBEAM,
Wait = ll::SDL_SYSTEM_CURSOR_WAIT,
Cr... |
/// Tests if the X1 mouse button was pressed.
pub fn x1(&self) -> bool { (self.flags & ll::SDL_BUTTON_X1MASK)!= 0 }
/// Tests if the X2 mouse button was pressed.
pub fn x2(&self) -> bool { (self.flags & ll::SDL_BUTTON_X2MASK)!= 0 }
pub fn from_flags(flags: u32) -> MouseState {
MouseState... | { (self.flags & ll::SDL_BUTTON_RMASK) != 0 } | identifier_body |
mouse.rs | use std::ptr;
use get_error;
use SdlResult;
use surface::SurfaceRef;
use video;
use sys::mouse as ll;
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[repr(u32)]
pub enum SystemCursor {
Arrow = ll::SDL_SYSTEM_CURSOR_ARROW,
IBeam = ll::SDL_SYSTEM_CURSOR_IBEAM,
Wait = ll::SDL_SYSTEM_CURSOR_WAIT,
Cr... | (button: u8) -> Mouse {
match button {
1 => Mouse::Left,
2 => Mouse::Middle,
3 => Mouse::Right,
4 => Mouse::X1,
5 => Mouse::X2,
_ => Mouse::Unknown(button)
}
}
}
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub struct MouseState... | from_ll | identifier_name |
mouse.rs | use std::ptr; | use SdlResult;
use surface::SurfaceRef;
use video;
use sys::mouse as ll;
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[repr(u32)]
pub enum SystemCursor {
Arrow = ll::SDL_SYSTEM_CURSOR_ARROW,
IBeam = ll::SDL_SYSTEM_CURSOR_IBEAM,
Wait = ll::SDL_SYSTEM_CURSOR_WAIT,
Crosshair = ll::SDL_SYSTEM_CURSO... |
use get_error; | random_line_split |
mouse.rs | use std::ptr;
use get_error;
use SdlResult;
use surface::SurfaceRef;
use video;
use sys::mouse as ll;
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[repr(u32)]
pub enum SystemCursor {
Arrow = ll::SDL_SYSTEM_CURSOR_ARROW,
IBeam = ll::SDL_SYSTEM_CURSOR_IBEAM,
Wait = ll::SDL_SYSTEM_CURSOR_WAIT,
Cr... |
}
}
/// Tests if the left mouse button was pressed.
pub fn left(&self) -> bool { (self.flags & ll::SDL_BUTTON_LMASK)!= 0 }
/// Tests if the middle mouse button was pressed.
pub fn middle(&self) -> bool { (self.flags & ll::SDL_BUTTON_MMASK)!= 0 }
/// Tests if the right mouse button wa... | {
assert!(x <= 32);
let mask = 1 << ((x as u32) - 1);
(self.flags & mask) != 0
} | conditional_block |
mod.rs |
#[derive(Default, Debug)]
pub struct | {
pub take: bool,
pub fold_left: bool,
pub fold_right: bool,
pub go_left: bool,
pub go_right: bool,
}
impl SearchAction {
pub fn new() -> SearchAction {
SearchAction {..Default::default() }
}
pub fn merge(&self, other: &SearchAction) -> Option<SearchAction> {
if self.g... | SearchAction | identifier_name |
mod.rs |
#[derive(Default, Debug)]
pub struct SearchAction {
pub take: bool,
pub fold_left: bool,
pub fold_right: bool,
pub go_left: bool,
pub go_right: bool,
}
impl SearchAction {
pub fn new() -> SearchAction {
SearchAction {..Default::default() }
}
pub fn merge(&self, other: &Search... |
pub fn fold_left(mut self) -> SearchAction {
self.fold_left = true;
self
}
}
| {
self.fold_right = true;
self
} | identifier_body |
mod.rs | #[derive(Default, Debug)]
pub struct SearchAction {
pub take: bool,
pub fold_left: bool,
pub fold_right: bool,
pub go_left: bool,
pub go_right: bool,
}
impl SearchAction {
pub fn new() -> SearchAction {
SearchAction {..Default::default() }
}
pub fn merge(&self, other: &SearchAc... | }
new_action.go_left = self.go_left;
new_action.go_right = self.go_right;
Some(new_action)
}
pub fn is_stopped(&self) -> bool {
!self.go_left &&!self.go_right
}
pub fn take(mut self) -> SearchAction {
self.take = true;
self
}
pub fn go_... | new_action.fold_right = true; | random_line_split |
mod.rs |
#[derive(Default, Debug)]
pub struct SearchAction {
pub take: bool,
pub fold_left: bool,
pub fold_right: bool,
pub go_left: bool,
pub go_right: bool,
}
impl SearchAction {
pub fn new() -> SearchAction {
SearchAction {..Default::default() }
}
pub fn merge(&self, other: &Search... |
if self.fold_right && other.fold_right {
new_action.fold_right = true;
}
new_action.go_left = self.go_left;
new_action.go_right = self.go_right;
Some(new_action)
}
pub fn is_stopped(&self) -> bool {
!self.go_left &&!self.go_right
}
pub fn ... | {
new_action.fold_left = true;
} | conditional_block |
method-self-arg-2.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let mut x = Foo;
let y = &mut x;
Foo::bar(&x); //~ERROR cannot borrow `x`
let x = Foo;
Foo::baz(&x); //~ERROR cannot borrow immutable dereference of `&`-pointer as mutable
}
| main | identifier_name |
method-self-arg-2.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 | |
method-self-arg-2.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 baz(&mut self) {}
}
fn main() {
let mut x = Foo;
let y = &mut x;
Foo::bar(&x); //~ERROR cannot borrow `x`
let x = Foo;
Foo::baz(&x); //~ERROR cannot borrow immutable dereference of `&`-pointer as mutable
}
| {} | identifier_body |
needless_range_loop2.rs | #![warn(clippy::needless_range_loop)]
fn calc_idx(i: usize) -> usize {
(i + i + 20) % 4
}
fn main() {
let ns = vec![2, 3, 5, 7];
for i in 3..10 {
println!("{}", ns[i]);
}
for i in 3..10 {
println!("{}", ns[i % 4]);
}
for i in 3..10 {
println!("{}", ns[i % ns.len(... |
for i in 3..10 {
println!("{}", ns[calc_idx(i)]);
}
for i in 3..10 {
println!("{}", ns[calc_idx(i) % 4]);
}
let mut ms = vec![1, 2, 3, 4, 5, 6];
for i in 0..ms.len() {
ms[i] *= 2;
}
assert_eq!(ms, vec![2, 4, 6, 8, 10, 12]);
let mut ms = vec![1, 2, 3, 4, 5,... | random_line_split | |
needless_range_loop2.rs | #![warn(clippy::needless_range_loop)]
fn calc_idx(i: usize) -> usize {
(i + i + 20) % 4
}
fn | () {
let ns = vec![2, 3, 5, 7];
for i in 3..10 {
println!("{}", ns[i]);
}
for i in 3..10 {
println!("{}", ns[i % 4]);
}
for i in 3..10 {
println!("{}", ns[i % ns.len()]);
}
for i in 3..10 {
println!("{}", ns[calc_idx(i)]);
}
for i in 3..10 {
... | main | identifier_name |
needless_range_loop2.rs | #![warn(clippy::needless_range_loop)]
fn calc_idx(i: usize) -> usize |
fn main() {
let ns = vec![2, 3, 5, 7];
for i in 3..10 {
println!("{}", ns[i]);
}
for i in 3..10 {
println!("{}", ns[i % 4]);
}
for i in 3..10 {
println!("{}", ns[i % ns.len()]);
}
for i in 3..10 {
println!("{}", ns[calc_idx(i)]);
}
for i in ... | {
(i + i + 20) % 4
} | identifier_body |
iso.rs | //! Isometric transformations.
#![allow(missing_docs)]
use std::ops::{Add, Sub, Mul, Neg};
use rand::{Rand, Rng};
use num::One;
use structs::mat::{Mat3, Mat4, Mat5};
use traits::structure::{Cast, Dim, Col, BaseFloat, BaseNum};
use traits::operations::{Inv, ApproxEq};
use traits::geometry::{RotationMatrix, Rotation, ... | (&mut self, eye: &Pnt3<N>, at: &Pnt3<N>, up: &Vec3<N>) {
self.rotation.look_at(&(*at - *eye), up);
self.translation = eye.as_vec().clone();
}
/// Reorient and translate this transformation such that its local `z` axis points to a given
/// direction.
///
/// # Arguments
/// * ... | look_at | identifier_name |
iso.rs | //! Isometric transformations.
#![allow(missing_docs)]
use std::ops::{Add, Sub, Mul, Neg};
use rand::{Rand, Rng};
use num::One;
use structs::mat::{Mat3, Mat4, Mat5};
use traits::structure::{Cast, Dim, Col, BaseFloat, BaseNum};
use traits::operations::{Inv, ApproxEq};
use traits::geometry::{RotationMatrix, Rotation, ... | pub translation: Vec3<N>
}
/// Four dimensional isometry.
///
/// Isometries conserve angles and distances, hence do not allow shearing nor scaling.
#[repr(C)]
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Copy)]
pub struct Iso4<N> {
/// The rotation applicable by this isometry.
pub... | /// The translation applicable by this isometry. | random_line_split |
iso.rs | //! Isometric transformations.
#![allow(missing_docs)]
use std::ops::{Add, Sub, Mul, Neg};
use rand::{Rand, Rng};
use num::One;
use structs::mat::{Mat3, Mat4, Mat5};
use traits::structure::{Cast, Dim, Col, BaseFloat, BaseNum};
use traits::operations::{Inv, ApproxEq};
use traits::geometry::{RotationMatrix, Rotation, ... |
}
iso_impl!(Iso2, Rot2, Vec2, Vec1);
rotation_matrix_impl!(Iso2, Rot2, Vec2, Vec1);
rotation_impl!(Iso2, Rot2, Vec1);
dim_impl!(Iso2, 2);
one_impl!(Iso2);
absolute_rotate_impl!(Iso2, Vec2);
rand_impl!(Iso2);
approx_eq_impl!(Iso2);
to_homogeneous_impl!(Iso2, Mat3);
inv_impl!(Iso2);
transform_impl!(Iso2, Pnt2);
transfo... | {
Iso4 {
rotation: rotation,
translation: translation
}
} | identifier_body |
illumos.rs | s! {
pub struct shmid_ds {
pub shm_perm: ::ipc_perm,
pub shm_segsz: ::size_t,
pub shm_amp: *mut ::c_void,
pub shm_lkcnt: ::c_ushort,
pub shm_lpid: ::pid_t,
pub shm_cpid: ::pid_t,
pub shm_nattch: ::shmatt_t,
pub shm_cnattch: ::c_ulong,
pub shm_a... |
pub fn mincore(addr: ::caddr_t, len: ::size_t, vec: *mut ::c_char) -> ::c_int;
pub fn pset_bind_lwp(
pset: ::psetid_t,
id: ::id_t,
pid: ::pid_t,
opset: *mut ::psetid_t,
) -> ::c_int;
pub fn pset_getloadavg(pset: ::psetid_t, load: *mut ::c_double, num: ::c_int) -> ::c_in... | extern "C" {
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; | random_line_split |
blob.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::InheritTypes::FileDerived;
use dom::bindings::global::GlobalRef;
use dom::bindings::js... | () -> Blob {
Blob {
reflector_: Reflector::new(),
type_: BlobTypeId
}
}
pub fn new(global: &GlobalRef) -> Temporary<Blob> {
reflect_dom_object(box Blob::new_inherited(),
global,
BlobBinding::Wrap)
}
p... | new_inherited | identifier_name |
blob.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::InheritTypes::FileDerived;
use dom::bindings::global::GlobalRef;
use dom::bindings::js... | pub fn new_inherited() -> Blob {
Blob {
reflector_: Reflector::new(),
type_: BlobTypeId
}
}
pub fn new(global: &GlobalRef) -> Temporary<Blob> {
reflect_dom_object(box Blob::new_inherited(),
global,
BlobBin... | random_line_split | |
blob.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::InheritTypes::FileDerived;
use dom::bindings::global::GlobalRef;
use dom::bindings::js... |
}
impl Reflectable for Blob {
fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector_
}
}
impl FileDerived for Blob {
fn is_file(&self) -> bool {
match self.type_ {
FileTypeId => true,
_ => false
}
}
}
| {
Ok(Blob::new(global))
} | identifier_body |
network_delay.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
#![forbid(unsafe_code)]
use crate::effects::Effect;
/// NetworkDelay introduces network delay from a given instance to a provided list of instances
/// If no instances are provided, network delay is introduced on all outgoing packets
u... |
}
/// three_region_simulation_effects returns the list of NetworkDelays which need to be applied to
/// all the instances in the cluster.
/// `regions` is a 3-tuple consisting of the list of instances in each region
/// `delays_bw_regions` is a 3-tuple consisting of the one-way delays between pairs of regions
/// del... | {
write!(f, "NetworkDelay from {}", self.instance)
} | identifier_body |
network_delay.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
#![forbid(unsafe_code)]
use crate::effects::Effect;
/// NetworkDelay introduces network delay from a given instance to a provided list of instances
/// If no instances are provided, network delay is introduced on all outgoing packets
u... | } | }
result | random_line_split |
network_delay.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
#![forbid(unsafe_code)]
use crate::effects::Effect;
/// NetworkDelay introduces network delay from a given instance to a provided list of instances
/// If no instances are provided, network delay is introduced on all outgoing packets
u... | {
instance: Instance,
// A vector of a pair of (delay, instance list)
// Applies delay to each instance in the instance list
configuration: Vec<(Vec<Instance>, Duration)>,
}
impl NetworkDelay {
pub fn new(instance: Instance, configuration: Vec<(Vec<Instance>, Duration)>) -> Self {
Self {
... | NetworkDelay | identifier_name |
candlestick.rs | //! "Candlestick" plots
use std::borrow::Cow;
use std::iter::IntoIterator;
use data::Matrix;
use traits::{self, Data, Set};
use {Color, Default, Display, Figure, Label, LineType, LineWidth, Plot, Script};
/// Properties common to candlestick plots
pub struct Properties {
color: Option<Color>,
label: Option<C... |
script
}
}
impl Set<Color> for Properties {
/// Sets the line color
fn set(&mut self, color: Color) -> &mut Properties {
self.color = Some(color);
self
}
}
impl Set<Label> for Properties {
/// Sets the legend label
fn set(&mut self, label: Label) -> &mut Properties {
... | {
script.push_str("notitle")
} | conditional_block |
candlestick.rs | //! "Candlestick" plots
use std::borrow::Cow;
use std::iter::IntoIterator;
use data::Matrix;
use traits::{self, Data, Set};
use {Color, Default, Display, Figure, Label, LineType, LineWidth, Plot, Script};
/// Properties common to candlestick plots
pub struct | {
color: Option<Color>,
label: Option<Cow<'static, str>>,
line_type: LineType,
linewidth: Option<f64>,
}
impl Default for Properties {
fn default() -> Properties {
Properties {
color: None,
label: None,
line_type: LineType::Solid,
linewidth: ... | Properties | identifier_name |
candlestick.rs | //! "Candlestick" plots
use std::borrow::Cow;
use std::iter::IntoIterator;
use data::Matrix;
use traits::{self, Data, Set};
use {Color, Default, Display, Figure, Label, LineType, LineWidth, Plot, Script};
/// Properties common to candlestick plots
pub struct Properties {
color: Option<Color>,
label: Option<C... | self
}
}
impl Set<LineType> for Properties {
/// Changes the line type
///
/// **Note** By default `Solid` lines are used
fn set(&mut self, lt: LineType) -> &mut Properties {
self.line_type = lt;
self
}
}
impl Set<LineWidth> for Properties {
/// Changes the width of... | self.label = Some(label.0); | random_line_split |
bind.rs | #[cfg(test)]
mod matrix44_tests {
use super::*;
use crate::math::*;
use std::rc::Rc;
use std::cell::RefCell;
use std::collections::HashMap;
pub struct Entity
{
pos: Vec3,
}
pub struct Camera
{
pos: Vec3,
}
pub struct Game
{
entities: Vec<Ent... | {
pub fn bind<T>(&mut self, from: &T, to: &T)
{
}
pub fn set_value<T>(&mut self, from: &mut T, v: T)
{
}
}
#[test]
fn matrix44_id_mul_id() {
let mut g = Game {
entities: Vec::new(),
cameras: Vec::new(),
};
... | HashMap<>
}
impl Game | random_line_split |
bind.rs | #[cfg(test)]
mod matrix44_tests {
use super::*;
use crate::math::*;
use std::rc::Rc;
use std::cell::RefCell;
use std::collections::HashMap;
pub struct Entity
{
pos: Vec3,
}
pub struct Camera
{
pos: Vec3,
}
pub struct Game
{
entities: Vec<Ent... | () {
let mut g = Game {
entities: Vec::new(),
cameras: Vec::new(),
};
let e = Entity { pos: Vec3::new(0.0, 0.0, 0.0) };
//g.entities.push(e);
let c = Camera { pos: Vec3::new(0.0, 0.0, 0.0) };
//g.cameras.push(c);
g.bind(&e.pos, &c.pos);
... | matrix44_id_mul_id | identifier_name |
continuous.rs | use std::collections::{HashSet, VecDeque};
use std::hash::{Hash, Hasher};
use std::iter::{FromIterator, Iterator};
use std::marker::PhantomData;
use std::sync::{Arc, RwLock, Weak};
use uuid::Uuid;
use super::{Continuous, DType};
use super::{Node, Observation, Variable};
use dists::{Normalization, Sample};
use err::Er... | /// Returns the total number of variables in the model.
pub fn var_num(&self) -> usize {
self.vars.nodes.len()
}
/// Iterate the model variables in topographical order.
pub fn iter_vars(&self) -> BayesNetIter<'a, N> {
BayesNetIter::new(&self.vars.nodes)
}
/// Get the node i... | if let Some(pos) = self
.vars
.nodes
.iter()
.position(|n| (&**n).get_dist() == var)
{
if pos < self.vars.nodes.len() - 1 {
let parent = &self.vars.nodes[pos];
for node in &self.vars.nodes[pos + 1..] {
... | identifier_body |
continuous.rs | use std::collections::{HashSet, VecDeque};
use std::hash::{Hash, Hasher};
use std::iter::{FromIterator, Iterator};
use std::marker::PhantomData;
use std::sync::{Arc, RwLock, Weak};
use uuid::Uuid;
use super::{Continuous, DType};
use super::{Node, Observation, Variable};
use dists::{Normalization, Sample};
use err::Er... | self) -> usize {
self.vars.nodes.len()
}
/// Iterate the model variables in topographical order.
pub fn iter_vars(&self) -> BayesNetIter<'a, N> {
BayesNetIter::new(&self.vars.nodes)
}
/// Get the node in the graph at position *i* unchecked.
pub fn get_var(&self, i: usize) -> Ar... | r_num(& | identifier_name |
continuous.rs | use std::collections::{HashSet, VecDeque};
use std::hash::{Hash, Hasher};
use std::iter::{FromIterator, Iterator};
use std::marker::PhantomData;
use std::sync::{Arc, RwLock, Weak};
use uuid::Uuid;
use super::{Continuous, DType};
use super::{Node, Observation, Variable};
use dists::{Normalization, Sample};
use err::Er... | let mut dists = Vec::with_capacity(parents.len());
for p in parents {
dists.push(p.dist);
}
dists
}
fn get_childs_dists(&self) -> Vec<&'a V> {
let childs = &*self.childs.read().unwrap();
let mut dists = Vec::with_capacity(childs.len());
for c ... | self.dist.sample(rng)
}
fn get_parents_dists(&self) -> Vec<&'a V> {
let parents = &*self.parents.read().unwrap(); | random_line_split |
msg_getdata.rs | use std;
extern crate time;
use primitive::UInt256;
use ::serialize::{self, Serializable};
use super::{Inv, InvType};
#[derive(Debug,Default)]
pub struct GetDataMessage {
pub invs : Vec<Inv>,
}
impl GetDataMessage {
pub fn new(invtype:InvType, hash: UInt256) -> Self {
GetDataMessage {
invs: vec![... | (hash: UInt256) -> Self { Self::new(InvType::Block, hash) }
pub fn new_filter_block(hash: UInt256) -> Self { Self::new(InvType::FilteredBlock, hash) }
}
impl super::Message for GetDataMessage {
fn get_command(&self) -> [u8; super::message_header::COMMAND_SIZE] {
super::message_header::COMMAND_GETDAT... | new_block | identifier_name |
msg_getdata.rs | use std;
extern crate time; | #[derive(Debug,Default)]
pub struct GetDataMessage {
pub invs : Vec<Inv>,
}
impl GetDataMessage {
pub fn new(invtype:InvType, hash: UInt256) -> Self {
GetDataMessage {
invs: vec![ Inv::new(invtype, hash) ]
}
}
pub fn new_tx(hash: UInt256) -> Self { Self::new(InvType::Tx, hash... | use primitive::UInt256;
use ::serialize::{self, Serializable};
use super::{Inv, InvType};
| random_line_split |
msg_getdata.rs | use std;
extern crate time;
use primitive::UInt256;
use ::serialize::{self, Serializable};
use super::{Inv, InvType};
#[derive(Debug,Default)]
pub struct GetDataMessage {
pub invs : Vec<Inv>,
}
impl GetDataMessage {
pub fn new(invtype:InvType, hash: UInt256) -> Self {
GetDataMessage {
invs: vec![... |
}
impl std::fmt::Display for GetDataMessage {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self.invs.len() {
0 => write!(f, "GetData(len={})", self.invs.len()),
1 => write!(f, "GetData(len={}, 0={})", self.invs.len(), self.invs[0]),
l => write!(f, "GetData(... | {
super::message_header::COMMAND_GETDATA
} | identifier_body |
flow_list.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 flow::Flow;
use flow_ref::FlowRef;
use std::collections::{dlist, DList};
// This needs to be reworked now th... | (&mut self, new_tail: FlowRef) {
self.flows.push_back(new_tail);
}
/// Create an empty list
#[inline]
pub fn new() -> FlowList {
FlowList {
flows: DList::new(),
}
}
/// Provide a forward iterator
#[inline]
pub fn iter<'a>(&'a self) -> FlowListIterato... | push_back | identifier_name |
flow_list.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 flow::Flow;
use flow_ref::FlowRef;
use std::collections::{dlist, DList};
// This needs to be reworked now th... | }
/// Provide a forward iterator
#[inline]
pub fn iter<'a>(&'a self) -> FlowListIterator<'a> {
FlowListIterator {
it: self.flows.iter(),
}
}
/// Provide a forward iterator with mutable references
#[inline]
pub fn iter_mut<'a>(&'a mut self) -> MutFlowListIter... | #[inline]
pub fn new() -> FlowList {
FlowList {
flows: DList::new(),
} | random_line_split |
flow_list.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 flow::Flow;
use flow_ref::FlowRef;
use std::collections::{dlist, DList};
// This needs to be reworked now th... |
/// Provide a reference to the back element, or None if the list is empty
#[inline]
pub fn back<'a>(&'a self) -> Option<&'a Flow> {
self.flows.back().map(|tail| tail.deref())
}
/// Provide a mutable reference to the back element, or None if the list is empty
#[inline]
pub unsafe f... | {
self.flows.front_mut().map(|head| head.deref_mut())
} | identifier_body |
2sum.rs | use std::collections::HashMap;
fn main() {
// 2 results - for `7` and both `-3` numbers
two_sum(vec![3, 5, 7, 0, -3, -2, -3], 4);
// No results
two_sum(vec![3, 5, 0, -3, -2, -3], 4);
}
fn two_sum(numbers: Vec<i32>, target: i32) {
let mut indices: HashMap<i32, usize> = HashMap::new();
println!... |
indices.insert(*number, i);
}
} | {
println!("Found two indices that sum-up to {}: {} and {}", target, indices.get(&hash_index).unwrap(), i);
} | conditional_block |
2sum.rs | use std::collections::HashMap;
fn main() {
// 2 results - for `7` and both `-3` numbers
two_sum(vec![3, 5, 7, 0, -3, -2, -3], 4); | fn two_sum(numbers: Vec<i32>, target: i32) {
let mut indices: HashMap<i32, usize> = HashMap::new();
println!("Numbers: {:?}", numbers);
for (i, number) in numbers.iter().enumerate() {
let hash_index = target - number;
if indices.get(&hash_index).is_some() {
println!("Found two... | // No results
two_sum(vec![3, 5, 0, -3, -2, -3], 4);
}
| random_line_split |
2sum.rs | use std::collections::HashMap;
fn main() |
fn two_sum(numbers: Vec<i32>, target: i32) {
let mut indices: HashMap<i32, usize> = HashMap::new();
println!("Numbers: {:?}", numbers);
for (i, number) in numbers.iter().enumerate() {
let hash_index = target - number;
if indices.get(&hash_index).is_some() {
println!("Found t... | {
// 2 results - for `7` and both `-3` numbers
two_sum(vec![3, 5, 7, 0, -3, -2, -3], 4);
// No results
two_sum(vec![3, 5, 0, -3, -2, -3], 4);
} | identifier_body |
2sum.rs | use std::collections::HashMap;
fn | () {
// 2 results - for `7` and both `-3` numbers
two_sum(vec![3, 5, 7, 0, -3, -2, -3], 4);
// No results
two_sum(vec![3, 5, 0, -3, -2, -3], 4);
}
fn two_sum(numbers: Vec<i32>, target: i32) {
let mut indices: HashMap<i32, usize> = HashMap::new();
println!("Numbers: {:?}", numbers);
for (i... | main | identifier_name |
compositor_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/. */
use azure::azure_hl::Color;
use constellation_msg::{Key, KeyModifiers, KeyState, PipelineId};
use euclid::{Matrix4... |
pub fn companion_layer_id(&self) -> LayerId {
let LayerId(layer_type, id, companion) = *self;
LayerId(layer_type, id, companion + 1)
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum LayerKind {
NoTransform,
HasTransform,
}
/// The scrolling policy of a layer.
#[derive(Clone, Par... | {
LayerId(layer_type, fragment_id, 0)
} | identifier_body |
compositor_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/. */
use azure::azure_hl::Color;
use constellation_msg::{Key, KeyModifiers, KeyState, PipelineId};
use euclid::{Matrix4... | /// These layers scroll when the parent receives a scrolling message.
Scrollable,
/// These layers do not scroll when the parent receives a scrolling message.
FixedPosition,
}
/// All layer-specific information that the painting task sends to the compositor other than the
/// buffer contents of the lay... |
/// The scrolling policy of a layer.
#[derive(Clone, PartialEq, Eq, Copy, Deserialize, Serialize, Debug, HeapSizeOf)]
pub enum ScrollPolicy { | random_line_split |
compositor_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/. */
use azure::azure_hl::Color;
use constellation_msg::{Key, KeyModifiers, KeyState, PipelineId};
use euclid::{Matrix4... | () -> LayerId {
LayerId(LayerType::FragmentBody, 0, 0)
}
pub fn new_of_type(layer_type: LayerType, fragment_id: usize) -> LayerId {
LayerId(layer_type, fragment_id, 0)
}
pub fn companion_layer_id(&self) -> LayerId {
let LayerId(layer_type, id, companion) = *self;
LayerI... | null | identifier_name |
interpreter.rs | use std::io::{Read, Write};
use state::State;
use common::BfResult;
use traits::Interpretable;
use super::*;
impl Interpretable for Program {
fn interpret_state<R: Read, W: Write>(
&self, mut state: State, mut input: R, mut output: W) -> BfResult<()>
|
}
fn interpret<R, W>(instructions: &Program, state: &mut State,
input: &mut R, output: &mut W)
-> BfResult<()>
where R: Read, W: Write
{
use common::Instruction::*;
let mut pc = 0;
while pc < instructions.len() {
match instructions[pc] {
... | {
interpret(self, &mut state, &mut input, &mut output)
} | identifier_body |
interpreter.rs | use std::io::{Read, Write};
use state::State;
use common::BfResult;
use traits::Interpretable;
use super::*;
impl Interpretable for Program {
fn interpret_state<R: Read, W: Write>(
&self, mut state: State, mut input: R, mut output: W) -> BfResult<()>
{
interpret(self, &mut state, &mut input, &... |
OffsetAddLeft(offset) => {
if state.load()!= 0 {
let value = state.load();
state.store(0);
state.up_neg_offset(offset, value)?;
}
}
FindZeroRight(offset) => {
while state.lo... | {
if state.load() != 0 {
let value = state.load();
state.store(0);
state.up_pos_offset(offset, value)?;
}
} | conditional_block |
interpreter.rs | use std::io::{Read, Write};
use state::State;
use common::BfResult;
use traits::Interpretable;
use super::*;
impl Interpretable for Program {
fn interpret_state<R: Read, W: Write>(
&self, mut state: State, mut input: R, mut output: W) -> BfResult<()>
{
interpret(self, &mut state, &mut input, &... |
JumpNotZero(address) => {
if state.load()!= 0 {
pc = address as usize;
}
}
SetZero => state.store(0),
OffsetAddRight(offset) => {
if state.load()!= 0 {
let value = state.load();
... | } | random_line_split |
interpreter.rs | use std::io::{Read, Write};
use state::State;
use common::BfResult;
use traits::Interpretable;
use super::*;
impl Interpretable for Program {
fn interpret_state<R: Read, W: Write>(
&self, mut state: State, mut input: R, mut output: W) -> BfResult<()>
{
interpret(self, &mut state, &mut input, &... | () {
assert_parse_interpret(HELLO_WORLD_SRC, "", "Hello, World!");
}
#[test]
fn factoring() {
assert_parse_interpret(FACTOR_SRC, "2\n", "2: 2\n");
assert_parse_interpret(FACTOR_SRC, "3\n", "3: 3\n");
assert_parse_interpret(FACTOR_SRC, "6\n", "6: 2 3\n");
assert_parse... | hello_world | identifier_name |
create-delete-cluster.rs | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_eks::model::VpcConfigRequest;
use aws_sdk_eks::{Client, Error, Region, PKG_VERSION};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]... | ) -> Result<(), aws_sdk_eks::Error> {
let cluster = client
.create_cluster()
.name(name)
.role_arn(arn)
.resources_vpc_config(
VpcConfigRequest::builder()
.set_subnet_ids(Some(subnet_ids))
.build(),
)
.send()
.await?;
pr... | client: &aws_sdk_eks::Client,
name: &str,
arn: &str,
subnet_ids: Vec<String>, | random_line_split |
create-delete-cluster.rs | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_eks::model::VpcConfigRequest;
use aws_sdk_eks::{Client, Error, Region, PKG_VERSION};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]... |
let region_provider = RegionProviderChain::first_try(region.map(Region::new))
.or_default_provider()
.or_else(Region::new("us-west-2"));
if verbose {
println!();
println!("EKS client version: {}", PKG_VERSION);
println!(
"Region: {}",
... | {
tracing_subscriber::fmt::init();
} | conditional_block |
create-delete-cluster.rs | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_eks::model::VpcConfigRequest;
use aws_sdk_eks::{Client, Error, Region, PKG_VERSION};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]... | () -> Result<(), Error> {
let Opt {
arn,
cluster_name,
region,
subnet_ids,
verbose,
} = Opt::from_args();
if verbose {
tracing_subscriber::fmt::init();
}
let region_provider = RegionProviderChain::first_try(region.map(Region::new))
.or_default... | main | identifier_name |
create-delete-cluster.rs | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_eks::model::VpcConfigRequest;
use aws_sdk_eks::{Client, Error, Region, PKG_VERSION};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]... | println!(
"Region: {}",
region_provider.region().await.unwrap().as_ref()
);
println!();
}
let shared_config = aws_config::from_env().region(region_provider).load().await;
let client = Client::new(&shared_config);
make_cluster(&client, &clust... | {
let Opt {
arn,
cluster_name,
region,
subnet_ids,
verbose,
} = Opt::from_args();
if verbose {
tracing_subscriber::fmt::init();
}
let region_provider = RegionProviderChain::first_try(region.map(Region::new))
.or_default_provider()
.or... | identifier_body |
util.rs | //! Provides common utility functions
use std::sync::{Arc, RwLock};
use co::prelude::*;
use coblas::plugin::*;
use conn;
use num::traits::{NumCast, cast};
/// Shared Lock used for our tensors
pub type ArcLock<T> = Arc<RwLock<T>>;
/// Create a simple native backend.
///
/// This is handy when you need to sync data to ... |
/// Extends IBlas with Axpby
pub trait Axpby<F> : Axpy<F> + Scal<F> {
/// Performs the operation y := a*x + b*y.
///
/// Consists of a scal(b, y) followed by a axpby(a,x,y).
fn axpby(&self, a: &mut SharedTensor<F>, x: &mut SharedTensor<F>, b: &mut SharedTensor<F>, y: &mut SharedTensor<F>) -> Result<()... | {
let mut out = Vec::new();
for i in input.iter() {
out.push(*i as i32);
}
out
} | identifier_body |
util.rs | //! Provides common utility functions
use std::sync::{Arc, RwLock};
use co::prelude::*;
use coblas::plugin::*;
use conn;
use num::traits::{NumCast, cast};
/// Shared Lock used for our tensors
pub type ArcLock<T> = Arc<RwLock<T>>;
/// Create a simple native backend.
///
/// This is handy when you need to sync data to ... |
/// Casts a Vec<usize> to as Vec<i32>
pub fn cast_vec_usize_to_i32(input: Vec<usize>) -> Vec<i32> {
let mut out = Vec::new();
for i in input.iter() {
out.push(*i as i32);
}
out
}
/// Extends IBlas with Axpby
pub trait Axpby<F> : Axpy<F> + Scal<F> {
/// Performs the operation y := a*x + b*y... | random_line_split | |
util.rs | //! Provides common utility functions
use std::sync::{Arc, RwLock};
use co::prelude::*;
use coblas::plugin::*;
use conn;
use num::traits::{NumCast, cast};
/// Shared Lock used for our tensors
pub type ArcLock<T> = Arc<RwLock<T>>;
/// Create a simple native backend.
///
/// This is handy when you need to sync data to ... | () -> Backend<Native> {
let framework = Native::new();
let hardwares = &framework.hardwares().to_vec();
let backend_config = BackendConfig::new(framework, hardwares);
Backend::new(backend_config).unwrap()
}
/// Write into a native Collenchyma Memory.
pub fn write_to_memory<T: NumCast + ::std::marker::C... | native_backend | identifier_name |
feature_gate.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 ... | (&mut self, sp: Span, id: ast::Ident, _: ()) {
let s = token::ident_to_str(&id);
if!s.is_ascii() {
self.gate_feature("non_ascii_idents", sp,
"non-ascii idents are not fully supported.");
}
}
fn visit_view_item(&mut self, i: &ast::ViewItem, _: (... | visit_ident | identifier_name |
feature_gate.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 ... | }
};
match KNOWN_FEATURES.iter().find(|& &(n, _)| n == name) {
Some(&(name, Active)) => { cx.features.push(name); }
Some(&(_, Removed)) => {
sess.span_err(mi.span, "feature has bee... | random_line_split | |
feature_gate.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 ... |
}
visit::walk_item(self, i, ());
}
fn visit_mac(&mut self, macro: &ast::Mac, _: ()) {
let ast::MacInvocTT(ref path, _, _) = macro.node;
if path.segments.last().identifier == self.sess.ident_of("macro_rules") {
self.gate_feature("macro_rules", path.span, "macro def... | {} | conditional_block |
feature_gate.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 ... | just one word");
continue
}
};
match KNOWN_FEATURES.iter().find(|& &(n, _)| n == name) {
Some(&(name, Active)) => { cx.features.push(name); }
... | {
let mut cx = Context {
features: ~[],
sess: sess,
};
for attr in crate.attrs.iter() {
if "feature" != attr.name() { continue }
match attr.meta_item_list() {
None => {
sess.span_err(attr.span, "malformed feature attribute, \
... | identifier_body |
issue-7012.rs | // run-pass
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
/*
# Comparison of static arrays
The expected behaviour would be that `test == test1`, therefore 'true'
would be printed, however the below prints false.
*/
struct signature<'a> { pattern : &'a [u32] }
static test1: signature<'static> = ... | {
let test: &[u32] = &[0x243f6a88,0x85a308d3,0x13198a2e,
0x03707344,0xa4093822,0x299f31d0];
println!("{}",test==test1.pattern);
} | identifier_body | |
issue-7012.rs | // run-pass
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
/*
# Comparison of static arrays
The expected behaviour would be that `test == test1`, therefore 'true'
would be printed, however the below prints false.
*/
struct | <'a> { pattern : &'a [u32] }
static test1: signature<'static> = signature {
pattern: &[0x243f6a88,0x85a308d3,0x13198a2e,0x03707344,0xa4093822,0x299f31d0]
};
pub fn main() {
let test: &[u32] = &[0x243f6a88,0x85a308d3,0x13198a2e,
0x03707344,0xa4093822,0x299f31d0];
println!("{}",test==test1... | signature | identifier_name |
issue-7012.rs | // run-pass
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
/*
# Comparison of static arrays
The expected behaviour would be that `test == test1`, therefore 'true'
would be printed, however the below prints false.
*/
struct signature<'a> { pattern : &'a [u32] }
static test1: signature<'static> = ... |
pub fn main() {
let test: &[u32] = &[0x243f6a88,0x85a308d3,0x13198a2e,
0x03707344,0xa4093822,0x299f31d0];
println!("{}",test==test1.pattern);
} | pattern: &[0x243f6a88,0x85a308d3,0x13198a2e,0x03707344,0xa4093822,0x299f31d0]
}; | random_line_split |
basic.rs | #[macro_use]
extern crate zookeeper_derive;
use std::convert::From;
use std::error::Error;
use std::string::ToString;
#[derive(Debug, EnumConvertFromInt, EnumDisplay, EnumError, PartialEq)]
#[EnumConvertFromIntFallback = "C"]
enum BasicError {
/// Documentation.
A = 1,
/// More documentation.
B = 5,
... |
#[test]
fn from() {
assert_eq!(BasicError::A, BasicError::from(1));
assert_eq!(BasicError::B, BasicError::from(5));
assert_eq!(BasicError::C, BasicError::from(10));
// fallback to...
assert_eq!(BasicError::C, BasicError::from(100));
}
| {
assert_eq!("A", BasicError::A.description());
assert_eq!("B", BasicError::B.description());
assert_eq!("C", BasicError::C.description());
} | identifier_body |
basic.rs | #[macro_use]
extern crate zookeeper_derive;
use std::convert::From;
use std::error::Error;
use std::string::ToString;
#[derive(Debug, EnumConvertFromInt, EnumDisplay, EnumError, PartialEq)]
#[EnumConvertFromIntFallback = "C"]
enum BasicError {
/// Documentation.
A = 1,
/// More documentation.
B = 5,
... |
#[test]
fn from() {
assert_eq!(BasicError::A, BasicError::from(1));
assert_eq!(BasicError::B, BasicError::from(5));
assert_eq!(BasicError::C, BasicError::from(10));
// fallback to...
assert_eq!(BasicError::C, BasicError::from(100));
} | } | random_line_split |
basic.rs | #[macro_use]
extern crate zookeeper_derive;
use std::convert::From;
use std::error::Error;
use std::string::ToString;
#[derive(Debug, EnumConvertFromInt, EnumDisplay, EnumError, PartialEq)]
#[EnumConvertFromIntFallback = "C"]
enum | {
/// Documentation.
A = 1,
/// More documentation.
B = 5,
/// Yes.
C = 10,
}
#[test]
fn display() {
assert_eq!("A", BasicError::A.to_string());
assert_eq!("B", BasicError::B.to_string());
assert_eq!("C", BasicError::C.to_string());
}
#[test]
fn description() {
assert_eq!("A",... | BasicError | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.