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 |
|---|---|---|---|---|
fetch.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::RequestBinding::RequestInfo;
use dom::bindings::codegen::Bindings::RequestBi... |
}
/// Use this if you don't want it to send a cancellation request
/// on drop (e.g. if the fetch completes)
pub fn ignore(&mut self) {
let _ = self.cancel_chan.take();
}
}
impl Drop for FetchCanceller {
fn drop(&mut self) {
self.cancel()
}
}
fn from_referrer_to_referrer_... | {
// stop trying to make fetch happen
// it's not going to happen
// The receiver will be destroyed if the request has already completed;
// so we throw away the error. Cancellation is a courtesy call,
// we don't actually care if the other side heard.
... | conditional_block |
suspicious_splitn.rs | #![warn(clippy::suspicious_splitn)]
fn main() {
let _ = "a,b,c".splitn(3, ',');
let _ = [0, 1, 2, 1, 3].splitn(3, |&x| x == 1);
let _ = "".splitn(0, ',');
let _ = [].splitn(0, |&x: &u32| x == 1);
let _ = "a,b".splitn(0, ','); | let _ = "a,b".rsplitn(0, ',');
let _ = "a,b".splitn(1, ',');
let _ = [0, 1, 2].splitn(0, |&x| x == 1);
let _ = [0, 1, 2].splitn_mut(0, |&x| x == 1);
let _ = [0, 1, 2].splitn(1, |&x| x == 1);
let _ = [0, 1, 2].rsplitn_mut(1, |&x| x == 1);
const X: usize = 0;
let _ = "a,b".splitn(X + 1, '... | random_line_split | |
suspicious_splitn.rs | #![warn(clippy::suspicious_splitn)]
fn main() | {
let _ = "a,b,c".splitn(3, ',');
let _ = [0, 1, 2, 1, 3].splitn(3, |&x| x == 1);
let _ = "".splitn(0, ',');
let _ = [].splitn(0, |&x: &u32| x == 1);
let _ = "a,b".splitn(0, ',');
let _ = "a,b".rsplitn(0, ',');
let _ = "a,b".splitn(1, ',');
let _ = [0, 1, 2].splitn(0, |&x| x == 1);
... | identifier_body | |
suspicious_splitn.rs | #![warn(clippy::suspicious_splitn)]
fn | () {
let _ = "a,b,c".splitn(3, ',');
let _ = [0, 1, 2, 1, 3].splitn(3, |&x| x == 1);
let _ = "".splitn(0, ',');
let _ = [].splitn(0, |&x: &u32| x == 1);
let _ = "a,b".splitn(0, ',');
let _ = "a,b".rsplitn(0, ',');
let _ = "a,b".splitn(1, ',');
let _ = [0, 1, 2].splitn(0, |&x| x == 1);
... | main | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains shared types and messages for use by devtools/script.
//! The traits are here instead of ... | /// `ViewportPx` is equal to `DeviceIndependentPixel` times a "page zoom" factor controlled by the user. This is
/// the desktop-style "full page" zoom that enlarges content but then reflows the layout viewport
/// so it still exactly fits the visible area.
///
/// At the default zoom level of 100%, one `PagePx` is eq... | /// | 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/. */
//! This module contains shared types and messages for use by devtools/script.
//! The traits are here instead of ... | {}
// In summary, the hierarchy of pixel units and the factors to convert from one to the next:
//
// DevicePixel
// / hidpi_ratio => DeviceIndependentPixel
// / desktop_zoom => ViewportPx
// / pinch_zoom => PagePx
pub mod cursor;
#[macro_use]
pub mod values;
pub mod viewport;
pub use values::{ToCss, On... | PagePx | identifier_name |
main.rs | // Copyright 2015-2017 Intecture Developers.
//
// Licensed under the Mozilla Public License 2.0 <LICENSE or
// https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied,
// modified, or distributed except according to those terms.
extern crate clap;
extern crate env_logger;
#[macro_use] extern crate error_cha... | {
remote: Remote,
}
impl Service for Api {
type Request = InMessage;
type Response = InMessage;
type Error = Error;
type Future = Box<Future<Item = Self::Response, Error = Self::Error>>;
fn call(&self, req: Self::Request) -> Self::Future {
let request = match Request::from_msg(req)
... | NewApi | identifier_name |
main.rs | // Copyright 2015-2017 Intecture Developers.
//
// Licensed under the Mozilla Public License 2.0 <LICENSE or
// https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied,
// modified, or distributed except according to those terms.
extern crate clap;
extern crate env_logger;
#[macro_use] extern crate error_cha... |
}
impl NewService for NewApi {
type Request = InMessage;
type Response = InMessage;
type Error = Error;
type Instance = Api;
fn new_service(&self) -> io::Result<Self::Instance> {
// XXX Danger zone! If we're running multiple threads, this `unwrap()`
// will explode. The API require... | {
let request = match Request::from_msg(req)
.chain_err(|| "Malformed Request")
{
Ok(r) => r,
Err(e) => return Box::new(future::ok(error_to_msg(e))),
};
Box::new(request.exec(&self.host)
.chain_err(|| "Failed to execute Request")
... | identifier_body |
main.rs | // Copyright 2015-2017 Intecture Developers.
//
// Licensed under the Mozilla Public License 2.0 <LICENSE or
// https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied,
// modified, or distributed except according to those terms.
extern crate clap;
extern crate env_logger;
#[macro_use] extern crate error_cha... | quick_main!(|| -> Result<()> {
env_logger::init().chain_err(|| "Could not start logging")?;
let matches = clap::App::new("Intecture Agent")
.version(env!("CARGO_PKG_VERSION"))
.author(env!("CARGO_PKG_AUTHORS"))
.about(env!("CARGO_... | random_line_split | |
array.rs | //! Array with SIMD alignment
use crate::types::*;
use ffi;
use num_traits::Zero;
use std::ops::{Deref, DerefMut};
use std::os::raw::c_void;
use std::slice::{from_raw_parts, from_raw_parts_mut};
/// A RAII-wrapper of `fftw_alloc` and `fftw_free` with the [SIMD alignment].
///
/// [SIMD alignment]: http://www.fftw.or... | (n: usize) -> Self {
let ptr = excall! { T::alloc(n) };
let mut vec = AlignedVec { n: n, data: ptr };
for v in vec.iter_mut() {
*v = T::zero();
}
vec
}
}
impl<T> Drop for AlignedVec<T> {
fn drop(&mut self) {
excall! { ffi::fftw_free(self.data as *mut ... | new | identifier_name |
array.rs | //! Array with SIMD alignment
use crate::types::*;
use ffi;
use num_traits::Zero;
use std::ops::{Deref, DerefMut};
use std::os::raw::c_void;
use std::slice::{from_raw_parts, from_raw_parts_mut};
/// A RAII-wrapper of `fftw_alloc` and `fftw_free` with the [SIMD alignment].
///
/// [SIMD alignment]: http://www.fftw.or... |
}
impl AlignedAllocable for f32 {
unsafe fn alloc(n: usize) -> *mut Self {
ffi::fftwf_alloc_real(n)
}
}
impl AlignedAllocable for c64 {
unsafe fn alloc(n: usize) -> *mut Self {
ffi::fftw_alloc_complex(n)
}
}
impl AlignedAllocable for c32 {
unsafe fn alloc(n: usize) -> *mut Self {... | {
ffi::fftw_alloc_real(n)
} | identifier_body |
array.rs | //! Array with SIMD alignment
use crate::types::*;
use ffi;
use num_traits::Zero;
use std::ops::{Deref, DerefMut};
use std::os::raw::c_void;
use std::slice::{from_raw_parts, from_raw_parts_mut};
/// A RAII-wrapper of `fftw_alloc` and `fftw_free` with the [SIMD alignment].
///
/// [SIMD alignment]: http://www.fftw.or... | ffi::fftw_alloc_complex(n)
}
}
impl AlignedAllocable for c32 {
unsafe fn alloc(n: usize) -> *mut Self {
ffi::fftwf_alloc_complex(n)
}
}
impl<T> AlignedVec<T> {
pub fn as_slice(&self) -> &[T] {
unsafe { from_raw_parts(self.data, self.n) }
}
pub fn as_slice_mut(&mut self... |
impl AlignedAllocable for c64 {
unsafe fn alloc(n: usize) -> *mut Self { | random_line_split |
mod.rs | mod api;
use gcrypt;
use hyper;
use rustc_serialize::base64;
use rustc_serialize::hex;
use rustc_serialize::json;
use crypto;
use std::fmt;
use std::io;
use rustc_serialize::base64::FromBase64;
use rustc_serialize::hex::FromHex;
use rustc_serialize::hex::ToHex;
#[derive(Debug)]
pub enum KeybaseError {
Http(St... | (err: gcrypt::error::Error) -> KeybaseError {
KeybaseError::Gcrypt(err)
}
}
impl From<hyper::Error> for KeybaseError {
fn from(err: hyper::Error) -> KeybaseError {
KeybaseError::Hyper(err)
}
}
impl From<io::Error> for KeybaseError {
fn from(err: io::Error) -> KeybaseError {
Keyb... | from | identifier_name |
mod.rs | mod api;
use gcrypt;
use hyper;
use rustc_serialize::base64;
use rustc_serialize::hex;
use rustc_serialize::json;
use crypto;
use std::fmt;
use std::io;
use rustc_serialize::base64::FromBase64;
use rustc_serialize::hex::FromHex;
use rustc_serialize::hex::ToHex;
#[derive(Debug)]
pub enum KeybaseError {
Http(St... | }
}
impl From<json::DecoderError> for KeybaseError {
fn from(err: json::DecoderError) -> KeybaseError {
KeybaseError::Json(err)
}
}
impl fmt::Display for KeybaseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
KeybaseError::Http(ref msg) => write... |
impl From<io::Error> for KeybaseError {
fn from(err: io::Error) -> KeybaseError {
KeybaseError::Io(err) | random_line_split |
borrowck-lend-flow-if.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | }
}
fn main() {} | let _w;
if cond() {
_w = &v;
} else {
borrow_mut(v); | random_line_split |
borrowck-lend-flow-if.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 ... |
borrow_mut(v); //~ ERROR cannot borrow
}
fn pre_freeze_else() {
// In this instance, the freeze and mut borrow are on separate sides
// of the if.
let mut v = ~3;
let _w;
if cond() {
_w = &v;
} else {
borrow_mut(v);
}
}
fn main() {}
| {
_w = &v;
} | conditional_block |
borrowck-lend-flow-if.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn produce<T>() -> T { fail!(); }
fn inc(v: &mut ~int) {
*v = ~(**v + 1);
}
fn pre_freeze_cond() {
// In this instance, the freeze is conditional and starts before
// the mut borrow.
let mut v = ~3;
let _w;
if cond() {
_w = &v;
}
borrow_mut(v); //~ ERROR cannot borrow
}
fn p... | { fail!() } | identifier_body |
borrowck-lend-flow-if.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 ... | (_v: &mut int) {}
fn cond() -> bool { fail!() }
fn for_func(_f: || -> bool) { fail!() }
fn produce<T>() -> T { fail!(); }
fn inc(v: &mut ~int) {
*v = ~(**v + 1);
}
fn pre_freeze_cond() {
// In this instance, the freeze is conditional and starts before
// the mut borrow.
let mut v = ~3;
let _w;
... | borrow_mut | identifier_name |
mod.rs | mod version;
mod init;
mod config;
mod ignore;
mod sweep;
mod burn;
mod start;
mod end;
mod destroy;
mod patrol;
use self::version::Version;
use self::init::Init;
use self::config::Config;
use self::ignore::Ignore;
use self::sweep::Sweep;
use self::burn::Burn;
use self::start::Start;
use self::end::End;
use self::dest... | (&self) -> bool { true }
fn check_settings(&self) -> Result<(), EssentialLack> {
if!setting::working_dir_exists() {
return Err(EssentialLack::new(EssentialKind::WorkingDir));
}
if!setting::Storage::exist() {
return Err(EssentialLack::new(EssentialKind::StorageDir));
... | allow_to_check_settings | identifier_name |
mod.rs | mod version;
mod init;
mod config;
mod ignore;
mod sweep;
mod burn;
mod start;
mod end;
mod destroy;
mod patrol;
use self::version::Version;
use self::init::Init;
use self::config::Config;
use self::ignore::Ignore;
use self::sweep::Sweep;
use self::burn::Burn;
use self::start::Start;
use self::end::End;
use self::dest... |
fn allow_to_check_settings(&self) -> bool { true }
fn check_settings(&self) -> Result<(), EssentialLack> {
if!setting::working_dir_exists() {
return Err(EssentialLack::new(EssentialKind::WorkingDir));
}
if!setting::Storage::exist() {
return Err(EssentialLack::ne... | {
let current_dir = try!(env::current_dir());
match BANNED_DIRS.iter().find(|d| current_dir.ends_with(d)) {
Some(d) => Err(From::from(RunningPlaceError::new(d.to_string()))),
None => Ok(()),
}
} | identifier_body |
mod.rs | mod version;
mod init;
mod config;
mod ignore;
mod sweep;
mod burn;
mod start;
mod end;
mod destroy;
mod patrol;
use self::version::Version;
use self::init::Init;
use self::config::Config;
use self::ignore::Ignore;
use self::sweep::Sweep;
use self::burn::Burn;
use self::start::Start;
use self::end::End;
use self::dest... | };
match command.as_ref() {
"version" => Version .exec(need_help),
"init" => Init .exec(need_help),
"config" => Config::new(args.next(), args.next(), args.next()).exec(need_help),
"ignore" ... | } else {
(command, false) | random_line_split |
error.rs | use crate::{constants::MAX_PRECISION_U32, Decimal};
use alloc::string::String;
use core::fmt;
/// Error type for the library.
#[derive(Clone, Debug, PartialEq)]
pub enum Error {
ErrorString(String),
ExceedsMaximumPossibleValue,
LessThanMinimumPossibleValue,
Underflow,
ScaleExceedsMaximumPrecision(u... | (&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Self::ErrorString(ref err) => f.pad(err),
Self::ExceedsMaximumPossibleValue => {
write!(f, "Number exceeds maximum value that can be represented.")
}
Self::LessThanMinimumPossibleVa... | fmt | identifier_name |
error.rs | use crate::{constants::MAX_PRECISION_U32, Decimal};
use alloc::string::String;
use core::fmt;
/// Error type for the library.
#[derive(Clone, Debug, PartialEq)]
pub enum Error {
ErrorString(String), | }
impl<S> From<S> for Error
where
S: Into<String>,
{
#[inline]
fn from(from: S) -> Self {
Self::ErrorString(from.into())
}
}
#[cold]
pub(crate) fn tail_error(from: &'static str) -> Result<Decimal, Error> {
Err(from.into())
}
#[cfg(feature = "std")]
impl std::error::Error for Error {}
imp... | ExceedsMaximumPossibleValue,
LessThanMinimumPossibleValue,
Underflow,
ScaleExceedsMaximumPrecision(u32), | random_line_split |
error.rs | use crate::{constants::MAX_PRECISION_U32, Decimal};
use alloc::string::String;
use core::fmt;
/// Error type for the library.
#[derive(Clone, Debug, PartialEq)]
pub enum Error {
ErrorString(String),
ExceedsMaximumPossibleValue,
LessThanMinimumPossibleValue,
Underflow,
ScaleExceedsMaximumPrecision(u... |
Self::ScaleExceedsMaximumPrecision(ref scale) => {
write!(
f,
"Scale exceeds the maximum precision allowed: {} > {}",
scale, MAX_PRECISION_U32
)
}
}
}
}
| {
write!(f, "Number has a high precision that can not be represented.")
} | conditional_block |
error.rs | use crate::{constants::MAX_PRECISION_U32, Decimal};
use alloc::string::String;
use core::fmt;
/// Error type for the library.
#[derive(Clone, Debug, PartialEq)]
pub enum Error {
ErrorString(String),
ExceedsMaximumPossibleValue,
LessThanMinimumPossibleValue,
Underflow,
ScaleExceedsMaximumPrecision(u... | }
}
| {
match *self {
Self::ErrorString(ref err) => f.pad(err),
Self::ExceedsMaximumPossibleValue => {
write!(f, "Number exceeds maximum value that can be represented.")
}
Self::LessThanMinimumPossibleValue => {
write!(f, "Number less tha... | identifier_body |
bitflags.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 ... |
#[test]
fn test_remove(){
let mut e1 = FlagA | FlagB;
let e2 = FlagA | FlagC;
e1.remove(e2);
assert!(e1 == FlagB);
}
#[test]
fn test_operators() {
let e1 = FlagA | FlagC;
let e2 = FlagB | FlagC;
assert!((e1 | e2) == FlagABC); // union
... | {
let mut e1 = FlagA;
let e2 = FlagA | FlagB;
e1.insert(e2);
assert!(e1 == e2);
} | identifier_body |
bitflags.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 ... | //! - `insert`: inserts the specified flags in-place
//! - `remove`: removes the specified flags in-place
#![macro_escape]
#[macro_export]
macro_rules! bitflags(
($(#[$attr:meta])* flags $BitFlags:ident: $T:ty {
$($(#[$Flag_attr:meta])* static $Flag:ident = $value:expr),+
}) => (
#[deriving(Eq... | random_line_split | |
bitflags.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 ... | (){
assert_eq!(Flags::empty().bits(), 0x00000000);
assert_eq!(FlagA.bits(), 0x00000001);
assert_eq!(FlagABC.bits(), 0x00000111);
}
#[test]
fn test_is_empty(){
assert!(Flags::empty().is_empty());
assert!(!FlagA.is_empty());
assert!(!FlagABC.is_empty());
}
... | test_bits | identifier_name |
tokenizer.rs | //! A whitespace and comment preserving lexer designed for use in both the compiler frontend
//! and IDEs.
//!
//! The output of the tokenizer is lightweight, and only contains information about the
//! type of a [Token] and where it occurred in the source.
use std::ops::Range;
use itertools::Itertools;
use logos::Le... | }
impl<'a> Iterator for Tokenizer<'a> {
type Item = (TokenKind, Range<usize>);
fn next(&mut self) -> Option<Self::Item> {
if self.seen_eof {
return None;
}
let ty = self.lexer.token;
let range = self.lexer.range();
self.lexer.advance();
if ty == T... | random_line_split | |
tokenizer.rs | //! A whitespace and comment preserving lexer designed for use in both the compiler frontend
//! and IDEs.
//!
//! The output of the tokenizer is lightweight, and only contains information about the
//! type of a [Token] and where it occurred in the source.
use std::ops::Range;
use itertools::Itertools;
use logos::Le... | {
let types: Vec<TokenKind> = tokenize("test abc 123")
.into_iter()
.map(|t| t.into())
.collect();
assert_eq!(
vec![
TokenKind::Name,
TokenKind::Whitespace,
TokenKind::Name,
TokenKind::Whitespace,
TokenKind::Integer,
... | identifier_body | |
tokenizer.rs | //! A whitespace and comment preserving lexer designed for use in both the compiler frontend
//! and IDEs.
//!
//! The output of the tokenizer is lightweight, and only contains information about the
//! type of a [Token] and where it occurred in the source.
use std::ops::Range;
use itertools::Itertools;
use logos::Le... | <'a> {
lexer: Lexer<TokenKind, &'a str>,
seen_eof: bool,
}
impl<'a> Tokenizer<'a> {
fn new(text: &'a str) -> Self {
Tokenizer {
lexer: TokenKind::lexer(text),
seen_eof: false,
}
}
}
impl<'a> Iterator for Tokenizer<'a> {
type Item = (TokenKind, Range<usize>);... | Tokenizer | identifier_name |
main.rs | extern crate rustbox;
extern crate memmap;
extern crate clap;
use std::error::Error;
// use std::default::Default;
// use std::cmp;
// use std::char;
use std::env;
use memmap::{Mmap, Protection};
use rustbox::{Color, RustBox, Key, Event};
use clap::{App, Arg};
fn longest_prefix<'a>(a: &'a str, b: &'a str) -> usize... | "-i, --interactive 'Use the interactive version instead of outputting to stdout'
[INPUT] 'Specifies the input file to use'").get_matches();
if let Some(file_path) = matches.value_of("INPUT") {
if matches.is_present("interactive") {
rustbox_output(&file_path);
... | random_line_split | |
main.rs | extern crate rustbox;
extern crate memmap;
extern crate clap;
use std::error::Error;
// use std::default::Default;
// use std::cmp;
// use std::char;
use std::env;
use memmap::{Mmap, Protection};
use rustbox::{Color, RustBox, Key, Event};
use clap::{App, Arg};
fn longest_prefix<'a>(a: &'a str, b: &'a str) -> usize... |
fn string_repeat(s: &str, n: usize) -> String {
std::iter::repeat(s).take(n).collect::<String>()
}
fn offset(offset: usize, width: usize, trimming_offset: Option<String>) -> String {
match trimming_offset {
None => { format!("{:01$x}: ", offset, width) }
Some(trimming_string) => {
... | {
format!("{:1$}0 1 2 3 4 5 6 7 8 9 A B C D E F", "", width + 3)
} | identifier_body |
main.rs | extern crate rustbox;
extern crate memmap;
extern crate clap;
use std::error::Error;
// use std::default::Default;
// use std::cmp;
// use std::char;
use std::env;
use memmap::{Mmap, Protection};
use rustbox::{Color, RustBox, Key, Event};
use clap::{App, Arg};
fn longest_prefix<'a>(a: &'a str, b: &'a str) -> usize... |
0xFF => { print!("## ") }
_ => { print!("{:02X} ", b) }
}
}
let trimming_offset = if should_trim { Some(prev_offset.clone()) } else { None };
let new_offset = offset((idx + 1) * 16, offset_width, trimming_offset); // TODO: idx + 1 is wrong
pri... | { print!(" ") } | conditional_block |
main.rs | extern crate rustbox;
extern crate memmap;
extern crate clap;
use std::error::Error;
// use std::default::Default;
// use std::cmp;
// use std::char;
use std::env;
use memmap::{Mmap, Protection};
use rustbox::{Color, RustBox, Key, Event};
use clap::{App, Arg};
fn longest_prefix<'a>(a: &'a str, b: &'a str) -> usize... | le_path: &str) {
let rustbox = match RustBox::init(Default::default()) {
Result::Ok(v) => v,
Result::Err(e) => panic!("{}", e),
};
let mut state = EditorState { open_file: None, read_only: false };
// rustbox.print(1, 1, rustbox::RB_BOLD, Color::White, Color::Black, "Hello, world!");
... | tbox_output(fi | identifier_name |
history.rs | use std::io::prelude::*;
use std::path::Path;
use curl::http;
use yaml_rust::Yaml;
use super::file;
use super::yaml_util;
use super::request::SpagRequest;
use super::remember;
const HISTORY_DIR: &'static str = ".spag";
const HISTORY_FILE: &'static str = ".spag/history.yml";
const HISTORY_LIMIT: usize = 100;
pub fn ... |
Ok(try!(yaml_util::dump_yaml_file(HISTORY_FILE, &y)))
}
pub fn list() -> Result<Vec<String>, String> {
ensure_history_exists();
let mut result = Vec::new();
let mut y = &mut try!(yaml_util::load_yaml_file(&HISTORY_FILE));
if let Yaml::Array(ref mut arr) = *y {
for y in arr.iter() {
... |
let new_entry = remember::serialize(req, resp);
arr.insert(0, new_entry);
} | random_line_split |
history.rs | use std::io::prelude::*;
use std::path::Path;
use curl::http;
use yaml_rust::Yaml;
use super::file;
use super::yaml_util;
use super::request::SpagRequest;
use super::remember;
const HISTORY_DIR: &'static str = ".spag";
const HISTORY_FILE: &'static str = ".spag/history.yml";
const HISTORY_LIMIT: usize = 100;
pub fn ... | ,
_ => { return Err(format!("Invalid headers in request history #{}.", index))},
};
output.push_str(format!("Body:\n{}\n", body).as_str());
Ok(output.to_string())
} else {
Err(format!("Failed to load history file {}", HISTORY_FILE))
}
}
| {} | conditional_block |
history.rs | use std::io::prelude::*;
use std::path::Path;
use curl::http;
use yaml_rust::Yaml;
use super::file;
use super::yaml_util;
use super::request::SpagRequest;
use super::remember;
const HISTORY_DIR: &'static str = ".spag";
const HISTORY_FILE: &'static str = ".spag/history.yml";
const HISTORY_LIMIT: usize = 100;
pub fn ... | }
pub fn list() -> Result<Vec<String>, String> {
ensure_history_exists();
let mut result = Vec::new();
let mut y = &mut try!(yaml_util::load_yaml_file(&HISTORY_FILE));
if let Yaml::Array(ref mut arr) = *y {
for y in arr.iter() {
let method = try!(yaml_util::get_value_as_string(&... | {
ensure_history_exists();
let mut y = &mut try!(yaml_util::load_yaml_file(&HISTORY_FILE));
if let Yaml::Array(ref mut arr) = *y {
// Trim the history, -1 so that our request fits under the limit
if arr.len() > HISTORY_LIMIT - 1 {
while arr.len() > HISTORY_LIMIT - 1 {
... | identifier_body |
history.rs | use std::io::prelude::*;
use std::path::Path;
use curl::http;
use yaml_rust::Yaml;
use super::file;
use super::yaml_util;
use super::request::SpagRequest;
use super::remember;
const HISTORY_DIR: &'static str = ".spag";
const HISTORY_FILE: &'static str = ".spag/history.yml";
const HISTORY_LIMIT: usize = 100;
pub fn | () {
if!Path::new(HISTORY_FILE).exists() {
file::ensure_dir_exists(HISTORY_DIR);
file::write_file(HISTORY_FILE, "[]");
}
}
pub fn append(req: &SpagRequest, resp: &http::Response) -> Result<(), String> {
ensure_history_exists();
let mut y = &mut try!(yaml_util::load_yaml_file(&HISTORY_F... | ensure_history_exists | identifier_name |
extern-return-TwoU32s.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | }
pub fn main() {
unsafe {
let y = rust_dbg_extern_return_TwoU32s();
assert_eq!(y.one, 10);
assert_eq!(y.two, 20);
}
} | pub fn rust_dbg_extern_return_TwoU32s() -> TwoU32s; | random_line_split |
extern-return-TwoU32s.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 ... | {
one: u32, two: u32
}
#[link(name = "rust_test_helpers")]
extern {
pub fn rust_dbg_extern_return_TwoU32s() -> TwoU32s;
}
pub fn main() {
unsafe {
let y = rust_dbg_extern_return_TwoU32s();
assert_eq!(y.one, 10);
assert_eq!(y.two, 20);
}
}
| TwoU32s | identifier_name |
htmlselectelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
use... |
// Note: this function currently only exists for union.html.
// https://html.spec.whatwg.org/multipage/#dom-select-add
fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) {
}
// https://html.spec.whatwg.org/multipage/#dom-fe-disabled
make_bool_g... | {
let window = window_from_node(self);
ValidityState::new(window.r(), self.upcast())
} | identifier_body |
htmlselectelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
use... | else {
el.check_disabled_attribute();
}
}
fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
match *local_name {
atom!("size") => AttrValue::from_u32(value.into(), DEFAULT_SELECT_SIZE),
_ => self.super_type().unwrap().parse_p... | {
el.check_ancestors_disabled_state_for_form_control();
} | conditional_block |
htmlselectelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
use... | fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) {
}
// https://html.spec.whatwg.org/multipage/#dom-fe-disabled
make_bool_getter!(Disabled, "disabled");
// https://html.spec.whatwg.org/multipage/#dom-fe-disabled
make_bool_setter!(SetDisabled, ... | // Note: this function currently only exists for union.html.
// https://html.spec.whatwg.org/multipage/#dom-select-add | random_line_split |
htmlselectelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
use... | (&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) {
}
// https://html.spec.whatwg.org/multipage/#dom-fe-disabled
make_bool_getter!(Disabled, "disabled");
// https://html.spec.whatwg.org/multipage/#dom-fe-disabled
make_bool_setter!(SetDisabled, "disabled"... | Add | identifier_name |
close_on_drop.rs | #![cfg(all(feature = "os-poll", feature = "net"))]
use std::io::Read;
use log::debug;
use mio::net::{TcpListener, TcpStream};
use mio::{Events, Interest, Poll, Token};
mod util;
use util::{any_local_address, init};
use self::TestState::{AfterRead, Initial};
const SERVER: Token = Token(0);
const CLIENT: Token = Tok... | () {
init();
debug!("Starting TEST_CLOSE_ON_DROP");
let mut poll = Poll::new().unwrap();
// == Create & setup server socket
let mut srv = TcpListener::bind(any_local_address()).unwrap();
let addr = srv.local_addr().unwrap();
poll.registry()
.register(&mut srv, SERVER, Interest::READ... | close_on_drop | identifier_name |
close_on_drop.rs | #![cfg(all(feature = "os-poll", feature = "net"))]
use std::io::Read;
use log::debug;
use mio::net::{TcpListener, TcpStream};
use mio::{Events, Interest, Poll, Token};
mod util;
use util::{any_local_address, init};
use self::TestState::{AfterRead, Initial};
const SERVER: Token = Token(0);
const CLIENT: Token = Tok... |
}
}
assert!(handler.state == AfterRead, "actual={:?}", handler.state);
}
| {
handler.handle_write(&mut poll, event.token());
} | conditional_block |
close_on_drop.rs | #![cfg(all(feature = "os-poll", feature = "net"))]
use std::io::Read;
use log::debug;
use mio::net::{TcpListener, TcpStream};
use mio::{Events, Interest, Poll, Token};
mod util;
use util::{any_local_address, init};
use self::TestState::{AfterRead, Initial};
const SERVER: Token = Token(0);
const CLIENT: Token = Tok... |
}
#[test]
pub fn close_on_drop() {
init();
debug!("Starting TEST_CLOSE_ON_DROP");
let mut poll = Poll::new().unwrap();
// == Create & setup server socket
let mut srv = TcpListener::bind(any_local_address()).unwrap();
let addr = srv.local_addr().unwrap();
poll.registry()
.register(... | {
match tok {
SERVER => panic!("received writable for token 0"),
CLIENT => {
debug!("client connected");
poll.registry()
.reregister(&mut self.cli, CLIENT, Interest::READABLE)
.unwrap();
}
_ =... | identifier_body |
close_on_drop.rs | #![cfg(all(feature = "os-poll", feature = "net"))]
use std::io::Read;
use log::debug;
use mio::net::{TcpListener, TcpStream};
use mio::{Events, Interest, Poll, Token};
mod util;
use util::{any_local_address, init};
use self::TestState::{AfterRead, Initial};
const SERVER: Token = Token(0);
const CLIENT: Token = Tok... |
// == Create & setup client socket
let mut sock = TcpStream::connect(addr).unwrap();
poll.registry()
.register(&mut sock, CLIENT, Interest::WRITABLE)
.unwrap();
// == Create storage for events
let mut events = Events::with_capacity(1024);
// == Setup test handler
let mut ha... |
poll.registry()
.register(&mut srv, SERVER, Interest::READABLE)
.unwrap(); | random_line_split |
lib.rs | // Copyright (C) 2020 Natanael Mojica <neithanmo@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later versio... | env!("BUILD_REL_DATE")
); | random_line_split | |
lib.rs | // Copyright (C) 2020 Natanael Mojica <neithanmo@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later versio... | (plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
filter::register(plugin)?;
Ok(())
}
gst_plugin_define!(
csound,
env!("CARGO_PKG_DESCRIPTION"),
plugin_init,
concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")),
"MIT/X11",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_NAME"),
... | plugin_init | identifier_name |
lib.rs | // Copyright (C) 2020 Natanael Mojica <neithanmo@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later versio... |
gst_plugin_define!(
csound,
env!("CARGO_PKG_DESCRIPTION"),
plugin_init,
concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")),
"MIT/X11",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_REPOSITORY"),
env!("BUILD_REL_DATE")
);
| {
filter::register(plugin)?;
Ok(())
} | identifier_body |
ne.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
// macro_rules! partial_eq_impl {
// ($($t:ty)*) => ($(
// #[stable(feature = "rust1", since = "1.0.0")]
// impl PartialEq for $t {
// #[inline]
// fn eq(&self, othe... | () {
let v1: bool = false;
{
let result: bool = v1.ne(&v1);
assert_eq!(result, false);
}
let v2: bool = true;
{
let result: bool = v1.ne(&v2);
assert_eq!(result, true);
}
}
#[test]
fn ne_test2() {
ne_test! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 };
}
}
| ne_test1 | identifier_name |
ne.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
// macro_rules! partial_eq_impl {
// ($($t:ty)*) => ($(
// #[stable(feature = "rust1", since = "1.0.0")]
// impl PartialEq for $t {
// #[inline]
// fn eq(&self, othe... | let v2: $t = 100 as $t;
{
let result: bool = v1.ne(&v2);
assert_eq!(result, true);
}
})*)
}
#[test]
fn ne_test1() {
let v1: bool = false;
{
let result: bool = v1.ne(&v1);
assert_eq!(result, false);
}
let v2: bool = true;
{
let result: bool = v1.ne(&v2);
assert_... | {
let result: bool = v1.ne(&v1);
assert_eq!(result, false);
}
| random_line_split |
ne.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
// macro_rules! partial_eq_impl {
// ($($t:ty)*) => ($(
// #[stable(feature = "rust1", since = "1.0.0")]
// impl PartialEq for $t {
// #[inline]
// fn eq(&self, othe... |
}
| {
ne_test! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 };
} | identifier_body |
mod.rs | extern crate rmp;
use std;
quick_error! {
#[derive(Debug)]
pub enum DBError {
Protocol(err: String) {
description("Protocol error")
display("Protocol error: {}", err)
}
FileFormat(err: String) {
description("File fromat error")
display("F... | description("IO error")
display("IO error: {}", err)
from()
cause(err)
}
}
} | random_line_split | |
if-check-panic.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | else {
return even(x - 2);
}
}
fn foo(x: usize) {
if even(x) {
println!("{}", x);
} else {
panic!("Number is odd");
}
}
fn main() {
foo(3);
}
| {
return true;
} | conditional_block |
if-check-panic.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 ... | println!("{}", x);
} else {
panic!("Number is odd");
}
}
fn main() {
foo(3);
} |
fn foo(x: usize) {
if even(x) { | random_line_split |
if-check-panic.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 ... | (x: usize) {
if even(x) {
println!("{}", x);
} else {
panic!("Number is odd");
}
}
fn main() {
foo(3);
}
| foo | identifier_name |
if-check-panic.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn foo(x: usize) {
if even(x) {
println!("{}", x);
} else {
panic!("Number is odd");
}
}
fn main() {
foo(3);
}
| {
if x < 2 {
return false;
} else if x == 2 {
return true;
} else {
return even(x - 2);
}
} | identifier_body |
password_based_encryption.rs | extern crate rustc_serialize;
extern crate rncryptor;
use rustc_serialize::hex::FromHex;
use rncryptor::v3::types::{IV, Salt};
use rncryptor::v3::encryptor::Encryptor;
struct TestVector {
password: &'static str,
encryption_salt: &'static str,
hmac_salt: &'static str,
iv: &'static str,
plain_text: ... | encryption_salt: "0203040506070001",
hmac_salt: "0304050607080102",
iv: "0405060708090a0b0c0d0e0f00010203",
plain_text: "0123456789abcdef 01234567",
cipher_text: "03010203 04050607 00010304 05060708 01020405 06070809 0a0b0c0d 0e0f0001 \
0203e01b bda5df2c a8a... | #[test]
fn more_than_one_block() {
test_vector(TestVector {
password: "thepassword", | random_line_split |
password_based_encryption.rs | extern crate rustc_serialize;
extern crate rncryptor;
use rustc_serialize::hex::FromHex;
use rncryptor::v3::types::{IV, Salt};
use rncryptor::v3::encryptor::Encryptor;
struct | {
password: &'static str,
encryption_salt: &'static str,
hmac_salt: &'static str,
iv: &'static str,
plain_text: &'static str,
cipher_text: &'static str,
}
fn test_vector(vector: TestVector) {
let encryption_salt = Salt(vector.encryption_salt.from_hex().unwrap());
let hmac_salt = Salt(v... | TestVector | identifier_name |
password_based_encryption.rs | extern crate rustc_serialize;
extern crate rncryptor;
use rustc_serialize::hex::FromHex;
use rncryptor::v3::types::{IV, Salt};
use rncryptor::v3::encryptor::Encryptor;
struct TestVector {
password: &'static str,
encryption_salt: &'static str,
hmac_salt: &'static str,
iv: &'static str,
plain_text: ... |
#[test]
fn multibyte_password() {
test_vector(TestVector {
password: "中文密码",
encryption_salt: "0304050607000102",
hmac_salt: "0405060708010203",
iv: "05060708090a0b0c0d0e0f0001020304",
plain_text: "23456789abcdef 0123456701",
cipher_text: "03010304 05060700 01020405... | {
test_vector(TestVector {
password: "thepassword",
encryption_salt: "0203040506070001",
hmac_salt: "0304050607080102",
iv: "0405060708090a0b0c0d0e0f00010203",
plain_text: "0123456789abcdef 01234567",
cipher_text: "03010203 04050607 00010304 05060708 01020405 06070809... | identifier_body |
trait-bounds-sugar.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 ... | (_x: Box<Foo+Send>) {
}
fn b(_x: &'static Foo) { // should be same as &'static Foo+'static
}
fn c(x: Box<Foo+Share>) {
a(x); //~ ERROR expected bounds `Send`
}
fn d(x: &'static Foo+Share) {
b(x); //~ ERROR expected bounds `'static`
}
fn main() {}
| a | identifier_name |
trait-bounds-sugar.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 b(_x: &'static Foo) { // should be same as &'static Foo+'static
}
fn c(x: Box<Foo+Share>) {
a(x); //~ ERROR expected bounds `Send`
}
fn d(x: &'static Foo+Share) {
b(x); //~ ERROR expected bounds `'static`
}
fn main() {} | trait Foo {}
fn a(_x: Box<Foo+Send>) {
} | random_line_split |
trait-bounds-sugar.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 d(x: &'static Foo+Share) {
b(x); //~ ERROR expected bounds `'static`
}
fn main() {}
| {
a(x); //~ ERROR expected bounds `Send`
} | identifier_body |
const-int-saturating-arith.rs | // run-pass
const INT_U32_NO: u32 = (42 as u32).saturating_add(2);
const INT_U32: u32 = u32::MAX.saturating_add(1);
const INT_U128: u128 = u128::MAX.saturating_add(1); | const INT_I128: i128 = i128::MAX.saturating_add(1);
const INT_I128_NEG: i128 = i128::MIN.saturating_add(-1);
const INT_U32_NO_SUB: u32 = (42 as u32).saturating_sub(2);
const INT_U32_SUB: u32 = (1 as u32).saturating_sub(2);
const INT_I32_NO_SUB: i32 = (-42 as i32).saturating_sub(2);
const INT_I32_NEG_SUB: i32 = i32::MI... | random_line_split | |
const-int-saturating-arith.rs | // run-pass
const INT_U32_NO: u32 = (42 as u32).saturating_add(2);
const INT_U32: u32 = u32::MAX.saturating_add(1);
const INT_U128: u128 = u128::MAX.saturating_add(1);
const INT_I128: i128 = i128::MAX.saturating_add(1);
const INT_I128_NEG: i128 = i128::MIN.saturating_add(-1);
const INT_U32_NO_SUB: u32 = (42 as u32).s... | {
assert_eq!(INT_U32_NO, 44);
assert_eq!(INT_U32, u32::MAX);
assert_eq!(INT_U128, u128::MAX);
assert_eq!(INT_I128, i128::MAX);
assert_eq!(INT_I128_NEG, i128::MIN);
assert_eq!(INT_U32_NO_SUB, 40);
assert_eq!(INT_U32_SUB, 0);
assert_eq!(INT_I32_NO_SUB, -44);
assert_eq!(INT_I32_NEG_SUB... | identifier_body | |
const-int-saturating-arith.rs | // run-pass
const INT_U32_NO: u32 = (42 as u32).saturating_add(2);
const INT_U32: u32 = u32::MAX.saturating_add(1);
const INT_U128: u128 = u128::MAX.saturating_add(1);
const INT_I128: i128 = i128::MAX.saturating_add(1);
const INT_I128_NEG: i128 = i128::MIN.saturating_add(-1);
const INT_U32_NO_SUB: u32 = (42 as u32).s... | () {
assert_eq!(INT_U32_NO, 44);
assert_eq!(INT_U32, u32::MAX);
assert_eq!(INT_U128, u128::MAX);
assert_eq!(INT_I128, i128::MAX);
assert_eq!(INT_I128_NEG, i128::MIN);
assert_eq!(INT_U32_NO_SUB, 40);
assert_eq!(INT_U32_SUB, 0);
assert_eq!(INT_I32_NO_SUB, -44);
assert_eq!(INT_I32_NEG_... | main | identifier_name |
mod.rs | //! Seat handling and managing.
use std::cell::RefCell;
use std::rc::Rc;
use sctk::reexports::protocols::unstable::relative_pointer::v1::client::zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1;
use sctk::reexports::protocols::unstable::pointer_constraints::v1::client::zwp_pointer_constraints_v1::ZwpPoint... | if let Some(text_input_manager) = self.text_input_manager.as_ref() {
if seat_data.defunct {
seat_info.text_input = None;
} else if seat_info.text_input.is_none() {
seat_info.text_input = Some(TextInput::new(&seat, &text_input_manager));
}
... |
// Handle text input. | random_line_split |
mod.rs | //! Seat handling and managing.
use std::cell::RefCell;
use std::rc::Rc;
use sctk::reexports::protocols::unstable::relative_pointer::v1::client::zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1;
use sctk::reexports::protocols::unstable::pointer_constraints::v1::client::zwp_pointer_constraints_v1::ZwpPoint... | else {
seat_info.keyboard = None;
}
// Handle touch.
if seat_data.has_touch &&!seat_data.defunct {
if seat_info.touch.is_none() {
seat_info.touch = Some(Touch::new(&seat));
}
} else {
seat_info.touch = None;
}
... | {
if seat_info.keyboard.is_none() {
seat_info.keyboard = Keyboard::new(
&seat,
self.loop_handle.clone(),
seat_info.modifiers_state.clone(),
);
}
} | conditional_block |
mod.rs | //! Seat handling and managing.
use std::cell::RefCell;
use std::rc::Rc;
use sctk::reexports::protocols::unstable::relative_pointer::v1::client::zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1;
use sctk::reexports::protocols::unstable::pointer_constraints::v1::client::zwp_pointer_constraints_v1::ZwpPoint... | (&mut self, seat: &Attached<WlSeat>, seat_data: &SeatData) {
let detached_seat = seat.detach();
let position = self.seats.iter().position(|si| si.seat == detached_seat);
let index = position.unwrap_or_else(|| {
self.seats.push(SeatInfo::new(detached_seat));
self.seats.le... | process_seat_update | identifier_name |
use-keyword.rs | // Copyright 2016 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 ... |
mod a {
mod b {
use self as A;
//~^ ERROR `self` imports are only allowed within a { } list
use super as B;
//~^ ERROR unresolved import `super` [E0432]
//~| no `super` in the root
use super::{self as C};
//~^ ERROR unresolved import `super` [E0432]
/... | // FIXME: this shouldn't fail during name resolution either | random_line_split |
use-keyword.rs | // Copyright 2016 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 |
use-keyword.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {} | identifier_body | |
demand.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 ... | (fcx: &FnCtxt, sp: Span, expected: ty::t, actual: ty::t) {
suptype_with_fn(fcx, sp, true, actual, expected,
|sp, a, e, s| { fcx.report_mismatched_types(sp, e, a, s) })
}
pub fn suptype_with_fn(fcx: &FnCtxt,
sp: Span,
b_is_expected: bool,
... | subtype | identifier_name |
demand.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | else { expected };
match fcx.mk_assignty(expr, expr_ty, expected) {
result::Ok(()) => { /* ok */ }
result::Err(ref err) => {
fcx.report_mismatched_types(sp, expected, expr_ty, err);
}
}
}
| {
resolve_type(fcx.infcx(), expected,
try_resolve_tvar_shallow).unwrap_or(expected)
} | conditional_block |
demand.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn suptype_with_fn(fcx: &FnCtxt,
sp: Span,
b_is_expected: bool,
ty_a: ty::t,
ty_b: ty::t,
handle_err: |Span, ty::t, ty::t, &ty::type_err|) {
// n.b.: order of actual, expected is reversed
mat... | {
suptype_with_fn(fcx, sp, true, actual, expected,
|sp, a, e, s| { fcx.report_mismatched_types(sp, e, a, s) })
} | identifier_body |
demand.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn subtype(fcx: &FnCtxt, sp: Span, expected: ty::t, actual: ty::t) {
suptype_with_fn(fcx, sp, true, actual, expected,
|sp, a, e, s| { fcx.report_mismatched_types(sp, e, a, s) })
}
pub fn suptype_with_fn(fcx: &FnCtxt,
sp: Span,
b_is_expected: bool,
... | suptype_with_fn(fcx, sp, false, expected, actual,
|sp, e, a, s| { fcx.report_mismatched_types(sp, e, a, s) })
} | random_line_split |
lifetime-update.rs | #![feature(type_changing_struct_update)]
#![allow(incomplete_features)]
#[derive(Clone)]
struct Machine<'a, S> { | }
#[derive(Clone)]
struct State1;
#[derive(Clone)]
struct State2;
fn update_to_state2() {
let s = String::from("hello");
let m1: Machine<State1> = Machine {
state: State1,
lt_str: &s,
//~^ ERROR `s` does not live long enough [E0597]
// FIXME: The error here actu... | state: S,
lt_str: &'a str,
common_field: i32, | random_line_split |
lifetime-update.rs | #![feature(type_changing_struct_update)]
#![allow(incomplete_features)]
#[derive(Clone)]
struct Machine<'a, S> {
state: S,
lt_str: &'a str,
common_field: i32,
}
#[derive(Clone)]
struct | ;
#[derive(Clone)]
struct State2;
fn update_to_state2() {
let s = String::from("hello");
let m1: Machine<State1> = Machine {
state: State1,
lt_str: &s,
//~^ ERROR `s` does not live long enough [E0597]
// FIXME: The error here actually comes from line 34. The
... | State1 | identifier_name |
lib.rs | #![doc(html_root_url = "http://cpjreynolds.github.io/rustty/rustty/index.html")]
//! # Rustty
//!
//! Rustty is a terminal UI library that provides a simple, concise abstraction over an
//! underlying terminal device.
//!
//! Rustty is based on the concepts of cells and events. A terminal display is an array of cells,... | pub use core::position::{Pos, Size, HasSize, HasPosition};
pub use core::input::Event;
pub use util::errors::Error; | Color,
Attr,
CellAccessor,
}; | random_line_split |
expressionset.rs | use ordered_float::NotNaN;
use bio::stats::probs;
use crate::model;
pub type MeanExpression = NotNaN<f64>;
pub type CDF = probs::cdf::CDF<MeanExpression>;
pub fn cdf(expression_cdfs: &[model::expression::NormalizedCDF], pseudocounts: f64) -> CDF |
// #[cfg(test)]
// mod tests {
// #![allow(non_upper_case_globals)]
//
// use bio::stats::{Prob, LogProb};
//
// use super::*;
// use model;
// use io;
//
//
// const GENE: &'static str = "COL5A1";
//
// fn setup() -> Box<model::readout::Model> {
// model::readout::new_model(
// ... | {
let pseudocounts = NotNaN::new(pseudocounts).unwrap();
if expression_cdfs.len() == 1 {
let mut cdf = expression_cdfs[0].clone();
for e in cdf.iter_mut() {
e.value += pseudocounts;
}
return cdf;
}
let cdf = model::meanvar::cdf(expression_cdfs, |mean, _| mea... | identifier_body |
expressionset.rs | use ordered_float::NotNaN;
use bio::stats::probs;
use crate::model;
pub type MeanExpression = NotNaN<f64>;
pub type CDF = probs::cdf::CDF<MeanExpression>;
pub fn cdf(expression_cdfs: &[model::expression::NormalizedCDF], pseudocounts: f64) -> CDF {
let pseudocounts = NotNaN::new(pseudocounts).unwrap();
if e... | // io::codebook::Codebook::from_file("tests/codebook/140genesData.1.txt").unwrap()
// )
// }
//
// #[test]
// fn test_cdf() {
// let readout = setup();
// let cdfs = [
// model::expression::cdf(GENE, 5, 5, &readout, 100).0,
// model::expression::cd... | random_line_split | |
expressionset.rs | use ordered_float::NotNaN;
use bio::stats::probs;
use crate::model;
pub type MeanExpression = NotNaN<f64>;
pub type CDF = probs::cdf::CDF<MeanExpression>;
pub fn | (expression_cdfs: &[model::expression::NormalizedCDF], pseudocounts: f64) -> CDF {
let pseudocounts = NotNaN::new(pseudocounts).unwrap();
if expression_cdfs.len() == 1 {
let mut cdf = expression_cdfs[0].clone();
for e in cdf.iter_mut() {
e.value += pseudocounts;
}
re... | cdf | identifier_name |
expressionset.rs | use ordered_float::NotNaN;
use bio::stats::probs;
use crate::model;
pub type MeanExpression = NotNaN<f64>;
pub type CDF = probs::cdf::CDF<MeanExpression>;
pub fn cdf(expression_cdfs: &[model::expression::NormalizedCDF], pseudocounts: f64) -> CDF {
let pseudocounts = NotNaN::new(pseudocounts).unwrap();
if e... |
let cdf = model::meanvar::cdf(expression_cdfs, |mean, _| mean + pseudocounts);
assert_relative_eq!(cdf.total_prob().exp(), 1.0, epsilon = 0.001);
cdf.reduce().sample(1000)
}
// #[cfg(test)]
// mod tests {
// #![allow(non_upper_case_globals)]
//
// use bio::stats::{Prob, LogProb};
//
// use su... | {
let mut cdf = expression_cdfs[0].clone();
for e in cdf.iter_mut() {
e.value += pseudocounts;
}
return cdf;
} | conditional_block |
load.rs | /*! # Reading and loading hyphenation dictionaries
To hyphenate words in a given language, it is first necessary to load
the relevant hyphenation dictionary into memory. This module offers
convenience methods for common retrieval patterns, courtesy of the
[`Load`] trait.
```
use hyphenation::Load;
use hyphenation::{S... | /// Deserialize a dictionary from the provided reader, verifying that it
/// belongs to the expected language.
fn from_reader<R>(lang : Language, reader : &mut R) -> Result<Self>
where R : io::Read;
/// Deserialize a dictionary from the provided reader.
fn any_from_reader<R>(reader : &mut R) ->... | let file = File::open(path) ?;
Self::from_reader(lang, &mut io::BufReader::new(file))
}
| identifier_body |
load.rs | /*! # Reading and loading hyphenation dictionaries
To hyphenate words in a given language, it is first necessary to load
the relevant hyphenation dictionary into memory. This module offers
convenience methods for common retrieval patterns, courtesy of the
[`Load`] trait.
```
use hyphenation::Load;
use hyphenation::{S... | a>(code : &str, suffix : &str) -> Result<&'a [u8]> {
let name = format!("{}.{}.bincode", code, suffix);
let res : Option<ResourceId> = ResourceId::from_name(&name);
match res {
Some(data) => Ok(data.load()),
None => Err(Error::Resource)
}
}
pub type Result<T> = result::Result<T, Error>... | trieve_resource<' | identifier_name |
load.rs | /*! # Reading and loading hyphenation dictionaries
To hyphenate words in a given language, it is first necessary to load
the relevant hyphenation dictionary into memory. This module offers
convenience methods for common retrieval patterns, courtesy of the
[`Load`] trait.
```
use hyphenation::Load;
use hyphenation::{S... | where R : io::Read {
let dict : Self = bin::config().limit(5_000_000).deserialize_from(reader)?;
let (found, expected) = (dict.language(), lang);
if found!= expected {
Err(Error::LanguageMismatch { expected, found })
} else ... | ($dict:ty, $suffix:expr) => {
impl Load for $dict {
fn from_reader<R>(lang : Language, reader : &mut R) -> Result<Self> | random_line_split |
tests.rs | use super::rocket;
use rocket::local::Client;
use rocket::http::{ContentType, Status};
fn test_login<T>(user: &str, pass: &str, age: &str, status: Status, body: T)
where T: Into<Option<&'static str>>
{
let client = Client::new(rocket()).unwrap();
let query = format!("username={}&password={}&age={}", user, ... |
#[test]
fn test_invalid_user() {
test_login("-1", "password", "30", Status::Ok, "Unrecognized user");
test_login("Mike", "password", "30", Status::Ok, "Unrecognized user");
}
#[test]
fn test_invalid_password() {
test_login("Sergio", "password1", "30", Status::Ok, "Wrong password!");
test_login("Sergi... | {
test_login("Sergio", "password", "30", Status::SeeOther, None);
} | identifier_body |
tests.rs | use super::rocket;
use rocket::local::Client;
use rocket::http::{ContentType, Status};
fn test_login<T>(user: &str, pass: &str, age: &str, status: Status, body: T)
where T: Into<Option<&'static str>>
{
let client = Client::new(rocket()).unwrap();
let query = format!("username={}&password={}&age={}", user, ... |
}
#[test]
fn test_good_login() {
test_login("Sergio", "password", "30", Status::SeeOther, None);
}
#[test]
fn test_invalid_user() {
test_login("-1", "password", "30", Status::Ok, "Unrecognized user");
test_login("Mike", "password", "30", Status::Ok, "Unrecognized user");
}
#[test]
fn test_invalid_passwo... | {
let body_str = response.body_string();
assert!(body_str.map_or(false, |s| s.contains(expected_str)));
} | conditional_block |
tests.rs | use super::rocket;
use rocket::local::Client;
use rocket::http::{ContentType, Status};
fn test_login<T>(user: &str, pass: &str, age: &str, status: Status, body: T)
where T: Into<Option<&'static str>>
{
let client = Client::new(rocket()).unwrap();
let query = format!("username={}&password={}&age={}", user, ... | () {
check_bad_form("&", Status::BadRequest);
check_bad_form("=", Status::BadRequest);
check_bad_form("&&&===&", Status::BadRequest);
}
#[test]
fn test_bad_form_missing_fields() {
let bad_inputs: [&str; 6] = [
"username=Sergio",
"password=pass",
"age=30",
"username=Sergi... | test_bad_form_abnromal_inputs | identifier_name |
tests.rs | use super::rocket;
use rocket::local::Client;
use rocket::http::{ContentType, Status};
fn test_login<T>(user: &str, pass: &str, age: &str, status: Status, body: T)
where T: Into<Option<&'static str>>
{
let client = Client::new(rocket()).unwrap();
let query = format!("username={}&password={}&age={}", user, ... | #[test]
fn test_bad_form_abnromal_inputs() {
check_bad_form("&", Status::BadRequest);
check_bad_form("=", Status::BadRequest);
check_bad_form("&&&===&", Status::BadRequest);
}
#[test]
fn test_bad_form_missing_fields() {
let bad_inputs: [&str; 6] = [
"username=Sergio",
"password=pass",
... |
assert_eq!(response.status(), status);
}
| random_line_split |
class-cast-to-trait.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
else {
error!("Not hungry!");
return false;
}
}
}
impl noisy for cat {
fn speak(&self) { self.meow(); }
}
impl cat {
fn meow(&self) {
error!("Meow");
self.meows += 1;
if self.meows % 5 == 0 {
self.how_hungry += 1;
}
}
}
fn cat(in_x : uint, in_y ... | {
error!("OM NOM NOM");
self.how_hungry -= 2;
return true;
} | conditional_block |
class-cast-to-trait.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
cat {
meows: in_x,
how_hungry: in_y,
name: in_name
}
}
fn main() {
let nyan : @noisy = @cat(0, 2, ~"nyan") as @noisy;
nyan.eat(); //~ ERROR does not implement any method in scope named `eat`
}
| {
error!("Meow");
self.meows += 1;
if self.meows % 5 == 0 {
self.how_hungry += 1;
}
} | identifier_body |
class-cast-to-trait.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 ... | (in_x : uint, in_y : int, in_name: ~str) -> cat {
cat {
meows: in_x,
how_hungry: in_y,
name: in_name
}
}
fn main() {
let nyan : @noisy = @cat(0, 2, ~"nyan") as @noisy;
nyan.eat(); //~ ERROR does not implement any method in scope named `eat`
}
| cat | identifier_name |
class-cast-to-trait.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 ... |
impl noisy for cat {
fn speak(&self) { self.meow(); }
}
impl cat {
fn meow(&self) {
error!("Meow");
self.meows += 1;
if self.meows % 5 == 0 {
self.how_hungry += 1;
}
}
}
fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
cat {
meows: in_x,
how_hun... | return false;
}
}
} | random_line_split |
cfg-macros-notfoo.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
assert!(!bar!())
} | identifier_body | |
cfg-macros-notfoo.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
assert!(!bar!())
}
| main | identifier_name |
cfg-macros-notfoo.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 ... | macro_rules! bar {
() => { true }
}
}
#[cfg(not(foo))]
#[macro_escape]
mod foo {
macro_rules! bar {
() => { false }
}
}
fn main() {
assert!(!bar!())
} | #[cfg(foo)]
#[macro_escape]
mod foo { | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.