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
p011.rs
use std::cmp; pub fn solve() -> i32
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54 01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48 "; let vvi: Vec<Vec<i32>> = S.trim().lines().map(|line| { line.split_whitespace().filter_map(|s| s.parse().ok()).collect() }).collect(); let mut ret = 0; for i in 0..vvi.len() { for j ...
{ const S: &'static str = r" 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28...
identifier_body
p011.rs
use std::cmp; pub fn solve() -> i32 { const S: &'static str = r" 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 22 31 16 7...
(vvi: &Vec<Vec<i32>>, x: usize, y: usize) -> i32 { let mut ret = vvi[x][y]; if x as i32 - 1 >= 0 && y + 1 < vvi[0].len() && x + 1 < vvi.len() && y as i32 - 1 >=0 && x + 2 < vvi.len() && y as i32 - 2 >= 0 { ret *= vvi[x - 1][y + 1] * vvi[x + 1][y - 1] * vvi[x + 2][y - 2]; } ret }
cal3
identifier_name
p011.rs
use std::cmp; pub fn solve() -> i32 { const S: &'static str = r" 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 22 31 16 7...
ret = cmp::max(ret, cal0(&vvi, i, j)); ret = cmp::max(ret, cal1(&vvi, i, j)); ret = cmp::max(ret, cal2(&vvi, i, j)); ret = cmp::max(ret, cal3(&vvi, i, j)); } } ret } // column fn cal0(vvi: &Vec<Vec<i32>>, x: usize, y: usize) -> i32 { let mut ret = vvi[x][y]; if x as i32 - 1 >= 0 && ...
for i in 0..vvi.len() { for j in 0..vvi[0].len() {
random_line_split
sepcomp-fns.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn main() { assert_eq!(one(), 1); assert_eq!(a::two(), 2); assert_eq!(b::three(), 3); }
{ ::one() + ::a::two() }
identifier_body
sepcomp-fns.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 ...
() -> uint { 1 } mod a { pub fn two() -> uint { ::one() + ::one() } } mod b { pub fn three() -> uint { ::one() + ::a::two() } } fn main() { assert_eq!(one(), 1); assert_eq!(a::two(), 2); assert_eq!(b::three(), 3); }
one
identifier_name
sepcomp-fns.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!(one(), 1); assert_eq!(a::two(), 2); assert_eq!(b::three(), 3); }
} fn main() {
random_line_split
build.rs
#[cfg(feature = "bindgen")] extern crate bindgen; extern crate pkg_config; use pkg_config::Config; use std::env; use std::fs; use std::io; use std::path::{Path, PathBuf}; #[cfg(feature = "bindgen")] pub fn write_bindings(include_paths: Vec<String>, out_path: &Path) { let mut builder = bindgen::Builder::default() ...
() { println!("cargo:rerun-if-env-changed=GDAL_STATIC"); println!("cargo:rerun-if-env-changed=GDAL_INCLUDE_DIR"); println!("cargo:rerun-if-env-changed=GDAL_LIB_DIR"); println!("cargo:rerun-if-env-changed=GDAL_HOME"); let mut need_metadata = true; let mut lib_name = String::from("gdal"); le...
main
identifier_name
build.rs
#[cfg(feature = "bindgen")] extern crate bindgen; extern crate pkg_config; use pkg_config::Config; use std::env; use std::fs; use std::io; use std::path::{Path, PathBuf}; #[cfg(feature = "bindgen")] pub fn write_bindings(include_paths: Vec<String>, out_path: &Path)
.write_to_file(out_path) .expect("Unable to write bindings to file"); } fn env_dir(var: &str) -> Option<PathBuf> { let dir = env::var_os(var).map(PathBuf::from); if let Some(ref dir) = dir { if!dir.exists() { panic!("{} was set to {}, which doesn't exist.", var, dir.display(...
{ let mut builder = bindgen::Builder::default() .header("wrapper.h") .constified_enum_module(".*") .ctypes_prefix("libc") .whitelist_function("CPL.*") .whitelist_function("GDAL.*") .whitelist_function("OGR.*") .whitelist_function("OSR.*") .whitelist_fu...
identifier_body
build.rs
#[cfg(feature = "bindgen")] extern crate bindgen; extern crate pkg_config; use pkg_config::Config; use std::env; use std::fs; use std::io; use std::path::{Path, PathBuf}; #[cfg(feature = "bindgen")] pub fn write_bindings(include_paths: Vec<String>, out_path: &Path) { let mut builder = bindgen::Builder::default() ...
env::var_os("GDAL_STATIC").is_some() && env::var_os("GDAL_DYNAMIC").is_none(); let mut include_dir = env_dir("GDAL_INCLUDE_DIR"); let mut lib_dir = env_dir("GDAL_LIB_DIR"); let home_dir = env_dir("GDAL_HOME"); let mut found = false; if cfg!(windows) { // first, look for a static li...
let mut need_metadata = true; let mut lib_name = String::from("gdal"); let mut prefer_static =
random_line_split
build.rs
#[cfg(feature = "bindgen")] extern crate bindgen; extern crate pkg_config; use pkg_config::Config; use std::env; use std::fs; use std::io; use std::path::{Path, PathBuf}; #[cfg(feature = "bindgen")] pub fn write_bindings(include_paths: Vec<String>, out_path: &Path) { let mut builder = bindgen::Builder::default() ...
} } } if!found { if cfg!(target_env = "msvc") { panic!("windows-gnu requires gdal_i.lib to be present in either $GDAL_LIB_DIR or $GDAL_HOME\\lib."); } // otherwise, look for a gdalxxx.dll in $GDAL_HOME/bin // wo...
{ // first, look for a static library in $GDAL_LIB_DIR or $GDAL_HOME/lib // works in windows-msvc and windows-gnu if let Some(ref lib_dir) = lib_dir { let lib_path = lib_dir.join("gdal_i.lib"); if lib_path.exists() { prefer_static = true; l...
conditional_block
lib.rs
// DO NOT EDIT! // This file was generated automatically from'src/mako/api/lib.rs.mako' // DO NOT EDIT! //! This documentation was generated from *taskqueue* crate version *0.1.8+20141111*, where *20141111* is the exact revision of the *taskqueue:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code ...
//! //! // Unused attributes happen thanks to defined, but unused structures // We don't warn about this, as depending on the API, some data structures or facilities are never used. // Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any // unused imports in fully featured ...
//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure //! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern //! [google-go-api]: https://github.com/google/google-api-go-client
random_line_split
mod.rs
// We have a lot of c-types in here, stop warning about their names! #![allow(non_camel_case_types)] // fmt::Debug isn't helpful on FFI types #![allow(missing_debug_implementations)] // unreachable_pub warns `#[no_mangle] pub extern fn` in private mod. #![allow(unreachable_pub)] //! # hyper C API //! //! This part of ...
(*mut std::ffi::c_void); // We don't actually know anything about this pointer, it's up to the user // to do the right thing. unsafe impl Send for UserDataPointer {} unsafe impl Sync for UserDataPointer {} /// cbindgen:ignore static VERSION_CSTR: &str = concat!(env!("CARGO_PKG_VERSION"), "\0"); ffi_fn! { /// Ret...
UserDataPointer
identifier_name
mod.rs
// We have a lot of c-types in here, stop warning about their names! #![allow(non_camel_case_types)] // fmt::Debug isn't helpful on FFI types #![allow(missing_debug_implementations)] // unreachable_pub warns `#[no_mangle] pub extern fn` in private mod. #![allow(unreachable_pub)] //! # hyper C API //! //! This part of ...
//! //! ## Building //! //! The C API is part of the Rust library, but isn't compiled by default. Using //! `cargo`, it can be compiled with the following command: //! //! ```notrust //! RUSTFLAGS="--cfg hyper_unstable_ffi" cargo build --features client,http1,http2,ffi //! ``` // We may eventually allow the FFI to be ...
random_line_split
mir_drop_order.rs
// run-pass // ignore-wasm32-bare compiled with panic=abort by default use std::cell::RefCell; use std::panic; pub struct DropLogger<'a> { id: usize, log: &'a panic::AssertUnwindSafe<RefCell<Vec<usize>>> } impl<'a> Drop for DropLogger<'a> { fn drop(&mut self) { self.log.0.borrow_mut().push(self.i...
; #[allow(unreachable_code)] fn main() { let log = panic::AssertUnwindSafe(RefCell::new(vec![])); let d = |id| DropLogger { id: id, log: &log }; let get = || -> Vec<_> { let mut m = log.0.borrow_mut(); let n = m.drain(..); n.collect() }; { let _x = (d(0), &d(1), d(2...
InjectedFailure
identifier_name
mir_drop_order.rs
// run-pass // ignore-wasm32-bare compiled with panic=abort by default use std::cell::RefCell; use std::panic; pub struct DropLogger<'a> { id: usize, log: &'a panic::AssertUnwindSafe<RefCell<Vec<usize>>> } impl<'a> Drop for DropLogger<'a> { fn drop(&mut self) { self.log.0.borrow_mut().push(self.i...
// all borrows are extended - nothing has been dropped yet assert_eq!(get(), vec![]); } // in a let-statement, extended places are dropped // *after* the let result (tho they have the same scope // as far as scope-based borrowck goes). assert_eq!(get(), vec![0, 2, 3, 1]); let _ ...
}; { let _x = (d(0), &d(1), d(2), &d(3));
random_line_split
htmlframeelement.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::utils::{DOMString, null_string, ErrorResult}; use dom::document::AbstractDocument; use dom::htm...
(&self) -> bool { false } pub fn SetNoResize(&mut self, _no_resize: bool, _rv: &mut ErrorResult) { } pub fn GetContentDocument(&self) -> Option<AbstractDocument> { None } pub fn GetContentWindow(&self) -> Option<@mut WindowProxy> { None } pub fn MarginHeight(&...
NoResize
identifier_name
htmlframeelement.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::utils::{DOMString, null_string, ErrorResult}; use dom::document::AbstractDocument; use dom::htm...
pub fn SetFrameBorder(&mut self, _frameborder: &DOMString, _rv: &mut ErrorResult) { } pub fn LongDesc(&self) -> DOMString { null_string } pub fn SetLongDesc(&mut self, _longdesc: &DOMString, _rv: &mut ErrorResult) { } pub fn NoResize(&self) -> bool { false } pub f...
random_line_split
htmlframeelement.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::utils::{DOMString, null_string, ErrorResult}; use dom::document::AbstractDocument; use dom::htm...
pub fn SetSrc(&mut self, _src: &DOMString, _rv: &mut ErrorResult) { } pub fn FrameBorder(&self) -> DOMString { null_string } pub fn SetFrameBorder(&mut self, _frameborder: &DOMString, _rv: &mut ErrorResult) { } pub fn LongDesc(&self) -> DOMString { null_string } ...
{ null_string }
identifier_body
reflect.rs
machine; use middle::trans::meth; use middle::trans::type_of::*; use middle::ty; use util::ppaux::ty_to_str; use core::libc::c_uint; use core::option::None; use core::vec; use syntax::ast::def_id; use syntax::ast; use syntax::ast_map::path_name; use syntax::parse::token::special_idents; pub struct
{ visitor_val: ValueRef, visitor_methods: @~[@ty::Method], final_bcx: block, tydesc_ty: TypeRef, bcx: block } pub impl Reflector { fn c_uint(&mut self, u: uint) -> ValueRef { C_uint(self.bcx.ccx(), u) } fn c_int(&mut self, i: int) -> ValueRef { C_int(self.bcx.ccx(), i)...
Reflector
identifier_name
reflect.rs
::machine; use middle::trans::meth; use middle::trans::type_of::*; use middle::ty; use util::ppaux::ty_to_str; use core::libc::c_uint; use core::option::None; use core::vec; use syntax::ast::def_id; use syntax::ast; use syntax::ast_map::path_name; use syntax::parse::token::special_idents; pub struct Reflector { v...
ty::ty_float(ast::ty_f32) => self.leaf(~"f32"), ty::ty_float(ast::ty_f64) => self.leaf(~"f64"), ty::ty_unboxed_vec(ref mt) => { let values = self.c_mt(mt); self.visit(~"vec", values) } ty::ty_estr(vst) => { let (name, extra) =...
ty::ty_uint(ast::ty_u64) => self.leaf(~"u64"), ty::ty_float(ast::ty_f) => self.leaf(~"float"),
random_line_split
reflect.rs
machine; use middle::trans::meth; use middle::trans::type_of::*; use middle::ty; use util::ppaux::ty_to_str; use core::libc::c_uint; use core::option::None; use core::vec; use syntax::ast::def_id; use syntax::ast; use syntax::ast_map::path_name; use syntax::parse::token::special_idents; pub struct Reflector { vis...
ty::ty_struct(did, ref substs) => { let bcx = self.bcx; let tcx = bcx.ccx().tcx; let fields = ty::struct_fields(tcx, did, substs); let extra = ~[self.c_uint(fields.len())] + self.c_size_and_align(t); do self.bracketed(~...
{ let pureval = ast_purity_constant(fty.purity); let sigilval = 0u; let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u}; let extra = ~[self.c_uint(pureval), self.c_uint(sigilval), self.c_uint(fty.sig.inputs.le...
conditional_block
reflect.rs
store_slice(ty::re_static); let str_ty = ty::mk_estr(bcx.tcx(), str_vstore); let scratch = scratch_datum(bcx, str_ty, false); let len = C_uint(bcx.ccx(), s.len() + 1); let c_str = PointerCast(bcx, C_cstr(bcx.ccx(), s), T_ptr(T_i8())); Store(bcx, c_str, GEPi(bcx, scratch.val, [ 0,...
{ use syntax::parse::token::special_idents::tydesc; let final = sub_block(bcx, "final"); assert!(bcx.ccx().tcx.intrinsic_defs.contains_key(&tydesc)); let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get_copy(&tydesc); let tydesc_ty = type_of(bcx.ccx(), tydesc_ty); let mut r = Reflector { ...
identifier_body
030.rs
// Copyright (C) 2014 Jorge Aparicio use std::iter::{AdditiveIterator,count}; use std::num::pow; use std::vec_ng::Vec; struct Digits(Vec<uint>); impl Digits { fn to_uint(&self) -> uint { let &Digits(ref ds) = self; ds.iter().rev().fold(0, |acc, &d| 10 * acc + d) } fn
(&self, powers: &[uint]) -> uint { let &Digits(ref ds) = self; ds.iter().fold(0, |acc, &d| acc + powers[d]) } fn next(&mut self) { let &Digits(ref mut ds) = self; let size = ds.len(); *ds.get_mut(0) += 1; for i in range(0, size) { if *ds.get(i) == ...
power_sum
identifier_name
030.rs
// Copyright (C) 2014 Jorge Aparicio use std::iter::{AdditiveIterator,count}; use std::num::pow; use std::vec_ng::Vec; struct Digits(Vec<uint>); impl Digits { fn to_uint(&self) -> uint { let &Digits(ref ds) = self; ds.iter().rev().fold(0, |acc, &d| 10 * acc + d) } fn power_sum(&self, po...
if i == size - 1 { ds.push(1); } else { *ds.get_mut(i + 1) += 1; } } } } } fn main() { let powers: Vec<uint> = range(0u, 10).map(|x| pow(x, 5)).collect(); let mut digits = Digits(vec!(0, 1)); l...
{ let &Digits(ref mut ds) = self; let size = ds.len(); let mut done = false; for i in range(0, size) { if *ds.get(i) == 0 { continue; } else if !done { done = true; *ds.get_mut(i) = 0; if i == size ...
identifier_body
030.rs
// Copyright (C) 2014 Jorge Aparicio use std::iter::{AdditiveIterator,count}; use std::num::pow; use std::vec_ng::Vec; struct Digits(Vec<uint>); impl Digits { fn to_uint(&self) -> uint { let &Digits(ref ds) = self; ds.iter().rev().fold(0, |acc, &d| 10 * acc + d) } fn power_sum(&self, po...
let &Digits(ref mut ds) = self; let size = ds.len(); let mut done = false; for i in range(0, size) { if *ds.get(i) == 0 { continue; } else if!done { done = true; *ds.get_mut(i) = 0; if i == size - 1...
random_line_split
dependency.rs
use core::{VersionReq,SourceId,Summary}; use util::CargoResult; #[deriving(PartialEq,Clone,Show)] pub struct Dependency { name: String, source_id: SourceId, req: VersionReq, transitive: bool, only_match_name: bool,
impl Dependency { pub fn parse(name: &str, version: Option<&str>, source_id: &SourceId) -> CargoResult<Dependency> { let version = match version { Some(v) => try!(VersionReq::parse(v)), None => VersionReq::any() }; Ok(Dependency { name: n...
}
random_line_split
dependency.rs
use core::{VersionReq,SourceId,Summary}; use util::CargoResult; #[deriving(PartialEq,Clone,Show)] pub struct Dependency { name: String, source_id: SourceId, req: VersionReq, transitive: bool, only_match_name: bool, } impl Dependency { pub fn parse(name: &str, version: Option<&str>, ...
(&self) -> &VersionReq { &self.req } pub fn get_name(&self) -> &str { self.name.as_slice() } pub fn get_source_id(&self) -> &SourceId { &self.source_id } pub fn as_dev(&self) -> Dependency { let mut dep = self.clone(); dep.transitive = false; de...
get_version_req
identifier_name
document_loader.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/. */ //! Tracking of pending loads in a document. //! //! <https://html.spec.whatwg.org/multipage/#the-end> use crate...
{ resource_threads: ResourceThreads, blocking_loads: Vec<LoadType>, events_inhibited: bool, cancellers: Vec<FetchCanceller>, } impl DocumentLoader { pub fn new(existing: &DocumentLoader) -> DocumentLoader { DocumentLoader::new_with_threads(existing.resource_threads.clone(), None) } ...
DocumentLoader
identifier_name
document_loader.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/. */ //! Tracking of pending loads in a document. //! //! <https://html.spec.whatwg.org/multipage/#the-end> use crate...
, None => warn!("unknown completed load {:?}", load), } } pub fn is_blocked(&self) -> bool { // TODO: Ensure that we report blocked if parsing is still ongoing. !self.blocking_loads.is_empty() } pub fn is_only_blocked_by_iframes(&self) -> bool { self.blocking...
{ self.blocking_loads.remove(i); }
conditional_block
document_loader.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/. */ //! Tracking of pending loads in a document. //! //! <https://html.spec.whatwg.org/multipage/#the-end> use crate...
pub fn events_inhibited(&self) -> bool { self.events_inhibited } pub fn resource_threads(&self) -> &ResourceThreads { &self.resource_threads } }
{ self.events_inhibited = true; }
identifier_body
document_loader.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/. */ //! Tracking of pending loads in a document. //! //! <https://html.spec.whatwg.org/multipage/#the-end> use crate...
}) } pub fn inhibit_events(&mut self) { self.events_inhibited = true; } pub fn events_inhibited(&self) -> bool { self.events_inhibited } pub fn resource_threads(&self) -> &ResourceThreads { &self.resource_threads } }
self.blocking_loads.iter().all(|load| match *load { LoadType::Subframe(_) => true, _ => false,
random_line_split
grid.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/. */ //! CSS handling for the computed value of //! [grids](https://drafts.csswg.org/css-grid/) use cssparser::{Parser...
if!track_size.is_fixed() { if is_auto { // should be <fixed-size> for <auto-repeat> return Err(StyleParseError::UnspecifiedError.into()) } if repea...
{ input.try(|i| i.expect_function_matching("repeat").map_err(|e| e.into())).and_then(|_| { input.parse_nested_block(|input| { let count = RepeatCount::parse(context, input)?; input.expect_comma()?; let is_auto = count == RepeatCount::AutoFit || count ...
identifier_body
grid.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/. */ //! CSS handling for the computed value of //! [grids](https://drafts.csswg.org/css-grid/) use cssparser::{Parser...
<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<(TrackRepeat<LengthOrPercentage>, RepeatType), ParseError<'i>> { input.try(|i| i.expect_function_matching("repeat").map_err(|e| e.into())).and_then(|_| { input.parse_nested_block(|input| { ...
parse_with_repeat_type
identifier_name
grid.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/. */ //! CSS handling for the computed value of //! [grids](https://drafts.csswg.org/css-grid/) use cssparser::{Parser...
let vec = mem::replace(&mut current_names, vec![]); names.push(vec.into_boxed_slice()); values.push(track_size); } else if let Ok((repeat, type_)) = input.try(|i| TrackRepeat::parse_with_repeat_type(context, i)) { if list_type == TrackListTyp...
{ atleast_one_not_fixed = true; if auto_repeat.is_some() { // <auto-track-list> only accepts <fixed-size> and <fixed-repeat> return Err(StyleParseError::UnspecifiedError.into()) } }
conditional_block
grid.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/. */
//! CSS handling for the computed value of //! [grids](https://drafts.csswg.org/css-grid/) use cssparser::{Parser, Token, BasicParseError}; use parser::{Parse, ParserContext}; use std::ascii::AsciiExt; use std::mem; use style_traits::{ParseError, StyleParseError}; use values::{CSSFloat, CustomIdent}; use values::gener...
random_line_split
signature.rs
use std::ffi::CString; use std::marker; use std::mem; use std::str; use std::fmt; use libc; use {raw, Error, Time}; use util::Binding; /// A Signature is used to indicate authorship of various actions throughout the /// library. /// /// Signatures contain a name, email, and timestamp. All fields can be specified /// ...
} } impl<'a> fmt::Display for Signature<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} <{}>", String::from_utf8_lossy(self.name_bytes()), String::from_utf8_lossy(self.email_bytes())) } } #[cfg(test)] mod tests { use {Signature, Time}...
{ unsafe { raw::git_signature_free(self.raw) } }
conditional_block
signature.rs
use std::ffi::CString; use std::marker; use std::mem; use std::str; use std::fmt; use libc; use {raw, Error, Time}; use util::Binding; /// A Signature is used to indicate authorship of various actions throughout the /// library. /// /// Signatures contain a name, email, and timestamp. All fields can be specified /// ...
(raw: *mut raw::git_signature) -> Signature<'a> { Signature { raw: raw, _marker: marker::PhantomData, owned: true, } } fn raw(&self) -> *mut raw::git_signature { self.raw } } /// Creates a new signature from the give raw pointer, tied to the lifetime /// of t...
from_raw
identifier_name
signature.rs
use std::ffi::CString; use std::marker; use std::mem; use std::str; use std::fmt; use libc; use {raw, Error, Time}; use util::Binding; /// A Signature is used to indicate authorship of various actions throughout the /// library. /// /// Signatures contain a name, email, and timestamp. All fields can be specified /// ...
/// Gets the name on the signature as a byte slice. pub fn name_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, (*self.raw).name).unwrap() } } /// Gets the email on the signature. /// /// Returns `None` if the email is not valid utf-8 pub fn email(&self) -> Option<&str> { ...
{ str::from_utf8(self.name_bytes()).ok() }
identifier_body
signature.rs
use std::ffi::CString; use std::marker; use std::mem; use std::str; use std::fmt; use libc; use {raw, Error, Time}; use util::Binding; /// A Signature is used to indicate authorship of various actions throughout the /// library. /// /// Signatures contain a name, email, and timestamp. All fields can be specified /// ...
} /// Creates a new signature from the give raw pointer, tied to the lifetime /// of the given object. /// /// This function is unsafe as there is no guarantee that `raw` is valid for /// `'a` nor if it's a valid pointer. pub unsafe fn from_raw_const<'b, T>(_lt: &'b T, raw: *const r...
owned: true, } } fn raw(&self) -> *mut raw::git_signature { self.raw }
random_line_split
site.rs
// Helianto -- static website generator // Copyright © 2015-2016 Mickaël RAYBAUD-ROIG // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your...
impl Site { pub fn new(setting: &Settings) -> Site { let mut site = Site::default(); site.title = setting.site_title.clone(); site.url = setting.site_url.clone(); if let Some(ref language) = setting.site_language { site.language = Some(language.clone()); } ...
Site { title: "Untitled website".into(), language: None, url: "/".into(), } } }
identifier_body
site.rs
// Helianto -- static website generator // Copyright © 2015-2016 Mickaël RAYBAUD-ROIG // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your...
pub title: String, pub language: Option<String>, pub url: String, } impl Default for Site { fn default() -> Site { Site { title: "Untitled website".into(), language: None, url: "/".into(), } } } impl Site { pub fn new(setting: &Settings) -> ...
te {
identifier_name
site.rs
// Helianto -- static website generator // Copyright © 2015-2016 Mickaël RAYBAUD-ROIG // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your...
site } }
site.language = Some(language.clone()); }
conditional_block
site.rs
// Helianto -- static website generator // Copyright © 2015-2016 Mickaël RAYBAUD-ROIG
// This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be...
//
random_line_split
characterdata.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/. */ //! DOM bindings for `CharacterData`. use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::...
; let mut data = self.data.borrow().slice_chars(0, offset as usize).to_owned(); data.push_str(arg.as_slice()); data.push_str(&self.data.borrow().slice_chars((offset + count) as usize, length as usize)); *self.data.borrow_mut() = data; // FIXME: Once we have `Range`, we should imp...
{ count }
conditional_block
characterdata.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/. */ //! DOM bindings for `CharacterData`. use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::...
(self, arg: DOMString) -> ErrorResult { *self.data.borrow_mut() = arg; Ok(()) } fn Length(self) -> u32 { self.data.borrow().chars().count() as u32 } fn SubstringData(self, offset: u32, count: u32) -> Fallible<DOMString> { Ok(self.data.borrow().slice_chars(offset as usiz...
SetData
identifier_name
characterdata.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/. */ //! DOM bindings for `CharacterData`. use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::...
fn Length(self) -> u32 { self.data.borrow().chars().count() as u32 } fn SubstringData(self, offset: u32, count: u32) -> Fallible<DOMString> { Ok(self.data.borrow().slice_chars(offset as usize, (offset + count) as usize).to_owned()) } fn AppendData(self, arg: DOMString) -> ErrorResu...
}
random_line_split
characterdata.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/. */ //! DOM bindings for `CharacterData`. use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::...
fn SubstringData(self, offset: u32, count: u32) -> Fallible<DOMString> { Ok(self.data.borrow().slice_chars(offset as usize, (offset + count) as usize).to_owned()) } fn AppendData(self, arg: DOMString) -> ErrorResult { self.data.borrow_mut().push_str(arg.as_slice()); Ok(()) } ...
{ self.data.borrow().chars().count() as u32 }
identifier_body
heat.rs
// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors // // 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 // // Unl...
(&mut self, mut _other: FakeRumor) -> bool { false } fn write_to_bytes(&self) -> Result<Vec<u8>> { Ok(Vec::from(format!("{}-{}", self.id, self.key).as_bytes())) } } /// Helper function that tests that a given rumor is currently /// considered "hot" for the g...
merge
identifier_name
heat.rs
// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors // // 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 // // Unl...
let heat = RumorHeat::default(); let member_one = "test_member_1"; let member_two = "test_member_2"; let rumor = FakeRumor::default(); heat.start_hot_rumor(&rumor); // Both members should see the rumor as hot. assert_rumor_is_hot(&heat, &member_one, &rumor); ...
#[test] fn rumor_heat_is_tracked_per_member() {
random_line_split
heat.rs
// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors // // 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 // // Unl...
fn merge(&mut self, mut _other: FakeRumor) -> bool { false } fn write_to_bytes(&self) -> Result<Vec<u8>> { Ok(Vec::from(format!("{}-{}", self.id, self.key).as_bytes())) } } /// Helper function that tests that a given rumor is currently /// consider...
{ &self.id }
identifier_body
heat.rs
// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors // // 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 // // Unl...
} } } } impl Default for RumorHeat { fn default() -> RumorHeat { RumorHeat(Arc::new(RwLock::new(HashMap::new()))) } } #[cfg(test)] mod tests { use super::*; use error::Result; use message::swim::Rumor_Type; use rumor::{Rumor, RumorKey}; use uuid::Uuid; ...
{ debug!( "Rumor does not exist in map; was probably deleted between retrieval \ and sending" ); }
conditional_block
packed-struct-generic-layout.rs
// run-pass #![allow(dead_code)] #![allow(overflowing_literals)] use std::mem; #[repr(packed)] struct
<T, S> { a: T, b: u8, c: S } pub fn main() { unsafe { let s = S { a: 0xff_ff_ff_ffu32, b: 1, c: 0xaa_aa_aa_aa as i32 }; let transd : [u8; 9] = mem::transmute(s); // Don't worry about endianness, the numbers are palindromic. assert_eq!(transd, [0xff, 0x...
S
identifier_name
packed-struct-generic-layout.rs
// run-pass #![allow(dead_code)] #![allow(overflowing_literals)] use std::mem; #[repr(packed)] struct S<T, S> { a: T, b: u8, c: S } pub fn main() { unsafe { let s = S { a: 0xff_ff_ff_ffu32, b: 1, c: 0xaa_aa_aa_aa as i32 }; let transd : [u8; 9] = mem::transmute(s); // Don't wo...
let s = S { a: 1u8, b: 2u8, c: 0b10000001_10000001 as i16}; let transd : [u8; 4] = mem::transmute(s); // Again, no endianness problems. assert_eq!(transd, [1, 2, 0b10000001, 0b10000001]); } }
[0xff, 0xff, 0xff, 0xff, 1, 0xaa, 0xaa, 0xaa, 0xaa]);
random_line_split
schema.rs
// // Copyright (C) 2017 Kubos Corporation // // 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 agree...
; /// Base GraphQL query model graphql_object!(QueryRoot : Context as "Query" |&self| { field subsystem(&executor) -> FieldResult<&Subsystem> as "Subsystem query" { // I don't know if we'll ever return anything other // than Ok here, as we are just returning back essentially // ...
QueryRoot
identifier_name
schema.rs
// // Copyright (C) 2017 Kubos Corporation // // 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 agree...
Ok(self.power()?) } field uptime() -> FieldResult<i32> as "Uptime of subsystem" { Ok(self.uptime()?) } field temperature() -> FieldResult<i32> as "Temperature of subsystem" { Ok(self.temperature()?) } }); /// GraphQL model for CalibrateThermometer return graphql_object!(C...
graphql_object!(Subsystem: Context as "Subsystem" |&self| { description: "Handler subsystem" field power() -> FieldResult<bool> as "Power state of subsystem" {
random_line_split
stream.rs
.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. /// Stream channels /// /// This is the flavor of channels which are optimized for one sender and one /// re...
DISCONNECTED => { self.cnt.store(DISCONNECTED, Ordering::SeqCst); } n => { let m = cmp::min(n, self.steals); self.steals -= m; self.bump...
// adding back in whatever we couldn't factor into steals. Some(data) => { if self.steals > MAX_STEALS { match self.cnt.swap(0, Ordering::SeqCst) {
random_line_split
stream.rs
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. /// Stream channels /// /// This is the flavor of channels which are optimized for one sender and one /// rec...
self.steals -= 1; data } data => data, } } pub fn try_recv(&mut self) -> Result<T, Failure<T>> { match self.queue.pop() { // If we stole some data, record to that effect (this will be // factored into cnt later on...
{ // Optimistic preflight check (scheduling is expensive). match self.try_recv() { Err(Empty) => {} data => return data, } // Welp, our channel has no data. Deschedule the current task and // initiate the blocking protocol. let (wait_token, signal...
identifier_body
stream.rs
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. /// Stream channels /// /// This is the flavor of channels which are optimized for one sender and one /// rec...
(&mut self) -> Result<bool, Receiver<T>> { // We peek at the queue to see if there's anything on it, and we use // this return value to determine if we should pop from the queue and // upgrade this channel immediately. If it looks like we've got an // upgrade pending, then go through the...
can_recv
identifier_name
iter.rs
use lua; /// An iterator for looping over the keys and values in a Lua table on the stack. pub struct TableIterator { index: lua::Index, state: lua::State, first: bool, } impl TableIterator { /// Creates a new iterator for a given table on the stack. pub fn new(mut state: lua::State, index: lua::...
// On the first call, push an initial key for the call to lua_next(). if self.first { self.state.push_nil(); self.first = false; } else { // Pop the previous value. self.state.pop(1); } if self.state.next(self.index) { ...
fn next(&mut self) -> Option<(i32, i32)> {
random_line_split
iter.rs
use lua; /// An iterator for looping over the keys and values in a Lua table on the stack. pub struct TableIterator { index: lua::Index, state: lua::State, first: bool, } impl TableIterator { /// Creates a new iterator for a given table on the stack. pub fn new(mut state: lua::State, index: lua::...
else { index }, state: state, first: true, } } } impl Iterator for TableIterator { type Item = (i32, i32); /// Fetches the next key/value index pair in the table. fn next(&mut self) -> Option<(i32, i32)> { // On the first call, push ...
{ state.get_top() + index }
conditional_block
iter.rs
use lua; /// An iterator for looping over the keys and values in a Lua table on the stack. pub struct TableIterator { index: lua::Index, state: lua::State, first: bool, } impl TableIterator { /// Creates a new iterator for a given table on the stack. pub fn new(mut state: lua::State, index: lua::...
(&mut self) -> Option<(i32, i32)> { // On the first call, push an initial key for the call to lua_next(). if self.first { self.state.push_nil(); self.first = false; } else { // Pop the previous value. self.state.pop(1); } if self.s...
next
identifier_name
i16.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } }
{ Some(x) }
conditional_block
i16.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 ...
} impl CheckedMul for i16 { #[inline] fn checked_mul(&self, v: &i16) -> Option<i16> { unsafe { let (x, y) = intrinsics::i16_mul_with_overflow(*self, *v); if y { None } else { Some(x) } } } }
{ unsafe { let (x, y) = intrinsics::i16_sub_with_overflow(*self, *v); if y { None } else { Some(x) } } }
identifier_body
i16.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 ...
impl Bitwise for i16 { /// Returns the number of ones in the binary representation of the number. #[inline] fn count_ones(&self) -> i16 { unsafe { intrinsics::ctpop16(*self as u16) as i16 } } /// Returns the number of leading zeros in the in the binary representation /// of the number. #[inline...
use str; use intrinsics; int_module!(i16, 16)
random_line_split
i16.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 ...
(&self, v: &i16) -> Option<i16> { unsafe { let (x, y) = intrinsics::i16_add_with_overflow(*self, *v); if y { None } else { Some(x) } } } } impl CheckedSub for i16 { #[inline] fn checked_sub(&self, v: &i16) -> Option<i16> { unsafe { let (x, y) = in...
checked_add
identifier_name
str.rs
//! Static strings can be stored in the heap. extern crate cell_gc; #[macro_use] extern crate cell_gc_derive; #[derive(IntoHeap)] struct Philosopher<'h> { name: &'static str, teacher: Option<PhilosopherRef<'h>>, } #[test] fn strings_in_heap() { cell_gc::with_heap(|hs| { let s = hs.alloc(Philosoph...
assert_eq!(a.name(), "Aristotle"); assert_eq!(s.name(), "Socrates"); assert_eq!(a.teacher().unwrap().name(), "Plato"); assert_eq!(a.teacher().unwrap().teacher().unwrap().name(), "Socrates"); }); }
}); let a = hs.alloc(Philosopher { name: "Aristotle", teacher: Some(p.clone()), });
random_line_split
str.rs
//! Static strings can be stored in the heap. extern crate cell_gc; #[macro_use] extern crate cell_gc_derive; #[derive(IntoHeap)] struct Philosopher<'h> { name: &'static str, teacher: Option<PhilosopherRef<'h>>, } #[test] fn strings_in_heap()
{ cell_gc::with_heap(|hs| { let s = hs.alloc(Philosopher { name: "Socrates", teacher: None, }); let p = hs.alloc(Philosopher { name: "Plato", teacher: Some(s.clone()), }); let a = hs.alloc(Philosopher { name: "Aristo...
identifier_body
str.rs
//! Static strings can be stored in the heap. extern crate cell_gc; #[macro_use] extern crate cell_gc_derive; #[derive(IntoHeap)] struct
<'h> { name: &'static str, teacher: Option<PhilosopherRef<'h>>, } #[test] fn strings_in_heap() { cell_gc::with_heap(|hs| { let s = hs.alloc(Philosopher { name: "Socrates", teacher: None, }); let p = hs.alloc(Philosopher { name: "Plato", ...
Philosopher
identifier_name
mod.rs
// Copyright 2014 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ...
impl fmt::Display for Atom { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { <str as fmt::Display>::fmt(self, f) } } impl fmt::Debug for Atom { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let ty_str = unsafe { match self.unpack() { ...
}
random_line_split
mod.rs
// Copyright 2014 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ...
} impl PartialOrd for Atom { #[inline] fn partial_cmp(&self, other: &Atom) -> Option<Ordering> { if self.data == other.data { return Some(Equal); } self.as_slice().partial_cmp(other.as_slice()) } } impl Ord for Atom { #[inline] fn cmp(&self, other: &Atom) -> Or...
{ let ty_str = unsafe { match self.unpack() { Dynamic(..) => "dynamic", Inline(..) => "inline", Static(..) => "static", } }; write!(f, "Atom('{}' type={})", self.as_slice(), ty_str) }
identifier_body
mod.rs
// Copyright 2014 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ...
<S>(&self, serializer: &mut S) -> Result<(),S::Error> where S: Serializer { let string: &str = self.as_ref(); string.serialize(serializer) } } impl Deserialize for Atom { fn deserialize<D>(deserializer: &mut D) -> Result<Atom,D::Error> where D: Deserializer { let string: String = try!(D...
serialize
identifier_name
permissionstatus.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindin...
pub fn get_query(&self) -> PermissionName { self.query.get() } } impl PermissionStatusMethods for PermissionStatus { // https://w3c.github.io/permissions/#dom-permissionstatus-state fn State(&self) -> PermissionState { self.state.get() } // https://w3c.github.io/permissions/#d...
} pub fn set_state(&self, state: PermissionState) { self.state.set(state); }
random_line_split
permissionstatus.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindin...
(global: &GlobalScope, query: &PermissionDescriptor) -> Root<PermissionStatus> { reflect_dom_object(box PermissionStatus::new_inherited(query.name), global, PermissionStatusBinding::Wrap) } pub fn set_state(&self, state: PermissionState) { s...
new
identifier_name
permissionstatus.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindin...
pub fn new(global: &GlobalScope, query: &PermissionDescriptor) -> Root<PermissionStatus> { reflect_dom_object(box PermissionStatus::new_inherited(query.name), global, PermissionStatusBinding::Wrap) } pub fn set_state(&self, state: PermissionSt...
{ PermissionStatus { eventtarget: EventTarget::new_inherited(), state: Cell::new(PermissionState::Denied), query: Cell::new(query), } }
identifier_body
storage.rs
use std::collections::HashMap; use message::{Key, Value}; use std::sync::Mutex; use std::fmt::Debug; /// A generic storage backend for `StorageNode`s to use as persistence layer. pub trait StorageBackend where Self: Debug + Send + Sync { fn new() -> Self; /// Persist `value` under `key`. fn insert(&self, k...
#[derive(Debug)] pub struct HashMapBackend { hashmap: Mutex<HashMap<Key, Value>>, } impl StorageBackend for HashMapBackend { fn new() -> HashMapBackend { debug!("New HashMapBackend"); let hm = HashMap::new(); HashMapBackend { hashmap: Mutex::new(hm) } } fn insert(&self, key: Ke...
random_line_split
storage.rs
use std::collections::HashMap; use message::{Key, Value}; use std::sync::Mutex; use std::fmt::Debug; /// A generic storage backend for `StorageNode`s to use as persistence layer. pub trait StorageBackend where Self: Debug + Send + Sync { fn new() -> Self; /// Persist `value` under `key`. fn insert(&self, k...
fn insert(&self, key: Key, value: Value) { debug!("[HashMapBackend] Going to insert {:?}, {:?}", key, value); let lock = self.hashmap.lock(); let mut map = lock.unwrap(); map.insert(key, value.clone()); debug!("[HashMapBackend] inserted {:?}", value); } fn get(&sel...
{ debug!("New HashMapBackend"); let hm = HashMap::new(); HashMapBackend { hashmap: Mutex::new(hm) } }
identifier_body
storage.rs
use std::collections::HashMap; use message::{Key, Value}; use std::sync::Mutex; use std::fmt::Debug; /// A generic storage backend for `StorageNode`s to use as persistence layer. pub trait StorageBackend where Self: Debug + Send + Sync { fn new() -> Self; /// Persist `value` under `key`. fn insert(&self, k...
(&self, key: &Key) -> Option<Value> { debug!("[HashMapBackend] Going to read {:?}", key); let lock = self.hashmap.lock(); let map = lock.unwrap(); let value = map.get(key); debug!("[HashMapBackend] Value read {:?}", value); match value { Some(x) => Some(x.to_o...
get
identifier_name
lib.rs
// The MIT License (MIT) // // Copyright (c) 2014 J.C. Moyer // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy...
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SO...
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
random_line_split
mod.rs
//! Crypto functions for OAuth 1.0 //! extern crate "rustc-serialize" as serialize; use std::fmt; use std::default::Default; #[unstable] pub mod sha1; pub mod rsa; #[unstable] pub mod hmac; #[stable] trait CircularShift { fn circular_shift(&self, bits : usize) -> Self; } #[stable] impl CircularShift for u32 {...
HMACSHA1, /// RSASHA1 RSASHA1, /// Plaintext PLAINTEXT } impl fmt::Display for SignatureMethod { /// Returns the String used to represent an OAuth signature method in a header fn fmt(&self, f : &mut fmt::Formatter) -> fmt::Result{ let out = match *self { SignatureMethod:...
random_line_split
mod.rs
//! Crypto functions for OAuth 1.0 //! extern crate "rustc-serialize" as serialize; use std::fmt; use std::default::Default; #[unstable] pub mod sha1; pub mod rsa; #[unstable] pub mod hmac; #[stable] trait CircularShift { fn circular_shift(&self, bits : usize) -> Self; } #[stable] impl CircularShift for u32 {...
} impl SignatureMethod { /// Signs a message with the given signature method pub fn sign(&self, msg: String, key: String) -> String { use self::serialize::base64::{self, ToBase64}; match *self { SignatureMethod::HMACSHA1 => { hmac::hmac_sha1(msg.as_bytes(), key.as_b...
{ SignatureMethod::HMACSHA1 }
identifier_body
mod.rs
//! Crypto functions for OAuth 1.0 //! extern crate "rustc-serialize" as serialize; use std::fmt; use std::default::Default; #[unstable] pub mod sha1; pub mod rsa; #[unstable] pub mod hmac; #[stable] trait CircularShift { fn circular_shift(&self, bits : usize) -> Self; } #[stable] impl CircularShift for u32 {...
() -> SignatureMethod { SignatureMethod::HMACSHA1 } } impl SignatureMethod { /// Signs a message with the given signature method pub fn sign(&self, msg: String, key: String) -> String { use self::serialize::base64::{self, ToBase64}; match *self { SignatureMethod::HMACSHA...
default
identifier_name
compiler.rs
use std::io::fs; use std::io::process::Command; use std::path::BytesContainer; use std::str; #[deriving(Decodable)] pub struct Compiler { byproduct: Vec<String>, command: String, flags: Vec<String>, output: String, } impl Compiler { pub fn compile(&self, source: &Path) -> Option<CompilerOutput> { ...
} impl Drop for CompilerOutput { fn drop(&mut self) { if fs::unlink(&self.binary).is_err() { println!("failed to unlink {}", self.binary.display()) } } }
{ &self.binary }
identifier_body
compiler.rs
use std::io::fs; use std::io::process::Command; use std::path::BytesContainer; use std::str; #[deriving(Decodable)] pub struct Compiler { byproduct: Vec<String>, command: String, flags: Vec<String>, output: String, } impl Compiler { pub fn
(&self, source: &Path) -> Option<CompilerOutput> { let command = self.command.as_slice(); let flags = self.flags.as_slice(); let output_file = match source.with_extension("").filename_str() { None => { println!("Malformed input file"); return None; ...
compile
identifier_name
compiler.rs
use std::io::fs; use std::io::process::Command; use std::path::BytesContainer; use std::str; #[deriving(Decodable)] pub struct Compiler { byproduct: Vec<String>, command: String, flags: Vec<String>, output: String, } impl Compiler { pub fn compile(&self, source: &Path) -> Option<CompilerOutput> { ...
impl CompilerOutput { fn new<T: BytesContainer>(path: T) -> CompilerOutput { CompilerOutput { binary: Path::new(path), } } pub fn binary<'a>(&'a self) -> &'a Path { &self.binary } } impl Drop for CompilerOutput { fn drop(&mut self) { if fs::unlink(&self...
binary: Path, }
random_line_split
ucontext.rs
#[cfg(not(target_env = "musl"))] use crate::Result; #[cfg(not(target_env = "musl"))] use crate::errno::Errno; #[cfg(not(target_env = "musl"))] use std::mem; use crate::sys::signal::SigSet; #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub struct UContext { context: libc::ucontext_t, } impl UContext { #[c...
}
&*(&self.context.uc_sigmask as *const libc::sigset_t as *const SigSet) } }
random_line_split
ucontext.rs
#[cfg(not(target_env = "musl"))] use crate::Result; #[cfg(not(target_env = "musl"))] use crate::errno::Errno; #[cfg(not(target_env = "musl"))] use std::mem; use crate::sys::signal::SigSet; #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub struct UContext { context: libc::ucontext_t, } impl UContext { #[c...
(&self) -> &SigSet { unsafe { &*(&self.context.uc_sigmask as *const libc::sigset_t as *const SigSet) } } }
sigmask
identifier_name
data.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/. */ //! Data needed to style a Gecko document. use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use dom:...
unsafe { let servo_media_list = self.raw()._base.mMedia.mRawPtr as *const ServoMediaList; if servo_media_list.is_null() { return None; } let raw_list = &*(*servo_media_list).mRawList.mRawPtr; let list = Locked::<MediaList>::as_arc(mem:...
use std::mem;
random_line_split
data.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/. */ //! Data needed to style a Gecko document. use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use dom:...
(s: *const ServoStyleSheet) -> Self { debug_assert!(!s.is_null()); bindings::Gecko_StyleSheet_AddRef(s); Self::from_addrefed(s) } /// Create a `GeckoStyleSheet` from a raw `ServoStyleSheet` pointer that /// already holds a strong reference. #[inline] pub unsafe fn from_addre...
new
identifier_name
data.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/. */ //! Data needed to style a Gecko document. use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use dom:...
} /// The container for data that a Servo-backed Gecko document needs to style /// itself. pub struct PerDocumentStyleDataImpl { /// Rule processor. pub stylist: Stylist, } /// The data itself is an `AtomicRefCell`, which guarantees the proper semantics /// and unexpected races while trying to mutate it. pub...
{ true }
identifier_body
data.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/. */ //! Data needed to style a Gecko document. use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use dom:...
let raw_list = &*(*servo_media_list).mRawList.mRawPtr; let list = Locked::<MediaList>::as_arc(mem::transmute(&raw_list)); Some(list.read_with(guard)) } } // All the stylesheets Servo knows about are enabled, because that state is // handled externally by Gecko. ...
{ return None; }
conditional_block
main.rs
extern crate rustc_serialize as serialize; use serialize::hex::{FromHex}; use std::env; use std::io::{self, Read}; use std::string::String; fn
() { // deal with args let args: Vec<String> = env::args().collect(); if args.len()!= 2 { println!("USAGE: echo HEX |./single_byte_xor BYTE"); return () } let supplied_string = &args[1]; let supplied_byte = match supplied_string.parse::<u8>() { Err(err) => panic!("sin...
main
identifier_name
main.rs
extern crate rustc_serialize as serialize; use serialize::hex::{FromHex};
fn main() { // deal with args let args: Vec<String> = env::args().collect(); if args.len()!= 2 { println!("USAGE: echo HEX |./single_byte_xor BYTE"); return () } let supplied_string = &args[1]; let supplied_byte = match supplied_string.parse::<u8>() { Err(err) => pan...
use std::env; use std::io::{self, Read}; use std::string::String;
random_line_split
main.rs
extern crate rustc_serialize as serialize; use serialize::hex::{FromHex}; use std::env; use std::io::{self, Read}; use std::string::String; fn main()
let mut decoded = match buffer.from_hex() { Err(err) => panic!("single_byte_xor: {}", err), Ok(val) => val, }; for byte in decoded.iter_mut() { *byte ^= supplied_byte; } let decrypted = match String::from_utf8(decoded) { Err(err) => panic!("single_byte_xor: {}", err), ...
{ // deal with args let args: Vec<String> = env::args().collect(); if args.len() != 2 { println!("USAGE: echo HEX | ./single_byte_xor BYTE"); return () } let supplied_string = &args[1]; let supplied_byte = match supplied_string.parse::<u8>() { Err(err) => panic!("sing...
identifier_body
cmdline.rs
// Copyright 2018 CoreOS, 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 // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
/// Check whether kernel cmdline file contains flags for network configuration. #[allow(unused)] pub fn has_network_kargs(fpath: &str) -> Result<bool> { const IP_PREFIX: &str = "ip="; let content = std::fs::read_to_string(fpath) .chain_err(|| format!("Failed to read cmdline file ({})", fpath))?; l...
{ let content = std::fs::read_to_string(fpath) .chain_err(|| format!("Failed to read cmdline file ({})", fpath))?; match find_flag_value(CMDLINE_PLATFORM_FLAG, &content) { Some(platform) => { trace!("found '{}' flag: {}", CMDLINE_PLATFORM_FLAG, platform); Ok(platform) ...
identifier_body
cmdline.rs
// Copyright 2018 CoreOS, 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 // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
(fpath: &str) -> Result<bool> { const IP_PREFIX: &str = "ip="; let content = std::fs::read_to_string(fpath) .chain_err(|| format!("Failed to read cmdline file ({})", fpath))?; let has_ip = contains_flag_prefix(&content, IP_PREFIX); Ok(has_ip) } /// Check whether cmdline contains any flag starti...
has_network_kargs
identifier_name
cmdline.rs
// Copyright 2018 CoreOS, 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 // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
let bare_val = val.trim(); if!bare_val.is_empty() { return Some(bare_val.to_string()); } } None } #[cfg(test)] mod tests { use super::*; #[test] fn test_find_flag() { let flagname = "coreos.oem.id"; let tests = vec![ ("", None), ...
{ continue; }
conditional_block
cmdline.rs
// Copyright 2018 CoreOS, 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 // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
#[cfg(not(feature = "cl-legacy"))] const CMDLINE_PLATFORM_FLAG: &str = "ignition.platform.id"; /// Platform key (CL and RHCOS legacy name: "OEM"). #[cfg(feature = "cl-legacy")] const CMDLINE_PLATFORM_FLAG: &str = "coreos.oem.id"; /// Get platform/OEM value from cmdline file. pub fn get_platform(fpath: &str) -> Result<...
/// Platform key.
random_line_split
coherence_copy_like_err_tuple.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 ...
struct MyType { x: i32 } trait MyTrait : MarkerTrait { } impl<T: lib::MyCopy> MyTrait for T { } //~ ERROR E0119 // Tuples are not fundamental, therefore this would require that // // (MyType,):!MyTrait // // which we cannot approve. impl MyTrait for (MyType,) { } fn main() { }
extern crate coherence_copy_like_lib as lib; use std::marker::MarkerTrait;
random_line_split
coherence_copy_like_err_tuple.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 ...
() { }
main
identifier_name
data_loader.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::fetch; use headers::{ContentType, HeaderMapExt}; use hyper_serde::Serde; use mime::{self, Mime}; use n...
#[test] fn plain_html() { assert_parse( "data:text/html,<p>Servo</p>", Some(ContentType::from(mime::TEXT_HTML)), None, Some(b"<p>Servo</p>"), ); } #[test] fn plain_charset() { assert_parse( "data:text/plain;charset=latin1,hello", Some(ContentType::from( ...
{ assert_parse( "data:text/plain,hello", Some(ContentType::from(mime::TEXT_PLAIN)), None, Some(b"hello"), ); }
identifier_body