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
tester.rs
use std::comm; use std::fmt::Show; use std::io::ChanWriter; use std::iter; use std::rand; use std::task::TaskBuilder; use super::{Arbitrary, Gen, Shrinker, StdGen}; use tester::trap::safe; use tester::Status::{Discard, Fail, Pass}; /// The main QuickCheck type for setting configuration and running QuickCheck. pub stru...
/// /// For functions, an implementation must generate random arguments /// and potentially shrink those arguments if they produce a failure. /// /// It's unlikely that you'll have to implement this trait yourself. /// This comes with a caveat: currently, only functions with 4 parameters /// or fewer (both `fn` and `|...
/// Anything that can be tested must be capable of producing a `TestResult` /// given a random number generator. This is trivial for types like `bool`, /// which are just converted to either a passing or failing test result.
random_line_split
map.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 ...
pub fn get(&self, key: &K) -> Result<V> where V: TryFrom<RetValue, Error = Error>, { let key = key.clone(); let oref: ObjectRef = map_get_item(self.object.clone(), key.upcast())?; oref.downcast() } } pub struct IntoIter<K, V> { // NB: due to FFI this isn't as lazy ...
{ let func = Function::get("node.Map").expect( "node.Map function is not registered, this is most likely a build or linking error", ); let map_data: ObjectPtr<Object> = func.invoke(data)?.try_into()?; debug_assert!( map_data.count() >= 1, "map_data c...
identifier_body
map.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 ...
V: IsObjectRef, { type Error = Error; fn try_from(array: RetValue) -> Result<Map<K, V>> { let object_ref = array.try_into()?; // TODO: type check Ok(Map { object: object_ref, _data: PhantomData, }) } } #[cfg(test)] mod test { use std::collect...
K: IsObjectRef,
random_line_split
map.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 ...
else { None } } #[inline] fn size_hint(&self) -> (usize, Option<usize>) { ((self.key_and_values.len() / 2) as usize, None) } } impl<K, V> IntoIterator for Map<K, V> where K: IsObjectRef, V: IsObjectRef, { type Item = (K, V); type IntoIter = IntoIter<K, V>; ...
{ let key = self .key_and_values .get(self.next_key as isize) .expect("this should always succeed"); let value = self .key_and_values .get((self.next_key as isize) + 1) .expect("this should always suc...
conditional_block
map.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 ...
(&self, key: &K) -> Result<V> where V: TryFrom<RetValue, Error = Error>, { let key = key.clone(); let oref: ObjectRef = map_get_item(self.object.clone(), key.upcast())?; oref.downcast() } } pub struct IntoIter<K, V> { // NB: due to FFI this isn't as lazy as one might lik...
get
identifier_name
mid-path-type-params.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 ...
<U>(x: isize, _: U) -> S2 { S2 { contents: x, } } } pub fn main() { let _ = S::<isize>::new::<f64>(1, 1.0); let _: S2 = Trait::<isize>::new::<f64>(1, 1.0); }
new
identifier_name
mid-path-type-params.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 ...
impl<T> S<T> { fn new<U>(x: T, _: U) -> S<T> { S { contents: x, } } } trait Trait<T> { fn new<U>(x: T, y: U) -> Self; } struct S2 { contents: isize, } impl Trait<isize> for S2 { fn new<U>(x: isize, _: U) -> S2 { S2 { contents: x, } } } ...
}
random_line_split
c-stack-returning-int64.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 ...
s.with_c_str(|x| unsafe { libc::atoll(x) as i64 }) } pub fn main() { assert_eq!(atol(~"1024") * 10, atol(~"10240")); assert!((atoll(~"11111111111111111") * 10) == atoll(~"111111111111111110")); }
} #[fixed_stack_segment] fn atoll(s: ~str) -> i64 {
random_line_split
c-stack-returning-int64.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 ...
(s: ~str) -> i64 { s.with_c_str(|x| unsafe { libc::atoll(x) as i64 }) } pub fn main() { assert_eq!(atol(~"1024") * 10, atol(~"10240")); assert!((atoll(~"11111111111111111") * 10) == atoll(~"111111111111111110")); }
atoll
identifier_name
c-stack-returning-int64.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 ...
#[fixed_stack_segment] fn atoll(s: ~str) -> i64 { s.with_c_str(|x| unsafe { libc::atoll(x) as i64 }) } pub fn main() { assert_eq!(atol(~"1024") * 10, atol(~"10240")); assert!((atoll(~"11111111111111111") * 10) == atoll(~"111111111111111110")); }
{ s.with_c_str(|x| unsafe { libc::atol(x) as int }) }
identifier_body
htmldataelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::HTMLDataElementBinding; use crate::dom::bindings::codegen::Bindings:...
pub fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, ) -> DomRoot<HTMLDataElement> { Node::reflect_node( Box::new(HTMLDataElement::new_inherited(local_name, prefix, document)), document, HTMLDataElementBinding::Wrap, ...
} #[allow(unrooted_must_root)]
random_line_split
htmldataelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::HTMLDataElementBinding; use crate::dom::bindings::codegen::Bindings:...
{ htmlelement: HTMLElement, } impl HTMLDataElement { fn new_inherited( local_name: LocalName, prefix: Option<Prefix>, document: &Document, ) -> HTMLDataElement { HTMLDataElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), } ...
HTMLDataElement
identifier_name
workfile.rs
use std; use std::io; use std::io::prelude::*; use std::fs::File; use std::io::{Error, ErrorKind}; // Helps creating a working file and move the working file // to the final file when done, or automatically delete the // working file in case of error. pub struct
{ file_path: String, work_file_path: String, file: Option<File> } impl WorkFile { pub fn create(file_path: &str) -> io::Result<WorkFile> { let work_file_path: String = format!("{}.work", file_path); let file = match File::create(&work_file_path) { Ok(file) => file, Err(err) => { return Err(err); } }; ...
WorkFile
identifier_name
workfile.rs
use std; use std::io; use std::io::prelude::*; use std::fs::File; use std::io::{Error, ErrorKind}; // Helps creating a working file and move the working file // to the final file when done, or automatically delete the // working file in case of error. pub struct WorkFile { file_path: String, work_file_path: String, ...
}
{ if self.file.is_some() { drop(self.file.take()); match std::fs::remove_file(&self.work_file_path) { Ok(_) => (), Err(err) => panic!("rollback failed: {}", err) } } }
identifier_body
workfile.rs
use std; use std::io; use std::io::prelude::*; use std::fs::File;
// Helps creating a working file and move the working file // to the final file when done, or automatically delete the // working file in case of error. pub struct WorkFile { file_path: String, work_file_path: String, file: Option<File> } impl WorkFile { pub fn create(file_path: &str) -> io::Result<WorkFile> { l...
use std::io::{Error, ErrorKind};
random_line_split
cstring.rs
use libc::c_char; use std::ffi::CStr; use std::str::Utf8Error; use std::ffi::CString; pub struct CStringUtils {} impl CStringUtils { pub fn c_str_to_string(cstr: *const c_char) -> Result<Option<String>, Utf8Error> { if cstr.is_null() { return Ok(None); } unsafe { ...
} //TODO DOCUMENT WHAT THIS DOES macro_rules! check_useful_c_str { ($x:ident, $e:expr) => { let $x = match CStringUtils::c_str_to_string($x) { Ok(Some(val)) => val, _ => return VcxError::from_msg($e, "Invalid pointer has been passed").into() }; if $x.is_empty() { ...
}
random_line_split
cstring.rs
use libc::c_char; use std::ffi::CStr; use std::str::Utf8Error; use std::ffi::CString; pub struct CStringUtils {} impl CStringUtils { pub fn c_str_to_string(cstr: *const c_char) -> Result<Option<String>, Utf8Error> { if cstr.is_null() { return Ok(None); } unsafe { ...
{ let len = v.len() as u32; (v.as_ptr() as *const u8, len) }
identifier_body
cstring.rs
use libc::c_char; use std::ffi::CStr; use std::str::Utf8Error; use std::ffi::CString; pub struct CStringUtils {} impl CStringUtils { pub fn c_str_to_string(cstr: *const c_char) -> Result<Option<String>, Utf8Error> { if cstr.is_null() { return Ok(None); } unsafe { ...
(s: String) -> CString { CString::new(s).unwrap() } } //TODO DOCUMENT WHAT THIS DOES macro_rules! check_useful_c_str { ($x:ident, $e:expr) => { let $x = match CStringUtils::c_str_to_string($x) { Ok(Some(val)) => val, _ => return VcxError::from_msg($e, "Invalid pointer ha...
string_to_cstring
identifier_name
connection_status.rs
use crate::{ auth::{Credentials, SASLMechanism}, Connection, ConnectionProperties, PromiseResolver, }; use parking_lot::Mutex; use std::{fmt, sync::Arc}; #[derive(Clone, Default)] pub struct ConnectionStatus(Arc<Mutex<Inner>>); impl ConnectionStatus { pub fn state(&self) -> ConnectionState { self....
[ConnectionState::Connecting, ConnectionState::Connected].contains(&self.0.lock().state) } } pub(crate) enum ConnectionStep { ProtocolHeader( PromiseResolver<Connection>, Connection, Credentials, SASLMechanism, ConnectionProperties, ), StartOk(PromiseReso...
pub(crate) fn auto_close(&self) -> bool {
random_line_split
connection_status.rs
use crate::{ auth::{Credentials, SASLMechanism}, Connection, ConnectionProperties, PromiseResolver, }; use parking_lot::Mutex; use std::{fmt, sync::Arc}; #[derive(Clone, Default)] pub struct ConnectionStatus(Arc<Mutex<Inner>>); impl ConnectionStatus { pub fn state(&self) -> ConnectionState { self....
(&self) -> bool { self.0.lock().state == ConnectionState::Error } pub(crate) fn auto_close(&self) -> bool { [ConnectionState::Connecting, ConnectionState::Connected].contains(&self.0.lock().state) } } pub(crate) enum ConnectionStep { ProtocolHeader( PromiseResolver<Connection>,...
errored
identifier_name
connection_status.rs
use crate::{ auth::{Credentials, SASLMechanism}, Connection, ConnectionProperties, PromiseResolver, }; use parking_lot::Mutex; use std::{fmt, sync::Arc}; #[derive(Clone, Default)] pub struct ConnectionStatus(Arc<Mutex<Inner>>); impl ConnectionStatus { pub fn state(&self) -> ConnectionState { self....
} struct Inner { connection_step: Option<ConnectionStep>, state: ConnectionState, vhost: String, username: String, blocked: bool, } impl Default for Inner { fn default() -> Self { Self { connection_step: None, state: ConnectionState::default(), vhos...
{ let mut debug = f.debug_struct("ConnectionStatus"); if let Some(inner) = self.0.try_lock() { debug .field("state", &inner.state) .field("vhost", &inner.vhost) .field("username", &inner.username) .field("blocked", &inner.blocke...
identifier_body
time.rs
//! Time support use std::cmp::Ordering; use std::ops::{Add, Sub}; use std::ptr; use libc::timespec as c_timespec; use libc::{c_int, c_long, time_t}; use remacs_lib::current_timespec; use remacs_macros::lisp_fn; use crate::{ lisp::LispObject, numbers::MOST_NEGATIVE_FIXNUM, remacs_sys::{lisp_time, EmacsD...
(validity: i32) { if validity <= 0 { if validity < 0 { time_overflow(); } else { invalid_time(); } } } fn invalid_time() ->! { error!("Invalid time specification"); } /// Report that a time value is out of range for Emacs. pub fn time_overflow() ->! { er...
check_time_validity
identifier_name
time.rs
//! Time support use std::cmp::Ordering; use std::ops::{Add, Sub}; use std::ptr; use libc::timespec as c_timespec; use libc::{c_int, c_long, time_t}; use remacs_lib::current_timespec; use remacs_macros::lisp_fn; use crate::{ lisp::LispObject, numbers::MOST_NEGATIVE_FIXNUM, remacs_sys::{lisp_time, EmacsD...
/// `UNKNOWN_MODTIME_NSECS`; in that case, the Lisp list contains a /// correspondingly negative picosecond count. #[no_mangle] pub extern "C" fn make_lisp_time(t: c_timespec) -> LispObject { make_lisp_time_1(t) } fn make_lisp_time_1(t: c_timespec) -> LispObject { let s = t.tv_sec; let ns = t.tv_nsec; ...
/// Make a Lisp list that represents the Emacs time T. T may be an /// invalid time, with a slightly negative `tv_nsec` value such as
random_line_split
time.rs
//! Time support use std::cmp::Ordering; use std::ops::{Add, Sub}; use std::ptr; use libc::timespec as c_timespec; use libc::{c_int, c_long, time_t}; use remacs_lib::current_timespec; use remacs_macros::lisp_fn; use crate::{ lisp::LispObject, numbers::MOST_NEGATIVE_FIXNUM, remacs_sys::{lisp_time, EmacsD...
if us < 0 { lo -= 1; us += 1_000_000; } if lo < 0 { hi -= 1; lo += 1 << LO_TIME_BITS; } (*result).hi = hi; (*result).lo = lo; (*result).us = us; (*result).ps = ps; true } #[no_mangle] pub extern "C" fn lisp_to_timespec(t: lisp_time) -> c_timespec ...
{ let lo_multiplier = f64::from(1 << LO_TIME_BITS); let emacs_time_min = MOST_NEGATIVE_FIXNUM as f64 * lo_multiplier; if !(emacs_time_min <= t && t < -emacs_time_min) { return false; } let small_t = t / lo_multiplier; let mut hi = small_t as EmacsInt; let t_sans_hi = t - (hi as f64)...
identifier_body
time.rs
//! Time support use std::cmp::Ordering; use std::ops::{Add, Sub}; use std::ptr; use libc::timespec as c_timespec; use libc::{c_int, c_long, time_t}; use remacs_lib::current_timespec; use remacs_macros::lisp_fn; use crate::{ lisp::LispObject, numbers::MOST_NEGATIVE_FIXNUM, remacs_sys::{lisp_time, EmacsD...
if!dresult.is_null() { *dresult = t; } return 1; } else if low.is_nil() { let now = current_timespec(); if!result.is_null() { (*result).hi = hi_time(now.tv_sec); (*result).lo = lo_time(now.tv_sec); ...
{ return -1; }
conditional_block
macro_crate_test.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(cx: &mut ExtCtxt, sp: Span, attr: Gc<MetaItem>, it: Gc<Item>) -> Gc<Item> { box(GC) Item { attrs: it.attrs.clone(), ..(*quote_item!(cx, enum Foo { Bar, Baz }).unwrap()).clone() } } fn expand_forged_ident(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult+'static>...
expand_into_foo
identifier_name
macro_crate_test.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// force-host #![feature(globs, plugin_registrar, macro_rules, quote)] extern crate syntax; extern crate rustc; use syntax::ast::{TokenTree, Item, MetaItem}; use syntax::codemap::Span; use syntax::ext::base::*; use syntax::parse::token; use syntax::parse; use rustc::plugin::Registry; use std::gc::{Gc, GC}; #[macr...
random_line_split
macro_crate_test.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
MacExpr::new(quote_expr!(cx, 1i)) } // See Issue #15750 fn expand_identity(cx: &mut ExtCtxt, _span: Span, tts: &[TokenTree]) -> Box<MacResult+'static> { // Parse an expression and emit it unchanged. let mut parser = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), Vec::from...
{ cx.span_fatal(sp, "make_a_1 takes no arguments"); }
conditional_block
macro_crate_test.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// See Issue #15750 fn expand_identity(cx: &mut ExtCtxt, _span: Span, tts: &[TokenTree]) -> Box<MacResult+'static> { // Parse an expression and emit it unchanged. let mut parser = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), Vec::from_slice(tts)); let expr = parser.pars...
{ if !tts.is_empty() { cx.span_fatal(sp, "make_a_1 takes no arguments"); } MacExpr::new(quote_expr!(cx, 1i)) }
identifier_body
listdir.rs
// Copyright 2014 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
}
{ println!("{}", path.display()); match fs::metadata(&path) { Ok(ref m) if m.is_dir() => Some(()), _ => None, } }
identifier_body
listdir.rs
// Copyright 2014 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
use threadpool; pub trait PathHandler<D> { fn handle_path(&self, D, PathBuf) -> Option<D>; } pub fn iterate_recursively<P:'static + Send + Clone, W:'static + PathHandler<P> + Send + Clone> (root: (PathBuf, P), worker: &mut W) { let threads = 10; let (push_ch, work_ch) = mpsc::sync_channel(threads); let po...
random_line_split
listdir.rs
// Copyright 2014 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
<P:'static + Send + Clone, W:'static + PathHandler<P> + Send + Clone> (root: (PathBuf, P), worker: &mut W) { let threads = 10; let (push_ch, work_ch) = mpsc::sync_channel(threads); let pool = threadpool::ThreadPool::new(threads); // Insert the first task into the queue: push_ch.send(Some(root)).unwrap(); ...
iterate_recursively
identifier_name
struct-pattern-matching-with-methods.rs
// edition:2021 //check-pass #![warn(unused)] #![allow(dead_code)] #![feature(rustc_attrs)] #[derive(Debug, Clone, Copy)] enum PointType { TwoD { x: u32, y: u32 }, ThreeD{ x: u32, y: u32, z: u32 } } // Testing struct patterns struct Points { points: Vec<PointType>, } impl Points { pub fn test1(&mut ...
points.points.push(PointType::TwoD{ x:0, y:0 }); println!("{:?}", points.test1()); println!("{:?}", points.points); }
random_line_split
struct-pattern-matching-with-methods.rs
// edition:2021 //check-pass #![warn(unused)] #![allow(dead_code)] #![feature(rustc_attrs)] #[derive(Debug, Clone, Copy)] enum PointType { TwoD { x: u32, y: u32 }, ThreeD{ x: u32, y: u32, z: u32 } } // Testing struct patterns struct Points { points: Vec<PointType>, } impl Points { pub fn test1(&mut ...
() { let mut points = Points { points: Vec::<PointType>::new() }; points.points.push(PointType::ThreeD { x:0, y:0, z:0 }); points.points.push(PointType::TwoD{ x:0, y:0 }); points.points.push(PointType::ThreeD{ x:0, y:0, z:0 }); points.points.push(PointType::TwoD{ x:0, y:0 }); print...
main
identifier_name
struct-pattern-matching-with-methods.rs
// edition:2021 //check-pass #![warn(unused)] #![allow(dead_code)] #![feature(rustc_attrs)] #[derive(Debug, Clone, Copy)] enum PointType { TwoD { x: u32, y: u32 }, ThreeD{ x: u32, y: u32, z: u32 } } // Testing struct patterns struct Points { points: Vec<PointType>, } impl Points { pub fn test1(&mut ...
{ let mut points = Points { points: Vec::<PointType>::new() }; points.points.push(PointType::ThreeD { x:0, y:0, z:0 }); points.points.push(PointType::TwoD{ x:0, y:0 }); points.points.push(PointType::ThreeD{ x:0, y:0, z:0 }); points.points.push(PointType::TwoD{ x:0, y:0 }); println!...
identifier_body
env.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 max_cached_stacks() -> uint { unsafe { MAX_CACHED_STACKS } } pub fn debug_borrow() -> bool { unsafe { DEBUG_BORROW } }
{ unsafe { MIN_STACK } }
identifier_body
env.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 ...
None => () } } } pub fn min_stack() -> uint { unsafe { MIN_STACK } } pub fn max_cached_stacks() -> uint { unsafe { MAX_CACHED_STACKS } } pub fn debug_borrow() -> bool { unsafe { DEBUG_BORROW } }
random_line_split
env.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 ...
() { unsafe { match os::getenv("RUST_MIN_STACK") { Some(s) => match from_str(s) { Some(i) => MIN_STACK = i, None => () }, None => () } match os::getenv("RUST_MAX_CACHED_STACKS") { Some(max) => MAX_CACHED_STACKS =...
init
identifier_name
issue-49973.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 ...
{ Min = -2147483648i32, _Max = 2147483647i32, } fn main() { assert_eq!(Some(E::Min).unwrap() as i32, -2147483648i32); }
E
identifier_name
issue-49973.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 ...
assert_eq!(Some(E::Min).unwrap() as i32, -2147483648i32); }
random_line_split
issue-49973.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 ...
{ assert_eq!(Some(E::Min).unwrap() as i32, -2147483648i32); }
identifier_body
unboxed-closure-sugar-region.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 same_type<A,B:Eq<A>>(a: A, b: B) { } fn test<'a,'b>() { // Parens are equivalent to omitting default in angle. eq::< Foo<(int,),()>, Foo(int) >(); // Here we specify'static explicitly in angle-bracket version. // Parenthesized winds up getting inferred. eq::< ...
impl<X> Eq<X> for X { } fn eq<A,B:Eq<A>>() { }
random_line_split
unboxed-closure-sugar-region.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 test<'a,'b>() { // Parens are equivalent to omitting default in angle. eq::< Foo<(int,),()>, Foo(int) >(); // Here we specify'static explicitly in angle-bracket version. // Parenthesized winds up getting inferred. eq::< Foo<'static, (int,),()>, ...
{ }
identifier_body
unboxed-closure-sugar-region.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'a,'b>() { // Parens are equivalent to omitting default in angle. eq::< Foo<(int,),()>, Foo(int) >(); // Here we specify'static explicitly in angle-bracket version. // Parenthesized winds up getting inferred. eq::< Foo<'static, (int,),()>, Foo(int) ...
test
identifier_name
i16_add_with_overflow.rs
#![feature(core, core_intrinsics)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::i16_add_with_overflow; // pub fn i16_add_with_overflow(x: i16, y: i16) -> (i16, bool); #[test] fn i16_add_with_overflow_test1()
#[test] #[allow(overflowing_literals)] fn i16_add_with_overflow_test2() { let x: i16 = 0x7fff; // 32767 let y: i16 = 0x0001; // 1 let (result, is_overflow): (i16, bool) = unsafe { i16_add_with_overflow(x, y) }; assert_eq!(result, 0x8000); // -32768 assert_eq!(is_overflow, true); } #[...
{ let x: i16 = 0x7f00; // 32512 let y: i16 = 0x00ff; // 255 let (result, is_overflow): (i16, bool) = unsafe { i16_add_with_overflow(x, y) }; assert_eq!(result, 0x7fff); // 32767 assert_eq!(is_overflow, false); }
identifier_body
i16_add_with_overflow.rs
#![feature(core, core_intrinsics)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::i16_add_with_overflow; // pub fn i16_add_with_overflow(x: i16, y: i16) -> (i16, bool); #[test] fn i16_add_with_overflow_test1() { let x: i16 = 0x7f00; // 32512 let y: i16 = 0x00ff; // 255 let (res...
() { let x: i16 = 0x7fff; // 32767 let y: i16 = 0x0001; // 1 let (result, is_overflow): (i16, bool) = unsafe { i16_add_with_overflow(x, y) }; assert_eq!(result, 0x8000); // -32768 assert_eq!(is_overflow, true); } #[test] #[allow(overflowing_literals)] fn i16_add_with_overflow_test3() { le...
i16_add_with_overflow_test2
identifier_name
i16_add_with_overflow.rs
#![feature(core, core_intrinsics)] extern crate core;
#[cfg(test)] mod tests { use core::intrinsics::i16_add_with_overflow; // pub fn i16_add_with_overflow(x: i16, y: i16) -> (i16, bool); #[test] fn i16_add_with_overflow_test1() { let x: i16 = 0x7f00; // 32512 let y: i16 = 0x00ff; // 255 let (result, is_overflow): (i16, bool) = unsafe { i16_add...
random_line_split
lib.rs
//! Letter count: library. //! //! Functions to count graphemes in a string and print a summary. use unicode_segmentation::UnicodeSegmentation; use std::collections::HashMap; /// Prints a summary of the contents of a grapheme counter. pub fn
<S: ::std::hash::BuildHasher>(counter: &HashMap<String, u64, S>) { for (key, val) in counter.iter() { println!("{}: {}", key, val); } } /// Counts all the graphemes in a string. pub fn count_graphemes_in_string<S: ::std::hash::BuildHasher>( to_parse: &str, counter: &mut HashMap<String, u64, S>,...
print_summary
identifier_name
lib.rs
//! Letter count: library. //! //! Functions to count graphemes in a string and print a summary. use unicode_segmentation::UnicodeSegmentation; use std::collections::HashMap;
pub fn print_summary<S: ::std::hash::BuildHasher>(counter: &HashMap<String, u64, S>) { for (key, val) in counter.iter() { println!("{}: {}", key, val); } } /// Counts all the graphemes in a string. pub fn count_graphemes_in_string<S: ::std::hash::BuildHasher>( to_parse: &str, counter: &mut Hash...
/// Prints a summary of the contents of a grapheme counter.
random_line_split
lib.rs
//! Letter count: library. //! //! Functions to count graphemes in a string and print a summary. use unicode_segmentation::UnicodeSegmentation; use std::collections::HashMap; /// Prints a summary of the contents of a grapheme counter. pub fn print_summary<S: ::std::hash::BuildHasher>(counter: &HashMap<String, u64, S>...
{ // Loop through each character in the current string... for grapheme in UnicodeSegmentation::graphemes(to_parse, true) { // If the character we are looking at already exists in the counter // hash, get its value. Otherwise, start a new counter at zero. let count = counter.entry(graphem...
identifier_body
snapshot_helpers.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! Element an snapshot common logic. use crate::gecko_bindings::bindings; use crate::gecko_bindings::structs::{...
.__bindgen_anon_1 .mValue .as_ref() .__bindgen_anon_1 .mAtomArray .as_ref(); Class::More(&***array) } #[inline(always)] unsafe fn get_id_from_attr(attr: &structs::nsAttrValue) -> &WeakAtom { debug_assert_eq!( base_type(attr), structs::nsAttrValue_ValueB...
(*container).mType, structs::nsAttrValue_ValueType_eAtomArray ); let array = (*container)
random_line_split
snapshot_helpers.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! Element an snapshot common logic. use crate::gecko_bindings::bindings; use crate::gecko_bindings::structs::{...
/// Finds the id attribute from a list of attributes. #[inline(always)] pub fn get_id(attrs: &[structs::AttrArray_InternalAttr]) -> Option<&WeakAtom> { Some(unsafe { get_id_from_attr(find_attr(attrs, &atom!("id"))?) }) } #[inline(always)] pub(super) fn exported_part( attrs: &[structs::AttrArray_InternalAttr]...
{ attrs .iter() .find(|attr| attr.mName.mBits == name.as_ptr() as usize) .map(|attr| &attr.mValue) }
identifier_body
snapshot_helpers.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! Element an snapshot common logic. use crate::gecko_bindings::bindings; use crate::gecko_bindings::structs::{...
<'a> { None, One(*const nsAtom), More(&'a [structs::RefPtr<nsAtom>]), } #[inline(always)] fn base_type(attr: &structs::nsAttrValue) -> structs::nsAttrValue_ValueBaseType { (attr.mBits & structs::NS_ATTRVALUE_BASETYPE_MASK) as structs::nsAttrValue_ValueBaseType } #[inline(always)] unsafe fn ptr<T>(attr...
Class
identifier_name
qualified_ident.rs
use nom::{ branch::alt, bytes::complete::{is_not, tag}, character::complete::{alpha1, alphanumeric1, space0}, combinator::{opt, recognize}, multi::{many0_count, separated_list0, separated_list1}, sequence::{delimited, pair, preceded, terminated}, IResult, }; use super::prelude::*; pub type...
)) ); assert_eq!( qident_segment("string < 42 >"), Ok(( "", QIdentSegment { ident: "string", parameters: vec![QIdentParam::Other("42")] } )) ); assert_eq!( qident_segment("string < 2, 3.0 >"), ...
{ assert_eq!( qident_segment("string"), Ok(( "", QIdentSegment { ident: "string", parameters: vec![], } )) ); assert_eq!( qident_segment("string<42>"), Ok(( "", QIdentSegment ...
identifier_body
qualified_ident.rs
use nom::{ branch::alt, bytes::complete::{is_not, tag}, character::complete::{alpha1, alphanumeric1, space0}, combinator::{opt, recognize}, multi::{many0_count, separated_list0, separated_list1}, sequence::{delimited, pair, preceded, terminated}, IResult, }; use super::prelude::*; pub type...
(input: Span) -> IResult<Span, QIdentParam> { match qualified_ident(input) { Ok((rest, result)) => Ok((rest, QIdentParam::QIdent(result))), Err(_) => match recognize(is_not("<,>"))(input) { Ok((rest, result)) => Ok((rest, QIdentParam::Other(result.trim()))), Err(err) => Err(e...
template_param
identifier_name
qualified_ident.rs
use nom::{ branch::alt, bytes::complete::{is_not, tag}, character::complete::{alpha1, alphanumeric1, space0}, combinator::{opt, recognize}, multi::{many0_count, separated_list0, separated_list1}, sequence::{delimited, pair, preceded, terminated}, IResult, }; use super::prelude::*; pub type...
"", QIdentSegment { ident: "string", parameters: vec![QIdentParam::Other("42")] } )) ); assert_eq!( qident_segment("string < 2, 3.0 >"), Ok(( "", QIdentSegment { ident: "string", ...
Ok((
random_line_split
util.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, _n: usize) {} } /// A reader which infinitely yields one byte. #[stable(feature = "rust1", since = "1.0.0")] pub struct Repeat { byte: u8 } /// Creates an instance of a reader that infinitely repeats one byte. /// /// All reads from this reader will succeed by filling the specified buffer with /// the giv...
consume
identifier_name
util.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 read(&mut self, _buf: &mut [u8]) -> io::Result<usize> { Ok(0) } } #[stable(feature = "rust1", since = "1.0.0")] impl BufRead for Empty { fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } fn consume(&mut self, _n: usize) {} } /// A reader which infinitely yields one byte. #[stable(feature = "rust1"...
impl Read for Empty {
random_line_split
issue-12127.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 do_it(x: &isize) { } fn main() { let x: Box<_> = box 22; let f = to_fn_once(move|| do_it(&*x)); to_fn_once(move|| { f(); f(); //~^ ERROR: use of moved value: `f` })() }
{ f }
identifier_body
issue-12127.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let x: Box<_> = box 22; let f = to_fn_once(move|| do_it(&*x)); to_fn_once(move|| { f(); f(); //~^ ERROR: use of moved value: `f` })() }
main
identifier_name
issue-12127.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
// option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(box_syntax, unboxed_closures)] fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f } fn do_it(x: &isize) { } fn main() { let x: Box<_> = box 22; let f = to_fn_once(move|| do_it(&*x)); to_fn_once(move||...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
foo.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 _main() { let _a = unsafe { _foo() }; }
#[lang="start"] fn start(_main: *const u8, _argc: int, _argv: *const *const u8) -> int { 0 } extern { fn _foo() -> [u8; 16];
random_line_split
foo.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
extern { fn _foo() -> [u8; 16]; } fn _main() { let _a = unsafe { _foo() }; }
{ 0 }
identifier_body
foo.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 ...
(_main: *const u8, _argc: int, _argv: *const *const u8) -> int { 0 } extern { fn _foo() -> [u8; 16]; } fn _main() { let _a = unsafe { _foo() }; }
start
identifier_name
mod.rs
#![allow(dead_code)] // XXX unused code belongs into translation of new extract_data_from_object fn use libc::ptrdiff_t; use md5; use sha1; use sha2::{Digest, Sha224, Sha256, Sha384, Sha512}; use std; use std::slice; use remacs_macros::lisp_fn; use remacs_sys::{make_specified_string, make_uninit_string, nsberror, Ema...
( object: LispObject, start: LispObject, end: LispObject, coding_system: LispObject, noerror: LispObject, ) -> LispObject { _secure_hash( HashAlg::MD5, object, start, end, coding_system, noerror, LispObject::constant_nil(), ) } /// Ret...
md5
identifier_name
mod.rs
#![allow(dead_code)] // XXX unused code belongs into translation of new extract_data_from_object fn use libc::ptrdiff_t; use md5; use sha1; use sha2::{Digest, Sha224, Sha256, Sha384, Sha512}; use std; use std::slice; use remacs_macros::lisp_fn; use remacs_sys::{make_specified_string, make_uninit_string, nsberror, Ema...
use lisp::{LispNumber, LispObject}; use lisp::defsubr; use multibyte::LispStringRef; use symbols::{fboundp, symbol_name}; use threads::ThreadState; #[derive(Clone, Copy)] enum HashAlg { MD5, SHA1, SHA224, SHA256, SHA384, SHA512, } static MD5_DIGEST_LEN: usize = 16; static SHA1_DIGEST_LEN: usiz...
random_line_split
mod.rs
#![allow(dead_code)] // XXX unused code belongs into translation of new extract_data_from_object fn use libc::ptrdiff_t; use md5; use sha1; use sha2::{Digest, Sha224, Sha256, Sha384, Sha512}; use std; use std::slice; use remacs_macros::lisp_fn; use remacs_sys::{make_specified_string, make_uninit_string, nsberror, Ema...
if buffer_file_name(object).is_not_nil() { /* Check file-coding-system-alist. */ let mut args = [ Qwrite_region, start.to_raw(), end.to_raw(), buffer_file_name(object).to_raw(), ]; let val = LispObject::from(unsafe { Ffind_...
{ if LispObject::from(buffer.enable_multibyte_characters).is_nil() { return LispObject::from(Qraw_text); } }
conditional_block
mod.rs
#![allow(dead_code)] // XXX unused code belongs into translation of new extract_data_from_object fn use libc::ptrdiff_t; use md5; use sha1; use sha2::{Digest, Sha224, Sha256, Sha384, Sha512}; use std; use std::slice; use remacs_macros::lisp_fn; use remacs_sys::{make_specified_string, make_uninit_string, nsberror, Ema...
/// Return a hash of the contents of BUFFER-OR-NAME. /// This hash is performed on the raw internal format of the buffer, /// disregarding any coding systems. If nil, use the current buffer. #[lisp_fn(min = "0")] pub fn buffer_hash(buffer_or_name: LispObject) -> LispObject { let buffer = if buffer_or_name.is_nil...
{ sha2_hash_buffer(Sha512::new(), buffer, dest_buf); }
identifier_body
context.rs
This is needed to test /// them. pub timer: Timer, /// Flags controlling how we traverse the tree. pub traversal_flags: TraversalFlags, /// A map with our snapshots in order to handle restyle hints. pub snapshot_map: &'a SnapshotMap, /// The animations that are currently running. #[c...
random_line_split
context.rs
(feature = "gecko")] fn get_env_bool(name: &str) -> bool { use std::env; match env::var(name) { Ok(s) =>!s.is_empty(), Err(_) => false, } } const DEFAULT_STATISTICS_THRESHOLD: usize = 50; #[cfg(feature = "gecko")] fn get_env_usize(name: &str) -> Option<usize> { use std::env; env::v...
get_sp
identifier_name
builder.rs
use ramp::{ Int, RandomInt}; use rand::{ OsRng, StdRng }; use super::{ KeyPair, PublicKey, PrivateKey }; use bigint_extensions::{ ModPow, ModInverse }; pub struct KeyPairBuilder { bits: usize, certainty: u32 } impl KeyPairBuilder { pub fn new() -> KeyPairBuilder { KeyPairBuilder { bits: 512, cer...
} return pp; } fn miller_rabin(n: &Int, k: u32) -> bool{ if n <= &Int::from(3) { return true; } let n_minus_one = n - Int::one(); let mut s = 0; let mut r = n_minus_one.clone(); let two = Int::from(2); while &r % &two == Int::zero() { s += 1; r = r / &two; ...
{ break; }
conditional_block
builder.rs
use ramp::{ Int, RandomInt}; use rand::{ OsRng, StdRng }; use super::{ KeyPair, PublicKey, PrivateKey }; use bigint_extensions::{ ModPow, ModInverse }; pub struct KeyPairBuilder { bits: usize, certainty: u32 } impl KeyPairBuilder { pub fn new() -> KeyPairBuilder { KeyPairBuilder { bits: 512, cer...
(&self) -> KeyPair { let mut sec_rng = match OsRng::new() { Ok(g) => g, Err(e) => panic!("Failed to obtain OS RNG: {}", e) }; let p = &generate_possible_prime(&mut sec_rng, self.bits, self.certainty); let q = &generate_possible_prime(&mut sec_rng, self.bits, sel...
finalize
identifier_name
builder.rs
use ramp::{ Int, RandomInt}; use rand::{ OsRng, StdRng }; use super::{ KeyPair, PublicKey, PrivateKey }; use bigint_extensions::{ ModPow, ModInverse }; pub struct KeyPairBuilder { bits: usize, certainty: u32 } impl KeyPairBuilder { pub fn new() -> KeyPairBuilder { KeyPairBuilder { bits: 512, cer...
Ok(g) => g, Err(e) => panic!("Failed to obtain OS RNG: {}", e) }; let mut a = Int::from(2); for _ in 0..k { let mut x = a.mod_pow(&r, &n); if x == Int::one() || x == n_minus_one { continue; } for _ in 1..(s - 1) { x = &x * &x % n; ...
} let mut rng = match StdRng::new() {
random_line_split
run_headless.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 compositing::*; use geom::size::Size2D; use std::unstable::intrinsics; /// Starts the compositor, which list...
Exit => break, GetSize(chan) => { chan.send(Size2D(500, 500)); } GetGraphicsMetadata(chan) => { unsafe { chan.send(intrinsics::uninit()); } } SetIds(_, response_chan, _) => { ...
/// It's intended for headless testing. pub fn run_compositor(compositor: &CompositorTask) { loop { match compositor.port.recv() {
random_line_split
run_headless.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 compositing::*; use geom::size::Size2D; use std::unstable::intrinsics; /// Starts the compositor, which list...
(compositor: &CompositorTask) { loop { match compositor.port.recv() { Exit => break, GetSize(chan) => { chan.send(Size2D(500, 500)); } GetGraphicsMetadata(chan) => { unsafe { chan.send(intrinsics::uninit())...
run_compositor
identifier_name
run_headless.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 compositing::*; use geom::size::Size2D; use std::unstable::intrinsics; /// Starts the compositor, which list...
// we'll notice and think about whether it needs a response, like // SetIds. NewLayer(*) | SetLayerPageSize(*) | SetLayerClipRect(*) | DeleteLayer(*) | Paint(*) | InvalidateRect(*) | ChangeReadyState(*) | ChangeRenderState(*) => () } } com...
{ loop { match compositor.port.recv() { Exit => break, GetSize(chan) => { chan.send(Size2D(500, 500)); } GetGraphicsMetadata(chan) => { unsafe { chan.send(intrinsics::uninit()); } ...
identifier_body
error.rs
use mysql; use std::{error, fmt, result}; #[derive(Debug)] pub enum Error { Mysql(mysql::Error), RecordNotFound(u64), ColumnNotFound, AddressChecksumToTrits, } pub type Result<T> = result::Result<T, Error>; impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self...
} impl From<mysql::Error> for Error { fn from(err: mysql::Error) -> Error { Error::Mysql(err) } }
{ match *self { Error::Mysql(ref err) => Some(err), Error::RecordNotFound(_) | Error::ColumnNotFound | Error::AddressChecksumToTrits => None, } }
identifier_body
error.rs
use mysql; use std::{error, fmt, result}; #[derive(Debug)] pub enum Error { Mysql(mysql::Error), RecordNotFound(u64), ColumnNotFound, AddressChecksumToTrits, } pub type Result<T> = result::Result<T, Error>; impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self...
write!(f, "can't convert address checksum to trits") } } } } impl error::Error for Error { fn description(&self) -> &str { match *self { Error::Mysql(ref err) => err.description(), Error::RecordNotFound(_) => "Record not found", Error::ColumnNotFound => "Column not found", ...
random_line_split
error.rs
use mysql; use std::{error, fmt, result}; #[derive(Debug)] pub enum Error { Mysql(mysql::Error), RecordNotFound(u64), ColumnNotFound, AddressChecksumToTrits, } pub type Result<T> = result::Result<T, Error>; impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self...
(&self) -> &str { match *self { Error::Mysql(ref err) => err.description(), Error::RecordNotFound(_) => "Record not found", Error::ColumnNotFound => "Column not found", Error::AddressChecksumToTrits => "Can't convert to trits", } } fn cause(&self) -> Option<&error::Error> { matc...
description
identifier_name
TestTan.rs
/* * Copyright (C) 2014 The Android Open Source Project *
* * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the Licen...
* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0
random_line_split
profile.rs
use std::cell::RefCell; use std::env; use std::fmt; use std::io::{stdout, StdoutLock, Write}; use std::iter::repeat; use std::mem; use std::time; thread_local!(static PROFILE_STACK: RefCell<Vec<time::Instant>> = RefCell::new(Vec::new())); thread_local!(static MESSAGES: RefCell<Vec<Message>> = RefCell::new(Vec::new()))...
msg ) .expect("printing profiling info to stdout"); print(lvl + 1, &msgs[last..i], enabled, stdout); last = i; } } let stdout = stdout(); MESSAGES.with(|msgs| { ...
random_line_split
profile.rs
use std::cell::RefCell; use std::env; use std::fmt; use std::io::{stdout, StdoutLock, Write}; use std::iter::repeat; use std::mem; use std::time; thread_local!(static PROFILE_STACK: RefCell<Vec<time::Instant>> = RefCell::new(Vec::new())); thread_local!(static MESSAGES: RefCell<Vec<Message>> = RefCell::new(Vec::new()))...
(&mut self) { let enabled = match enabled_level() { Some(i) => i, None => return, }; let (start, stack_len) = PROFILE_STACK.with(|stack| { let mut stack = stack.borrow_mut(); let start = stack.pop().unwrap(); (start, stack.len()) ...
drop
identifier_name
profile.rs
use std::cell::RefCell; use std::env; use std::fmt; use std::io::{stdout, StdoutLock, Write}; use std::iter::repeat; use std::mem; use std::time; thread_local!(static PROFILE_STACK: RefCell<Vec<time::Instant>> = RefCell::new(Vec::new())); thread_local!(static MESSAGES: RefCell<Vec<Message>> = RefCell::new(Vec::new()))...
impl Drop for Profiler { fn drop(&mut self) { let enabled = match enabled_level() { Some(i) => i, None => return, }; let (start, stack_len) = PROFILE_STACK.with(|stack| { let mut stack = stack.borrow_mut(); let start = stack.pop().unwrap(); ...
{ if enabled_level().is_none() { return Profiler { desc: String::new(), }; } PROFILE_STACK.with(|stack| stack.borrow_mut().push(time::Instant::now())); Profiler { desc: desc.to_string(), } }
identifier_body
profile.rs
use std::cell::RefCell; use std::env; use std::fmt; use std::io::{stdout, StdoutLock, Write}; use std::iter::repeat; use std::mem; use std::time; thread_local!(static PROFILE_STACK: RefCell<Vec<time::Instant>> = RefCell::new(Vec::new())); thread_local!(static MESSAGES: RefCell<Vec<Message>> = RefCell::new(Vec::new()))...
PROFILE_STACK.with(|stack| stack.borrow_mut().push(time::Instant::now())); Profiler { desc: desc.to_string(), } } impl Drop for Profiler { fn drop(&mut self) { let enabled = match enabled_level() { Some(i) => i, None => return, }; let (start, ...
{ return Profiler { desc: String::new(), }; }
conditional_block
line_path.rs
use crate::LinePathCommand; use geometry::{Point, Transform, Transformation}; use internal_iter::{ ExtendFromInternalIterator, FromInternalIterator, InternalIterator, IntoInternalIterator, }; use std::iter::Cloned; use std::slice::Iter; /// A sequence of commands that defines a set of contours, each of which consi...
} /// An iterator over the commands that make up a line path. #[derive(Clone, Debug)] pub struct Commands<'a> { verbs: Cloned<Iter<'a, Verb>>, points: Cloned<Iter<'a, Point>>, } impl<'a> Iterator for Commands<'a> { type Item = LinePathCommand; fn next(&mut self) -> Option<LinePathCommand> { s...
{ for point in self.points_mut() { point.transform_mut(t); } }
random_line_split
line_path.rs
use crate::LinePathCommand; use geometry::{Point, Transform, Transformation}; use internal_iter::{ ExtendFromInternalIterator, FromInternalIterator, InternalIterator, IntoInternalIterator, }; use std::iter::Cloned; use std::slice::Iter; /// A sequence of commands that defines a set of contours, each of which consi...
} impl Transform for LinePath { fn transform<T>(mut self, t: &T) -> LinePath where T: Transformation, { self.transform_mut(t); self } fn transform_mut<T>(&mut self, t: &T) where T: Transformation, { for point in self.points_mut() { point...
{ let mut path = LinePath::new(); path.extend_from_internal_iter(internal_iter); path }
identifier_body
line_path.rs
use crate::LinePathCommand; use geometry::{Point, Transform, Transformation}; use internal_iter::{ ExtendFromInternalIterator, FromInternalIterator, InternalIterator, IntoInternalIterator, }; use std::iter::Cloned; use std::slice::Iter; /// A sequence of commands that defines a set of contours, each of which consi...
(&mut self) -> &mut [Point] { &mut self.points } /// Adds a new contour, starting at the given point. pub fn move_to(&mut self, p: Point) { self.verbs.push(Verb::MoveTo); self.points.push(p); } /// Adds a line segment to the current contour, starting at the current point. ...
points_mut
identifier_name
raw.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
//! iOS-specific raw type definitions use os::raw::c_long; use os::unix::raw::{uid_t, gid_t}; pub type blkcnt_t = i64; pub type blksize_t = i32; pub type dev_t = i32; pub type ino_t = u64; pub type mode_t = u16; pub type nlink_t = u16; pub type off_t = i64; pub type time_t = c_long; #[repr(C)] pub struct stat { ...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
raw.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ pub st_dev: dev_t, pub st_mode: mode_t, pub st_nlink: nlink_t, pub st_ino: ino_t, pub st_uid: uid_t, pub st_gid: gid_t, pub st_rdev: dev_t, pub st_atime: time_t, pub st_atime_nsec: c_long, pub st_mtime: time_t, pub st_mtime_nsec: c_long, pub st_ctime: time_t, pub s...
stat
identifier_name
animation.rs
use std::collections::HashMap; use ggez::Context; use serde_derive::{Deserialize, Serialize}; use warmy; use loadable_macro_derive::{LoadableRon, LoadableYaml}; #[derive(Default, Debug, Clone, Serialize, Deserialize)] pub struct SpriteData { pub sprites: HashMap<String, Sprite>, } #[derive(Debug, Clone, Eq, Par...
} #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct Frame { pub images: Vec<Image>, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Animation { pub frames: Vec<Frame>, #[serde(default)] pub order: Option<Vec<i32>>, } #[derive(Debug, Clone, Serialize, Deserialize, Loadab...
}
random_line_split
animation.rs
use std::collections::HashMap; use ggez::Context; use serde_derive::{Deserialize, Serialize}; use warmy; use loadable_macro_derive::{LoadableRon, LoadableYaml}; #[derive(Default, Debug, Clone, Serialize, Deserialize)] pub struct SpriteData { pub sprites: HashMap<String, Sprite>, } #[derive(Debug, Clone, Eq, Par...
{ NonSolid, Collidee, Collider, Blood, BloodStain, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Image { pub sheet: String, pub image: usize, pub x: i32, pub y: i32, pub image_type: ImageType, } impl Image { pub fn is_collidee(&self) -> bool { self.i...
ImageType
identifier_name
main-config.rs
extern crate cargo_update; extern crate tabwriter; use std::io::{Write, stdout}; use tabwriter::TabWriter; use std::process::exit; use std::mem; fn
() { let result = actual_main().err().unwrap_or(0); exit(result); } fn actual_main() -> Result<(), i32> { let mut opts = cargo_update::ConfigOptions::parse(); let config_file = cargo_update::ops::resolve_crates_file(mem::replace(&mut opts.crates_file.1, Default::default())).with_file_name(".install_con...
main
identifier_name
main-config.rs
extern crate cargo_update; extern crate tabwriter; use std::io::{Write, stdout}; use tabwriter::TabWriter; use std::process::exit; use std::mem; fn main() { let result = actual_main().err().unwrap_or(0); exit(result); } fn actual_main() -> Result<(), i32> { let mut opts = cargo_update::ConfigOptions::pa...
if let Some(rb) = cfg.respect_binaries { writeln!(out, "Respect binaries\t{}", rb).unwrap(); } if let Some(ref tv) = cfg.target_version { writeln!(out, "Target version\t{}", tv).unwrap(); } writeln!(out, "Default features\t{}", cfg.default_features).unwra...
{ writeln!(out, "Enforce lock\t{}", el).unwrap(); }
conditional_block
main-config.rs
extern crate cargo_update; extern crate tabwriter; use std::io::{Write, stdout}; use tabwriter::TabWriter; use std::process::exit; use std::mem; fn main()
fn actual_main() -> Result<(), i32> { let mut opts = cargo_update::ConfigOptions::parse(); let config_file = cargo_update::ops::resolve_crates_file(mem::replace(&mut opts.crates_file.1, Default::default())).with_file_name(".install_config.toml"); let mut configuration = cargo_update::ops::PackageConfig::...
{ let result = actual_main().err().unwrap_or(0); exit(result); }
identifier_body
main-config.rs
extern crate cargo_update; extern crate tabwriter; use std::io::{Write, stdout}; use tabwriter::TabWriter; use std::process::exit; use std::mem; fn main() { let result = actual_main().err().unwrap_or(0); exit(result); } fn actual_main() -> Result<(), i32> { let mut opts = cargo_update::ConfigOptions::pa...
writeln!(out, "Toolchain\t{}", t).unwrap(); } if let Some(d) = cfg.debug { writeln!(out, "Debug mode\t{}", d).unwrap(); } if let Some(ip) = cfg.install_prereleases { writeln!(out, "Install prereleases\t{}", ip).unwrap(); } if let Some(e...
let mut out = TabWriter::new(stdout()); if let Some(ref t) = cfg.toolchain {
random_line_split
factory.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
{ /// factory for evm. pub vm: EvmFactory, /// factory for tries. pub trie: TrieFactory, /// factory for account databases. pub accountdb: AccountFactory, }
Factories
identifier_name
factory.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
pub struct Factories { /// factory for evm. pub vm: EvmFactory, /// factory for tries. pub trie: TrieFactory, /// factory for account databases. pub accountdb: AccountFactory, }
use evm::Factory as EvmFactory; use account_db::Factory as AccountFactory; /// Collection of factories. #[derive(Default, Clone)]
random_line_split
windows_base.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// On more recent versions of gcc on mingw, apparently the section name // is *not* truncated, but rather stored elsewhere in a separate lookup // table. On older versions of gcc, they apparently always truncated th // section names (at least in some cases). Truncating th...
// but COFF (at least according to LLVM). COFF doesn't officially allow // for section names over 8 characters, apparently. Our metadata // section, ".note.rustc", you'll note is over 8 characters. //
random_line_split
windows_base.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() -> TargetOptions { TargetOptions { // FIXME(#13846) this should be enabled for windows function_sections: false, linker: "gcc".to_string(), dynamic_linking: true, executables: true, dll_prefix: "".to_string(), dll_suffix: ".dll".to_string(), exe_suf...
opts
identifier_name
windows_base.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// for section names over 8 characters, apparently. Our metadata // section, ".note.rustc", you'll note is over 8 characters. // // On more recent versions of gcc on mingw, apparently the section name // is *not* truncated, but rather stored elsewhere in a sep...
{ TargetOptions { // FIXME(#13846) this should be enabled for windows function_sections: false, linker: "gcc".to_string(), dynamic_linking: true, executables: true, dll_prefix: "".to_string(), dll_suffix: ".dll".to_string(), exe_suffix: ".exe".to_strin...
identifier_body