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
input_process.rs
extern crate glutin; extern crate state; use state::{GraphicsState, CoreState}; use glutin::Event::{Closed, KeyboardInput}; use glutin::ElementState::{Pressed}; use glutin::VirtualKeyCode as VK; pub fn
(graphics_state: &mut GraphicsState, core_state: &mut CoreState) -> () { for event in graphics_state.display.poll_events() { match event { Closed => { core_state.quit = true } KeyboardInput(Pressed, _, Some(VK::Escape)) => { core_state.quit...
execute
identifier_name
input_process.rs
extern crate glutin; extern crate state; use state::{GraphicsState, CoreState}; use glutin::Event::{Closed, KeyboardInput}; use glutin::ElementState::{Pressed}; use glutin::VirtualKeyCode as VK; pub fn execute(graphics_state: &mut GraphicsState, core_state: &mut CoreState) -> ()
} }
{ for event in graphics_state.display.poll_events() { match event { Closed => { core_state.quit = true } KeyboardInput(Pressed, _, Some(VK::Escape)) => { core_state.quit = true } KeyboardInput(Pressed, _, Some(VK::F3...
identifier_body
input_process.rs
extern crate glutin; extern crate state; use state::{GraphicsState, CoreState}; use glutin::Event::{Closed, KeyboardInput}; use glutin::ElementState::{Pressed}; use glutin::VirtualKeyCode as VK; pub fn execute(graphics_state: &mut GraphicsState, core_state: &mut CoreState) -> () { for event in graphics_state.displ...
_ => () } } }
{ core_state.reset = true }
conditional_block
version.rs
/*! Querying SDL Version */ use std::ffi::CStr; use std::fmt; use sys::version as ll; /// A structure that contains information about the version of SDL in use. #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct
{ /// major version pub major: u8, /// minor version pub minor: u8, /// update version (patchlevel) pub patch: u8, } impl Version { /// Convert a raw *SDL_version to Version. pub fn from_ll(v: ll::SDL_version) -> Version { Version { major: v.major, minor: v.minor, patch: v.patc...
Version
identifier_name
version.rs
/*! Querying SDL Version */ use std::ffi::CStr; use std::fmt; use sys::version as ll; /// A structure that contains information about the version of SDL in use. #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct Version { /// major version pub major: u8, /// minor version pub minor: u8, ...
pub fn version() -> Version { unsafe { let mut cver = ll::SDL_version { major: 0, minor: 0, patch: 0}; ll::SDL_GetVersion(&mut cver); Version::from_ll(cver) } } /// Get the code revision of SDL that is linked against your program. pub fn revision() -> String { unsafe { let r...
} /// Get the version of SDL that is linked against your program.
random_line_split
version.rs
/*! Querying SDL Version */ use std::ffi::CStr; use std::fmt; use sys::version as ll; /// A structure that contains information about the version of SDL in use. #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct Version { /// major version pub major: u8, /// minor version pub minor: u8, ...
} /// Get the version of SDL that is linked against your program. pub fn version() -> Version { unsafe { let mut cver = ll::SDL_version { major: 0, minor: 0, patch: 0}; ll::SDL_GetVersion(&mut cver); Version::from_ll(cver) } } /// Get the code revision of SDL that is linked against yo...
{ write!(f, "{}.{}.{}", self.major, self.minor, self.patch) }
identifier_body
mod.rs
mod block_on_serial_directory_create; pub use block_on_serial_directory_create::block_on_serial_directory_create; mod watch_device_directory; pub use watch_device_directory::watch_device_directory; use xactor::Actor; use eyre::{ // eyre, Result, // Context as _, }; #[xactor::message(result = "()")] struc...
} #[async_trait::async_trait] impl xactor::Handler<WatchDevices> for DevSerialWatcher { #[instrument(skip(self, ctx, _msg))] async fn handle(&mut self, ctx: &mut xactor::Context<Self>, _msg: WatchDevices) -> () { let result = self.watch_dev_serial().await; if let Err(err) = result { ...
{ ctx.address().send(WatchDevices)?; Ok(()) }
identifier_body
mod.rs
mod block_on_serial_directory_create; pub use block_on_serial_directory_create::block_on_serial_directory_create; mod watch_device_directory; pub use watch_device_directory::watch_device_directory; use xactor::Actor; use eyre::{ // eyre, Result, // Context as _, }; #[xactor::message(result = "()")] struc...
} } pub struct KlipperWatcher { pub device_manager: crate::DeviceManagerAddr, } #[async_trait::async_trait] impl Actor for KlipperWatcher { #[instrument(skip(self, ctx))] async fn started(&mut self, ctx: &mut xactor::Context<Self>) -> Result<()> { ctx.address().send(WatchDevices)?; Ok(...
warn!("Error watching /dev/serial/by-id/ device files: {:?}", err); ctx.stop(Some(err)); };
random_line_split
mod.rs
mod block_on_serial_directory_create; pub use block_on_serial_directory_create::block_on_serial_directory_create; mod watch_device_directory; pub use watch_device_directory::watch_device_directory; use xactor::Actor; use eyre::{ // eyre, Result, // Context as _, }; #[xactor::message(result = "()")] struc...
; } } pub struct KlipperWatcher { pub device_manager: crate::DeviceManagerAddr, } #[async_trait::async_trait] impl Actor for KlipperWatcher { #[instrument(skip(self, ctx))] async fn started(&mut self, ctx: &mut xactor::Context<Self>) -> Result<()> { ctx.address().send(WatchDevices)?; O...
{ warn!("Error watching /dev/serial/by-id/ device files: {:?}", err); ctx.stop(Some(err)); }
conditional_block
mod.rs
mod block_on_serial_directory_create; pub use block_on_serial_directory_create::block_on_serial_directory_create; mod watch_device_directory; pub use watch_device_directory::watch_device_directory; use xactor::Actor; use eyre::{ // eyre, Result, // Context as _, }; #[xactor::message(result = "()")] struc...
(&self) -> Result<()> { // Normally serial ports are created at /dev/serial/by-id/ loop { // /dev/serial is only created when a serial port is connected to the computer block_on_serial_directory_create().await?; // Once /dev/serial exists watch for new device files in...
watch_dev_serial
identifier_name
re_set.rs
// Copyright 2014-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-MI...
define_set! { bytes, |exprs| ExecBuilder::new_many(exprs).only_utf8(false).build(), &[u8], as_bytes_bytes }
}
random_line_split
indexed_vec.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self) -> bool { self.raw.is_empty() } #[inline] pub fn into_iter(self) -> vec::IntoIter<T> { self.raw.into_iter() } #[inline] pub fn iter(&self) -> slice::Iter<T> { self.raw.iter() } #[inline] pub fn iter_mut(&mut self) -> slice::IterMut<T> { self...
is_empty
identifier_name
indexed_vec.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
&self.raw[index.index()] } } impl<I: Idx, T> IndexMut<I> for IndexVec<I, T> { #[inline] fn index_mut(&mut self, index: I) -> &mut T { &mut self.raw[index.index()] } } impl<I: Idx, T> Default for IndexVec<I, T> { #[inline] fn default() -> Self { Self::new() } } impl...
type Output = T; #[inline] fn index(&self, index: I) -> &T {
random_line_split
indexed_vec.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} impl<'a, I: Idx, T> IntoIterator for &'a mut IndexVec<I, T> { type Item = &'a mut T; type IntoIter = slice::IterMut<'a, T>; #[inline] fn into_iter(mut self) -> slice::IterMut<'a, T> { self.raw.iter_mut() } }
{ self.raw.iter() }
identifier_body
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! This module contains shared types and messages for use by devtools/script. //! The traits are here instead of ...
pub mod cursor; #[macro_use] pub mod values; pub mod viewport; pub use values::ToCss;
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! This module contains shared types and messages for use by devtools/script. //! The traits are here instead of ...
{} // In summary, the hierarchy of pixel units and the factors to convert from one to the next: // // DevicePixel // / hidpi_ratio => ScreenPx // / desktop_zoom => ViewportPx // / pinch_zoom => PagePx pub mod cursor; #[macro_use] pub mod values; pub mod viewport; pub use values::ToCss;
PagePx
identifier_name
color.rs
use crate::{ DocumentSelector, DynamicRegistrationClientCapabilities, PartialResultParams, Range, TextDocumentIdentifier, TextEdit, WorkDoneProgressParams, }; use serde::{Deserialize, Serialize}; pub type DocumentColorClientCapabilities = DynamicRegistrationClientCapabilities; #[derive(Debug, Eq, PartialEq, C...
{ /// The text document pub text_document: TextDocumentIdentifier, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "cam...
DocumentColorParams
identifier_name
color.rs
use crate::{ DocumentSelector, DynamicRegistrationClientCapabilities, PartialResultParams, Range, TextDocumentIdentifier, TextEdit, WorkDoneProgressParams, }; use serde::{Deserialize, Serialize}; pub type DocumentColorClientCapabilities = DynamicRegistrationClientCapabilities; #[derive(Debug, Eq, PartialEq, C...
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct StaticTextDocumentColorProviderOptions { /// A document selector to identify the scope of the registration. If set to null /// the document selector provided on the client side will be used. pub doc...
random_line_split
x86.rs
// Copyright 2012-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-MI...
}, target_triple: target_triple, cc_args: vec!("-m32".to_string()), }; }
{ "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string() }
conditional_block
x86.rs
// Copyright 2012-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-MI...
(target_triple: String, target_os: abi::Os) -> target_strs::t { return target_strs::t { module_asm: "".to_string(), data_layout: match target_os { abi::OsMacos => { "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\ -i32:32:32-i64:32:64\ ...
get_target_strs
identifier_name
x86.rs
// Copyright 2012-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-MI...
target_triple: target_triple, cc_args: vec!("-m32".to_string()), }; }
random_line_split
x86.rs
// Copyright 2012-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-MI...
abi::OsWindows => { "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32".to_string() } abi::OsLinux => { "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string() } abi::OsAndroid => { "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:...
{ return target_strs::t { module_asm: "".to_string(), data_layout: match target_os { abi::OsMacos => { "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\ -i32:32:32-i64:32:64\ -f32:32:32-f64:32:64-v64:64:64\ -v128:128:128-a:0:64-f80:128:128\...
identifier_body
http2.rs
extern crate hyper; extern crate futures; extern crate tokio_tls; extern crate native_tls; extern crate tokio_core; extern crate httpbis; extern crate tls_api_openssl; use std::thread; use std::str::FromStr; use std::net::SocketAddr; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use tokio_core::r...
} impl httpbis::Service for Proxy4Http2 { fn start_request(&self, headers: httpbis::Headers, _req: httpbis::HttpPartStream) -> httpbis::Response { let mut core = Core::new().expect("http2 backend client core error"); let handle = core.handle(); let backend_client = hyper::Clien...
{ Self { routes: Arc::new(routes), roundrobin_counter: Arc::new(AtomicUsize::new(0)), } }
identifier_body
http2.rs
extern crate hyper; extern crate futures; extern crate tokio_tls; extern crate native_tls; extern crate tokio_core; extern crate httpbis; extern crate tls_api_openssl; use std::thread; use std::str::FromStr; use std::net::SocketAddr; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use tokio_core::r...
let url = url_str.parse::<hyper::Uri>().expect("uri error"); let proxied_req = hyper::client::Request::new( hyper::Method::from_str(headers.method()).expect("invalid method"), url); let mut backend_req_headers = hyper::header::Headers::new(); for req_header in headers.0 { ...
// FIXME: only use index 0 let backend_index = self.roundrobin_counter.fetch_add(1, Ordering::Relaxed); let backend_addr = self.routes[backend_index % self.routes.len()].clone(); let url_str = format!("http://{}{}", backend_addr, headers.path());
random_line_split
http2.rs
extern crate hyper; extern crate futures; extern crate tokio_tls; extern crate native_tls; extern crate tokio_core; extern crate httpbis; extern crate tls_api_openssl; use std::thread; use std::str::FromStr; use std::net::SocketAddr; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use tokio_core::r...
(&self, headers: httpbis::Headers, _req: httpbis::HttpPartStream) -> httpbis::Response { let mut core = Core::new().expect("http2 backend client core error"); let handle = core.handle(); let backend_client = hyper::Client::new(&handle); // FIXME: only use index 0 let...
start_request
identifier_name
io.rs
use std::os::raw::{c_char, c_void}; use std::mem::transmute; use super::CFixedString; #[repr(C)] pub enum
{ Ok, Fail, Converted, Truncated, OutOfData, } #[repr(C)] pub struct CPDSaveState { pub priv_data: *mut c_void, pub write_int: fn(priv_data: *mut c_void, data: i64), pub write_double: fn(priv_data: *mut c_void, data: f64), pub write_string: fn(priv_data: *mut c_void, data: *const c...
LoadState
identifier_name
io.rs
use std::os::raw::{c_char, c_void}; use std::mem::transmute; use super::CFixedString; #[repr(C)] pub enum LoadState { Ok, Fail, Converted, Truncated, OutOfData, } #[repr(C)] pub struct CPDSaveState { pub priv_data: *mut c_void, pub write_int: fn(priv_data: *mut c_void, data: i64), pub ...
}
{ let mut len: i32 = 0; let len_state = ((*self.0).read_string_len)((*self.0).priv_data, &mut len); match len_state { LoadState::Fail => return LoadResult::Fail, LoadState::OutOfData => return LoadResult::OutOfData, _ => {} } let mut buf = vec!...
identifier_body
io.rs
use std::os::raw::{c_char, c_void}; use std::mem::transmute; use super::CFixedString; #[repr(C)] pub enum LoadState { Ok, Fail, Converted, Truncated, OutOfData, } #[repr(C)] pub struct CPDSaveState { pub priv_data: *mut c_void, pub write_int: fn(priv_data: *mut c_void, data: i64), pub ...
pub fn new(api: *mut CPDLoadState) -> StateLoader<'a> { unsafe { StateLoader(&mut *api) } } pub fn read_int(&mut self) -> LoadResult<i64> { let mut res: i64 = 0; let state = ((*self.0).read_int)((*self.0).priv_data, &mut res); LoadResult::from_state(state, res) } pu...
pub struct StateLoader<'a>(&'a mut CPDLoadState); impl<'a> StateLoader<'a> {
random_line_split
instr_kxnorb.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn kxnorb_1() { run_test(&Instruction { mnemonic: Mnemonic::KXNORB, operand1: Some(Direct(K1...
{ run_test(&Instruction { mnemonic: Mnemonic::KXNORB, operand1: Some(Direct(K1)), operand2: Some(Direct(K2)), operand3: Some(Direct(K5)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[197, 237, 70, 205], OperandSize::Qword) }
identifier_body
instr_kxnorb.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn
() { run_test(&Instruction { mnemonic: Mnemonic::KXNORB, operand1: Some(Direct(K1)), operand2: Some(Direct(K4)), operand3: Some(Direct(K4)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[197, 221, 70, 204], OperandSize::Dword) } #[test] fn kxnorb_2...
kxnorb_1
identifier_name
instr_kxnorb.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*;
#[test] fn kxnorb_1() { run_test(&Instruction { mnemonic: Mnemonic::KXNORB, operand1: Some(Direct(K1)), operand2: Some(Direct(K4)), operand3: Some(Direct(K4)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[197, 221, 70, 204], OperandSize::Dword) } ...
use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test;
random_line_split
cluster.rs
//! This modules contains an implementation of [r2d2](https://github.com/sfackler/r2d2) //! functionality of connection pools. To get more details about creating r2d2 pools //! please refer to original documentation. use std::iter::Iterator; use query::QueryBuilder; use client::{CDRS, Session}; use error::{Error as CEr...
use rand; use std::sync::atomic::{AtomicIsize, Ordering}; /// Load balancing strategy #[derive(PartialEq)] pub enum LoadBalancingStrategy { /// Round Robin balancing strategy RoundRobin, /// Random balancing strategy Random, } impl LoadBalancingStrategy { /// Returns next value for selected load b...
use authenticators::Authenticator; use compression::Compression; use r2d2; use transport::CDRSTransport;
random_line_split
cluster.rs
//! This modules contains an implementation of [r2d2](https://github.com/sfackler/r2d2) //! functionality of connection pools. To get more details about creating r2d2 pools //! please refer to original documentation. use std::iter::Iterator; use query::QueryBuilder; use client::{CDRS, Session}; use error::{Error as CEr...
<T> { strategy: LoadBalancingStrategy, nodes: Vec<T>, i: AtomicIsize, } impl<T> LoadBalancer<T> { /// Factory function which creates new `LoadBalancer` with provided strategy. pub fn new(nodes: Vec<T>, strategy: LoadBalancingStrategy) -> LoadBalancer<T> { LoadBalancer { nodes: n...
LoadBalancer
identifier_name
cluster.rs
//! This modules contains an implementation of [r2d2](https://github.com/sfackler/r2d2) //! functionality of connection pools. To get more details about creating r2d2 pools //! please refer to original documentation. use std::iter::Iterator; use query::QueryBuilder; use client::{CDRS, Session}; use error::{Error as CEr...
/// Returns next node basing on provided strategy. pub fn next(&self) -> Option<&T> { let next = self.strategy .next(&self.nodes, self.i.load(Ordering::Relaxed) as usize); if self.strategy == LoadBalancingStrategy::RoundRobin { self.i.fetch_add(1, Ordering::Relaxed); ...
{ LoadBalancer { nodes: nodes, strategy: strategy, i: AtomicIsize::new(0), } }
identifier_body
custom_properties.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 cssparser::{Parser, ParserInput}; use servo_arc::Arc; use style::custom_properties::{ CssEnvironment, Cus...
} #[bench] fn cascade_custom_simple(b: &mut Bencher) { b.iter(|| { let parent = cascade(&[("foo", "10px"), ("bar", "100px")], None); test::black_box(cascade( &[("baz", "calc(40em + 4px)"), ("bazz", "calc(30em + 4px)")], parent.as_ref(), )) }) }
{ let declarations = name_and_value .iter() .map(|&(name, value)| { let mut input = ParserInput::new(value); let mut parser = Parser::new(&mut input); let name = Name::from(name); let value = CustomDeclarationValue::Value(SpecifiedValue::parse(&mut par...
identifier_body
custom_properties.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 cssparser::{Parser, ParserInput}; use servo_arc::Arc; use style::custom_properties::{ CssEnvironment, CustomPropertiesBuilder, CustomPropertiesMap, Name, SpecifiedValue, }; use...
random_line_split
custom_properties.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 cssparser::{Parser, ParserInput}; use servo_arc::Arc; use style::custom_properties::{ CssEnvironment, Cus...
(b: &mut Bencher) { b.iter(|| { let parent = cascade(&[("foo", "10px"), ("bar", "100px")], None); test::black_box(cascade( &[("baz", "calc(40em + 4px)"), ("bazz", "calc(30em + 4px)")], parent.as_ref(), )) }) }
cascade_custom_simple
identifier_name
symbol.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
impl<'de> Deserialize<'de> for Symbol { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de> { String::deserialize(deserializer).map(|s| Symbol::intern(&s)) } } impl<T: ::std::ops::Deref<Target=str>> PartialEq<T> for Symbol { fn eq(&self, other: &T) -...
}
random_line_split
symbol.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T { thread_local!(static INTERNER: RefCell<Interner> = { RefCell::new(Interner::fresh()) }); INTERNER.with(|interner| f(&mut *interner.borrow_mut())) } /// Represents a string stored in the thread-local interner. Because the /// interner lives for the lif...
with_interner
identifier_name
symbol.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn prefill(init: &[&str]) -> Self { let mut this = Interner::new(); for &string in init { this.intern(string); } this } pub fn intern(&mut self, string: &str) -> Symbol { if let Some(&name) = self.names.get(string) { return name; } ...
{ Interner::default() }
identifier_body
symbol.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
) } } /// A symbol is an interned or gensymed string. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Symbol(u32); // FIXME syntex // The interner in thread-local, so `Symbol` shouldn't move between threads. // impl!Send for Symbol { } impl Symbol { /// Maps a string to its interned r...
{ // FIXME(jseyfried) intercrate hygiene Ident::with_empty_ctxt(Symbol::gensym(&string[1..])) }
conditional_block
knight_tour.rs
extern crate nalgebra as na; extern crate num; use na::DMatrix; use na::Scalar; use na::dimension::Dynamic; use std::fmt::Display; use num::FromPrimitive; const N: usize = 5; //map size N x N trait ChessFunc { fn isSafe(&self, x: isize, y: isize) -> bool; fn solveKTUtil( &mut self, x: isize, ...
fn isSafe(&self, x: isize, y: isize) -> bool { let mut result = false; //println!("({},{})", x, y); match ((x + 1) as usize, (y + 1) as usize) { (1...N, 1...N) => { match self.iter().nth((y * N as isize + x) as usize) { Some(sc) => { ...
{ for (idx, item) in self.iter().enumerate() { print!("{position:>3}", position = item); if idx % N == (N - 1) { println!(); } } }
identifier_body
knight_tour.rs
extern crate nalgebra as na; extern crate num; use na::DMatrix; use na::Scalar; use na::dimension::Dynamic; use std::fmt::Display; use num::FromPrimitive; const N: usize = 5; //map size N x N trait ChessFunc { fn isSafe(&self, x: isize, y: isize) -> bool; fn solveKTUtil( &mut self, x: isize, ...
} if self.solveKTUtil(next_x, next_y, movei + 1, moves) { result = true; break; } else { unsafe { *self.get_unchecked_mut(next_x as usize, next_y as usize) = ...
if self.isSafe(next_x, next_y) { unsafe { *self.get_unchecked_mut(next_x as usize, next_y as usize) = FromPrimitive::from_usize(movei).unwrap();
random_line_split
knight_tour.rs
extern crate nalgebra as na; extern crate num; use na::DMatrix; use na::Scalar; use na::dimension::Dynamic; use std::fmt::Display; use num::FromPrimitive; const N: usize = 5; //map size N x N trait ChessFunc { fn isSafe(&self, x: isize, y: isize) -> bool; fn solveKTUtil( &mut self, x: isize, ...
} None => {} }; } _ => {} } //println!("({})", result); result } } fn main() { let DimN = Dynamic::new(N); //from nalgebra make dynamic dimension in here make N dimension let mut chessmap = DMatrix::fro...
{ result = true; }
conditional_block
knight_tour.rs
extern crate nalgebra as na; extern crate num; use na::DMatrix; use na::Scalar; use na::dimension::Dynamic; use std::fmt::Display; use num::FromPrimitive; const N: usize = 5; //map size N x N trait ChessFunc { fn isSafe(&self, x: isize, y: isize) -> bool; fn solveKTUtil( &mut self, x: isize, ...
() { let DimN = Dynamic::new(N); //from nalgebra make dynamic dimension in here make N dimension let mut chessmap = DMatrix::from_fn_generic(DimN, DimN, |r, c| match (r, c) { (0, 0) => 0, _ => -1, }); //initialize matrix (0,0) set 0 and the others set -1 //chessmap.printSolution(); c...
main
identifier_name
apr.rs
#![allow(non_camel_case_types)] use std::ffi::CString; use std::marker::PhantomData; use ffi; use wrapper::{Wrapper, from_char_ptr, WrappedType, FromRaw}; pub enum HookOrder { REALLY_FIRST, // run this hook first, before ANYTHING FIRST, // run this hook first MIDDLE, // run this hook somew...
{ unsafe { ffi::apr_time_now() } }
identifier_body
apr.rs
#![allow(non_camel_case_types)] use std::ffi::CString; use std::marker::PhantomData; use ffi; use wrapper::{Wrapper, from_char_ptr, WrappedType, FromRaw}; pub enum HookOrder { REALLY_FIRST, // run this hook first, before ANYTHING FIRST, // run this hook first MIDDLE, // run this hook somew...
<T: Into<Vec<u8>>, U: Into<Vec<u8>>>(&mut self, key: T, val: U) -> Result<(), ()> { let key = match CString::new(key) { Ok(s) => s, Err(_) => return Err(()) }; let val = match CString::new(val) { Ok(s) => s, Err(_) => return Err(()) }; unsafe { ...
set
identifier_name
apr.rs
#![allow(non_camel_case_types)] use std::ffi::CString; use std::marker::PhantomData; use ffi; use wrapper::{Wrapper, from_char_ptr, WrappedType, FromRaw}; pub enum HookOrder { REALLY_FIRST, // run this hook first, before ANYTHING FIRST, // run this hook first MIDDLE, // run this hook somew...
} else { None } } fn size_hint(&self) -> (usize, Option<usize>) { if self.array_header.is_null() { return (0, None); } let array_header: &ffi::apr_array_header_t = unsafe { &*self.array_header }; let rem = array_header.nelts as usize - self.next_idx; (r...
T::from_raw(elt as *mut <T as WrappedType>::wrapped_type)
random_line_split
16835_H2.rs
Per(s)PSA @ damp 02% PSA @ damp 05% PSA @ damp 07% PSA @ damp 10% PSA @ damp 20% PSA @ damp 30% (m/s/s) 0.000 1.4743128E+000 1.4743128E+000 1.4743128E+000 1.4743128E+000 1.4743128E+000 1.4743128E+000 0.010 1.4791120E+000 1.4787466E+000 1.4785237E+000 1.4781326E+000 1.4764196E+000 1.4751683E+000 0.020 1.5104053E+000 ...
0.280 4.0103836E+000 2.8828108E+000 2.3853471E+000 1.8648334E+000 1.2753470E+000 1.0055252E+000 0.300 2.8487566E+000 2.2245429E+000 1.9282485E+000 1.5859742E+000 1.0897597E+000 8.9366448E-001 0.320 2.0230498E+000 1.5607424E+000 1.4466788E+000 1.2987298E+000 9.3179417E-001 8.1396568E-001 0.340 1.5434318E+000 1.351621...
0.200 4.6951294E+000 3.5387561E+000 2.9914527E+000 2.4170172E+000 1.9933550E+000 1.6257334E+000 0.220 5.5433970E+000 3.4664059E+000 2.8443663E+000 2.3755868E+000 1.8310739E+000 1.4639518E+000 0.240 4.2906198E+000 2.8333371E+000 2.5657334E+000 2.2435493E+000 1.6571624E+000 1.3000077E+000 0.260 3.8741798E+000 2.860464...
random_line_split
main.rs
// main.rs // Copyright 2016 Alexander Altman // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law ...
> { args: clap::ArgMatches<'a>, textures: SpriteTextures, window: &'a mut PistonWindow, drag_ctrl: &'a mut DragController, scene: &'a mut Scene<Texture<GLResources>>, sprite_map: &'a mut collections::HashMap<Pos, Uuid>, game: &'a mut Game, rng: &'a mut StdRng, } struct SpriteTextures { white_piece: T...
eContext<'a
identifier_name
main.rs
// main.rs // Copyright 2016 Alexander Altman // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law ...
fn load_texture(texture_data: &[u8], factory: &mut GLFactory) -> errors::Result<Texture<GLResources>> { let texture_image = try!(piston_image::load_from_memory_with_format(texture_data, piston_image::ImageFormat::PNG)) .res...
let mut window: PistonWindow = try!(WindowSettings::new("kōnane", [TILE_SIZE * 10, TILE_SIZE * 10]).exit_on_esc(true).build()); let textures = SpriteTextures { white_piece: try!(load_texture(WHITE_PIECE_DATA, &mut window.factory)), black_piece: try!(load_texture(BLACK_PIECE_DATA, &mut window.factory)), ...
identifier_body
main.rs
// main.rs // Copyright 2016 Alexander Altman // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law ...
e { } } } Ok(cxt) } fn run(cxt: GameContext) -> errors::Result<()> { let mut events = cxt.window.events(); while let Some(event) = events.next(cxt.window) { cxt.scene.event(&event); } Ok(()) }
} els
conditional_block
main.rs
// main.rs // Copyright 2016 Alexander Altman // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law ...
use drag_controller::*; #[macro_use] extern crate clap; extern crate rand; use rand::{Rng, StdRng}; const TILE_SIZE: u32 = 75; const WHITE_PIECE_DATA: &'static [u8] = include_bytes!("../resources/white_piece.png"); const BLACK_PIECE_DATA: &'static [u8] = include_bytes!("../resources/black_piece.png"); const EMPTY_PI...
use piston_image::GenericImage; use gfx_device_gl::{Factory as GLFactory, Resources as GLResources}; use piston_window::*; use sprite::*;
random_line_split
event.rs
use std::list::*; use core::cmp::Eq; use core::option::*; use transaction::*; type Listen<A> = @fn(@fn(A)) -> @fn(); struct Event<P,A> { part : Option<Partition<P>>, listener : Listen<A> } pub impl<P,A : Copy> Event<P,A> { pub fn never() -> Event<P,A> { Event { part : None, ...
pub fn listen(&self, handler : @fn(A)) -> @fn() { return (self.listener)(handler); } } fn delete<A: Eq + Copy,B: Copy>(l : &List<(A,B)>, key : &A) -> @List<(A,B)> { match l { &Nil => @Nil, &Cons((k, v), t) => { if k == *key { delete(t, key) } ...
{ let state = @mut EventState{ handlers : @Nil, nextIx : 0 }; ( Event { part : Some(part), listener : |handler| { let ix = state.nextIx; state.handlers = @Cons((ix, handler), state.handlers); ...
identifier_body
event.rs
use std::list::*; use core::cmp::Eq; use core::option::*; use transaction::*; type Listen<A> = @fn(@fn(A)) -> @fn(); struct Event<P,A> { part : Option<Partition<P>>, listener : Listen<A> } pub impl<P,A : Copy> Event<P,A> { pub fn never() -> Event<P,A> { Event { part : None, ...
{ match l { &Nil => @Nil, &Cons((k, v), t) => { if k == *key { delete(t, key) } else { @Cons((k, v), delete(t, key)) } } } } struct EventState<A> { handlers : @List<(int, @fn(A))>, nextIx : int }
fn delete<A: Eq + Copy,B: Copy>(l : &List<(A,B)>, key : &A) -> @List<(A,B)>
random_line_split
event.rs
use std::list::*; use core::cmp::Eq; use core::option::*; use transaction::*; type Listen<A> = @fn(@fn(A)) -> @fn(); struct Event<P,A> { part : Option<Partition<P>>, listener : Listen<A> } pub impl<P,A : Copy> Event<P,A> { pub fn never() -> Event<P,A> { Event { part : None, ...
(&self, handler : @fn(A)) -> @fn() { return (self.listener)(handler); } } fn delete<A: Eq + Copy,B: Copy>(l : &List<(A,B)>, key : &A) -> @List<(A,B)> { match l { &Nil => @Nil, &Cons((k, v), t) => { if k == *key { delete(t, key) } else { @Cons(...
listen
identifier_name
global_asm_include.rs
// ignore-aarch64 // ignore-aarch64_be // ignore-arm // ignore-armeb // ignore-avr // ignore-bpfel // ignore-bpfeb // ignore-hexagon // ignore-mips // ignore-mips64 // ignore-msp430 // ignore-powerpc64 // ignore-powerpc64le // ignore-powerpc // ignore-r600 // ignore-amdgcn // ignore-sparc // ignore-sparcv9 // ignore-sp...
// ignore-xcore // ignore-nvptx // ignore-nvptx64 // ignore-le32 // ignore-le64 // ignore-amdil // ignore-amdil64 // ignore-hsail // ignore-hsail64 // ignore-spir // ignore-spir64 // ignore-kalimba // ignore-shave // ignore-wasm32 // ignore-wasm64 // ignore-emscripten // compile-flags: -C no-prepopulate-passes #![feat...
// ignore-thumb // ignore-thumbeb
random_line_split
global_asm_include.rs
// ignore-aarch64 // ignore-aarch64_be // ignore-arm // ignore-armeb // ignore-avr // ignore-bpfel // ignore-bpfeb // ignore-hexagon // ignore-mips // ignore-mips64 // ignore-msp430 // ignore-powerpc64 // ignore-powerpc64le // ignore-powerpc // ignore-r600 // ignore-amdgcn // ignore-sparc // ignore-sparcv9 // ignore-sp...
{}
identifier_body
global_asm_include.rs
// ignore-aarch64 // ignore-aarch64_be // ignore-arm // ignore-armeb // ignore-avr // ignore-bpfel // ignore-bpfeb // ignore-hexagon // ignore-mips // ignore-mips64 // ignore-msp430 // ignore-powerpc64 // ignore-powerpc64le // ignore-powerpc // ignore-r600 // ignore-amdgcn // ignore-sparc // ignore-sparcv9 // ignore-sp...
() {}
baz
identifier_name
error.rs
use std::error::Error as StdError; use std::fmt::{self, Display}; /// An error that occurred while attempting to deal with the gateway. /// /// Note that - from a user standpoint - there should be no situation in which /// you manually handle these. #[derive(Clone, Debug)] pub enum
{ /// There was an error building a URL. BuildingUrl, /// The connection closed, potentially uncleanly. Closed(Option<u16>, String), /// Expected a Hello during a handshake ExpectedHello, /// Expected a Ready or an InvalidateSession InvalidHandshake, /// An indicator that an unknown...
Error
identifier_name
error.rs
use std::error::Error as StdError; use std::fmt::{self, Display}; /// An error that occurred while attempting to deal with the gateway. /// /// Note that - from a user standpoint - there should be no situation in which /// you manually handle these. #[derive(Clone, Debug)] pub enum Error { /// There was an error b...
}
{ match *self { Error::BuildingUrl => "Error building url", Error::Closed(_, _) => "Connection closed", Error::ExpectedHello => "Expected a Hello", Error::InvalidHandshake => "Expected a valid Handshake", Error::InvalidOpCode => "Invalid OpCode", ...
identifier_body
error.rs
use std::error::Error as StdError; use std::fmt::{self, Display}; /// An error that occurred while attempting to deal with the gateway. /// /// Note that - from a user standpoint - there should be no situation in which /// you manually handle these. #[derive(Clone, Debug)] pub enum Error { /// There was an error b...
match *self { Error::BuildingUrl => "Error building url", Error::Closed(_, _) => "Connection closed", Error::ExpectedHello => "Expected a Hello", Error::InvalidHandshake => "Expected a valid Handshake", Error::InvalidOpCode => "Invalid OpCode", ...
impl StdError for Error { fn description(&self) -> &str {
random_line_split
os.rs
// Copyright 2018 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 exit(code: i32) ->! { unsafe { libc::exit(code as c_int) } }
{ // cloudlibc's strerror() is guaranteed to be thread-safe. There is // thus no need to use strerror_r(). str::from_utf8(unsafe { CStr::from_ptr(libc::strerror(errno)) }.to_bytes()) .unwrap() .to_owned() }
identifier_body
os.rs
// Copyright 2018 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 ...
(code: i32) ->! { unsafe { libc::exit(code as c_int) } }
exit
identifier_name
os.rs
// Copyright 2018 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 ...
use libc::{self, c_int}; use str; pub use sys::cloudabi::shims::os::*; pub fn errno() -> i32 { extern "C" { #[thread_local] static errno: c_int; } unsafe { errno as i32 } } /// Gets a detailed string description for the given error number. pub fn error_string(errno: i32) -> String { ...
random_line_split
error.rs
use crate::codec::{CodecError, Message, ZmtpVersion}; use crate::endpoint::Endpoint; use crate::endpoint::EndpointError; use crate::task_handle::TaskError; use crate::ZmqMessage; use thiserror::Error; pub type ZmqResult<T> = Result<T, ZmqError>; #[derive(Error, Debug)] pub enum ZmqError { #[error("Endpoint Error...
Codec(#[from] CodecError), #[error("Socket Error: {0}")] Socket(&'static str), #[error("{0}")] BufferFull(&'static str), #[error("Failed to deliver message cause of {reason}")] ReturnToSender { reason: &'static str, message: ZmqMessage, }, // TODO refactor this. /...
#[error("Codec Error: {0}")]
random_line_split
error.rs
use crate::codec::{CodecError, Message, ZmtpVersion}; use crate::endpoint::Endpoint; use crate::endpoint::EndpointError; use crate::task_handle::TaskError; use crate::ZmqMessage; use thiserror::Error; pub type ZmqResult<T> = Result<T, ZmqError>; #[derive(Error, Debug)] pub enum ZmqError { #[error("Endpoint Error...
(_: futures::channel::mpsc::SendError) -> Self { ZmqError::BufferFull("Failed to send message. Send queue full/broken") } }
from
identifier_name
error.rs
use crate::codec::{CodecError, Message, ZmtpVersion}; use crate::endpoint::Endpoint; use crate::endpoint::EndpointError; use crate::task_handle::TaskError; use crate::ZmqMessage; use thiserror::Error; pub type ZmqResult<T> = Result<T, ZmqError>; #[derive(Error, Debug)] pub enum ZmqError { #[error("Endpoint Error...
} impl From<futures::channel::mpsc::SendError> for ZmqError { fn from(_: futures::channel::mpsc::SendError) -> Self { ZmqError::BufferFull("Failed to send message. Send queue full/broken") } }
{ ZmqError::BufferFull("Failed to send message. Send queue full/broken") }
identifier_body
mod.rs
// Copyright 2015, 2016 Ethcore (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 later version....
/// Create a new Morden chain spec. pub fn new_morden() -> Spec { Spec::load(include_bytes!("../../res/ethereum/morden.json")) } #[cfg(test)] mod tests { use common::*; use state::*; use engine::*; use super::*; use tests::helpers::*; #[test] fn ensure_db_good() { let spec = new_morden(); let engine = &s...
random_line_split
mod.rs
// Copyright 2015, 2016 Ethcore (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 later version....
() -> Spec { Spec::load(include_bytes!("../../res/ethereum/morden.json")) } #[cfg(test)] mod tests { use common::*; use state::*; use engine::*; use super::*; use tests::helpers::*; #[test] fn ensure_db_good() { let spec = new_morden(); let engine = &spec.engine; let genesis_header = spec.genesis_header...
new_morden
identifier_name
mod.rs
// Copyright 2015, 2016 Ethcore (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 later version....
/// Create a new Frontier chain spec as though it never changes to Homestead. pub fn new_frontier_test() -> Spec { Spec::load(include_bytes!("../../res/ethereum/frontier_test.json")) } /// Create a new Homestead chain spec as though it never changed from Frontier. pub fn new_homestead_test() -> Spec { Spec::load(i...
{ Spec::load(include_bytes!("../../res/ethereum/frontier.json")) }
identifier_body
lib.rs
#![feature(lang_items)] #![feature(const_fn)] #![feature(unique)] #![feature(alloc, collections)] #![no_std] extern crate rlibc; extern crate spin; extern crate multiboot2; #[macro_use] extern crate bitflags; extern crate x86; extern crate hole_list_allocator; extern crate alloc; #[macro_use] extern crate collections;...
fn enable_write_protect_bit() { use x86::controlregs::{cr0, cr0_write}; let wp_bit = 1 << 16; unsafe { cr0_write(cr0() | wp_bit) }; }
{ use x86::msr::{IA32_EFER, rdmsr, wrmsr}; let nxe_bit = 1 << 11; unsafe { let efer = rdmsr(IA32_EFER); wrmsr(IA32_EFER, efer | nxe_bit); } }
identifier_body
lib.rs
#![feature(lang_items)] #![feature(const_fn)] #![feature(unique)] #![feature(alloc, collections)] #![no_std] extern crate rlibc; extern crate spin; extern crate multiboot2; #[macro_use] extern crate bitflags; extern crate x86; extern crate hole_list_allocator; extern crate alloc; #[macro_use] extern crate collections;...
() { use x86::controlregs::{cr0, cr0_write}; let wp_bit = 1 << 16; unsafe { cr0_write(cr0() | wp_bit) }; }
enable_write_protect_bit
identifier_name
lib.rs
#![feature(lang_items)] #![feature(const_fn)] #![feature(unique)] #![feature(alloc, collections)] #![no_std] extern crate rlibc; extern crate spin; extern crate multiboot2; #[macro_use] extern crate bitflags; extern crate x86; extern crate hole_list_allocator; extern crate alloc; #[macro_use] extern crate collections;...
#[lang = "eh_personality"] extern "C" fn eh_personality() {} #[lang = "panic_fmt"] extern "C" fn panic_fmt(fmt: core::fmt::Arguments, file: &str, line: u32) ->! { println!("\n\nPANIC in {} at line {}:", file, line); println!(" {}", fmt); loop {} } fn enable_nxe_bit() { use x86::msr::{IA32_EFER, rd...
}
random_line_split
static-methods-crate.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 ...
}
Some(x) => x, _ => fail2!("read failed!") }
random_line_split
static-methods-crate.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 ...
{ match read::readMaybe(s) { Some(x) => x, _ => fail2!("read failed!") } }
identifier_body
static-methods-crate.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 ...
<T:read>(s: ~str) -> T { match read::readMaybe(s) { Some(x) => x, _ => fail2!("read failed!") } }
read
identifier_name
objects-owned-object-owned-method.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 ...
impl FooTrait for BarStruct { fn foo(self: Box<BarStruct>) -> usize { self.x } } pub fn main() { let foo = box BarStruct{ x: 22 } as Box<FooTrait>; assert_eq!(22, foo.foo()); }
random_line_split
objects-owned-object-owned-method.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ x: usize } impl FooTrait for BarStruct { fn foo(self: Box<BarStruct>) -> usize { self.x } } pub fn main() { let foo = box BarStruct{ x: 22 } as Box<FooTrait>; assert_eq!(22, foo.foo()); }
BarStruct
identifier_name
error.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the ...
} }
display("Failed to start viewer") }
random_line_split
hello.rs
// Copyright 2015 The Rust-Windows Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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/MI...
font: RefCell::new(None), }); let win_params = WindowParams { window_name: title, style: window::WS_OVERLAPPEDWINDOW, x: 0, y: 0, width: 400, height: 400, parent: Window::null(), menu: ptr::null_...
let wproc = Box::new(MainFrame { win: Window::null(), title: title.clone(), text_height: text_height, edit: RefCell::new(None),
random_line_split
hello.rs
// Copyright 2015 The Rust-Windows Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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/MI...
} impl OnFocus for MainFrame { fn on_focus(&self, _w: Window) { self.edit.borrow().expect("edit is empty").set_focus(); } } impl OnMessage for MainFrame { fn on_message(&self, _message: UINT, _wparam: WPARAM, _lparam: LPARAM) -> Option<LRESULT> { match _message { WM_COMMAND =>...
{ let font = self.font.borrow(); let pdc = PaintDc::new(self).expect("Paint DC"); pdc.dc.select_font(&font.expect("font is empty")); pdc.dc.text_out(0, 0, self.title.as_ref()); }
identifier_body
hello.rs
// Copyright 2015 The Rust-Windows Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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/MI...
} }, _ => { /* Other messages. */ } } None } } impl MainFrame { fn new(instance: Instance, title: String, text_height: isize) -> Option<Window> { let icon = Image::load_resource(instance, IDI_ICON, ImageType::IMAGE_ICON, 0, 0); let wnd_...
{}
conditional_block
hello.rs
// Copyright 2015 The Rust-Windows Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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/MI...
{ win: Window, title: String, text_height: isize, edit: RefCell<Option<Window>>, font: RefCell<Option<Font>>, } wnd_proc!(MainFrame, win, WM_CREATE, WM_DESTROY, WM_SIZE, WM_SETFOCUS, WM_PAINT, ANY); impl OnCreate for MainFrame { fn on_create(&self, _cs: &CREATESTRUCTW) -> bool { let r...
MainFrame
identifier_name
socket_event.rs
use td_rp::Buffer;
client_ip: String, server_port: u16, buffer: Buffer, out_cache: Buffer, online: bool, websocket: bool, } impl SocketEvent { pub fn new(socket_fd: i32, client_ip: String, server_port: u16) -> SocketEvent { SocketEvent { socket_fd: socket_fd, cookie: 0, ...
#[derive(Debug)] pub struct SocketEvent { socket_fd: i32, cookie: u32,
random_line_split
socket_event.rs
use td_rp::Buffer; #[derive(Debug)] pub struct SocketEvent { socket_fd: i32, cookie: u32, client_ip: String, server_port: u16, buffer: Buffer, out_cache: Buffer, online: bool, websocket: bool, } impl SocketEvent { pub fn new(socket_fd: i32, client_ip: String, server_port: u16) -> S...
(&mut self, online: bool) { self.online = online; } pub fn is_online(&self) -> bool { self.online } pub fn set_websocket(&mut self, websocket: bool) { self.websocket = websocket; } pub fn is_websocket(&self) -> bool { self.websocket } }
set_online
identifier_name
socket_event.rs
use td_rp::Buffer; #[derive(Debug)] pub struct SocketEvent { socket_fd: i32, cookie: u32, client_ip: String, server_port: u16, buffer: Buffer, out_cache: Buffer, online: bool, websocket: bool, } impl SocketEvent { pub fn new(socket_fd: i32, client_ip: String, server_port: u16) -> S...
pub fn set_websocket(&mut self, websocket: bool) { self.websocket = websocket; } pub fn is_websocket(&self) -> bool { self.websocket } }
{ self.online }
identifier_body
set_cookie.rs
use header::{Header, Raw, CookiePair, CookieJar}; use std::fmt::{self, Display}; use std::str::from_utf8; /// `Set-Cookie` header, defined [RFC6265](http://tools.ietf.org/html/rfc6265#section-4.1) /// /// The Set-Cookie HTTP response header is used to send cookies from the /// server to the user agent. /// /// Inform...
#[test] fn cookie_jar() { let jar = CookieJar::new(b"secret"); let cookie = CookiePair::new("foo".to_owned(), "bar".to_owned()); jar.add(cookie); let cookies = SetCookie::from_cookie_jar(&jar); let mut new_jar = CookieJar::new(b"secret"); cookies.apply_to_cookie_jar(&mut new_jar); asser...
{ use header::Headers; let mut cookie = CookiePair::new("foo".to_owned(), "bar".to_owned()); cookie.httponly = true; cookie.path = Some("/p".to_owned()); let cookies = SetCookie(vec![cookie, CookiePair::new("baz".to_owned(), "quux".to_owned())]); let mut headers = Headers::new(); headers.se...
identifier_body
set_cookie.rs
use header::{Header, Raw, CookiePair, CookieJar}; use std::fmt::{self, Display}; use std::str::from_utf8; /// `Set-Cookie` header, defined [RFC6265](http://tools.ietf.org/html/rfc6265#section-4.1) /// /// The Set-Cookie HTTP response header is used to send cookies from the /// server to the user agent. /// /// Inform...
try!(Display::fmt(cookie, f)); } Ok(()) } } impl SetCookie { /// Use this to create SetCookie header from CookieJar using /// calculated delta. pub fn from_cookie_jar(jar: &CookieJar) -> SetCookie { SetCookie(jar.delta()) } /// Use this on client to apply ...
{ try!(f.write_str("\r\nSet-Cookie: ")); }
conditional_block
set_cookie.rs
use header::{Header, Raw, CookiePair, CookieJar}; use std::fmt::{self, Display}; use std::str::from_utf8; /// `Set-Cookie` header, defined [RFC6265](http://tools.ietf.org/html/rfc6265#section-4.1) /// /// The Set-Cookie HTTP response header is used to send cookies from the /// server to the user agent. /// /// Inform...
try!(f.write_str("\r\nSet-Cookie: ")); } try!(Display::fmt(cookie, f)); } Ok(()) } } impl SetCookie { /// Use this to create SetCookie header from CookieJar using /// calculated delta. pub fn from_cookie_jar(jar: &CookieJar) -> SetCookie { ...
} fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result { for (i, cookie) in self.0.iter().enumerate() { if i != 0 {
random_line_split
set_cookie.rs
use header::{Header, Raw, CookiePair, CookieJar}; use std::fmt::{self, Display}; use std::str::from_utf8; /// `Set-Cookie` header, defined [RFC6265](http://tools.ietf.org/html/rfc6265#section-4.1) /// /// The Set-Cookie HTTP response header is used to send cookies from the /// server to the user agent. /// /// Inform...
() { use header::Headers; let mut cookie = CookiePair::new("foo".to_owned(), "bar".to_owned()); cookie.httponly = true; cookie.path = Some("/p".to_owned()); let cookies = SetCookie(vec![cookie, CookiePair::new("baz".to_owned(), "quux".to_owned())]); let mut headers = Headers::new(); headers...
test_fmt
identifier_name
erase_regions.rs
use crate::mir; use crate::ty::fold::{TypeFoldable, TypeFolder}; use crate::ty::{self, Ty, TyCtxt, TypeFlags}; pub(super) fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { erase_regions_ty,..*providers }; } fn erase_regions_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>...
impl TypeFolder<'tcx> for RegionEraserVisitor<'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> { if ty.needs_infer() { ty.super_fold_with(self) } else { Ok(self.tcx.erase_regions_ty(ty)) } } fn fold_bind...
random_line_split
erase_regions.rs
use crate::mir; use crate::ty::fold::{TypeFoldable, TypeFolder}; use crate::ty::{self, Ty, TyCtxt, TypeFlags}; pub(super) fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { erase_regions_ty,..*providers }; } fn erase_regions_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>...
} fn fold_binder<T>(&mut self, t: ty::Binder<'tcx, T>) -> Result<ty::Binder<'tcx, T>, Self::Error> where T: TypeFoldable<'tcx>, { let u = self.tcx.anonymize_late_bound_regions(t); u.super_fold_with(self) } fn fold_region(&mut self, r: ty::Region<'tcx>) -> Result<ty::Re...
{ Ok(self.tcx.erase_regions_ty(ty)) }
conditional_block
erase_regions.rs
use crate::mir; use crate::ty::fold::{TypeFoldable, TypeFolder}; use crate::ty::{self, Ty, TyCtxt, TypeFlags}; pub(super) fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { erase_regions_ty,..*providers }; } fn erase_regions_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>...
(&mut self, r: ty::Region<'tcx>) -> Result<ty::Region<'tcx>, Self::Error> { // because late-bound regions affect subtyping, we can't // erase the bound/free distinction, but we can replace // all free regions with 'erased. // // Note that we *CAN* replace early-bound regions -- t...
fold_region
identifier_name
erase_regions.rs
use crate::mir; use crate::ty::fold::{TypeFoldable, TypeFolder}; use crate::ty::{self, Ty, TyCtxt, TypeFlags}; pub(super) fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { erase_regions_ty,..*providers }; } fn erase_regions_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>...
impl<'tcx> TyCtxt<'tcx> { /// Returns an equivalent value with all free regions removed (note /// that late-bound regions remain, because they are important for /// subtyping, but they are anonymized and normalized as well).. pub fn erase_regions<T>(self, value: T) -> T where T: TypeFoldab...
{ // N.B., use `super_fold_with` here. If we used `fold_with`, it // could invoke the `erase_regions_ty` query recursively. ty.super_fold_with(&mut RegionEraserVisitor { tcx }).into_ok() }
identifier_body
classify.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 expr_is_simple_block(e: @ast::Expr) -> bool { match e.node { ast::ExprBlock(block) => block.rules == ast::DefaultBlock, _ => false } } // this statement requires a semicolon after it. // note that in one case (stmt_semi), we've already // seen the semicolon, and thus don't need another. ...
{ match e.node { ast::ExprIf(..) | ast::ExprMatch(..) | ast::ExprBlock(_) | ast::ExprWhile(..) | ast::ExprLoop(..) | ast::ExprForLoop(..) | ast::ExprCall(_, _, ast::DoSugar) | ast::ExprCall(_, _, ast::ForSugar) | ast::ExprMethodCall(_, _, _, _, _, ast::DoSugar) ...
identifier_body
classify.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 ...
ast::StmtMac(..) => { false } } }
random_line_split
classify.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 ...
} }
{ false }
conditional_block
classify.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 ...
(stmt: &ast::Stmt) -> bool { return match stmt.node { ast::StmtDecl(d, _) => { match d.node { ast::DeclLocal(_) => true, ast::DeclItem(_) => false } } ast::StmtExpr(e, _) => { expr_requires_semi_to_be_stmt(e) } ast::StmtSemi(..)...
stmt_ends_with_semi
identifier_name
default.rs
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
cx.span_fatal(span, "`Default` cannot be derived for enums, \ only structs") } _ => cx.bug("Non-static method in `deriving(Default)`") }; }
random_line_split