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
read-scale.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 ...
() { let display; let client; let xlib = Xlib::open().unwrap(); unsafe { display = (xlib.XOpenDisplay)(ptr::null_mut()); // Enumerate all properties. client = Client::new(display, (xlib.XDefaultScreen)(display), Box::new(...
main
identifier_name
read-scale.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 ...
let gdk_xft_dpi: &[u8] = b"Xft/DPI"; let gdk_window_scaling_factor: &[u8] = b"Gdk/WindowScalingFactor"; for key in &[gdk_unscaled_dpi, gdk_xft_dpi, gdk_window_scaling_factor] { let key_str = str::from_utf8(key).unwrap(); match client.get_setting(*key) { Err(err) => println!("{}: ...
Box::new(|_, _, _| {})); } // Print out a few well-known properties that describe the window scale. let gdk_unscaled_dpi: &[u8] = b"Gdk/UnscaledDPI";
random_line_split
heapview.rs
use l2::ast::*; use std::vec::Vec; #[derive(Clone, Copy)] pub enum HeapCellView<'a> { Str(usize, &'a Atom), Var(usize) } pub struct
<'a> { heap: &'a Heap, state_stack: Vec<(usize, &'a HeapCellValue)> } impl<'a> HeapCellViewer<'a> { pub fn new(heap: &'a Heap, focus: usize) -> Self { HeapCellViewer { heap: heap, state_stack: vec![(focus, &heap[focus])] } } fn follow(&self, value: &'a HeapC...
HeapCellViewer
identifier_name
heapview.rs
use l2::ast::*; use std::vec::Vec; #[derive(Clone, Copy)] pub enum HeapCellView<'a> { Str(usize, &'a Atom), Var(usize) } pub struct HeapCellViewer<'a> { heap: &'a Heap, state_stack: Vec<(usize, &'a HeapCellValue)> } impl<'a> HeapCellViewer<'a> { pub fn new(heap: &'a Heap, focus: usize) -> Self {...
return Some(HeapCellView::Str(arity, name)); }, (_, &HeapCellValue::Ref(cell_num)) => { let new_hcv = self.follow(hcv.1); if hcv.1 == new_hcv { return Some(HeapCellView::Var(cell_num)); ...
for i in (1 .. arity + 1).rev() { self.state_stack.push((focus + i, &self.heap[focus + i])); }
random_line_split
macros.rs
// Rust JSON-RPC Library // Written in 2015 by // Andrew Poelstra <apoelstra@wpsoftware.net> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warran...
struct $enum_visitor; impl ::serde::de::Visitor for $enum_visitor { type Value = $enum_ty; fn visit_str<E>(&mut self, value: &str) -> Result<$enum_ty, E> where E: ::serde::de::Error { ...
impl ::serde::Deserialize for $enum_ty { fn deserialize<D>(deserializer: &mut D) -> Result<$enum_ty, D::Error> where D: ::serde::de::Deserializer {
random_line_split
lib.rs
extern crate libc; use std::os::raw; use std::ffi::CString; use std::mem::{transmute, size_of}; use std::default::Default; #[link(name = "kleeRuntest")] extern { fn klee_make_symbolic(data: *mut raw::c_void, length: libc::size_t, name: *const raw::c_char); fn klee_set_forking(state: bool); } pub unsafe fn an...
<T>(data: *mut T, name: &str) { unsafe{ any(transmute(data), size_of::<T>(), name); } }
symbol
identifier_name
lib.rs
extern crate libc; use std::os::raw; use std::ffi::CString; use std::mem::{transmute, size_of}; use std::default::Default; #[link(name = "kleeRuntest")] extern { fn klee_make_symbolic(data: *mut raw::c_void, length: libc::size_t, name: *const raw::c_char); fn klee_set_forking(state: bool); } pub unsafe fn an...
return new_symbol; } pub fn symbol<T>(data: *mut T, name: &str) { unsafe{ any(transmute(data), size_of::<T>(), name); } }
symbol(&mut new_symbol, name);
random_line_split
lib.rs
extern crate libc; use std::os::raw; use std::ffi::CString; use std::mem::{transmute, size_of}; use std::default::Default; #[link(name = "kleeRuntest")] extern { fn klee_make_symbolic(data: *mut raw::c_void, length: libc::size_t, name: *const raw::c_char); fn klee_set_forking(state: bool); } pub unsafe fn an...
pub fn some<T: Default>(name: &str) -> T { let mut new_symbol = T::default(); symbol(&mut new_symbol, name); return new_symbol; } pub fn symbol<T>(data: *mut T, name: &str) { unsafe{ any(transmute(data), size_of::<T>(), name); } }
{ unsafe { klee_set_forking(state); } }
identifier_body
canvaspattern.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 canvas_traits::canvas::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle}; use dom::bindings::codegen::Binding...
origin_clean: bool, ) -> DomRoot<CanvasPattern> { reflect_dom_object( Box::new(CanvasPattern::new_inherited( surface_data, surface_size, repeat, origin_clean, )), global, CanvasPatternBind...
global: &GlobalScope, surface_data: Vec<u8>, surface_size: Size2D<i32>, repeat: RepetitionStyle,
random_line_split
canvaspattern.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 canvas_traits::canvas::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle}; use dom::bindings::codegen::Binding...
{ reflector_: Reflector, surface_data: Vec<u8>, surface_size: Size2D<i32>, repeat_x: bool, repeat_y: bool, origin_clean: bool, } impl CanvasPattern { fn new_inherited( surface_data: Vec<u8>, surface_size: Size2D<i32>, repeat: RepetitionStyle, origin_clean: b...
CanvasPattern
identifier_name
canvaspattern.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 canvas_traits::canvas::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle}; use dom::bindings::codegen::Binding...
}
{ FillOrStrokeStyle::Surface(SurfaceStyle::new( self.surface_data.clone(), self.surface_size, self.repeat_x, self.repeat_y, )) }
identifier_body
send-type-inference.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 ...
<K:Send+'static,V:Send+'static>(mut tx: Sender<Sender<Command<K, V>>>) { let (tx1, _rx) = channel(); tx.send(tx1); } pub fn main() { }
cache_server
identifier_name
send-type-inference.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} pub fn main() { }
tx.send(tx1);
random_line_split
send-type-inference.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { }
{ let (tx1, _rx) = channel(); tx.send(tx1); }
identifier_body
box_shadow.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 api::{BorderRadius, BoxShadowClipMode, ClipMode, ColorF, DeviceIntSize, LayoutPrimitiveInfo}; use api::{Layout...
BoxShadowClipMode::Inset => { // If the inner shadow rect contains the prim // rect, no pixels will be shadowed. if border_radius.is_zero() && shadow_rect.inflate(-blur_radius, -blur_radius).contains_rect(&prim_info.rect...
{ // Certain spread-radii make the shadow invalid. if !shadow_rect.is_well_formed_and_nonempty() { return; } // Add the box-shadow clip source. extra_clips.push(shadow_clip_source); ...
conditional_block
box_shadow.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 api::{BorderRadius, BoxShadowClipMode, ClipMode, ColorF, DeviceIntSize, LayoutPrimitiveInfo}; use api::{Layout...
( corner: LayoutSize, spread_amount: f32, ) -> LayoutSize { LayoutSize::new( adjust_radius_for_box_shadow( corner.width, spread_amount ), adjust_radius_for_box_shadow( corner.height, spread_amount ), ) } fn adjust_radius_fo...
adjust_corner_for_box_shadow
identifier_name
box_shadow.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 api::{BorderRadius, BoxShadowClipMode, ClipMode, ColorF, DeviceIntSize, LayoutPrimitiveInfo}; use api::{Layout...
} } fn adjust_corner_for_box_shadow( corner: LayoutSize, spread_amount: f32, ) -> LayoutSize { LayoutSize::new( adjust_radius_for_box_shadow( corner.width, spread_amount ), adjust_radius_for_box_shadow( corner.height, spread_amount...
bottom_left: adjust_corner_for_box_shadow( radius.bottom_left, spread_amount, ),
random_line_split
char.rs
// Copyright 2012-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...
turns whether the specified `char` satisfies the 'XID_Continue' /// Unicode property. /// /// 'XID_Continue' is a Unicode Derived Property specified in /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications), /// mostly similar to 'ID_Continue' but modified for closure under NFKx. #[u...
operty::XID_Start(self) } /// Re
identifier_body
char.rs
// Copyright 2012-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...
#[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn is_alphanumeric(self) -> bool { self.is_alphabetic() || self.is_numeric() } /// Indicates whether a character is a control code point. /// /// Control code points are defined in terms of the Unicode General /// Categ...
/// 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
random_line_split
char.rs
// Copyright 2012-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...
f) -> EscapeUnicode { C::escape_unicode(self) } /// Returns an iterator that yields the 'default' ASCII and /// C++11-like literal escape of a character, as `char`s. /// /// The default is chosen with a bias toward producing literals that are /// legal in a variety of languages, including C++11 and...
pe_unicode(sel
identifier_name
errors.rs
/* Copyright 2017 Takashi Ogura 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 or agreed to in writing...
See the License for the specific language governing permissions and limitations under the License. */ use std::io; use thiserror::Error; #[derive(Debug, Error)] pub enum Error { #[error("Error: {:?}", error)] Other { error: String }, #[error("IOError: {:?}", source)] IoError { #[from] ...
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
random_line_split
errors.rs
/* Copyright 2017 Takashi Ogura 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 or agreed to in writing...
(error: String) -> Error { Error::Other { error } } }
from
identifier_name
037.rs
use std::str::FromStr; fn read_line() -> String { let mut input = String::new(); std::io::stdin().read_line(&mut input).expect("Could not read stdin!"); input } fn read_one<F>() -> F where F: FromStr { read_line().trim().parse().ok().unwrap() } fn main() {
let mut prime = vec![true; limit]; prime[0] = false; prime[1] = false; // Sieve of Eratosthenes to find primes for p in 2.. limit { if prime[p] { let mut multiple = 2 * p; while multiple < limit { prime[multiple] = false; multiple += p; } } } let mut right_truncata...
let limit = read_one::<usize>();
random_line_split
037.rs
use std::str::FromStr; fn read_line() -> String { let mut input = String::new(); std::io::stdin().read_line(&mut input).expect("Could not read stdin!"); input } fn read_one<F>() -> F where F: FromStr { read_line().trim().parse().ok().unwrap() } fn main() { let limit = read_one::<usize>(); let mut prim...
} let mut right_truncatable = prime.clone(); let mut left_truncatable = prime.clone(); // For the algorithm we'll assume one digit primes to be truncatable for p in 10.. limit { right_truncatable[p] &= right_truncatable[p / 10]; left_truncatable[p] &= left_truncatable[p % 10usize.pow((p as f64).log1...
{ let mut multiple = 2 * p; while multiple < limit { prime[multiple] = false; multiple += p; } }
conditional_block
037.rs
use std::str::FromStr; fn read_line() -> String { let mut input = String::new(); std::io::stdin().read_line(&mut input).expect("Could not read stdin!"); input } fn read_one<F>() -> F where F: FromStr { read_line().trim().parse().ok().unwrap() } fn
() { let limit = read_one::<usize>(); let mut prime = vec![true; limit]; prime[0] = false; prime[1] = false; // Sieve of Eratosthenes to find primes for p in 2.. limit { if prime[p] { let mut multiple = 2 * p; while multiple < limit { prime[multiple] = false; multiple += p; ...
main
identifier_name
037.rs
use std::str::FromStr; fn read_line() -> String
fn read_one<F>() -> F where F: FromStr { read_line().trim().parse().ok().unwrap() } fn main() { let limit = read_one::<usize>(); let mut prime = vec![true; limit]; prime[0] = false; prime[1] = false; // Sieve of Eratosthenes to find primes for p in 2.. limit { if prime[p] { let mut multiple =...
{ let mut input = String::new(); std::io::stdin().read_line(&mut input).expect("Could not read stdin!"); input }
identifier_body
locate_project.rs
use cargo::core::MultiShell; use cargo::util::{CliResult, CliError, human, ChainError}; use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] struct LocateProjectFlags { flag_manifest_path: Option<String>, } pub const USAGE: &'static str = " Usage: cargo locate-project [opt...
{ root: String } pub fn execute(flags: LocateProjectFlags, _: &mut MultiShell) -> CliResult<Option<ProjectLocation>> { let root = try!(find_root_manifest_for_cwd(flags.flag_manifest_path)); let string = try!(root.as_str() .chain_error(|| human("Your project path contai...
ProjectLocation
identifier_name
locate_project.rs
use cargo::core::MultiShell; use cargo::util::{CliResult, CliError, human, ChainError}; use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] struct LocateProjectFlags { flag_manifest_path: Option<String>, } pub const USAGE: &'static str = " Usage: cargo locate-project [opt...
Ok(Some(ProjectLocation { root: string.to_string() })) }
random_line_split
render_context.rs
use std::collections::{HashMap}; use std::path::{Path}; use std::sync::{Arc}; use crossbeam::sync::{MsQueue}; use glium::backend::{Facade}; use debug::{gnomon, indicator}; use inverse_kinematics::{Chain}; use model::{Model}; use unlit_model::{UnlitModel}; use render::render_frame::{RenderFrame}; pub const DEPTH_DIM...
} // TODO: don't pass in chains but make something like IntoModel // fn load_initial_models<F: Facade>(facade: &F, ik_chains: &[Chain]) -> HashMap<ModelId, Arc<Model>> { let mut map = HashMap::new(); const MODEL_PATH_STRINGS: [(ModelId, &'static str); 3] = [ (ModelId::Player, "./data/player.obj"), (ModelId::Sc...
{ (self.window_size.0 as f32) / (self.window_size.1 as f32) }
identifier_body
render_context.rs
use std::collections::{HashMap}; use std::path::{Path}; use std::sync::{Arc}; use crossbeam::sync::{MsQueue}; use glium::backend::{Facade}; use debug::{gnomon, indicator}; use inverse_kinematics::{Chain}; use model::{Model}; use unlit_model::{UnlitModel}; use render::render_frame::{RenderFrame}; pub const DEPTH_DIM...
<F: Facade>(facade: &F, q: Arc<MsQueue<RenderFrame>>, window_size: (u32, u32), ik_chains: &[Chain]) -> RenderContext { let model_map = load_initial_models(facade, ik_chains); // DEBUG let mut unlit_models = HashMap::new(); unlit_models.insert(ModelId::Gnomon, Arc::new(gnomon::model(facade))); unlit_models.in...
new
identifier_name
render_context.rs
use std::collections::{HashMap}; use std::path::{Path}; use std::sync::{Arc}; use crossbeam::sync::{MsQueue}; use glium::backend::{Facade}; use debug::{gnomon, indicator}; use inverse_kinematics::{Chain}; use model::{Model}; use unlit_model::{UnlitModel}; use render::render_frame::{RenderFrame}; pub const DEPTH_DIM...
unlit_models.insert(ModelId::Indicator, Arc::new(indicator::model(facade))); RenderContext { q: q, window_size: window_size, models: model_map, // DEBUG unlit_models: unlit_models, } } pub fn aspect_ratio(&self) -> f32 { (self.window_size.0 as f32) / (self.window_size.1 as f32) } } // TODO...
random_line_split
build.rs
// // Copyright 2022 The Project Oak Authors // // 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 o...
{ generate_grpc_code( "../", &["oak_functions/proto/streaming_server.proto"], CodegenOptions { build_client: true, build_server: true, ..Default::default() }, )?; Ok(()) }
identifier_body
build.rs
// // Copyright 2022 The Project Oak Authors // // 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 o...
..Default::default() }, )?; Ok(()) }
&["oak_functions/proto/streaming_server.proto"], CodegenOptions { build_client: true, build_server: true,
random_line_split
build.rs
// // Copyright 2022 The Project Oak Authors // // 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 o...
() -> Result<(), Box<dyn std::error::Error>> { generate_grpc_code( "../", &["oak_functions/proto/streaming_server.proto"], CodegenOptions { build_client: true, build_server: true, ..Default::default() }, )?; Ok(()) }
main
identifier_name
uds_split.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; use tokio::net::UnixStream; /// Checks that `UnixStream` can be split into a read half and a write half using /// `UnixStream::split` and `UnixStream::split_mut`. /// /// Verifies th...
( read: &mut (dyn AsyncRead + Unpin), write: &mut (dyn AsyncWrite + Unpin), input: &[u8], ) -> std::io::Result<Vec<u8>> { write.write_all(input).await?; write.shutdown().await?; let mut output = Vec::new(); read.read_to_end(&mut output).await?; Ok(output) }
send_recv_all
identifier_name
uds_split.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; use tokio::net::UnixStream; /// Checks that `UnixStream` can be split into a read half and a write half using /// `UnixStream::split` and `UnixStream::split_mut`. /// /// Verifies th...
send_recv_all(&mut a_read, &mut a_write, b"A"), send_recv_all(&mut b_read, &mut b_write, b"B"), ) .await?; assert_eq!(a_response, b"B"); assert_eq!(b_response, b"A"); Ok(()) } async fn send_recv_all( read: &mut (dyn AsyncRead + Unpin), write: &mut (dyn AsyncWrite + Unpin), ...
let (mut b_read, mut b_write) = b.split(); let (a_response, b_response) = futures::future::try_join(
random_line_split
uds_split.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; use tokio::net::UnixStream; /// Checks that `UnixStream` can be split into a read half and a write half using /// `UnixStream::split` and `UnixStream::split_mut`. /// /// Verifies th...
async fn send_recv_all( read: &mut (dyn AsyncRead + Unpin), write: &mut (dyn AsyncWrite + Unpin), input: &[u8], ) -> std::io::Result<Vec<u8>> { write.write_all(input).await?; write.shutdown().await?; let mut output = Vec::new(); read.read_to_end(&mut output).await?; Ok(output) }
{ let (mut a, mut b) = UnixStream::pair()?; let (mut a_read, mut a_write) = a.split(); let (mut b_read, mut b_write) = b.split(); let (a_response, b_response) = futures::future::try_join( send_recv_all(&mut a_read, &mut a_write, b"A"), send_recv_all(&mut b_read, &mut b_write, b"B"), ...
identifier_body
ofrefsofrects.rs
use rect::Rect; pub fn run() { println!("********* Option<&Rect> examples *********"); demo_basic_matching(); demo_as_ref(); demo_as_mut(); demo_unwrap(); demo_take(); demo_logical_or_and_combinators(); demo_chaining(); demo_map(); // demo_collection_of_options(); } fn demo_ba...
() { // This is quite simple, but there is a wrinkle. let r = Rect::demo(); let a = Some(&r); let b : Option<&Rect> = None; // For 'or', both options must be of the same type. let c = a.or(b).unwrap(); assert_eq!(c.title, "first demo"); // Reset. let a = Some(&r); let b : Opti...
demo_logical_or_and_combinators
identifier_name
ofrefsofrects.rs
use rect::Rect; pub fn run() { println!("********* Option<&Rect> examples *********"); demo_basic_matching(); demo_as_ref(); demo_as_mut(); demo_unwrap(); demo_take(); demo_logical_or_and_combinators(); demo_chaining(); demo_map(); // demo_collection_of_options(); } fn demo_ba...
let x = a.unwrap_or_else(|| &r2); assert!(x.title == "first demo"); // Let's make a None. let a : Option<&Rect> = None; let x = a.unwrap_or(&r2); assert!(x.title == "second demo"); // let a : Option<&Rect> = None; // let x = a.unwrap_or_default(); // Type needs to implement the De...
{ println!(">>> demo_unwrap"); let r = Rect::demo(); let r2 = Rect::demo2(); let a = Some(&r); let x = a.unwrap(); println!("x = {}", x); // These are all no-ops because is a Some. let a = Some(&r); let x = a.unwrap_or(&r2); assert!(x.title == "first demo"); // Won't compi...
identifier_body
ofrefsofrects.rs
use rect::Rect; pub fn run() { println!("********* Option<&Rect> examples *********"); demo_basic_matching(); demo_as_ref(); demo_as_mut(); demo_unwrap(); demo_take(); demo_logical_or_and_combinators(); demo_chaining(); demo_map(); // demo_collection_of_options(); } fn demo_ba...
match a { Some(x) => println!("MATCH: x (from a) = {}. x is of type &Rect.", x), None => panic!("a should not be None") } // If let is equivalent to a match where we do nothing in the None. // Because x is automatically a borrow, both of these compile fine. if let Some(x) = a { ...
assert!(!a.is_none()); // Match is the most basic way of getting at an option. // Note that x is now &Rect automatically, so we do not need 'ref x'.
random_line_split
mod.rs
// Copyright 2016 Alexander Reece // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according...
, _ => Err(Error::ExpectedEnd), } } } impl<'a> From<Constant<'a>> for Child<'a> { fn from(child: Constant<'a>) -> Self { Child::Constant(child) } } impl<'a> From<Domain<'a>> for Child<'a> { fn from(child: Domain<'a>) -> Self { Child::Domain(child) } } impl<'a>...
{ let parser = try!(parser.parse(event)); Ok(match parser.child() { Ok(child) => Parser::Finished(child.into()), Err(parser) => Parser::Parsing(parser), }) }
conditional_block
mod.rs
// Copyright 2016 Alexander Reece // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according...
use xml::reader::XmlEvent; use {Class, Constant, Domain}; use parser::Error; pub use self::inner::Parser as InnerParser; #[derive(Debug)] pub enum Child<'a> { Constant(Constant<'a>), Domain(Domain<'a>), Class(Class<'a>), } #[derive(Debug)] pub enum Parser<'a> { Parsing(InnerParser<'a>), Finished(...
random_line_split
mod.rs
// Copyright 2016 Alexander Reece // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according...
}
{ Child::Class(child) }
identifier_body
mod.rs
// Copyright 2016 Alexander Reece // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according...
(child: Domain<'a>) -> Self { Child::Domain(child) } } impl<'a> From<Class<'a>> for Child<'a> { fn from(child: Class<'a>) -> Self { Child::Class(child) } }
from
identifier_name
call_chain.rs
// CITA // Copyright 2016-2017 Cryptape Technologies LLC. // This program is free software: you can redistribute it // and/or modify it under the terms of the GNU General Public // License as published by the Free Software Foundation, // either version 3 of the License, or (at your option) any // later version. // Th...
} pub fn get_height(&self) -> u64 { self.chain.get_current_height() } pub fn get_pre_hash(&self) -> H256 { *self.chain.current_hash.read() } pub fn get_contract_address(&self, hash: H256) -> H160 { let receipt = self.chain.localized_receipt(hash).unwrap(); matc...
pub fn add_block(&self, block: Block) { self.chain.set_block(block);
random_line_split
call_chain.rs
// CITA // Copyright 2016-2017 Cryptape Technologies LLC. // This program is free software: you can redistribute it // and/or modify it under the terms of the GNU General Public // License as published by the Free Software Foundation, // either version 3 of the License, or (at your option) any // later version. // Th...
pub fn add_block(&self, block: Block) { self.chain.set_block(block); } pub fn get_height(&self) -> u64 { self.chain.get_current_height() } pub fn get_pre_hash(&self) -> H256 { *self.chain.current_hash.read() } pub fn get_contract_address(&self, hash: H256) -> H1...
{ let (chain, st) = Chain::init_chain(db, genesis, sync_sender); Callchain { chain: chain } }
identifier_body
call_chain.rs
// CITA // Copyright 2016-2017 Cryptape Technologies LLC. // This program is free software: you can redistribute it // and/or modify it under the terms of the GNU General Public // License as published by the Free Software Foundation, // either version 3 of the License, or (at your option) any // later version. // Th...
(&self) -> u64 { self.chain.get_current_height() } pub fn get_pre_hash(&self) -> H256 { *self.chain.current_hash.read() } pub fn get_contract_address(&self, hash: H256) -> H160 { let receipt = self.chain.localized_receipt(hash).unwrap(); match receipt.contract_address {...
get_height
identifier_name
cache.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/. */ //! A simple LRU cache. use arrayvec::{Array, ArrayVec}; /// A LRU cache using a statically-sized array for stor...
/// Remove an from the linked list. /// /// Note: This only unlinks the entry from the list; it does not remove it from the array. fn remove(&mut self, i: u16) { let prev = self.entries[i as usize].prev; let next = self.entries[i as usize].next; if i == self.head { ...
{ let entry = Entry { val, prev: 0, next: 0 }; // If the cache is full, replace the oldest entry. Otherwise, add an entry. let new_head = if self.entries.len() == self.entries.capacity() { let i = self.pop_back(); self.entries[i as usize] = entry; i }...
identifier_body
cache.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/. */ //! A simple LRU cache. use arrayvec::{Array, ArrayVec}; /// A LRU cache using a statically-sized array for stor...
} } /// Insert a new entry at the head of the list. fn push_front(&mut self, i: u16) { if self.entries.len() == 1 { self.tail = i; } else { self.entries[i as usize].next = self.head; self.entries[self.head as usize].prev = i; } sel...
random_line_split
cache.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/. */ //! A simple LRU cache. use arrayvec::{Array, ArrayVec}; /// A LRU cache using a statically-sized array for stor...
(&mut self) -> LRUCacheMutIterator<T, A> { LRUCacheMutIterator { pos: self.head, done: self.entries.len() == 0, cache: self, } } /// Insert a given key in the cache. pub fn insert(&mut self, val: T) { let entry = Entry { val, prev: 0, next: 0 }; ...
iter_mut
identifier_name
cache.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/. */ //! A simple LRU cache. use arrayvec::{Array, ArrayVec}; /// A LRU cache using a statically-sized array for stor...
if i == self.tail { self.tail = prev; } else { self.entries[next as usize].prev = prev; } } /// Insert a new entry at the head of the list. fn push_front(&mut self, i: u16) { if self.entries.len() == 1 { self.tail = i; } else { ...
{ self.entries[prev as usize].next = next; }
conditional_block
validation.rs
// Copyright 2015, 2016 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 la...
() { // given let server = serve_hosts(Some(vec!["localhost:8080".into()])); // when let response = request(server, "\ GET /ui/ HTTP/1.1\r\n\ Host: localhost:8080\r\n\ Connection: close\r\n\ \r\n\ {} " ); // then assert_eq!(response.status, "HTTP/1.1 200 OK".to_owned()); } #[test] fn should...
should_allow_valid_host
identifier_name
validation.rs
// Copyright 2015, 2016 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 la...
// given let server = serve_hosts(Some(vec!["localhost:8080".into()])); // when let response = request(server, "\ POST /rpc HTTP/1.1\r\n\ Host: localhost:8080\r\n\ Origin: null\r\n\ Content-Type: application/json\r\n\ Connection: close\r\n\ \r\n\ {} " ); // then assert_eq!(response.sta...
random_line_split
validation.rs
// Copyright 2015, 2016 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 la...
#[test] fn should_serve_dapps_domains() { // given let server = serve_hosts(Some(vec!["localhost:8080".into()])); // when let response = request(server, "\ GET / HTTP/1.1\r\n\ Host: ui.parity\r\n\ Connection: close\r\n\ \r\n\ {} " ); // then assert_eq!(response.status, "HTTP/1.1 200 OK".to...
{ // given let server = serve_hosts(Some(vec!["localhost:8080".into()])); // when let response = request(server, "\ GET /ui/ HTTP/1.1\r\n\ Host: localhost:8080\r\n\ Connection: close\r\n\ \r\n\ {} " ); // then assert_eq!(response.status, "HTTP/1.1 200 OK".to_owned()); }
identifier_body
main.rs
#![feature(plugin)] #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; mod primary_index; mod secondary_index; mod table; mod find; use std::fs::File; use std::io::Read; use serde_json::{Value, Error}; fn
() { let db_path = "/data/testdb"; let mut t = table::Table::new("test_table", db_path); t.create_secondary_index("Type", secondary_index::key_types::Str(20)); t.create_secondary_index("Name", secondary_index::key_types::Str(128)); t.create_secondary_index("X", secondary_index::key_types::F32); ...
main
identifier_name
main.rs
#![feature(plugin)] #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; mod primary_index; mod secondary_index; mod table; mod find; use std::fs::File; use std::io::Read; use serde_json::{Value, Error}; fn main() { let db_path = "/data/testdb"; let mut t = table::Table::...
// load_dummy_data(&mut t); println!("Get by id 3 {:?}", t.get(3)); println!("Get by id 4 {:?}", t.get(4)); println!("Get by id 33 {:?}", t.get(33)); println!("Get by id 333 {:?}, has an index of {:?}", t.get(333), t.get(333).get_id()); println!("Search index {:?}", t.secondary_indexes[0].ge...
t.create_secondary_index("X", secondary_index::key_types::F32); t.create_secondary_index("Y", secondary_index::key_types::F32);
random_line_split
main.rs
#![feature(plugin)] #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; mod primary_index; mod secondary_index; mod table; mod find; use std::fs::File; use std::io::Read; use serde_json::{Value, Error}; fn main()
println!("Get by id 333 {:?}, has an index of {:?}", t.get(333), t.get(333).get_id()); println!("Search index {:?}", t.secondary_indexes[0].get("TEST", "TEST2")); println!("{}", t.table_name); } fn load_dummy_data(t:&mut table::Table) { // load json from thing let mut s = String::new(); File...
{ let db_path = "/data/testdb"; let mut t = table::Table::new("test_table", db_path); t.create_secondary_index("Type", secondary_index::key_types::Str(20)); t.create_secondary_index("Name", secondary_index::key_types::Str(128)); t.create_secondary_index("X", secondary_index::key_types::F32); ...
identifier_body
browsingcontext.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject}; use dom::bindings::inheritance::Cast...
(&self) { self.active_document.set(None) } } #[allow(unsafe_code)] unsafe fn GetSubframeWindow(cx: *mut JSContext, proxy: HandleObject, id: HandleId) -> Option<Root<Window>> { let index = get_array_index_from_id(cx, id)...
unset_active_document
identifier_name
browsingcontext.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject}; use dom::bindings::inheritance::Cast...
#[allow(unsafe_code)] unsafe extern "C" fn set(cx: *mut JSContext, proxy: HandleObject, id: HandleId, v: HandleValue, receiver: HandleValue, res: *mut ObjectOpResult) -> ...
random_line_split
browsingcontext.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject}; use dom::bindings::inheritance::Cast...
None } #[allow(unsafe_code)] unsafe extern "C" fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: HandleObject, id: HandleId, mut desc: MutableHandle<PropertyDescriptor>) ...
{ rooted!(in(cx) let target = GetProxyPrivate(*proxy.ptr).to_object()); let win = root_from_handleobject::<Window>(target.handle()).unwrap(); let mut found = false; return win.IndexedGetter(index, &mut found); }
conditional_block
browsingcontext.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject}; use dom::bindings::inheritance::Cast...
pub fn active_window(&self) -> Root<Window> { Root::from_ref(self.active_document().window()) } pub fn frame_element(&self) -> Option<&Element> { self.frame_element.r() } pub fn window_proxy(&self) -> *mut JSObject { let window_proxy = self.reflector.get_jsobject(); ...
{ self.active_document.get() }
identifier_body
cow.rs
#![allow(unused_imports)] use geometry::prim::{Prim}; use geometry::prims::{Plane, Sphere, Triangle}; use light::light::{Light}; use light::lights::{PointLight, SphereLight}; use material::materials::{CookTorranceMaterial, FlatMaterial, PhongMaterial}; use material::Texture; use material::textures::{CheckerTexture, Cu...
skybox: None } }
{ let mut lights: Vec<Box<Light+Send+Sync>> = Vec::new(); lights.push(Box::new(SphereLight { position: Vec3 {x: 3.0, y: 10.0, z: 6.0}, color: Vec3::one(), radius: 5.0 })); let red = CookTorranceMaterial { k_a: 0.0, k_d: 0.6, k_s: 1.0, k_sg: 0.2, k_tg: 0.0, gauss_constant: 30.0, roughness: 0.1, glossiness...
identifier_body
cow.rs
#![allow(unused_imports)] use geometry::prim::{Prim}; use geometry::prims::{Plane, Sphere, Triangle}; use light::light::{Light}; use light::lights::{PointLight, SphereLight}; use material::materials::{CookTorranceMaterial, FlatMaterial, PhongMaterial}; use material::Texture; use material::textures::{CheckerTexture, Cu...
() -> Scene { let mut lights: Vec<Box<Light+Send+Sync>> = Vec::new(); lights.push(Box::new(SphereLight { position: Vec3 {x: 3.0, y: 10.0, z: 6.0}, color: Vec3::one(), radius: 5.0 })); let red = CookTorranceMaterial { k_a: 0.0, k_d: 0.6, k_s: 1.0, k_sg: 0.2, k_tg: 0.0, gauss_constant: 30.0, roughness: 0.1...
get_scene
identifier_name
cow.rs
#![allow(unused_imports)] use geometry::prim::{Prim}; use geometry::prims::{Plane, Sphere, Triangle}; use light::light::{Light}; use light::lights::{PointLight, SphereLight}; use material::materials::{CookTorranceMaterial, FlatMaterial, PhongMaterial}; use material::Texture; use material::textures::{CheckerTexture, Cu...
Scene { lights: lights, octree: octree, background: Vec3 { x: 0.3, y: 0.5, z: 0.8 }, skybox: None } }
println!("Generating octree..."); let octree = prims.into_iter().collect(); println!("Octree generated...");
random_line_split
fields.rs
//! # fields //! All necessery functions for appliying fields to json results. use serde_json::Value; use serde_json; use service::query_api::Queries; /// let only named fields array according to the query api pub fn apply(obj: &mut Value, queries: &Queries) { let ref fields = queries.fields; if fields.len() ...
#[cfg(test)] mod tests { use super::*; fn get_json() -> Value { let json_string = r#"[ { "name":"seray", "age":31, "active":true, "password":"123" }, { "name":"kamil", "...
{ let mut diff = Vec::<String>::new(); 'outer: for a_item in a { for b_item in b { if a_item == b_item { continue 'outer; } } diff.push(a_item.clone()); } diff }
identifier_body
fields.rs
//! # fields //! All necessery functions for appliying fields to json results. use serde_json::Value; use serde_json; use service::query_api::Queries; /// let only named fields array according to the query api pub fn apply(obj: &mut Value, queries: &Queries) { let ref fields = queries.fields; if fields.len() ...
i += 1; } } &mut Value::Object(ref mut map) => { let remove_keys = diff_left(map.keys(), fields); for key in &remove_keys { map.remove(key); } } _ => { //No need to handle other types } ...
{ for key in &remove_keys { obj.remove(key); } }
conditional_block
fields.rs
//! # fields //! All necessery functions for appliying fields to json results. use serde_json::Value; use serde_json; use service::query_api::Queries; /// let only named fields array according to the query api pub fn apply(obj: &mut Value, queries: &Queries) { let ref fields = queries.fields; if fields.len() ...
}, { "name":"kamil", "age":900, "active":false, "password":"333" }, { "name":"hasan", "age":25, "active":true, "password":"321" } ...
{ "name":"seray", "age":31, "active":true, "password":"123"
random_line_split
fields.rs
//! # fields //! All necessery functions for appliying fields to json results. use serde_json::Value; use serde_json; use service::query_api::Queries; /// let only named fields array according to the query api pub fn apply(obj: &mut Value, queries: &Queries) { let ref fields = queries.fields; if fields.len() ...
() -> Value { let json_string = r#"[ { "name":"seray", "age":31, "active":true, "password":"123" }, { "name":"kamil", "age":900, "active":false, "pa...
get_json
identifier_name
bloom.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/. */ //! The style bloom filter is used as an optimization when matching deep //! descendant selectors. #![deny(missi...
} } /// Return the bloom filter used properly by the `selectors` crate. pub fn filter(&self) -> &BloomFilter { &*self.filter } /// Push an element to the bloom filter, knowing that it's a child of the /// last element parent. pub fn push(&mut self, element: E) { if ...
random_line_split
bloom.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/. */ //! The style bloom filter is used as an optimization when matching deep //! descendant selectors. #![deny(missi...
(&mut self, element: E) { let mut count = 0; each_relevant_element_hash(element, |hash| { count += 1; self.filter.insert_hash(hash); self.pushed_hashes.push(hash); }); self.elements.push(PushedElement::new(element, count)); } /// Pop the last ...
push_internal
identifier_name
bloom.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/. */ //! The style bloom filter is used as an optimization when matching deep //! descendant selectors. #![deny(missi...
} impl<E: TElement> StyleBloom<E> { /// Create an empty `StyleBloom`. Because StyleBloom acquires the thread- /// local filter buffer, creating multiple live StyleBloom instances at /// the same time on the same thread will panic. // Forced out of line to limit stack frame sizes after extra inlining ...
{ // Leave the reusable bloom filter in a zeroed state. self.clear(); }
identifier_body
bloom.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/. */ //! The style bloom filter is used as an optimization when matching deep //! descendant selectors. #![deny(missi...
} /// Rebuilds the bloom filter up to the parent of the given element. pub fn rebuild(&mut self, mut element: E) { self.clear(); let mut parents_to_insert = SmallVec::<[E; 16]>::new(); while let Some(parent) = element.traversal_parent() { parents_to_insert.push(parent)...
{ for hash in self.pushed_hashes.drain() { self.filter.remove_hash(hash); } debug_assert!(self.filter.is_zeroed()); }
conditional_block
filter.rs
use expression::{Expression, SelectableExpression, NonAggregate}; use expression::expression_methods::*; use expression::predicates::And; use helper_types::Filter; use query_builder::*; use query_dsl::FilterDsl; use query_source::QuerySource; use types::Bool; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Fil...
} } impl<Source, Predicate> QuerySource for FilteredQuerySource<Source, Predicate> where Source: QuerySource, { fn from_clause(&self, out: &mut QueryBuilder) -> BuildQueryResult { self.source.from_clause(out) } } impl<Source, Predicate> UpdateTarget for FilteredQuerySource<Source, Predicate> w...
random_line_split
filter.rs
use expression::{Expression, SelectableExpression, NonAggregate}; use expression::expression_methods::*; use expression::predicates::And; use helper_types::Filter; use query_builder::*; use query_dsl::FilterDsl; use query_source::QuerySource; use types::Bool; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Fil...
fn table(&self) -> &Self::Table { self.source.table() } }
{ out.push_sql(" WHERE "); self.predicate.to_sql(out) }
identifier_body
filter.rs
use expression::{Expression, SelectableExpression, NonAggregate}; use expression::expression_methods::*; use expression::predicates::And; use helper_types::Filter; use query_builder::*; use query_dsl::FilterDsl; use query_source::QuerySource; use types::Bool; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct
<Source, Predicate> { source: Source, predicate: Predicate, } impl<Source, Predicate> FilteredQuerySource<Source, Predicate> { pub fn new(source: Source, predicate: Predicate) -> Self { FilteredQuerySource { source: source, predicate: predicate, } } } impl<Sourc...
FilteredQuerySource
identifier_name
invalid-crate-type.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 ...
// regression test for issue 11256 #![crate_type="foo"] //~ ERROR invalid `crate_type` value // Tests for suggestions (#53958) #![crate_type="statoclib"] //~^ ERROR invalid `crate_type` value //~| HELP did you mean //~| SUGGESTION staticlib #![crate_type="procmacro"] //~^ ERROR invalid `crate_type` value //~| HEL...
random_line_split
invalid-crate-type.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 ...
{ return }
identifier_body
invalid-crate-type.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 ...
() { return }
main
identifier_name
issue-2631-a.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 request<T:Copy>(req: &header_map) { let _x = copy *(copy **req.get(&~"METHOD"))[0u]; }
pub type header_map = HashMap<~str, @mut ~[@~str]>; // the unused ty param is necessary so this gets monomorphized
random_line_split
issue-2631-a.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:Copy>(req: &header_map) { let _x = copy *(copy **req.get(&~"METHOD"))[0u]; }
request
identifier_name
issue-2631-a.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let _x = copy *(copy **req.get(&~"METHOD"))[0u]; }
identifier_body
handle.rs
use std::{ffi::CString, sync::Arc}; use crate::{ core_interfaces::{WL_DISPLAY_INTERFACE, WL_REGISTRY_INTERFACE}, protocol::{same_interface, Argument, Interface, Message, ObjectInfo, ANONYMOUS_INTERFACE}, types::server::{DisconnectReason, GlobalInfo, InvalidId}, }; use smallvec::SmallVec; use super::{ ...
object_id: ObjectId, opcode: u16, arguments: SmallVec<[Argument<ObjectId>; 4]>, is_destructor: bool, created_id: Option<ObjectId>, }, Bind { object: ObjectId, client: ClientId, global: GlobalId, handler: Arc<dyn GlobalHandler<D>>, }, } ...
} enum DispatchAction<D> { Request { object: Object<Data<D>>,
random_line_split
handle.rs
use std::{ffi::CString, sync::Arc}; use crate::{ core_interfaces::{WL_DISPLAY_INTERFACE, WL_REGISTRY_INTERFACE}, protocol::{same_interface, Argument, Interface, Message, ObjectInfo, ANONYMOUS_INTERFACE}, types::server::{DisconnectReason, GlobalInfo, InvalidId}, }; use smallvec::SmallVec; use super::{ ...
(&self, id: ClientId) -> Result<Credentials, InvalidId> { let client = self.clients.get_client(id)?; Ok(client.get_credentials()) } /// Returns an iterator over all clients connected to the server. pub fn all_clients<'a>(&'a self) -> Box<dyn Iterator<Item = ClientId> + 'a> { Box::ne...
get_client_credentials
identifier_name
handle.rs
use std::{ffi::CString, sync::Arc}; use crate::{ core_interfaces::{WL_DISPLAY_INTERFACE, WL_REGISTRY_INTERFACE}, protocol::{same_interface, Argument, Interface, Message, ObjectInfo, ANONYMOUS_INTERFACE}, types::server::{DisconnectReason, GlobalInfo, InvalidId}, }; use smallvec::SmallVec; use super::{ ...
/// Retrieve the `ObjectId` for a wayland object given its protocol numerical ID pub fn object_for_protocol_id( &self, client_id: ClientId, interface: &'static Interface, protocol_id: u32, ) -> Result<ObjectId, InvalidId> { let client = self.clients.get_client(clien...
{ let client = self.clients.get_client(client_id)?; Ok(Box::new(client.all_objects())) }
identifier_body
handle.rs
use std::{ffi::CString, sync::Arc}; use crate::{ core_interfaces::{WL_DISPLAY_INTERFACE, WL_REGISTRY_INTERFACE}, protocol::{same_interface, Argument, Interface, Message, ObjectInfo, ANONYMOUS_INTERFACE}, types::server::{DisconnectReason, GlobalInfo, InvalidId}, }; use smallvec::SmallVec; use super::{ ...
else { let object_id = ObjectId { id: message.sender_id, serial: object.data.serial, interface: object.interface, client_id: client.id.clone(), }; let opcode = mes...
{ if let Some((client, global, object, handler)) = client.handle_registry_request(message, &mut self.registry) { DispatchAction::Bind { client, global, object, handler } } else { continue;...
conditional_block
registry.rs
use std::collections::HashSet; use std::collections::hash_map::HashMap; use core::{Source, SourceId, SourceMap, Summary, Dependency, PackageId, Package}; use util::{CargoResult, ChainError, Config, human, profile}; /// Source of information about a group of packages. /// /// See also `core::Source`. pub trait Registr...
pub fn overrides(mut self, summaries: Vec<Summary>) -> RegistryBuilder { self.overrides.extend(summaries.into_iter()); self } fn query_overrides(&self, dep: &Dependency) -> Vec<Summary> { self.overrides.iter() .filter(|s| s.name() == dep.name...
{ self.overrides.push(summary); self }
identifier_body
registry.rs
use std::collections::HashSet; use std::collections::hash_map::HashMap; use core::{Source, SourceId, SourceMap, Summary, Dependency, PackageId, Package}; use util::{CargoResult, ChainError, Config, human, profile}; /// Source of information about a group of packages. /// /// See also `core::Source`. pub trait Registr...
(&self, summary: Summary) -> Summary { let pair = self.locked.get(summary.source_id()).and_then(|map| { map.get(summary.name()) }).and_then(|vec| { vec.iter().find(|&&(ref id, _)| id == summary.package_id()) }); // Lock the summary's id if possible let su...
lock
identifier_name
registry.rs
use std::collections::HashSet; use std::collections::hash_map::HashMap; use core::{Source, SourceId, SourceMap, Summary, Dependency, PackageId, Package}; use util::{CargoResult, ChainError, Config, human, profile}; /// Source of information about a group of packages. /// /// See also `core::Source`. pub trait Registr...
#[cfg(test)] pub mod test { use core::{Summary, Registry, Dependency}; use util::{CargoResult}; pub struct RegistryBuilder { summaries: Vec<Summary>, overrides: Vec<Summary> } impl RegistryBuilder { pub fn new() -> RegistryBuilder { RegistryBuilder { summaries:...
random_line_split
lib.rs
//! # Half-precision conversion for Rust //! This crate uses the fast table-based f32 <-> f16 conversions given in //! "Fast Half Float Conversions" by Jeroen van der Zijp; see //! `ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf`. use std::mem::transmute; #[allow(non_camel_case_types)] #[derive(Copy, Clone...
{ for bytes in 0..65535 as u16 { let h0 = f16 { bytes: bytes }; let f: f32 = h0.into(); let h1 = f16::from(f); assert_eq!(h0, h1); } }
identifier_body
lib.rs
//! # Half-precision conversion for Rust //! This crate uses the fast table-based f32 <-> f16 conversions given in //! "Fast Half Float Conversions" by Jeroen van der Zijp; see //! `ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf`. use std::mem::transmute;
} impl PartialEq for f16 { fn eq(self: &f16, other: &f16) -> bool { return self.bytes == other.bytes; } } impl From<f32> for f16 { fn from(f: f32) -> f16 { unsafe { let base_table: *const u16 = transmute(include_bytes!("base_table.bin")); let shift_table: *const u8 ...
#[allow(non_camel_case_types)] #[derive(Copy, Clone, Debug)] pub struct f16 { pub bytes: u16,
random_line_split
lib.rs
//! # Half-precision conversion for Rust //! This crate uses the fast table-based f32 <-> f16 conversions given in //! "Fast Half Float Conversions" by Jeroen van der Zijp; see //! `ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf`. use std::mem::transmute; #[allow(non_camel_case_types)] #[derive(Copy, Clone...
() { for bytes in 0..65535 as u16 { let h0 = f16 { bytes: bytes }; let f: f32 = h0.into(); let h1 = f16::from(f); assert_eq!(h0, h1); } }
test
identifier_name
conf.rs
/* Copyright (C) 2017 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
let res = val * unit as f64; Ok(res as u64) } #[cfg(test)] mod tests { use super::*; #[test] fn test_memval_nospace() { let s = "10"; let res = 10 ; assert_eq!(Ok(10), get_memval(s)); let s = "10kb"; assert_eq!(Ok(res * KILOBYTE), get_memval(s)); ...
{ return Err("Invalid memory unit"); }
conditional_block
conf.rs
/* Copyright (C) 2017 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
() { let s = " 10 "; let res = 10 ; assert_eq!(Ok(res), get_memval(s)); let s = "10Kb "; assert_eq!(Ok(res * KILOBYTE), get_memval(s)); let s = "10mb "; assert_eq!(Ok(res * MEGABYTE), get_memval(s)); let s = " 10Gb ...
test_memval_space_end
identifier_name
conf.rs
/* Copyright (C) 2017 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
let s = CString::new(key).unwrap(); if ConfGet(s.as_ptr(), &mut vptr)!= 1 { SCLogDebug!("Failed to find value for key {}", key); return None; } } if vptr.is_null() { return None; } let value = str::from_utf8(unsafe{ CStr::from_ptr(vptr).t...
unsafe {
random_line_split
details.rs
decimal_prefix, Prefixed, Standalone, PrefixNames}; use users::{OSUsers, Users}; use users::mock::MockUsers; use super::filename; /// With the **Details** view, the output gets formatted into columns, with /// each `Column` object showing some piece of information about the file, /// such as its size, or its permi...
let name = Cell { text: filename(&file, &self.colours, true), length: file.file_name_width() }; let mut dir = None; if let Some(r) = self.recurse { if file.is_direct...
random_line_split
details.rs
_prefix, Prefixed, Standalone, PrefixNames}; use users::{OSUsers, Users}; use users::mock::MockUsers; use super::filename; /// With the **Details** view, the output gets formatted into columns, with /// each `Column` object showing some piece of information about the file, /// such as its size, or its permissions. ...
Cell::paint(self.colours.date, &format.format(&date, &self.time)) } fn render_git_status(&self, git: f::Git) -> Cell { Cell { text: ANSIStrings(&[ self.render_git_char(git.staged), self.render_git_char(git.unstaged) ]).to_string(), length...
.len(), } } } } else { Cell::paint(self.colours.punctuation, "-") } } fn render_time(&self, timestamp: f::Time) -> Cell { let date = self.tz.at(LocalDateTime::at(timestamp.0)); let format = if date.year() == se...
conditional_block
details.rs
_prefix, Prefixed, Standalone, PrefixNames}; use users::{OSUsers, Users}; use users::mock::MockUsers; use super::filename; /// With the **Details** view, the output gets formatted into columns, with /// each `Column` object showing some piece of information about the file, /// such as its size, or its permissions. ...
lish()), tz: TimeZone::localtime().unwrap(), users: OSUsers::empty_cache(), colours: colours, current_year: LocalDateTime::now().year(), } } } impl<U> Table<U> where U: Users { /// Add a dummy "header" row to the table, which contai...
ic::eng
identifier_name
details.rs
::Error, depth: usize, last: bool, path: Option<PathBuf>) { let error_message = match path { Some(path) => format!("<{}: {}>", path.display(), error), None => format!("<{}>", error), }; let row = Row { depth: depth, cells: None, ...
identifier_body
cabi_powerpc.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...
(ccx: &CrateContext, ty: Type) -> Type { let size = ty_size(ty) * 8; Type::struct_(ccx, coerce_to_int(ccx, size).as_slice(), false) } pub fn compute_abi_info(ccx: &CrateContext, atys: &[Type], rty: Type, ret_def: bool) -> FnType { let ...
struct_ty
identifier_name
cabi_powerpc.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...
}
{ let ret_ty = if ret_def { classify_ret_ty(ccx, rty) } else { ArgType::direct(Type::void(ccx), None, None, None) }; let sret = ret_ty.is_indirect(); let mut arg_tys = Vec::new(); let mut offset = if sret { 4 } else { 0 }; for aty in atys.iter() { let ty = classify_...
identifier_body