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
ast_clone.rs
use std::str::FromStr; use { proc_macro2::{Span, TokenStream}, syn::{ self, Data, DataEnum, DataStruct, DeriveInput, Field, Fields, FieldsNamed, FieldsUnnamed, Generics, Ident, Variant, }, }; use crate::{ attr, shared::{map_lifetimes, map_type_params, split_for_impl}, }; pub fn de...
(ident: &Ident, _tag: usize, variant: &Variant) -> TokenStream { let variant_ident = &variant.ident; // depending on the type of the variant we need to generate different constructors // for the enum match &variant.fields { Fields::Unit => quote! { #ident::#variant_ident => #ident::...
gen_variant_match
identifier_name
mod.rs
use std::iter; use super::super::fundamentals::stacks_and_queues::bag::Bag; use super::super::fundamentals::stacks_and_queues::{Stack, Queue}; use super::super::fundamentals::stacks_and_queues::linked_stack; use super::super::fundamentals::stacks_and_queues::resizing_array_queue::ResizingArrayQueue; #[derive(Clone, De...
pub fn path_to(&self, v: usize) -> Option<Vec<usize>> { if!self.has_path_to(v) { None } else { let mut path = linked_stack::LinkedStack::new(); let mut x = v; while x!= self.s { path.push(x); x = self.edge_to[x].unwrap...
{ self.marked[v] }
identifier_body
mod.rs
use std::iter; use super::super::fundamentals::stacks_and_queues::bag::Bag; use super::super::fundamentals::stacks_and_queues::{Stack, Queue}; use super::super::fundamentals::stacks_and_queues::linked_stack; use super::super::fundamentals::stacks_and_queues::resizing_array_queue::ResizingArrayQueue; #[derive(Clone, De...
} } fn bfs(&mut self, s: usize) { let mut q = ResizingArrayQueue::new(); q.enqueue(s); self.marked[s] = true; while!q.is_empty() { let v = q.dequeue().unwrap(); for w in self.graph.adj(v) { if!self.marked[w] { ...
{ self.dfs(w); self.edge_to[w] = Some(v); }
conditional_block
mod.rs
use std::iter; use super::super::fundamentals::stacks_and_queues::bag::Bag; use super::super::fundamentals::stacks_and_queues::{Stack, Queue}; use super::super::fundamentals::stacks_and_queues::linked_stack; use super::super::fundamentals::stacks_and_queues::resizing_array_queue::ResizingArrayQueue; #[derive(Clone, De...
(&self, v: usize) -> usize { self.validate_vertex(v); self.adj[v].len() } pub fn max_degree(&self) -> usize { (0.. self.v()).map(|v| self.degree(v)).max().unwrap_or(0) } pub fn average_degree(&self) -> f64 { // (0.. self.v()).map(|v| self.degree(v)).sum::<usize>() as f6...
degree
identifier_name
mod.rs
use std::iter; use super::super::fundamentals::stacks_and_queues::bag::Bag; use super::super::fundamentals::stacks_and_queues::{Stack, Queue}; use super::super::fundamentals::stacks_and_queues::linked_stack; use super::super::fundamentals::stacks_and_queues::resizing_array_queue::ResizingArrayQueue; #[derive(Clone, De...
} pub fn add_edge(&mut self, v: usize, w: usize) { self.validate_vertex(v); self.validate_vertex(w); self.e += 1; self.adj[v].add(w); self.adj[w].add(v); } // FIXME: should this be a global function pub fn degree(&self, v: usize) -> usize { self.val...
self.e
random_line_split
applicable_declarations.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/. */ //! Applicable declarations management. use properties::PropertyDeclarationBlock; use rule_tree::{CascadeLevel, S...
}
random_line_split
applicable_declarations.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/. */ //! Applicable declarations management. use properties::PropertyDeclarationBlock; use rule_tree::{CascadeLevel, S...
fn order(&self) -> u32 { self.0 & SOURCE_ORDER_MASK } fn level(&self) -> CascadeLevel { unsafe { // Transmute rather than shifting so that we're sure the compiler // emits a simple byte-aligned load. let as_bytes: [u8; 4] = mem::transmute(self.0); ...
{ let mut bits = ::std::cmp::min(source_order, SOURCE_ORDER_MAX); bits |= (cascade_level as u8 as u32) << SOURCE_ORDER_BITS; SourceOrderAndCascadeLevel(bits) }
identifier_body
applicable_declarations.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/. */ //! Applicable declarations management. use properties::PropertyDeclarationBlock; use rule_tree::{CascadeLevel, S...
(&self) -> u32 { self.order_and_level.order() } /// Returns the cascade level of the block. #[inline] pub fn level(&self) -> CascadeLevel { self.order_and_level.level() } /// Convenience method to consume self and return the source alongside the /// level. #[inline] ...
source_order
identifier_name
os_str.rs
// // 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 to those terms. /// The underlyi...
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT.
random_line_split
os_str.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(self.as_slice(), formatter) } } impl fmt::Display for Buf { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(self.as_slice(), formatter) } } impl IntoInner<Vec<u8>> for Buf { fn int...
fmt
identifier_name
os_str.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn push_slice(&mut self, s: &Slice) { self.inner.extend_from_slice(&s.inner) } #[inline] pub fn into_box(self) -> Box<Slice> { unsafe { mem::transmute(self.inner.into_boxed_slice()) } } #[inline] pub fn from_box(boxed: Box<Slice>) -> Buf { let inner: Box<[u8]>...
{ String::from_utf8(self.inner).map_err(|p| Buf { inner: p.into_bytes() } ) }
identifier_body
presale.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
use ethcore::account_provider::{AccountProvider, AccountProviderSettings}; use helpers::{password_prompt, password_from_file}; use params::SpecType; #[derive(Debug, PartialEq)] pub struct ImportWallet { pub iterations: u32, pub path: String, pub spec: SpecType, pub wallet_path: String, pub password_file: Option<S...
random_line_split
presale.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
{ pub iterations: u32, pub path: String, pub spec: SpecType, pub wallet_path: String, pub password_file: Option<String>, } pub fn execute(cmd: ImportWallet) -> Result<String, String> { let password: String = match cmd.password_file { Some(file) => password_from_file(file)?, None => password_prompt()?, }; ...
ImportWallet
identifier_name
presale.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
{ let password: String = match cmd.password_file { Some(file) => password_from_file(file)?, None => password_prompt()?, }; let dir = Box::new(RootDiskDirectory::create(cmd.path).unwrap()); let secret_store = Box::new(EthStore::open_with_iterations(dir, cmd.iterations).unwrap()); let acc_provider = AccountProv...
identifier_body
last-use-in-cap-clause.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { assert_eq!(foo()(), 22); }
main
identifier_name
last-use-in-cap-clause.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() { assert_eq!(foo()(), 22); }
{ let k = ~22; let _u = A {a: k.clone()}; let result: @fn() -> int = || 22; result }
identifier_body
unboxed-closures-blanket-fn.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn c<F:Fn() -> i32>(f: &F) -> i32 { a(f) } fn main() { let z: isize = 7; let x = b(&|| 22); assert_eq!(x, 22); let x = c(&|| 22); assert_eq!(x, 22); }
random_line_split
unboxed-closures-blanket-fn.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn b(f: &Fn() -> i32) -> i32 { a(f) } fn c<F:Fn() -> i32>(f: &F) -> i32 { a(f) } fn main() { let z: isize = 7; let x = b(&|| 22); assert_eq!(x, 22); let x = c(&|| 22); assert_eq!(x, 22); }
{ f() }
identifier_body
unboxed-closures-blanket-fn.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 ...
(f: &Fn() -> i32) -> i32 { a(f) } fn c<F:Fn() -> i32>(f: &F) -> i32 { a(f) } fn main() { let z: isize = 7; let x = b(&|| 22); assert_eq!(x, 22); let x = c(&|| 22); assert_eq!(x, 22); }
b
identifier_name
TestAcosh.rs
/* * Copyright (C) 2014 The Android Open Source Project * * 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 *
* distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma version(1) #pragma rs java_package_name(android.renderscr...
* Unless required by applicable law or agreed to in writing, software
random_line_split
lib.rs
pub struct RailFence { rails: usize, } impl RailFence { pub fn new(rails: u32) -> RailFence
pub fn encode(&self, text: &str) -> String { let mut rails = vec![String::new(); self.rails]; let indexes = (0..self.rails).chain((1..self.rails - 1).rev()).cycle(); text.chars() .zip(indexes) .for_each(|(c, i)| rails[i as usize].push(c)); rails.concat() ...
{ RailFence { rails: rails as usize, } }
identifier_body
lib.rs
pub struct RailFence { rails: usize, } impl RailFence { pub fn new(rails: u32) -> RailFence { RailFence { rails: rails as usize, } } pub fn
(&self, text: &str) -> String { let mut rails = vec![String::new(); self.rails]; let indexes = (0..self.rails).chain((1..self.rails - 1).rev()).cycle(); text.chars() .zip(indexes) .for_each(|(c, i)| rails[i as usize].push(c)); rails.concat() } pub fn deco...
encode
identifier_name
lib.rs
pub struct RailFence { rails: usize, } impl RailFence { pub fn new(rails: u32) -> RailFence { RailFence { rails: rails as usize, } } pub fn encode(&self, text: &str) -> String { let mut rails = vec![String::new(); self.rails]; let indexes = (0..self.rails).c...
} }
text.iter().collect::<String>()
random_line_split
main.rs
use std::str::FromStr; use std::io::Read; use std::fs::File; // Input types and decoding // #[derive(Debug, Clone, Copy)] enum Rotation { Left = 1, Forward = 0, Right = -1, } #[derive(Debug)] struct Step { rotation: Rotation, distance: i32, } impl FromStr for Rotation { type Err = String; ...
} impl FromStr for Step { type Err = String; fn from_str(s: &str) -> Result<Self, Self::Err> { let (dir, dist) = s.split_at(1); Ok(Step { rotation: Rotation::from_str(dir).unwrap(), distance: i32::from_str(dist.trim()).unwrap(), }) } } // Common helpers // ...
{ match s.chars().next() { Some('L') => Ok(Rotation::Left), Some('R') => Ok(Rotation::Right), c => Err(format!("Unknown entry: {:?}", c)), } }
identifier_body
main.rs
use std::str::FromStr; use std::io::Read; use std::fs::File; // Input types and decoding // #[derive(Debug, Clone, Copy)] enum Rotation { Left = 1, Forward = 0, Right = -1, } #[derive(Debug)] struct Step { rotation: Rotation, distance: i32, } impl FromStr for Rotation { type Err = String; ...
let (x, y) = match int_dir { 0 => (pos.x, pos.y + step.distance), 1 => (pos.x - step.distance, pos.y), 2 => (pos.x, pos.y - step.distance), 3 => (pos.x + step.distance, pos.y), _ => panic!("Unknown direction {}", int_dir), }; Position {direction: int_dir, x: x, y: y}...
} fn walk(pos: Position, step: Step) -> Position { let int_dir = (pos.direction + step.rotation as i8 + 4) % 4;
random_line_split
main.rs
use std::str::FromStr; use std::io::Read; use std::fs::File; // Input types and decoding // #[derive(Debug, Clone, Copy)] enum Rotation { Left = 1, Forward = 0, Right = -1, } #[derive(Debug)] struct Step { rotation: Rotation, distance: i32, } impl FromStr for Rotation { type Err = String; ...
(&self) -> i32 { self.x.abs() + self.y.abs() } } fn walk(pos: Position, step: Step) -> Position { let int_dir = (pos.direction + step.rotation as i8 + 4) % 4; let (x, y) = match int_dir { 0 => (pos.x, pos.y + step.distance), 1 => (pos.x - step.distance, pos.y), 2 => (pos.x, ...
distance
identifier_name
seg_queue.rs
//! Unrolled Michael—Scott queues. use std::cell::UnsafeCell; use std::ops::Range; use std::sync::atomic::{self, AtomicBool, AtomicUsize}; use std::{ptr, mem, fmt, cmp}; use epoch::{self, Atomic}; /// The maximal number of entries in a segment. const SEG_SIZE: usize = 32; /// A segment. /// /// Segments are like a ...
{ enum LR { Left(i64), Right(i64), } let q: Arc<SegQueue<LR>> = Arc::new(SegQueue::new()); let mut v = Vec::new(); for _t in 0..2 { let qc = q.clone(); v.push(thread::spawn(move || for i in CONC_COUNT - 1..CONC_COUNT { ...
eue_dequeue_many_mpmc()
identifier_name
seg_queue.rs
//! Unrolled Michael—Scott queues. use std::cell::UnsafeCell; use std::ops::Range; use std::sync::atomic::{self, AtomicBool, AtomicUsize}; use std::{ptr, mem, fmt, cmp}; use epoch::{self, Atomic}; /// The maximal number of entries in a segment. const SEG_SIZE: usize = 32; /// A segment. /// /// Segments are like a ...
} } let mut vl2 = vl.clone(); let mut vr2 = vr.clone(); vl2.sort(); vr2.sort(); assert_eq!(vl, vl2); assert_eq!(vr, vr2); })); } for i in v { i.j...
for _i in 0..CONC_COUNT { match qc.dequeue() { Some(LR::Left(x)) => vl.push(x), Some(LR::Right(x)) => vr.push(x), _ => {}
random_line_split
seg_queue.rs
//! Unrolled Michael—Scott queues. use std::cell::UnsafeCell; use std::ops::Range; use std::sync::atomic::{self, AtomicBool, AtomicUsize}; use std::{ptr, mem, fmt, cmp}; use epoch::{self, Atomic}; /// The maximal number of entries in a segment. const SEG_SIZE: usize = 32; /// A segment. /// /// Segments are like a ...
// Write that data. unsafe { // Obtain the cell. let cell = (*tail).data[i].get(); // Write the data into the cell. ptr::write(&mut *cell, elem); // Now that the cell is initialized, we can set the valid flag. ...
continue; }
conditional_block
term.rs
pub static GREEN: Color = 2u16; pub static YELLOW: Color = 3u16; pub static BLUE: Color = 4u16; pub static MAGENTA: Color = 5u16; pub static CYAN: Color = 6u16; pub static WHITE: Color = 7u16; pub static BRIGHT_BLACK: Color = 8u16; pub static BRIGHT_RED: Color = 9u16; ...
pub mod color { pub type Color = u16; pub static BLACK: Color = 0u16; pub static RED: Color = 1u16;
random_line_split
error.rs
pub use crate::api::naming::error as naming; pub use crate::rosxmlrpc::error as rosxmlrpc; pub use crate::rosxmlrpc::ResponseError; pub use crate::tcpros::error as tcpros; error_chain::error_chain! { foreign_links { Io(::std::io::Error); FromUTF8(::std::string::FromUtf8Error); Response(Resp...
error_chain::error_chain! { errors { SystemFail(message: String) { description("Failure to handle API call") display("Failure to handle API call: {}", message) } BadData(message: String) { description("Bad parameters provide...
pub mod api {
random_line_split
rest_api.rs
use db; use hyper::header::Authorization; use iron; use iron::prelude::*; use iron::status; use iron::status::Status; use router::Router; use serde_json; use std::error::Error; use std::fmt; use std::io::Read; use utils::json_response; pub fn rest_router() -> Router { let mut router = Router::new(); router.ge...
fn _tile_post(req: &mut Request) -> Result<(Status, String), Box<Error>> { let (dashboard_name, tile_id) = { let router = req.extensions.get::<Router>().unwrap(); ( router.find("dashboard_name").unwrap(), router.find("tile_id").unwrap(), ) }; let request_tok...
{ let (dashboard_name, tile_id) = { let router = req.extensions.get::<Router>().unwrap(); ( router.find("dashboard_name").unwrap(), router.find("tile_id").unwrap(), ) }; let db = match db::Db::new() { Err(e) => return json_response(Status::InternalSer...
identifier_body
rest_api.rs
use db; use hyper::header::Authorization; use iron; use iron::prelude::*; use iron::status; use iron::status::Status; use router::Router; use serde_json; use std::error::Error; use std::fmt; use std::io::Read; use utils::json_response; pub fn rest_router() -> Router { let mut router = Router::new(); router.ge...
(req: &mut Request) -> IronResult<Response> { let (dashboard_name, tile_id) = { let router = req.extensions.get::<Router>().unwrap(); ( router.find("dashboard_name").unwrap(), router.find("tile_id").unwrap(), ) }; let db = match db::Db::new() { Err(e)...
tile_get
identifier_name
rest_api.rs
use db; use hyper::header::Authorization; use iron; use iron::prelude::*; use iron::status; use iron::status::Status; use router::Router; use serde_json; use std::error::Error; use std::fmt; use std::io::Read; use utils::json_response; pub fn rest_router() -> Router { let mut router = Router::new(); router.ge...
} } } pub fn tile_get(req: &mut Request) -> IronResult<Response> { let (dashboard_name, tile_id) = { let router = req.extensions.get::<Router>().unwrap(); ( router.find("dashboard_name").unwrap(), router.find("tile_id").unwrap(), ) }; let db = ma...
status::Forbidden, )) } Some(_) => Ok(()),
random_line_split
add.rs
use anyhow::Result; use clap::{App, ArgMatches}; use rhq::Workspace; use std::{env, path::PathBuf}; #[derive(Debug)] pub struct AddCommand { paths: Option<Vec<PathBuf>>, verbose: bool, } impl AddCommand { pub fn
<'a, 'b: 'a>(app: App<'a, 'b>) -> App<'a, 'b> { app.about("Add existed repositories into management") .arg_from_usage("[paths]... 'Location of local repositories'") .arg_from_usage("-v, --verbose 'Use verbose output'") } pub fn from_matches(m: &ArgMatches) -> AddCommand { ...
app
identifier_name
add.rs
use anyhow::Result; use clap::{App, ArgMatches}; use rhq::Workspace; use std::{env, path::PathBuf}; #[derive(Debug)] pub struct AddCommand { paths: Option<Vec<PathBuf>>, verbose: bool, } impl AddCommand { pub fn app<'a, 'b: 'a>(app: App<'a, 'b>) -> App<'a, 'b> { app.about("Add existed repositories...
let mut workspace = Workspace::new()?.verbose_output(self.verbose); for path in paths { workspace.add_repository_if_exists(&path)?; } workspace.save_cache()?; Ok(()) } }
pub fn run(self) -> Result<()> { let paths = self .paths .unwrap_or_else(|| vec![env::current_dir().expect("env::current_dir()")]);
random_line_split
add.rs
use anyhow::Result; use clap::{App, ArgMatches}; use rhq::Workspace; use std::{env, path::PathBuf}; #[derive(Debug)] pub struct AddCommand { paths: Option<Vec<PathBuf>>, verbose: bool, } impl AddCommand { pub fn app<'a, 'b: 'a>(app: App<'a, 'b>) -> App<'a, 'b> { app.about("Add existed repositories...
pub fn run(self) -> Result<()> { let paths = self .paths .unwrap_or_else(|| vec![env::current_dir().expect("env::current_dir()")]); let mut workspace = Workspace::new()?.verbose_output(self.verbose); for path in paths { workspace.add_repository_if_exists(...
{ AddCommand { paths: m.values_of("paths").map(|s| s.map(PathBuf::from).collect()), verbose: m.is_present("verbose"), } }
identifier_body
raytracer_pinhole.rs
#![feature(box_syntax)] use std::io::prelude::*; use std::fs::File; use std::ops::{Add, Sub, Mul}; use std::num::Float; use std::default::Default; #[derive(Debug, Copy, Clone, Default)] struct Vector { x: f64, y: f64, z: f64 } #[derive(Debug, Copy, Clone, Default)] struct Ray { o: Vector, d: Vect...
if (b - det) > eps { return b-det; } if (b + det) > eps { return b+det; } return 0.0; } } static LIGHT: Ray = Ray { o: Vector{x: 0.0, y: 0.0, z: 0.0 }, d: Vector{x: 0.0, y: 0.0, z: 1.0 } }; impl<'a> ShapeRef for &'a Sphere { fn color(self, r...
{ det = det.sqrt(); }
conditional_block
raytracer_pinhole.rs
#![feature(box_syntax)] use std::io::prelude::*; use std::fs::File; use std::ops::{Add, Sub, Mul}; use std::num::Float; use std::default::Default; #[derive(Debug, Copy, Clone, Default)] struct Vector { x: f64, y: f64, z: f64 } #[derive(Debug, Copy, Clone, Default)] struct Ray { o: Vector, d: Vect...
(self, b: Vector) -> Vector { Vector{x: self.y * b.z - self.z * b.y, y: self.z * b.x - self.x * b.z, z: self.x * b.y - self.y * b.x} } fn dot(&self, other: &Vector) -> f64 { (*self).x * (*other).x + (*self).y * (*other).y + (*self).z * (*other).z } } fn clamp(x: f64) -> f64 { if x < 0....
cross
identifier_name
raytracer_pinhole.rs
#![feature(box_syntax)] use std::io::prelude::*; use std::fs::File; use std::ops::{Add, Sub, Mul}; use std::num::Float; use std::default::Default; #[derive(Debug, Copy, Clone, Default)] struct Vector { x: f64, y: f64, z: f64 } #[derive(Debug, Copy, Clone, Default)] struct Ray { o: Vector, d: Vect...
let mut cam: Camera = Default::default(); cam.eye.o = Vector {x: 0.0, y: 0.0, z: 1.0}; cam.eye.d = Vector {x: 0.0, y: 0.0, z: -1.0}; cam.up = Vector{x: 0.0, y: 1.0, z: 0.0}; let mut output = box [[Vector{x: 0.0, y: 0.0, z: 0.0}; WIDTH]; HEIGHT]; for i in 0..HEIGHT { for j in 0..WIDTH { ...
const HEIGHT: usize = 500; fn main() { println!("Raytracing...");
random_line_split
editfns.rs
//! Lisp functions pertaining to editing. use libc::{c_uchar, ptrdiff_t}; use remacs_macros::lisp_fn; use remacs_sys::{EmacsInt, Fadd_text_properties, Fcons, Fcopy_sequence, Finsert_char, Qinteger_or_marker_p, Qmark_inactive, Qnil}; use remacs_sys::{buf_charpos_to_bytepos, globals, set_point_both}; ...
/// Return the integer value of point or mark, whichever is larger. #[lisp_fn] fn region_end() -> LispObject { region_limit(false) } /// Return this buffer's mark, as a marker object. /// Watch out! Moving this marker changes the mark position. /// If you set the marker not to point anywhere, the buffer will ha...
{ region_limit(true) }
identifier_body
editfns.rs
//! Lisp functions pertaining to editing. use libc::{c_uchar, ptrdiff_t}; use remacs_macros::lisp_fn; use remacs_sys::{EmacsInt, Fadd_text_properties, Fcons, Fcopy_sequence, Finsert_char, Qinteger_or_marker_p, Qmark_inactive, Qnil}; use remacs_sys::{buf_charpos_to_bytepos, globals, set_point_both}; ...
} /// Return the byte position for character position POSITION. /// If POSITION is out of range, the value is nil. #[lisp_fn] pub fn position_bytes(position: LispObject) -> LispObject { let pos = position.as_fixnum_coerce_marker_or_error() as ptrdiff_t; let cur_buf = ThreadState::current_buffer(); if pos ...
wrong_type!(Qinteger_or_marker_p, position) }; position
random_line_split
editfns.rs
//! Lisp functions pertaining to editing. use libc::{c_uchar, ptrdiff_t}; use remacs_macros::lisp_fn; use remacs_sys::{EmacsInt, Fadd_text_properties, Fcons, Fcopy_sequence, Finsert_char, Qinteger_or_marker_p, Qmark_inactive, Qnil}; use remacs_sys::{buf_charpos_to_bytepos, globals, set_point_both}; ...
() -> LispObject { region_limit(false) } /// Return this buffer's mark, as a marker object. /// Watch out! Moving this marker changes the mark position. /// If you set the marker not to point anywhere, the buffer will have no mark. #[lisp_fn] fn mark_marker() -> LispObject { ThreadState::current_buffer().mark...
region_end
identifier_name
editfns.rs
//! Lisp functions pertaining to editing. use libc::{c_uchar, ptrdiff_t}; use remacs_macros::lisp_fn; use remacs_sys::{EmacsInt, Fadd_text_properties, Fcons, Fcopy_sequence, Finsert_char, Qinteger_or_marker_p, Qmark_inactive, Qnil}; use remacs_sys::{buf_charpos_to_bytepos, globals, set_point_both}; ...
} else { let p = pos.as_fixnum_coerce_marker_or_error() as ptrdiff_t; if p < buffer_ref.begv || p >= buffer_ref.zv() { LispObject::constant_nil() } else { let pos_byte = unsafe { buf_charpos_to_bytepos(buffer_ref.as_ptr(), p) }; LispObject::from_natnum(bu...
{ LispObject::from_natnum(buffer_ref.fetch_char(pos_byte) as EmacsInt) }
conditional_block
ast.rs
use std::fmt::{Debug, Error, Formatter}; pub enum Expr { Number(i32), Op(Box<Expr>, Opcode, Box<Expr>), Error, } #[derive(Copy, Clone)]
Div, Add, Sub, } impl Debug for Expr { fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> { use self::Expr::*; match *self { Number(n) => write!(fmt, "{:?}", n), Op(ref l, op, ref r) => write!(fmt, "({:?} {:?} {:?})", l, op, r), Error => write!(f...
pub enum Opcode { Mul,
random_line_split
ast.rs
use std::fmt::{Debug, Error, Formatter}; pub enum Expr { Number(i32), Op(Box<Expr>, Opcode, Box<Expr>), Error, } #[derive(Copy, Clone)] pub enum Opcode { Mul, Div, Add, Sub, } impl Debug for Expr { fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> { use self::Expr::*; ...
}
{ use self::Opcode::*; match *self { Mul => write!(fmt, "*"), Div => write!(fmt, "/"), Add => write!(fmt, "+"), Sub => write!(fmt, "-"), } }
identifier_body
ast.rs
use std::fmt::{Debug, Error, Formatter}; pub enum Expr { Number(i32), Op(Box<Expr>, Opcode, Box<Expr>), Error, } #[derive(Copy, Clone)] pub enum Opcode { Mul, Div, Add, Sub, } impl Debug for Expr { fn
(&self, fmt: &mut Formatter) -> Result<(), Error> { use self::Expr::*; match *self { Number(n) => write!(fmt, "{:?}", n), Op(ref l, op, ref r) => write!(fmt, "({:?} {:?} {:?})", l, op, r), Error => write!(fmt, "error"), } } } impl Debug for Opcode { f...
fmt
identifier_name
command.rs
// Copyright 2017 Google Inc. // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
() { let tokens = parse_cmd(r#"cmd 1 2 3 " 4" {}"#, &["5"]).unwrap(); assert_eq!("cmd", tokens[0]); assert_eq!("1", tokens[1]); assert_eq!("2", tokens[2]); assert_eq!("3", tokens[3]); assert_eq!("\n 4", tokens[4]); assert_eq!("5", tokens[5]); } #[test] fn te...
test_parse_cmd
identifier_name
command.rs
// Copyright 2017 Google Inc. // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
impl Token { fn into_string(self, args: &mut Iterator<Item = &str>) -> Result<String, VarError> { let mut token = String::from(""); for part in self.0 { match part { TokenPart::Bare(s) => token += &s, TokenPart::Placeholder => ...
EnvVariable(String), } struct Token(Vec<TokenPart>);
random_line_split
command.rs
// Copyright 2017 Google Inc. // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
/// Creates a new command from `format` and `args`. /// The function is invoked from `cmd!` macro internally. pub fn new_command(format: &str, args: &[&str]) -> Result<ShellCommand, VarError> { let vec = parse_cmd(format, args)?; let mut command = Command::new(&vec[0]); if vec.len() > 1 { ...
{ let tokens = match command(format) { IResult::Done(_, result) => result, IResult::Error(error) => panic!("Error {:?}", error), IResult::Incomplete(needed) => panic!("Needed {:?}", needed) }; let args = args.iter().map(|a| *a).collect::<Vec<_>>(); let mut args = args.into_iter()...
identifier_body
document_rule.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/. */ //! [@document rules](https://www.w3.org/TR/2012/WD-css3-conditional-20120911/#at-document) //! initially in CSS C...
/// function or a final substring of the host component is a /// period (U+002E) immediately followed by the argument to the /// ‘domain()’ function. Domain(String), /// Regular expression matching function. It evaluates to true /// whenever the regular expression matches the entirety of the URL...
/// host subcomponent is exactly the argument to the ‘domain()’
random_line_split
document_rule.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/. */ //! [@document rules](https://www.w3.org/TR/2012/WD-css3-conditional-20120911/#at-document) //! initially in CSS C...
input.try(|input| input.expect_function_matching("regexp")).is_ok() { input.parse_nested_block(|input| { Ok(UrlMatchingFunction::RegExp(input.expect_string()?.into_owned())) }) } else if let Ok(url) = input.try(|input| SpecifiedUrl::parse(context, input)) { O...
parse_quoted_or_unquoted_string!(input, UrlMatchingFunction::Domain) } else if
conditional_block
document_rule.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/. */ //! [@document rules](https://www.w3.org/TR/2012/WD-css3-conditional-20120911/#at-document) //! initially in CSS C...
} impl DeepCloneWithLock for DocumentRule { /// Deep clones this DocumentRule. fn deep_clone_with_lock( &self, lock: &SharedRwLock, guard: &SharedRwLockReadGuard, ) -> Self { let rules = self.rules.read_with(guard); DocumentRule { condition: self.conditi...
{ try!(dest.write_str("@-moz-document ")); try!(self.condition.to_css(dest)); try!(dest.write_str(" {")); for rule in self.rules.read_with(guard).0.iter() { try!(dest.write_str(" ")); try!(rule.to_css(guard, dest)); } dest.write_str(" }") }
identifier_body
document_rule.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/. */ //! [@document rules](https://www.w3.org/TR/2012/WD-css3-conditional-20120911/#at-document) //! initially in CSS C...
{ /// The parsed condition pub condition: DocumentCondition, /// Child rules pub rules: Arc<Locked<CssRules>>, /// The line and column of the rule's source code. pub source_location: SourceLocation, } impl ToCssWithGuard for DocumentRule { fn to_css<W>(&self, guard: &SharedRwLockReadGuard,...
DocumentRule
identifier_name
issue-4264.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 ...
pub type Foo = [int,..3u]; pub struct Bar { pub x: [int,..3u] } pub struct TupleBar([int,..4u]); pub enum Baz { BazVariant([int,..5u]) } pub fn id<T>(x: T) -> T { x } pub fn use_id() { let _ = id::<[int,..3u]>([1,2,3]); } fn main() {}
random_line_split
issue-4264.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 ...
pub fn use_id() { let _ = id::<[int,..3u]>([1,2,3]); } fn main() {}
{ x }
identifier_body
issue-4264.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 ...
([int,..4u]); pub enum Baz { BazVariant([int,..5u]) } pub fn id<T>(x: T) -> T { x } pub fn use_id() { let _ = id::<[int,..3u]>([1,2,3]); } fn main() {}
TupleBar
identifier_name
mod.rs
/* convert module * === * */ use std::fmt; use std::fmt::{Display, Formatter}; use std::rc::Rc; use ::runtime::units::{Unit, UnitDatabase}; use ::runtime::parse::ConvPrimitive; use ::utils::{NO_PREFIX, prefix_as_num}; #[derive(Debug)] pub enum ConversionError { OutOfRange(bool), // input or output value n...
{ Short, Desc, Long, } impl Display for ConversionFmt { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match *self { ConversionFmt::Short => write!(f, "s: short / value only"), ConversionFmt::Desc => write!(f, "d: descriptive / value and output unit"), Co...
ConversionFmt
identifier_name
mod.rs
/* convert module * === * */ use std::fmt; use std::fmt::{Display, Formatter}; use std::rc::Rc; use ::runtime::units::{Unit, UnitDatabase}; use ::runtime::parse::ConvPrimitive; use ::utils::{NO_PREFIX, prefix_as_num}; #[derive(Debug)] pub enum ConversionError { OutOfRange(bool), // input or output value n...
// S1 let mut output_val = conversion.input * prefix_as_num( conversion.from_prefix) .unwrap().powi(from_dims); // S2 if from_is_inverse { output_val = 1.0 / output_val; } output_val *= from_conv_factor; // S3 output_val += from_zero_point - to_zero_point; // S4 ...
random_line_split
static-relocation-model.rs
// revisions: x64 A64 ppc64le // assembly-output: emit-asm // [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=static // [x64] needs-llvm-components: x86 // [A64] compile-flags: --target aarch64-unknown-linux-gnu -Crelocation-model=static // [A64] needs-llvm-components: aarch64 // [ppc64le] com...
fn chaenomeles(); } // CHECK-LABEL: banana: // x64: movb chaenomeles{{(\(%[a-z0-9]+\))?}}, %{{[a-z0-9]+}} // A64: adrp [[REG:[a-z0-9]+]], chaenomeles // A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG]], :lo12:chaenomeles] #[no_mangle] pub fn banana() -> u8 { unsafe { *(chaenomeles as *mut u8) ...
pub static PIERIS: u8 = 42; extern "C" { static EXOCHORDA: *mut u8;
random_line_split
static-relocation-model.rs
// revisions: x64 A64 ppc64le // assembly-output: emit-asm // [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=static // [x64] needs-llvm-components: x86 // [A64] compile-flags: --target aarch64-unknown-linux-gnu -Crelocation-model=static // [A64] needs-llvm-components: aarch64 // [ppc64le] com...
() -> &'static u8 { &PIERIS } // For ppc64 we need to make sure to generate TOC entries even with the static relocation model // ppc64le:.tc chaenomeles[TC],chaenomeles // ppc64le:.tc banana[TC],banana // ppc64le:.tc EXOCHORDA[TC],EXOCHORDA // ppc64le:.tc PIERIS[TC],PIERIS
orange
identifier_name
static-relocation-model.rs
// revisions: x64 A64 ppc64le // assembly-output: emit-asm // [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=static // [x64] needs-llvm-components: x86 // [A64] compile-flags: --target aarch64-unknown-linux-gnu -Crelocation-model=static // [A64] needs-llvm-components: aarch64 // [ppc64le] com...
// For ppc64 we need to make sure to generate TOC entries even with the static relocation model // ppc64le:.tc chaenomeles[TC],chaenomeles // ppc64le:.tc banana[TC],banana // ppc64le:.tc EXOCHORDA[TC],EXOCHORDA // ppc64le:.tc PIERIS[TC],PIERIS
{ &PIERIS }
identifier_body
unsized.rs
// compile-flags:-g // === GDB TESTS =================================================================================== // gdb-command:run // gdb-command:print *a
// gdb-command:print *b // gdbg-check:$2 = {value = {value = [...] "abc"}} // gdbr-check:$2 = unsized::Foo<unsized::Foo<[u8]>> {value: unsized::Foo<[u8]> {value: [...]}} #![feature(omit_gdb_pretty_printer_section)] #![omit_gdb_pretty_printer_section] struct Foo<T:?Sized> { value: T } fn main() { let foo: F...
// gdbg-check:$1 = {value = [...] "abc"} // gdbr-check:$1 = unsized::Foo<[u8]> {value: [...]}
random_line_split
unsized.rs
// compile-flags:-g // === GDB TESTS =================================================================================== // gdb-command:run // gdb-command:print *a // gdbg-check:$1 = {value = [...] "abc"} // gdbr-check:$1 = unsized::Foo<[u8]> {value: [...]} // gdb-command:print *b // gdbg-check:$2 = {value = {value...
<T:?Sized> { value: T } fn main() { let foo: Foo<Foo<[u8; 4]>> = Foo { value: Foo { value: *b"abc\0" } }; let a: &Foo<[u8]> = &foo.value; let b: &Foo<Foo<[u8]>> = &foo; zzz(); // #break } fn zzz() { () }
Foo
identifier_name
feature-gate-unboxed-closures-manual-impls.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn main() {}
struct Baz; impl FnOnce<(), ()> for Baz { //~ ERROR manual implementations of `FnOnce` are experimental extern "rust-call" fn call_once(&self, args: ()) -> () {}
random_line_split
feature-gate-unboxed-closures-manual-impls.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 ...
} struct Baz; impl FnOnce<(), ()> for Baz { //~ ERROR manual implementations of `FnOnce` are experimental extern "rust-call" fn call_once(&self, args: ()) -> () {} } fn main() {}
{}
identifier_body
feature-gate-unboxed-closures-manual-impls.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 ...
(&self, args: ()) -> () {} } struct Baz; impl FnOnce<(), ()> for Baz { //~ ERROR manual implementations of `FnOnce` are experimental extern "rust-call" fn call_once(&self, args: ()) -> () {} } fn main() {}
call_mut
identifier_name
main.rs
extern crate tera; use std::alloc::System; use tera::{Context, Tera}; #[global_allocator] static GLOBAL: System = System; static BIG_TABLE_TEMPLATE: &'static str = "<table> {% for row in table %} <tr>{% for col in row %}<td>{{ col }}</td>{% endfor %}</tr> {% endfor %} </table>"; fn main() { let size = 100; ...
table.push(inner); } let mut tera = Tera::default(); tera.add_raw_templates(vec![("big-table.html", BIG_TABLE_TEMPLATE)]).unwrap(); let mut ctx = Context::new(); ctx.insert("table", &table); let _ = tera.render("big-table.html", &ctx).unwrap(); println!("Done!"); }
inner.push(i); }
random_line_split
main.rs
extern crate tera; use std::alloc::System; use tera::{Context, Tera}; #[global_allocator] static GLOBAL: System = System; static BIG_TABLE_TEMPLATE: &'static str = "<table> {% for row in table %} <tr>{% for col in row %}<td>{{ col }}</td>{% endfor %}</tr> {% endfor %} </table>"; fn
() { let size = 100; let mut table = Vec::with_capacity(size); for _ in 0..size { let mut inner = Vec::with_capacity(size); for i in 0..size { inner.push(i); } table.push(inner); } let mut tera = Tera::default(); tera.add_raw_templates(vec![("big-tab...
main
identifier_name
main.rs
extern crate tera; use std::alloc::System; use tera::{Context, Tera}; #[global_allocator] static GLOBAL: System = System; static BIG_TABLE_TEMPLATE: &'static str = "<table> {% for row in table %} <tr>{% for col in row %}<td>{{ col }}</td>{% endfor %}</tr> {% endfor %} </table>"; fn main()
{ let size = 100; let mut table = Vec::with_capacity(size); for _ in 0..size { let mut inner = Vec::with_capacity(size); for i in 0..size { inner.push(i); } table.push(inner); } let mut tera = Tera::default(); tera.add_raw_templates(vec![("big-table....
identifier_body
zhttpto.rs
// // zhttpto.rs // // Starting code for PS1 // Running on Rust 0.9 // // Note that this code has serious security risks! You should not run it // on any system with access to sensitive files. // // University of Virginia - cs4414 Spring 2014 // Weilin Xu and David Evans // Version 0.3 #[feature(globs)]; use std::i...
() { let addr = from_str::<SocketAddr>(format!("{:s}:{:d}", IP, PORT)).unwrap(); let mut acceptor = net::tcp::TcpListener::bind(addr).listen(); println(format!("Listening on [{:s}]...", addr.to_str())); for stream in acceptor.incoming() { // Spawn a task to handle the connection ...
main
identifier_name
zhttpto.rs
// // zhttpto.rs // // Starting code for PS1 // Running on Rust 0.9 // // Note that this code has serious security risks! You should not run it // on any system with access to sensitive files. // // University of Virginia - cs4414 Spring 2014 // Weilin Xu and David Evans // Version 0.3 #[feature(globs)]; use std::i...
stream.read(buf); let request_str = str::from_utf8(buf).to_owned(); if(request_str.contains("GET")){ let tempstr: ~[&str]= request_str.split(' ').collect(); if(tempstr[1].len() >2){ let file = Path::new(tempstr[1].slice_from(1)); println!("{}",tempstr[1].slice_from(1)); if temp...
}, None => () } let mut buf = [0, ..500];
random_line_split
zhttpto.rs
// // zhttpto.rs // // Starting code for PS1 // Running on Rust 0.9 // // Note that this code has serious security risks! You should not run it // on any system with access to sensitive files. // // University of Virginia - cs4414 Spring 2014 // Weilin Xu and David Evans // Version 0.3 #[feature(globs)]; use std::i...
let mut buf = [0,..500]; stream.read(buf); let request_str = str::from_utf8(buf).to_owned(); if(request_str.contains("GET")){ let tempstr: ~[&str]= request_str.split(' ').collect(); if(tempstr[1].len() >2){ let file = Path::new(tempstr[1].slice_from(1)); p...
{ let addr = from_str::<SocketAddr>(format!("{:s}:{:d}", IP, PORT)).unwrap(); let mut acceptor = net::tcp::TcpListener::bind(addr).listen(); println(format!("Listening on [{:s}] ...", addr.to_str())); for stream in acceptor.incoming() { // Spawn a task to handle the connection ...
identifier_body
domstringmap.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DOMStringMapBinding; use dom::bindings::codegen::Bindings::DOMStringMapBindi...
GlobalRef::Window(window.r()), DOMStringMapBinding::Wrap) } } // https://html.spec.whatwg.org/multipage/#domstringmap impl DOMStringMapMethods for DOMStringMap { // https://html.spec.whatwg.org/multipage/#dom-domstringmap-removeitem fn NamedDeleter(&sel...
} pub fn new(element: &HTMLElement) -> Root<DOMStringMap> { let window = window_from_node(element); reflect_dom_object(box DOMStringMap::new_inherited(element),
random_line_split
domstringmap.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DOMStringMapBinding; use dom::bindings::codegen::Bindings::DOMStringMapBindi...
} // https://html.spec.whatwg.org/multipage/#domstringmap impl DOMStringMapMethods for DOMStringMap { // https://html.spec.whatwg.org/multipage/#dom-domstringmap-removeitem fn NamedDeleter(&self, name: DOMString) { self.element.delete_custom_attr(name) } // https://html.spec.whatwg.org/multip...
{ let window = window_from_node(element); reflect_dom_object(box DOMStringMap::new_inherited(element), GlobalRef::Window(window.r()), DOMStringMapBinding::Wrap) }
identifier_body
domstringmap.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DOMStringMapBinding; use dom::bindings::codegen::Bindings::DOMStringMapBindi...
(&self) -> Vec<DOMString> { self.element.supported_prop_names_custom_attr().iter().cloned().collect() } }
SupportedPropertyNames
identifier_name
video.rs
use ffmpeg::frame; use glium::texture::{SrgbTexture2d}; use glium::{Program, Display, VertexBuffer, Surface}; use glium::buffer::BufferView; use glium::buffer::BufferMode::Persistent; use glium::buffer::BufferType::PixelUnpackBuffer; use glium::index::PrimitiveType::TriangleStrip; use glium::index::NoIndices; use gliu...
<'a> { display: &'a Display, program: Program, vertices: VertexBuffer<Vertex>, timestamp: i64, buffer: Option<BufferView<[(u8, u8, u8, u8)]>>, texture: Option<SrgbTexture2d>, } impl<'a> Video<'a> { pub fn new<'b>(display: &'b Display) -> Video<'b> { Video { display: display, program: program!(d...
Video
identifier_name
video.rs
use ffmpeg::frame; use glium::texture::{SrgbTexture2d}; use glium::{Program, Display, VertexBuffer, Surface}; use glium::buffer::BufferView; use glium::buffer::BufferMode::Persistent; use glium::buffer::BufferType::PixelUnpackBuffer; use glium::index::PrimitiveType::TriangleStrip; use glium::index::NoIndices; use gliu...
// write to the buffer self.buffer.as_mut().unwrap().write(frame.plane(0)); // write the buffer to the texture self.texture.as_mut().unwrap().main_level() .raw_upload_from_pixel_buffer_inverted(self.buffer.as_ref().unwrap().as_slice(), 0.. frame.width(), 0.. frame.height(), 0.. 1); } let un...
{ self.buffer = Some(BufferView::empty_array(self.display, PixelUnpackBuffer, (frame.width() * frame.height()) as usize, Persistent).unwrap()); self.texture = Some(SrgbTexture2d::empty_with_format(self.display, U8U8U8U8, NoMipmap, frame.width(), frame.height()).unwrap()); }
conditional_block
video.rs
use ffmpeg::frame; use glium::texture::{SrgbTexture2d}; use glium::{Program, Display, VertexBuffer, Surface}; use glium::buffer::BufferView; use glium::buffer::BufferMode::Persistent; use glium::buffer::BufferType::PixelUnpackBuffer; use glium::index::PrimitiveType::TriangleStrip; use glium::index::NoIndices; use gliu...
self.texture = Some(SrgbTexture2d::empty_with_format(self.display, U8U8U8U8, NoMipmap, frame.width(), frame.height()).unwrap()); } // write to the buffer self.buffer.as_mut().unwrap().write(frame.plane(0)); // write the buffer to the texture self.texture.as_mut().unwrap().main_level() .raw...
random_line_split
type_channel.rs
//! Type channel. //! //! A type channel is a number that represents the number of channel a type is associated with. For //! instance, most people people might already be used to RGB and RGBA colors. They can for instance //! be encoded as 4D-floating numbers. Type channels encode such information. use std::fmt; use ...
fn visit_u64<E>(self, x: u64) -> Result<Self::Value, E> where E: de::Error { match x { 1 => Ok(TypeChan::One), 2 => Ok(TypeChan::Two), 3 => Ok(TypeChan::Three), 4 => Ok(TypeChan::Four), x => Err(E::invalid_value(Unexpected::Unsigned(x as u64), &"1, 2, 3 ...
{ f.write_str("a valid type channel") }
identifier_body
type_channel.rs
//! Type channel. //! //! A type channel is a number that represents the number of channel a type is associated with. For //! instance, most people people might already be used to RGB and RGBA colors. They can for instance //! be encoded as 4D-floating numbers. Type channels encode such information. use std::fmt; use ...
(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { f.write_str("a valid type channel") } fn visit_u64<E>(self, x: u64) -> Result<Self::Value, E> where E: de::Error { match x { 1 => Ok(TypeChan::One), 2 => Ok(TypeChan::Two), 3 => Ok(TypeChan::Three), ...
expecting
identifier_name
type_channel.rs
//! Type channel. //! //! A type channel is a number that represents the number of channel a type is associated with. For //! instance, most people people might already be used to RGB and RGBA colors. They can for instance //! be encoded as 4D-floating numbers. Type channels encode such information. use std::fmt; use ...
} } } impl<'de> Deserialize<'de> for TypeChan { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de> { struct V; impl<'de> Visitor<'de> for V { type Value = TypeChan; fn expecting(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { ...
TypeChan::One => serializer.serialize_u8(1), TypeChan::Two => serializer.serialize_u8(2), TypeChan::Three => serializer.serialize_u8(3), TypeChan::Four => serializer.serialize_u8(4),
random_line_split
mod.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ma...
(&self) -> io::Result<TcpStream> { self.accept().map(|res| res.0) } } impl<F, T> TransportServer for F where F: Fn() -> io::Result<T>, T: Transport { type Transport = T; fn accept(&self) -> io::Result<T> { self() } }
accept
identifier_name
mod.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ma...
type Transport = TcpStream; fn accept(&self) -> io::Result<TcpStream> { self.accept().map(|res| res.0) } } impl<F, T> TransportServer for F where F: Fn() -> io::Result<T>, T: Transport { type Transport = T; fn accept(&self) -> io::Result<T> { self() } }
random_line_split
mod.rs
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ma...
}
{ self() }
identifier_body
location.rs
//! Fractal Global Location module //! //! This module holds the Fractal Global Address, and Geological location data type objects. #[cfg(feature = "json-types")] use rustc_serialize::json; /// The particulars of the place where an organization or person resides #[derive(PartialEq, Debug, Clone, RustcEncodable, Rustc...
/// Returns the city pub fn get_city(&self) -> &str { &self.city } /// Returns the state pub fn get_state(&self) -> &str { &self.state } /// Returns the zip code pub fn get_zip(&self) -> &str { &self.zip } /// Returns the country pub fn get_countr...
{ match self.address2 { Some(ref addr2) => Some(addr2), None => None, } }
identifier_body
location.rs
//! Fractal Global Location module //! //! This module holds the Fractal Global Address, and Geological location data type objects. #[cfg(feature = "json-types")] use rustc_serialize::json; /// The particulars of the place where an organization or person resides #[derive(PartialEq, Debug, Clone, RustcEncodable, Rustc...
pub fn get_address1(&self) -> &str { &self.address1 } /// Returns address line 2 pub fn get_address2(&self) -> Option<&str> { match self.address2 { Some(ref addr2) => Some(addr2), None => None, } } /// Returns the city pub fn get_city(&self) ...
} } /// Returns address line 1
random_line_split
location.rs
//! Fractal Global Location module //! //! This module holds the Fractal Global Address, and Geological location data type objects. #[cfg(feature = "json-types")] use rustc_serialize::json; /// The particulars of the place where an organization or person resides #[derive(PartialEq, Debug, Clone, RustcEncodable, Rustc...
(&self) -> &str { &self.address1 } /// Returns address line 2 pub fn get_address2(&self) -> Option<&str> { match self.address2 { Some(ref addr2) => Some(addr2), None => None, } } /// Returns the city pub fn get_city(&self) -> &str { &self...
get_address1
identifier_name
rustc.rs
use std::path::Path; use util::{self, CargoResult, internal, ChainError}; pub struct Rustc { pub verbose_version: String, pub host: String, pub cap_lints: bool, } impl Rustc { /// Run the compiler at `path` to learn varioues pieces of information about /// it. /// /// If successful this f...
() -> Rustc { Rustc { verbose_version: String::new(), host: String::new(), cap_lints: false, } } }
blank
identifier_name
rustc.rs
use std::path::Path; use util::{self, CargoResult, internal, ChainError}; pub struct Rustc { pub verbose_version: String, pub host: String, pub cap_lints: bool, } impl Rustc { /// Run the compiler at `path` to learn varioues pieces of information about /// it. /// /// If successful this f...
cmd.arg("-vV"); let mut ret = Rustc::blank(); let mut first = cmd.clone(); first.arg("--cap-lints").arg("allow"); let output = match first.exec_with_output() { Ok(output) => { ret.cap_lints = true; output } Err(..) => try!(cmd.exec_with_output()), ...
random_line_split
cell.rs
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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modi...
/// Panics if the value is currently mutably borrowed. /// /// # Examples /// /// ``` /// use std::cell::RefCell; /// /// let c = RefCell::new(5); /// /// let borrowed_five = c.borrow(); /// let borrowed_five2 = c.borrow(); /// ``` /// /// An example of panic: ...
///
random_line_split
cell.rs
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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or d...
(&self) -> *mut T { &self.value as *const T as *mut T } /// Unwraps the value /// /// # Unsafety /// /// This function is unsafe because there is no guarantee that this or other threads are /// currently inspecting the inner value. /// /// # Examples /// /// ``` /// use std:...
get
identifier_name
cell.rs
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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or d...
} #[stable(feature = "rust1", since = "1.0.0")] unsafe impl<T> Send for RefCell<T> where T: Send {} #[stable(feature = "rust1", since = "1.0.0")] impl<T: Clone> Clone for RefCell<T> { fn clone(&self) -> RefCell<T> { RefCell::new(self.borrow().clone()) } } #[stable(feature = "rust1", since = "1.0.0")...
{ &self.value }
identifier_body
config.rs
//! Defines configuration file format. use anyhow::{anyhow, Result}; use glob::Pattern; use lazy_static::lazy_static; use serde::Deserialize; use std::{ fs, io::Read, ops::{Deref, DerefMut}, path::{Path, PathBuf}, }; lazy_static! { static ref CONFIG_PATH: PathBuf = dirs::config_dir() .map(|...
(raw: RawConfigData) -> Result<Self> { let root_dir = raw.root.as_deref().unwrap_or("~/rhq"); let root_dir = crate::util::make_path_buf(root_dir)?; let include_dirs = raw .includes .as_deref() .unwrap_or(&[]) .iter() .filter_map(|root| crat...
from_raw
identifier_name
config.rs
//! Defines configuration file format. use anyhow::{anyhow, Result}; use glob::Pattern; use lazy_static::lazy_static; use serde::Deserialize; use std::{ fs, io::Read, ops::{Deref, DerefMut},
}; lazy_static! { static ref CONFIG_PATH: PathBuf = dirs::config_dir() .map(|config_path| config_path.join("rhq/config.toml")) .expect("failed to determine the configuration path"); } /// configuration load from config files #[derive(Deserialize)] struct RawConfigData { root: Option<String>, ...
path::{Path, PathBuf},
random_line_split
config.rs
//! Defines configuration file format. use anyhow::{anyhow, Result}; use glob::Pattern; use lazy_static::lazy_static; use serde::Deserialize; use std::{ fs, io::Read, ops::{Deref, DerefMut}, path::{Path, PathBuf}, }; lazy_static! { static ref CONFIG_PATH: PathBuf = dirs::config_dir() .map(|...
}
{ &mut self.data }
identifier_body
config.rs
//! Defines configuration file format. use anyhow::{anyhow, Result}; use glob::Pattern; use lazy_static::lazy_static; use serde::Deserialize; use std::{ fs, io::Read, ops::{Deref, DerefMut}, path::{Path, PathBuf}, }; lazy_static! { static ref CONFIG_PATH: PathBuf = dirs::config_dir() .map(|...
let mut content = String::new(); fs::File::open(config_path)?.read_to_string(&mut content)?; let data = ::toml::from_str(&content)?; Ok(Config { path: config_path.into(), data: ConfigData::from_raw(data)?, }) } pub fn cache_dir(&self) -> PathBu...
{ return Err(anyhow!( "Failed to load configuration file (config_path = {})", config_path.display() )); }
conditional_block
opcode.rs
enum_from_primitive! { #[derive(Debug)] pub enum Opcode { Special = 0b000000, RegImm = 0b000001, Addi = 0b001000, Addiu = 0b001001, Andi = 0b001100, Ori = 0b001101, Lui = 0b001111, Mtc0 = 0b010000, Beq = 0b000100...
enum_from_primitive! { #[derive(Debug)] pub enum SpecialOpcode { Sll = 0b000000, Srl = 0b000010, Sllv = 0b000100, Srlv = 0b000110, Jr = 0b001000, Multu = 0b011001, Mfhi = 0b010000, Mflo = 0b010010, Addu = 0b100001, ...
random_line_split
sync.rs
#![crate_name = "sync"] /* * This file is part of the uutils coreutils package. * * (c) Alexander Fomin <xander.fomin@ya.ru> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* Last synced with: sync (GNU coreutils) 8.13 */ exte...
(name: &str) { let name_buffer = name.to_c_str().as_ptr(); if 0x00000003 == GetDriveTypeA(name_buffer) { // DRIVE_FIXED let sliced_name = &name[..name.len() - 1]; // eliminate trailing backslash let sliced_name_buffer = sliced_name.to_c_str().as_ptr(); match CreateFil...
flush_volume
identifier_name
sync.rs
#![crate_name = "sync"] /* * This file is part of the uutils coreutils package. * * (c) Alexander Fomin <xander.fomin@ya.ru> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* Last synced with: sync (GNU coreutils) 8.13 */ exte...
} } #[allow(unused_unsafe)] unsafe fn find_all_volumes() -> Vec<String> { match find_first_volume() { (first_volume, next_volume_handle) => { let mut volumes = vec![first_volume]; loop { let mut name: [libc::c_char; 260] = mem...
{ (string::raw::from_buf(name.as_ptr() as *const u8), handle) }
conditional_block