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
combine.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 glb(&self) -> Glb<'a, 'tcx> { Glb::new(self.clone()) } pub fn instantiate(&self, a_ty: Ty<'tcx>, dir: RelationDir, b_vid: ty::TyVid) -> RelateResult<'tcx, ()> { let tcx = self.infcx.tcx;...
{ Lub::new(self.clone()) }
identifier_body
combine.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 int_unification_error<'tcx>(a_is_expected: bool, v: (ty::IntVarValue, ty::IntVarValue)) -> ty::type_err<'tcx> { let (a, b) = v; ty::terr_int_mismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b)) } fn float_unification_error<'tcx>(a_is_expected: b...
{ Err(f()) }
conditional_block
combine.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 ...
<'tcx>(a_is_expected: bool, v: (ast::FloatTy, ast::FloatTy)) -> ty::type_err<'tcx> { let (a, b) = v; ty::terr_float_mismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b)) }
float_unification_error
identifier_name
regions-infer-contravariance-due-to-decl.rs
// Test that a type which is contravariant with respect to its region // parameter yields an error when used in a covariant way. // // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. use std::marker; // This is contravariant with respect to 'a, meaning...
<'a> { marker: marker::PhantomData<&'a()> } fn use_<'short,'long>(c: Contravariant<'short>, s: &'short isize, l: &'long isize, _where:Option<&'short &'long ()>) { // Test whether Contravariant<'short> <: Contravariant<'long>. Since //'shor...
Contravariant
identifier_name
regions-infer-contravariance-due-to-decl.rs
// Test that a type which is contravariant with respect to its region // parameter yields an error when used in a covariant way. // // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. use std::marker; // This is contravariant with respect to 'a, meaning...
fn use_<'short,'long>(c: Contravariant<'short>, s: &'short isize, l: &'long isize, _where:Option<&'short &'long ()>) { // Test whether Contravariant<'short> <: Contravariant<'long>. Since //'short <= 'long, this would be true if the Contravaria...
}
random_line_split
out_of.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 core::ops::{Range, RangeTo, RangeFrom, RangeFull}; pub trait OutOf<T = ()> { fn out_of(t: T) -> Self; } imp...
} zero!(u8 ); zero!(u16 ); zero!(u32 ); zero!(u64 ); zero!(usize ); zero!(i8 ); zero!(i16 ); zero!(i32 ); zero!(i64 ); zero!(isize ); impl<T> OutOf for Option<T> { fn out_of(_: ()) -> Option<T> { None } }
}
random_line_split
out_of.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 core::ops::{Range, RangeTo, RangeFrom, RangeFull}; pub trait OutOf<T = ()> { fn out_of(t: T) -> Self; } imp...
(_: RangeFull) -> Self { Range { start: None, end: None } } } macro_rules! as_out_of { ($from:ty as $to:ty) => { impl OutOf<$from> for $to { fn out_of(from: $from) -> $to { from as $to } } } } as_out_of!(u8 as u16); as_out_of!(u8 as u32); as_out_of!(u8 as u64); as_ou...
out_of
identifier_name
out_of.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 core::ops::{Range, RangeTo, RangeFrom, RangeFull}; pub trait OutOf<T = ()> { fn out_of(t: T) -> Self; } imp...
} impl<T> OutOf<RangeTo<T>> for Range<Option<T>> { fn out_of(u: RangeTo<T>) -> Self { Range { start: None, end: Some(u.end) } } } impl<T> OutOf<RangeFrom<T>> for Range<Option<T>> { fn out_of(u: RangeFrom<T>) -> Self { Range { start: Some(u.start), end: None } } } impl<T> OutOf<RangeF...
{ Range { start: Some(u.start), end: Some(u.end) } }
identifier_body
lib.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&mut self, record: &LogRecord) { match writeln!(&mut self.handle, "{}:{}: {}", record.level, record.module_path, record.args) { Err(e) => panic!("failed to log: {:?}", e), Ok(()) => {} } ...
log
identifier_name
lib.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
//! #[macro_use] extern crate log; //! //! fn main() { //! debug!("this is a debug {:?}", "message"); //! error!("this is printed by default"); //! //! if log_enabled!(log::INFO) { //! let x = 3i * 4i; // expensive computation //! info!("the answer was: {:?}", x); //! } //! } //! ``` //!...
//! # Examples //! //! ```
random_line_split
lib.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// This assertion should never get tripped unless we're in an at_exit // handler after logging has been torn down and a logging attempt was made. assert!(unsafe {!DIRECTIVES.is_null() }); enabled(level, module, unsafe { (*DIRECTIVES).iter() }) } fn enabled(level: u32, module: &str, ...
{ return false }
conditional_block
lib.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn enabled(level: u32, module: &str, iter: slice::Iter<directive::LogDirective>) -> bool { // Search for the longest match, the vector is assumed to be pre-sorted. for directive in iter.rev() { match directive.name { Some(ref name) if!module.starts_with(&na...
{ static INIT: Once = ONCE_INIT; INIT.call_once(init); // It's possible for many threads are in this function, only one of them // will perform the global initialization, but all of them will need to check // again to whether they should really be here or not. Hence, despite this // check being...
identifier_body
arithmetic_ast.rs
#[macro_use] extern crate nom; use std::fmt; use std::fmt::{Display, Debug, Formatter}; use std::str; use std::str::FromStr; use nom::{IResult, digit, multispace}; pub enum Expr { Value(i64), Add(Box<Expr>, Box<Expr>), Sub(Box<Expr>, Box<Expr>), Mul(Box<Expr>, Box<Expr>), Div(Box<Expr>, Box<Expr...
() { assert_eq!(expr(&b" 1 + 2 * 3 "[..]).map(|x| format!("{:?}", x)), IResult::Done(&b""[..], String::from("(1 + (2 * 3))"))); assert_eq!(expr(&b" 1 + 2 * 3 / 4 - 5 "[..]).map(|x| format!("{:?}", x)), IResult::Done(&b""[..], String::from("((1 + ((2 * 3) / 4)) - 5)"))); asser...
expr_test
identifier_name
arithmetic_ast.rs
#[macro_use] extern crate nom; use std::fmt; use std::fmt::{Display, Debug, Formatter}; use std::str; use std::str::FromStr; use nom::{IResult, digit, multispace}; pub enum Expr { Value(i64), Add(Box<Expr>, Box<Expr>), Sub(Box<Expr>, Box<Expr>), Mul(Box<Expr>, Box<Expr>), Div(Box<Expr>, Box<Expr...
chain!(tag!("/") ~ div: factor, || { (Oper::Div, div) }) ) ), || fold_exprs(initial, remainder)) ); named!(expr< Expr >, chain!( initial: term ~ remainder: many0!( alt!( chain!(tag!("+") ~ add: term, || { (Oper::Add, add) }) | chain!(tag...
remainder: many0!( alt!( chain!(tag!("*") ~ mul: factor, || { (Oper::Mul, mul) }) |
random_line_split
at_exit_imp.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 ...
else { // can't re-init after a cleanup rtassert!(QUEUE as uint!= 1); } // FIXME: switch this to use atexit as below. Currently this // segfaults (the queue's memory is mysteriously gone), so // instead the cleanup is tied to the `std::rt` entry point. // // ::libc::atexit(clea...
{ let state: Box<Queue> = box Vec::new(); QUEUE = mem::transmute(state); }
conditional_block
at_exit_imp.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn cleanup() { unsafe { LOCK.lock(); let queue = QUEUE; QUEUE = 1 as *mut _; LOCK.unlock(); // make sure we're not recursively cleaning up rtassert!(queue as uint!= 1); // If we never called init, not need to cleanup! if queue as uint!= 0 { ...
{ if QUEUE.is_null() { let state: Box<Queue> = box Vec::new(); QUEUE = mem::transmute(state); } else { // can't re-init after a cleanup rtassert!(QUEUE as uint != 1); } // FIXME: switch this to use atexit as below. Currently this // segfaults (the queue's memory is m...
identifier_body
at_exit_imp.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 ...
// except according to those terms. //! Implementation of running at_exit routines //! //! Documentation can be found on the `rt::at_exit` function. use core::prelude::*; use boxed::Box; use vec::Vec; use mem; use thunk::Thunk; use sys_common::mutex::{Mutex, MUTEX_INIT}; type Queue = Vec<Thunk<'static>>; // NB the...
random_line_split
at_exit_imp.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 ...
() { if QUEUE.is_null() { let state: Box<Queue> = box Vec::new(); QUEUE = mem::transmute(state); } else { // can't re-init after a cleanup rtassert!(QUEUE as uint!= 1); } // FIXME: switch this to use atexit as below. Currently this // segfaults (the queue's memory is...
init
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::attr::AttrHelpers; use dom::bindings::codegen::Bindings::HTMLSelectElementBinding; u...
// Note: this function currently only exists for test_union.html. fn Add(self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option<HTMLElementOrLong>) { } // http://www.whatwg.org/html/#dom-fe-disabled make_bool_getter!(Disabled) // http://www.whatwg.org/html/#dom-fe-disabled ...
{ let window = window_from_node(self).root(); ValidityState::new(window.r()) }
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::attr::AttrHelpers; use dom::bindings::codegen::Bindings::HTMLSelectElementBinding; u...
else { "select-one".into_string() } } } impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> { fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> { let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self); Some(htmlelement as &VirtualMethod...
{ "select-multiple".into_string() }
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::attr::AttrHelpers; use dom::bindings::codegen::Bindings::HTMLSelectElementBinding; u...
let node: JSRef<Node> = NodeCast::from_ref(*self); if node.ancestors().any(|ancestor| ancestor.is_htmlfieldsetelement()) { node.check_ancestors_disabled_state_for_form_control(); } else { node.check_disabled_attribute(); } } }
match self.super_type() { Some(ref s) => s.unbind_from_tree(tree_in_doc), _ => (), }
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::attr::AttrHelpers; use dom::bindings::codegen::Bindings::HTMLSelectElementBinding; u...
(&self, attr: JSRef<Attr>) { match self.super_type() { Some(ref s) => s.before_remove_attr(attr), _ => () } match attr.local_name() { &atom!("disabled") => { let node: JSRef<Node> = NodeCast::from_ref(*self); node.set_disabled_...
before_remove_attr
identifier_name
pattern.rs
use address::PAYMENT_ADDRESS_PREFIX; use bs58; use byteorder::{BigEndian, ByteOrder}; use std::fmt; #[derive(Clone)] pub struct Pattern { pub prefix: String, pub range: (u64, u64), } impl fmt::Display for Pattern { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(self.prefix.as_s...
() { let pattern = Pattern::new("zcA".to_string()).unwrap(); assert_eq!( pattern .case_insensitive() .iter() .map(|p| p.prefix.as_str()) .collect::<Vec<&str>>(), vec![ "zcA", "zca", ...
case_insensitive_a
identifier_name
pattern.rs
use address::PAYMENT_ADDRESS_PREFIX; use bs58; use byteorder::{BigEndian, ByteOrder}; use std::fmt; #[derive(Clone)] pub struct Pattern { pub prefix: String, pub range: (u64, u64), } impl fmt::Display for Pattern { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(self.prefix.as_s...
pub fn case_insensitive(&self) -> Vec<Pattern> { let prefix_bytes = self.prefix.as_bytes().to_owned(); let mut patterns = vec![]; let alpha = bs58::alphabet::DEFAULT; let mut rev = [0xff; 128]; for (i, &c) in alpha.iter().enumerate() { rev[c as usize] = i; ...
{ match prefix_to_range_u64(prefix.as_str()) { Ok(range) => Ok(Pattern { prefix, range, }), Err(err) => Err(err), } }
identifier_body
pattern.rs
use address::PAYMENT_ADDRESS_PREFIX; use bs58; use byteorder::{BigEndian, ByteOrder}; use std::fmt; #[derive(Clone)] pub struct Pattern { pub prefix: String, pub range: (u64, u64), } impl fmt::Display for Pattern { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(self.prefix.as_s...
k <<= 1; } } max = k; if let Ok(pattern) = Pattern::new(String::from_utf8(tmp).unwrap()) { patterns.push(pattern); } i += 1; } patterns } } fn prefix_to_range_u64(prefix: &str) -> Result...
for c in &mut tmp { if alpha[rev[*c as usize]] != *c { if i & k != 0 { *c = alpha[rev[*c as usize]]; }
random_line_split
pattern.rs
use address::PAYMENT_ADDRESS_PREFIX; use bs58; use byteorder::{BigEndian, ByteOrder}; use std::fmt; #[derive(Clone)] pub struct Pattern { pub prefix: String, pub range: (u64, u64), } impl fmt::Display for Pattern { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(self.prefix.as_s...
k <<= 1; } } max = k; if let Ok(pattern) = Pattern::new(String::from_utf8(tmp).unwrap()) { patterns.push(pattern); } i += 1; } patterns } } fn prefix_to_range_u64(prefix: &str) -> Resul...
{ *c = alpha[rev[*c as usize]]; }
conditional_block
copy.rs
use super::{copy_buf, BufReader, CopyBuf}; use futures_core::future::Future; use futures_core::task::{Context, Poll}; use futures_io::{AsyncRead, AsyncWrite}; use pin_project_lite::pin_project; use std::io; use std::pin::Pin; /// Creates a future which copies all the bytes from one object to another. /// /// The retur...
pin_project! { /// Future for the [`copy()`] function. #[derive(Debug)] #[must_use = "futures do nothing unless you `.await` or poll them"] pub struct Copy<'a, R, W:?Sized> { #[pin] inner: CopyBuf<'a, BufReader<R>, W>, } } impl<R: AsyncRead, W: AsyncWrite + Unpin +?Sized> Future f...
{ Copy { inner: copy_buf(BufReader::new(reader), writer) } }
identifier_body
copy.rs
use super::{copy_buf, BufReader, CopyBuf}; use futures_core::future::Future; use futures_core::task::{Context, Poll}; use futures_io::{AsyncRead, AsyncWrite}; use pin_project_lite::pin_project; use std::io; use std::pin::Pin; /// Creates a future which copies all the bytes from one object to another. /// /// The retur...
(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { self.project().inner.poll(cx) } }
poll
identifier_name
copy.rs
use super::{copy_buf, BufReader, CopyBuf}; use futures_core::future::Future; use futures_core::task::{Context, Poll}; use futures_io::{AsyncRead, AsyncWrite}; use pin_project_lite::pin_project; use std::io; use std::pin::Pin; /// Creates a future which copies all the bytes from one object to another. /// /// The retur...
} impl<R: AsyncRead, W: AsyncWrite + Unpin +?Sized> Future for Copy<'_, R, W> { type Output = io::Result<u64>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { self.project().inner.poll(cx) } }
#[pin] inner: CopyBuf<'a, BufReader<R>, W>, }
random_line_split
submatrix.rs
use crate::math::{Determinant, Matrix, Matrix2, Matrix3, Matrix4, Scalar}; pub trait Submatrix : Matrix { type Output: Matrix; fn submatrix(&self, y: usize, x: usize) -> <Self as Submatrix>::Output; fn minor(&self, y: usize, x: usize) -> Scalar { self.submatrix(y, x).determinant() } fn c...
; data[ny][nx] = self[oy][ox]; } } Matrix2::new(data) } } impl Submatrix for Matrix4 { type Output = Matrix3; fn submatrix(&self, y: usize, x: usize) -> Matrix3 { let mut data = [[0.0; 3]; 3]; for ny in 0..3 { for nx in 0..3 { ...
{ nx }
conditional_block
submatrix.rs
use crate::math::{Determinant, Matrix, Matrix2, Matrix3, Matrix4, Scalar}; pub trait Submatrix : Matrix {
type Output: Matrix; fn submatrix(&self, y: usize, x: usize) -> <Self as Submatrix>::Output; fn minor(&self, y: usize, x: usize) -> Scalar { self.submatrix(y, x).determinant() } fn cofactor(&self, y: usize, x: usize) -> Scalar { if (x + y) % 2 == 0 { self.minor(y, x) ...
random_line_split
submatrix.rs
use crate::math::{Determinant, Matrix, Matrix2, Matrix3, Matrix4, Scalar}; pub trait Submatrix : Matrix { type Output: Matrix; fn submatrix(&self, y: usize, x: usize) -> <Self as Submatrix>::Output; fn minor(&self, y: usize, x: usize) -> Scalar { self.submatrix(y, x).determinant() } fn c...
(&self, y: usize, x: usize) -> Matrix2 { let mut data = [[0.0; 2]; 2]; for ny in 0..2 { for nx in 0..2 { let oy = if ny >= y { ny + 1 } else { ny }; let ox = if nx >= x { nx + 1 } else { nx }; data[ny][nx] = self[oy][ox]; } ...
submatrix
identifier_name
submatrix.rs
use crate::math::{Determinant, Matrix, Matrix2, Matrix3, Matrix4, Scalar}; pub trait Submatrix : Matrix { type Output: Matrix; fn submatrix(&self, y: usize, x: usize) -> <Self as Submatrix>::Output; fn minor(&self, y: usize, x: usize) -> Scalar { self.submatrix(y, x).determinant() } fn c...
} impl Submatrix for Matrix4 { type Output = Matrix3; fn submatrix(&self, y: usize, x: usize) -> Matrix3 { let mut data = [[0.0; 3]; 3]; for ny in 0..3 { for nx in 0..3 { let oy = if ny >= y { ny + 1 } else { ny }; let ox = if nx >= x { nx + 1 } el...
{ let mut data = [[0.0; 2]; 2]; for ny in 0..2 { for nx in 0..2 { let oy = if ny >= y { ny + 1 } else { ny }; let ox = if nx >= x { nx + 1 } else { nx }; data[ny][nx] = self[oy][ox]; } } Matrix2::new(data) }
identifier_body
while-loop-constraints-2.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let mut y: int = 42; let mut z: int = 42; let mut x: int; while z < 50 { z += 1; while false { x = y; y = z; } info!("{}", y); } assert!((y == 42 && z == 50)); }
main
identifier_name
while-loop-constraints-2.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let mut y: int = 42; let mut z: int = 42; let mut x: int; while z < 50 { z += 1; while false { x = y; y = z; } info!("{}", y); } assert!((y == 42 && z == 50)); }
random_line_split
while-loop-constraints-2.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let mut y: int = 42; let mut z: int = 42; let mut x: int; while z < 50 { z += 1; while false { x = y; y = z; } info!("{}", y); } assert!((y == 42 && z == 50)); }
identifier_body
link.rs
// * This file is part of the uutils coreutils package. // *
use clap::{crate_version, App, AppSettings, Arg}; use std::fs::hard_link; use std::path::Path; use uucore::display::Quotable; use uucore::error::{FromIo, UResult}; use uucore::format_usage; static ABOUT: &str = "Call the link function to create a link named FILE2 to an existing FILE1."; const USAGE: &str = "{} FILE1 F...
// * (c) Michael Gehring <mg@ebfe.org> // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code.
random_line_split
link.rs
// * This file is part of the uutils coreutils package. // * // * (c) Michael Gehring <mg@ebfe.org> // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. use clap::{crate_version, App, AppSettings, Arg}; use std::fs::hard_link; use ...
{ App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) .setting(AppSettings::InferLongArgs) .arg( Arg::new(options::FILES) .hide(true) .required(true) .min_value...
identifier_body
link.rs
// * This file is part of the uutils coreutils package. // * // * (c) Michael Gehring <mg@ebfe.org> // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. use clap::{crate_version, App, AppSettings, Arg}; use std::fs::hard_link; use ...
<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) .setting(AppSettings::InferLongArgs) .arg( Arg::new(options::FILES) .hide(true) .required(true) ...
uu_app
identifier_name
sign.rs
use integer::Integer; use malachite_base::num::arithmetic::traits::Sign; use std::cmp::Ordering; impl Sign for Integer { /// Returns the sign of an `Integer`. Interpret the result as the result of a comparison to /// zero, so that `Equal` means zero, `Greater` means positive, and `Less` means negative. ///...
else { Ordering::Greater } } else { Ordering::Less } } }
{ Ordering::Equal }
conditional_block
sign.rs
use integer::Integer; use malachite_base::num::arithmetic::traits::Sign; use std::cmp::Ordering; impl Sign for Integer { /// Returns the sign of an `Integer`. Interpret the result as the result of a comparison to /// zero, so that `Equal` means zero, `Greater` means positive, and `Less` means negative. ///...
(&self) -> Ordering { if self.sign { if self.abs == 0 { Ordering::Equal } else { Ordering::Greater } } else { Ordering::Less } } }
sign
identifier_name
sign.rs
use integer::Integer; use malachite_base::num::arithmetic::traits::Sign; use std::cmp::Ordering; impl Sign for Integer { /// Returns the sign of an `Integer`. Interpret the result as the result of a comparison to /// zero, so that `Equal` means zero, `Greater` means positive, and `Less` means negative. ///...
/// use std::cmp::Ordering; /// /// assert_eq!(Integer::ZERO.sign(), Ordering::Equal); /// assert_eq!(Integer::from(123).sign(), Ordering::Greater); /// assert_eq!(Integer::from(-123).sign(), Ordering::Less); /// ``` fn sign(&self) -> Ordering { if self.sign { if self.abs...
/// /// use malachite_base::num::arithmetic::traits::Sign; /// use malachite_base::num::basic::traits::Zero; /// use malachite_nz::integer::Integer;
random_line_split
sign.rs
use integer::Integer; use malachite_base::num::arithmetic::traits::Sign; use std::cmp::Ordering; impl Sign for Integer { /// Returns the sign of an `Integer`. Interpret the result as the result of a comparison to /// zero, so that `Equal` means zero, `Greater` means positive, and `Less` means negative. ///...
}
{ if self.sign { if self.abs == 0 { Ordering::Equal } else { Ordering::Greater } } else { Ordering::Less } }
identifier_body
shootout-reverse-complement.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2013-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
b'B' | b'b' => b'V', b'N' | b'n' => b'N', i => i, } } /// Retreives the complement for `i`. fn cpl8(&self, i: u8) -> u8 { self.table8[i as uint] } /// Retreives the complement for `i`. fn cpl16(&self, i: u16) -> u16 { self.table16[i a...
b'Y' | b'y' => b'R', b'K' | b'k' => b'M', b'V' | b'v' => b'B', b'H' | b'h' => b'D', b'D' | b'd' => b'H',
random_line_split
shootout-reverse-complement.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2013-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
fn main() { let mut data = read_to_end(&mut stdin_raw()).unwrap(); let tables = &Tables::new(); parallel(mut_dna_seqs(data.as_mut_slice()), |&: seq| reverse_complement(seq, tables)); stdout_raw().write(data.as_mut_slice()).unwrap(); }
{ use std::mem; use std::raw::Repr; iter.map(|chunk| { // Need to convert `f` and `chunk` to something that can cross the task // boundary. let f = Racy(&f as *const F as *const uint); let raw = Racy(chunk.repr()); Thread::scoped(move|| { let f = f.0 as *...
identifier_body
shootout-reverse-complement.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2013-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
(seq: &mut [u8], tables: &Tables) { let seq = seq.init_mut();// Drop the last newline let len = seq.len(); let off = LINE_LEN - len % (LINE_LEN + 1); let mut i = LINE_LEN; while i < len { unsafe { copy_memory(seq.as_mut_ptr().offset((i - off + 1) as int), ...
reverse_complement
identifier_name
Z_Algorithm.rs
/* Problem Statement : Find all occurrences of * a pattern in a string in linear time O(m+n) * where m is the length of the pattern and n * is the length of the string.*/ use std::io::{stdin, stdout, Write}; use std::convert::TryInto; fn z_array(zstring: &Vec<char>) -> Vec<u32> { let z_length = zstring.len();...
() { println!("Enter the string :"); let mut strng = String::new(); //let _ = stdout().flush(); stdin().read_line(&mut strng).expect("Error in string input."); let strng: String = strng.trim().parse().unwrap(); let strng: &str = &*strng; let mut pattern = String::new(); // make a mutabl...
main
identifier_name
Z_Algorithm.rs
/* Problem Statement : Find all occurrences of * a pattern in a string in linear time O(m+n) * where m is the length of the pattern and n * is the length of the string.*/ use std::io::{stdin, stdout, Write}; use std::convert::TryInto; fn z_array(zstring: &Vec<char>) -> Vec<u32> { let z_length = zstring.len();...
} } fn main() { println!("Enter the string :"); let mut strng = String::new(); //let _ = stdout().flush(); stdin().read_line(&mut strng).expect("Error in string input."); let strng: String = strng.trim().parse().unwrap(); let strng: &str = &*strng; let mut pattern = String::new()...
{ println!("Pattern found at index : {}", index - pattern_length - 1); }
conditional_block
Z_Algorithm.rs
/* Problem Statement : Find all occurrences of * a pattern in a string in linear time O(m+n) * where m is the length of the pattern and n * is the length of the string.*/ use std::io::{stdin, stdout, Write}; use std::convert::TryInto; fn z_array(zstring: &Vec<char>) -> Vec<u32> { let z_length = zstring.len();...
fn main() { println!("Enter the string :"); let mut strng = String::new(); //let _ = stdout().flush(); stdin().read_line(&mut strng).expect("Error in string input."); let strng: String = strng.trim().parse().unwrap(); let strng: &str = &*strng; let mut pattern = String::new(); // make...
{ let strng: Vec<char> = strng.chars().collect(); let pattern: Vec<char> = pattern.chars().collect(); let mut z_string = Vec::with_capacity(strng.len() + pattern.len()); let pattern_length = pattern.len(); z_string.extend(pattern); z_string.push('$'); z_string.extend(strng); let z_array ...
identifier_body
Z_Algorithm.rs
/* Problem Statement : Find all occurrences of * a pattern in a string in linear time O(m+n) * where m is the length of the pattern and n * is the length of the string.*/ use std::io::{stdin, stdout, Write}; use std::convert::TryInto; fn z_array(zstring: &Vec<char>) -> Vec<u32> { let z_length = zstring.len();...
let mut pattern = String::new(); // make a mutable string variable println!("Enter the pattern :"); stdin().read_line(&mut pattern).expect("Error in pattern input."); let pattern: String = pattern.trim().parse().unwrap(); let pattern: &str = &*pattern; //let tokens:Vec<&str>= strng.split(",").co...
let strng: String = strng.trim().parse().unwrap(); let strng: &str = &*strng;
random_line_split
resource.rs
use std::path::Path; use glium::{self, Display}; use glium::texture::CompressedTexture2d; use image::{self, GenericImage}; use oil_shared::resource::new_resource_id; // Reexport pub use oil_shared::resource::ResourceId; pub use oil_shared::resource::BasicResourceManager; // ======================================== ...
} pub struct NullResourceManager; impl BasicResourceManager for NullResourceManager { fn get_texture_id(&mut self, _: &Path) -> ResourceId { unsafe { new_resource_id(0) } } fn get_image_dimensions(&self, _: ResourceId) -> (u32, u32) { (0, 0) } } impl ResourceManager for...
{ unsafe { &self.textures[id.get()].handle } }
identifier_body
resource.rs
use std::path::Path; use glium::{self, Display}; use glium::texture::CompressedTexture2d; use image::{self, GenericImage}; use oil_shared::resource::new_resource_id; // Reexport pub use oil_shared::resource::ResourceId; pub use oil_shared::resource::BasicResourceManager; // ======================================== ...
( &self, id: ResourceId) -> (u32, u32) { unsafe { (self.textures[id.get()].img_width, self.textures[id.get()].img_height) } } } impl<'a> ResourceManager for ResourceManagerImpl<'a> { fn get_texture(&self, id: ResourceId) -> &CompressedTexture2d ...
get_image_dimensions
identifier_name
resource.rs
use std::path::Path; use glium::{self, Display}; use glium::texture::CompressedTexture2d; use image::{self, GenericImage};
pub use oil_shared::resource::ResourceId; pub use oil_shared::resource::BasicResourceManager; // ======================================== // // INTERFACE // // ======================================== // pub trait ResourceManager: BasicResourceManager { fn get_texture(&self, id: Re...
use oil_shared::resource::new_resource_id; // Reexport
random_line_split
test_option.rs
fn checked_division(dividend: i32, divisor: i32) -> Option<i32> { if divisor == 0 { None } else { Some(dividend / divisor) } } fn try_division(dividend: i32, divisor: i32) { match checked_division(dividend, divisor) { None =>println!("{} / {} failed", dividend, divisor), ...
{ try_division(4,2); try_division(1,0); let none: Option<i32> = None; let _equivalent_none = None::<i32>; let optional_float = Some(0f32); println!("1- {:?} unwraps to {:?}", optional_float, optional_float.unwrap()); //println!("2- {:?} unwraps to {:?}", _equivalent_none, _equivalent_none.u...
identifier_body
test_option.rs
fn checked_division(dividend: i32, divisor: i32) -> Option<i32> { if divisor == 0 { None } else { Some(dividend / divisor) } } fn try_division(dividend: i32, divisor: i32) { match checked_division(dividend, divisor) {
Some(quotient) => { println!("{} / {} = {}", dividend, divisor, quotient) }, } } fn main () { try_division(4,2); try_division(1,0); let none: Option<i32> = None; let _equivalent_none = None::<i32>; let optional_float = Some(0f32); println!("1- {:?} unwraps to {...
None =>println!("{} / {} failed", dividend, divisor),
random_line_split
test_option.rs
fn checked_division(dividend: i32, divisor: i32) -> Option<i32> { if divisor == 0 { None } else
} fn try_division(dividend: i32, divisor: i32) { match checked_division(dividend, divisor) { None =>println!("{} / {} failed", dividend, divisor), Some(quotient) => { println!("{} / {} = {}", dividend, divisor, quotient) }, } } fn main () { try_division(4,2); try_...
{ Some(dividend / divisor) }
conditional_block
test_option.rs
fn checked_division(dividend: i32, divisor: i32) -> Option<i32> { if divisor == 0 { None } else { Some(dividend / divisor) } } fn try_division(dividend: i32, divisor: i32) { match checked_division(dividend, divisor) { None =>println!("{} / {} failed", dividend, divisor), ...
() { try_division(4,2); try_division(1,0); let none: Option<i32> = None; let _equivalent_none = None::<i32>; let optional_float = Some(0f32); println!("1- {:?} unwraps to {:?}", optional_float, optional_float.unwrap()); //println!("2- {:?} unwraps to {:?}", _equivalent_none, _equivalent_no...
main
identifier_name
build.rs
extern crate gcc; use std::env; use std::io::{self, Write}; use std::fmt; fn main()
}, _ => () } }
{ match (env::var("JDK_HOME"), env::var("OPENCV_PATH")) { (Ok(jdk_path), Ok(opencv_path)) => { //compile JNI code gcc::Config::new() //.compiler("g++") .file("c/rs_jni_pipe.c") .flag("-fpermissive") .inc...
identifier_body
build.rs
extern crate gcc; use std::env; use std::io::{self, Write}; use std::fmt; fn
() { match (env::var("JDK_HOME"), env::var("OPENCV_PATH")) { (Ok(jdk_path), Ok(opencv_path)) => { //compile JNI code gcc::Config::new() //.compiler("g++") .file("c/rs_jni_pipe.c") .flag("-fpermissive") .inc...
main
identifier_name
build.rs
extern crate gcc; use std::env; use std::io::{self, Write}; use std::fmt; fn main() { match (env::var("JDK_HOME"), env::var("OPENCV_PATH")) { (Ok(jdk_path), Ok(opencv_path)) => { //compile JNI code gcc::Config::new() //.compiler("g++") ...
} }
random_line_split
notifications.rs
use std::path::Path; use std::fmt::{self, Display}; use url::Url; use notify::NotificationLevel; #[derive(Debug)] pub enum Notification<'a> { CreatingDirectory(&'a str, &'a Path), LinkingDirectory(&'a Path, &'a Path), CopyingDirectory(&'a Path, &'a Path), RemovingDirectory(&'a str, &'a Path), Dow...
UsingHyper, UsingRustls, } impl<'a> Notification<'a> { pub fn level(&self) -> NotificationLevel { use self::Notification::*; match *self { CreatingDirectory(_, _) | RemovingDirectory(_, _) => NotificationLevel::Verbose, LinkingDirectory(_, _) | CopyingDir...
NoCanonicalPath(&'a Path), ResumingPartialDownload, UsingCurl,
random_line_split
notifications.rs
use std::path::Path; use std::fmt::{self, Display}; use url::Url; use notify::NotificationLevel; #[derive(Debug)] pub enum Notification<'a> { CreatingDirectory(&'a str, &'a Path), LinkingDirectory(&'a Path, &'a Path), CopyingDirectory(&'a Path, &'a Path), RemovingDirectory(&'a str, &'a Path), Dow...
} } }
{ use self::Notification::*; match *self { CreatingDirectory(name, path) => { write!(f, "creating {} directory: '{}'", name, path.display()) } LinkingDirectory(_, dest) => write!(f, "linking directory from: '{}'", dest.display()), CopyingDi...
identifier_body
notifications.rs
use std::path::Path; use std::fmt::{self, Display}; use url::Url; use notify::NotificationLevel; #[derive(Debug)] pub enum
<'a> { CreatingDirectory(&'a str, &'a Path), LinkingDirectory(&'a Path, &'a Path), CopyingDirectory(&'a Path, &'a Path), RemovingDirectory(&'a str, &'a Path), DownloadingFile(&'a Url, &'a Path), /// Received the Content-Length of the to-be downloaded data. DownloadContentLengthReceived(u64),...
Notification
identifier_name
string.rs
use crate::ffi_fn; use libc::c_char; use std::ffi::{CStr, CString}; use std::ops::Not; // All of this module is `pub(crate)` and should not appear in the C header file // or documentation. /// Converts the string into a C-compatible null terminated string, /// then forgets the container while returning a pointer to t...
ffi_fn! { /// Delete a string previously returned by this FFI. /// /// It is explicitly allowed to pass a null pointer to this function; /// in that case the function will do nothing. fn pactffi_string_delete(string: *mut c_char) { if string.is_null().not() { let string = unsaf...
{ Ok(CString::new(t)?.into_raw()) }
identifier_body
string.rs
use crate::ffi_fn; use libc::c_char; use std::ffi::{CStr, CString}; use std::ops::Not; // All of this module is `pub(crate)` and should not appear in the C header file // or documentation. /// Converts the string into a C-compatible null terminated string, /// then forgets the container while returning a pointer to t...
}
{ unsafe { CStr::from_ptr(s).to_string_lossy().to_string() } }
conditional_block
string.rs
use crate::ffi_fn; use libc::c_char; use std::ffi::{CStr, CString}; use std::ops::Not; // All of this module is `pub(crate)` and should not appear in the C header file // or documentation. /// Converts the string into a C-compatible null terminated string, /// then forgets the container while returning a pointer to t...
$crate::cstr!($name).to_str().context(concat!( "error parsing ", stringify!($name), " as UTF-8" ))? }}; } /// Returns the Rust string from the C string pointer, returning the default value if the pointer /// is NULL pub(crate) fn if_null(s: *const c_char, default...
macro_rules! safe_str { ( $name:ident ) => {{
random_line_split
string.rs
use crate::ffi_fn; use libc::c_char; use std::ffi::{CStr, CString}; use std::ops::Not; // All of this module is `pub(crate)` and should not appear in the C header file // or documentation. /// Converts the string into a C-compatible null terminated string, /// then forgets the container while returning a pointer to t...
(s: *const c_char, default: &str) -> String { if s.is_null() { default.to_string() } else { unsafe { CStr::from_ptr(s).to_string_lossy().to_string() } } }
if_null
identifier_name
track.rs
// Copyright (c) 2016, Mikkel Kroman <mk@uplink.io> // All rights reserved. // // 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, mo...
filter: None, license: None, ids: None, duration: None, bpm: None, genres: None, types: None, } } /// Sets the search query filter, which will only return tracks with a matching query. pub fn query<S>(&'a mut self, ...
TrackRequestBuilder { client: client, query: None, tags: None,
random_line_split
track.rs
// Copyright (c) 2016, Mikkel Kroman <mk@uplink.io> // All rights reserved. // // 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, mo...
(&mut self) -> Result<Track> { let no_params: Option<&[(&str, &str)]> = None; let response = try!(self.client.get(&format!("/tracks/{}", self.id), no_params)); let track: Track = try!(serde_json::from_reader(response)); Ok(track) } pub fn request_url(&self) -> Url { let...
get
identifier_name
lib.rs
/// Requests a string from the user with the specified prompt. pub fn get_string(prompt: &str) -> String { get_input(prompt, false).unwrap_or_default() } /// Requests a string from the user with the specified prompt, treating the input as a password. pub fn get_password(prompt: &str) -> String
fn get_input(prompt: &str, is_password: bool) -> Option<String> { if is_password { println!("{}:{}", GET_CMD_PASSWORD, prompt); } else { println!("{}:{}", GET_CMD, prompt); } let mut line = String::new(); std::io::stdin().read_line(&mut line).ok()?; Some(line.trim().to_owned())...
{ get_input(prompt, true).unwrap_or_default() }
identifier_body
lib.rs
/// Requests a string from the user with the specified prompt. pub fn get_string(prompt: &str) -> String { get_input(prompt, false).unwrap_or_default() } /// Requests a string from the user with the specified prompt, treating the input as a password. pub fn get_password(prompt: &str) -> String { get_input(prom...
else { println!("{}:{}", GET_CMD, prompt); } let mut line = String::new(); std::io::stdin().read_line(&mut line).ok()?; Some(line.trim().to_owned()) } // The following constants are here so that they can be shared between this crate and Evcxr. They're // not really intended to be used. #[doc(...
{ println!("{}:{}", GET_CMD_PASSWORD, prompt); }
conditional_block
lib.rs
/// Requests a string from the user with the specified prompt. pub fn
(prompt: &str) -> String { get_input(prompt, false).unwrap_or_default() } /// Requests a string from the user with the specified prompt, treating the input as a password. pub fn get_password(prompt: &str) -> String { get_input(prompt, true).unwrap_or_default() } fn get_input(prompt: &str, is_password: bool) -...
get_string
identifier_name
lib.rs
/// Requests a string from the user with the specified prompt. pub fn get_string(prompt: &str) -> String { get_input(prompt, false).unwrap_or_default() }
/// Requests a string from the user with the specified prompt, treating the input as a password. pub fn get_password(prompt: &str) -> String { get_input(prompt, true).unwrap_or_default() } fn get_input(prompt: &str, is_password: bool) -> Option<String> { if is_password { println!("{}:{}", GET_CMD_PASSW...
random_line_split
easage_pack.rs
use clap::{Arg, ArgMatches, App, SubCommand}; use ::std::fs::OpenOptions; use ::std::io::Write; use ::lib::{Kind, packer}; use ::{CliResult, CliError}; pub const COMMAND_NAME: &'static str = "pack"; const ARG_NAME_SOURCE: &'static str = "source"; const ARG_NAME_OUTPUT: &'static str = "output"; const ARG_NAME_KIND: &...
<'a, 'b>() -> App<'a, 'b> { SubCommand::with_name(COMMAND_NAME) .about("Recursively package a directory structure into a BIG archive") .author("Taryn Hill <taryn@phrohdoh.com>") .arg(Arg::with_name(ARG_NAME_SOURCE) .long(ARG_NAME_SOURCE) .value_name(ARG_NAME_SOURCE...
get_command
identifier_name
easage_pack.rs
use clap::{Arg, ArgMatches, App, SubCommand}; use ::std::fs::OpenOptions; use ::std::io::Write; use ::lib::{Kind, packer}; use ::{CliResult, CliError}; pub const COMMAND_NAME: &'static str = "pack"; const ARG_NAME_SOURCE: &'static str = "source"; const ARG_NAME_OUTPUT: &'static str = "output"; const ARG_NAME_KIND: &...
} fn validate_order(v: String) -> Result<(), String> { if v == ARG_VALUE_ORDER_SMALLEST_TO_LARGEST || v == ARG_VALUE_ORDER_PATH { Ok(()) } else { Err(format!("{} must be one of '{}' or '{}'", ARG_NAME_ORDER, ARG_VALUE_ORDER_SMALLEST_TO_LARGEST, ARG_VALUE_ORDE...
}, }
random_line_split
easage_pack.rs
use clap::{Arg, ArgMatches, App, SubCommand}; use ::std::fs::OpenOptions; use ::std::io::Write; use ::lib::{Kind, packer}; use ::{CliResult, CliError}; pub const COMMAND_NAME: &'static str = "pack"; const ARG_NAME_SOURCE: &'static str = "source"; const ARG_NAME_OUTPUT: &'static str = "output"; const ARG_NAME_KIND: &...
{ if v == ARG_VALUE_ORDER_SMALLEST_TO_LARGEST || v == ARG_VALUE_ORDER_PATH { Ok(()) } else { Err(format!("{} must be one of '{}' or '{}'", ARG_NAME_ORDER, ARG_VALUE_ORDER_SMALLEST_TO_LARGEST, ARG_VALUE_ORDER_PATH)) } }
identifier_body
build.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
assert!( Path::new(&format!("{}/deploy_lib.o", out_dir)).exists(), "Could not prepare demo: {}", String::from_utf8(output.stderr) .unwrap() .trim() .split("\n") .last() .unwrap_or("") ); println!("cargo:rustc-link-search=native=...
{ let out_dir = std::env::var("CARGO_MANIFEST_DIR")?; let python_script = concat!(env!("CARGO_MANIFEST_DIR"), "/src/build_resnet.py"); let synset_txt = concat!(env!("CARGO_MANIFEST_DIR"), "/synset.txt"); println!("cargo:rerun-if-changed={}", python_script); println!("cargo:rerun-if-changed={}", syn...
identifier_body
build.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
() -> Result<()> { let out_dir = std::env::var("CARGO_MANIFEST_DIR")?; let python_script = concat!(env!("CARGO_MANIFEST_DIR"), "/src/build_resnet.py"); let synset_txt = concat!(env!("CARGO_MANIFEST_DIR"), "/synset.txt"); println!("cargo:rerun-if-changed={}", python_script); println!("cargo:rerun-if...
main
identifier_name
build.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
let out_dir = std::env::var("CARGO_MANIFEST_DIR")?; let python_script = concat!(env!("CARGO_MANIFEST_DIR"), "/src/build_resnet.py"); let synset_txt = concat!(env!("CARGO_MANIFEST_DIR"), "/synset.txt"); println!("cargo:rerun-if-changed={}", python_script); println!("cargo:rerun-if-changed={}", synse...
use anyhow::{Context, Result}; use std::{io::Write, path::Path, process::Command}; fn main() -> Result<()> {
random_line_split
build.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
assert!( Path::new(&format!("{}/deploy_lib.o", out_dir)).exists(), "Could not prepare demo: {}", String::from_utf8(output.stderr) .unwrap() .trim() .split("\n") .last() .unwrap_or("") ); println!("cargo:rustc-link-search=native...
{ std::io::stdout() .write_all(&output.stderr) .context("Failed to write error")?; panic!("Failed to execute build script"); }
conditional_block
open_action.rs
use crate::{ actionable_events::{ActionDispatcher, ActionableEvent}, entity::{Entity, EntityRef, Realm}, player_output::PlayerOutput, utils::{capitalize, definite_character_name}, }; use std::time::Duration; /// Opens a portal. pub fn open( realm: &mut Realm, action_dispatcher: &ActionDispatche...
( realm: &mut Realm, character_ref: EntityRef, portal_ref: EntityRef, ) -> Result<Vec<PlayerOutput>, String> { let (_, room) = realm.character_and_room_res(character_ref)?; let portal = realm.portal(portal_ref).ok_or("That exit doesn't exist.")?; if!portal.can_open_from_room(room.entity_ref()) ...
close
identifier_name
open_action.rs
use crate::{ actionable_events::{ActionDispatcher, ActionableEvent}, entity::{Entity, EntityRef, Realm}, player_output::PlayerOutput, utils::{capitalize, definite_character_name},
/// Opens a portal. pub fn open( realm: &mut Realm, action_dispatcher: &ActionDispatcher, character_ref: EntityRef, portal_ref: EntityRef, ) -> Result<Vec<PlayerOutput>, String> { let (character, room) = realm.character_and_room_res(character_ref)?; let portal = realm.portal(portal_ref).ok_or("...
}; use std::time::Duration;
random_line_split
open_action.rs
use crate::{ actionable_events::{ActionDispatcher, ActionableEvent}, entity::{Entity, EntityRef, Realm}, player_output::PlayerOutput, utils::{capitalize, definite_character_name}, }; use std::time::Duration; /// Opens a portal. pub fn open( realm: &mut Realm, action_dispatcher: &ActionDispatche...
format!("You open the {}.\n", name), )); } else if character .inventory() .iter() .any(|item| match realm.item(*item) { Some(item) => item.name() == required_key, _ => false, }) { output....
{ let (character, room) = realm.character_and_room_res(character_ref)?; let portal = realm.portal(portal_ref).ok_or("That exit doesn't exist.")?; if !portal.can_open_from_room(room.entity_ref()) { return Err("Exit cannot be opened.".into()); } let name = portal.name_from_room(room.entity_r...
identifier_body
lib.rs
#![feature(cstr_memory)] extern crate libc; use std::collections::HashMap; use std::ffi::{CStr, CString}; use libc::c_char; use std::str; #[derive(Debug)] pub struct Usage { calls: HashMap<String, u32>, total: u32 } impl Usage { fn new() -> Usage { Usage { calls: HashMap::new(), ...
() -> Box<Usage> { Box::new(Usage::new()) } #[no_mangle] pub extern "C" fn record(usage: &mut Usage, event: *const c_char, file: *const c_char, line: u32, id: *const c_char, classname: *cons...
new_usage
identifier_name
lib.rs
#![feature(cstr_memory)] extern crate libc; use std::collections::HashMap; use std::ffi::{CStr, CString}; use libc::c_char; use std::str; #[derive(Debug)] pub struct Usage { calls: HashMap<String, u32>, total: u32 } impl Usage { fn new() -> Usage { Usage { calls: HashMap::new(), ...
} #[no_mangle] pub extern "C" fn report(usage: &Usage) -> Report { let mut counts: Vec<CallCount> = usage.calls .iter() .map(|(method, count)| CallCount::new(method, count) ) .collect(); counts.sort_by(|a, b| a.count.cmp(&b.count).reverse()); let c_counts: Vec<CCallCount> = counts ...
{ let method_name = unsafe { CStr::from_ptr(id) }; let method_name = str::from_utf8(method_name.to_bytes()).unwrap(); let class_name = unsafe { CStr::from_ptr(classname) }; let class_name = str::from_utf8(class_name.to_bytes()).unwrap(); usage.record(class_name.to_string() + "#" ...
conditional_block
lib.rs
#![feature(cstr_memory)] extern crate libc; use std::collections::HashMap; use std::ffi::{CStr, CString}; use libc::c_char; use std::str; #[derive(Debug)] pub struct Usage { calls: HashMap<String, u32>, total: u32 } impl Usage { fn new() -> Usage { Usage { calls: HashMap::new(), ...
#[no_mangle] pub extern "C" fn record(usage: &mut Usage, event: *const c_char, file: *const c_char, line: u32, id: *const c_char, classname: *const c_char) { let event = unsafe { CStr::from...
{ Box::new(Usage::new()) }
identifier_body
lib.rs
#![feature(cstr_memory)] extern crate libc; use std::collections::HashMap; use std::ffi::{CStr, CString}; use libc::c_char; use std::str; #[derive(Debug)] pub struct Usage { calls: HashMap<String, u32>, total: u32 } impl Usage {
total: 0 } } fn record(&mut self, method_name: String) { *self.calls.entry(method_name).or_insert(0) += 1; self.total += 1; } } #[derive(Debug)] pub struct CallCount { count: u32, method_name: String } impl CallCount { fn new(method: &str, count: &u32) -> C...
fn new() -> Usage { Usage { calls: HashMap::new(),
random_line_split
deriving-cmp-generic-struct-enum.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let (es11, es12, es21, es22) = (ES1 {x: 1}, ES1 {x: 2}, ES2 {x: 1, y: 1}, ES2 {x: 1, y: 2}); // in order for both Ord and TotalOrd let ess = [es11, es12, es21, es22]; for (i, es1) in ess.iter().enumerate() { for (j, es2) in ess.iter().enumerate() { let ord = i.cmp(&j); ...
main
identifier_name
deriving-cmp-generic-struct-enum.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
assert_eq!(*es1 > *es2, gt); assert_eq!(*es1 <= *es2, le); assert_eq!(*es1 >= *es2, ge); // TotalOrd assert_eq!(es1.cmp(es2), ord); } } }
{ let (es11, es12, es21, es22) = (ES1 {x: 1}, ES1 {x: 2}, ES2 {x: 1, y: 1}, ES2 {x: 1, y: 2}); // in order for both Ord and TotalOrd let ess = [es11, es12, es21, es22]; for (i, es1) in ess.iter().enumerate() { for (j, es2) in ess.iter().enumerate() { let ord = i.cmp(&j); ...
identifier_body
deriving-cmp-generic-struct-enum.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let (es11, es12, es21, es22) = (ES1 {x: 1}, ES1 {x: 2}, ES2 {x: 1, y: 1}, ES2 {x: 1, y: 2}); // in order for both Ord and TotalOrd let ess = [es11, es12, es21, es22]; for (i, es1) in ess.iter().enumerate() { for (j, es2) in ess.iter().enumerate() { let ord = i.cmp(&j); ...
pub fn main() {
random_line_split
stack.rs
//! Low-level details of stack accesses. //! //! The `ir::StackSlots` type deals with stack slots and stack frame layout. The `StackRef` type //! defined in this module expresses the low-level details of accessing a stack slot from an //! encoded instruction. use crate::ir::stackslot::{StackOffset, StackSlotKind, Stac...
pub fn contains(self, base: StackBase) -> bool { self.0 & (1 << base as usize)!= 0 } }
#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct StackBaseMask(pub u8); impl StackBaseMask { /// Check if this mask contains the `base` variant.
random_line_split
stack.rs
//! Low-level details of stack accesses. //! //! The `ir::StackSlots` type deals with stack slots and stack frame layout. The `StackRef` type //! defined in this module expresses the low-level details of accessing a stack slot from an //! encoded instruction. use crate::ir::stackslot::{StackOffset, StackSlotKind, Stac...
; Self { base: StackBase::SP, offset, } } } /// Generic base register for referencing stack slots. /// /// Most ISAs have a stack pointer and an optional frame pointer, so provide generic names for /// those two base pointers. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub...
{ // All other slots have offsets relative to our caller's stack frame. // Offset where SP is pointing. (All ISAs have stacks growing downwards.) let sp_offset = -(size as StackOffset); slot.offset.unwrap() - sp_offset }
conditional_block
stack.rs
//! Low-level details of stack accesses. //! //! The `ir::StackSlots` type deals with stack slots and stack frame layout. The `StackRef` type //! defined in this module expresses the low-level details of accessing a stack slot from an //! encoded instruction. use crate::ir::stackslot::{StackOffset, StackSlotKind, Stac...
}
{ self.0 & (1 << base as usize) != 0 }
identifier_body
stack.rs
//! Low-level details of stack accesses. //! //! The `ir::StackSlots` type deals with stack slots and stack frame layout. The `StackRef` type //! defined in this module expresses the low-level details of accessing a stack slot from an //! encoded instruction. use crate::ir::stackslot::{StackOffset, StackSlotKind, Stac...
{ /// Use the stack pointer. SP = 0, /// Use the frame pointer (if one is present). FP = 1, /// Use an explicit zone pointer in a general-purpose register. /// /// This feature is not yet implemented. Zone = 2, } /// Bit mask of supported stack bases. /// /// Many instruction encodin...
StackBase
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/. */ #![feature(plugin)] #![plugin(serde_macros)] #![plugin(clippy)] #![deny(clippy)] #[macro_use] extern crate hype...
{ Enabled, Disabled, }
TlsOption
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/. */ #![feature(plugin)] #![plugin(serde_macros)] #![plugin(clippy)] #![deny(clippy)] #[macro_use] extern crate hype...
} ); macro_rules! current_dir { () => { { use std::path::PathBuf; let mut this_file = PathBuf::from(file!()); this_file.pop(); this_file.to_str().unwrap().to_owned() } }; } mod certificate_manager; mod certificate_record; mod dns_client; mod ...
random_line_split
htmlbodyelement.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::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindin...
fn after_set_attr(&self, name: &Atom, value: DOMString) { match self.super_type() { Some(ref s) => s.after_set_attr(name, value.clone()), _ => (), } if name.as_slice().starts_with("on") { static forwarded_events: &'static [&'static str] = ...
{ let element: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self); Some(element as &VirtualMethods) }
identifier_body
htmlbodyelement.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::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindin...
{ pub htmlelement: HTMLElement } impl HTMLBodyElementDerived for EventTarget { fn is_htmlbodyelement(&self) -> bool { self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLBodyElementTypeId)) } } impl HTMLBodyElement { pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> ...
HTMLBodyElement
identifier_name
htmlbodyelement.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::WindowBinding::WindowMethods; use dom::bindings::codegen::InheritTypes::EventTargetCast; use dom::bindings::codegen::InheritTypes::{HTMLBodyElementDerived, HTMLElementCast}; use dom::bindings::js::{JSRef, Temporary}; use dom::bindings::utils::{Reflectable, Reflector}; use dom::docu...
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindings::HTMLBodyElementBinding; use dom::bindings::codegen::Bindings::HTMLBodyElementBinding::HTMLBodyElementMethods;
random_line_split
htmlbodyelement.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::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindin...
} } impl Reflectable for HTMLBodyElement { fn reflector<'a>(&'a self) -> &'a Reflector { self.htmlelement.reflector() } }
{ static forwarded_events: &'static [&'static str] = &["onfocus", "onload", "onscroll", "onafterprint", "onbeforeprint", "onbeforeunload", "onhashchange", "onlanguagechange", "onmessage", "onoffline", "ononline", "onpagehide", "onpageshow", "onpopstate", ...
conditional_block