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 |
|---|---|---|---|---|
binlink.rs | // Copyright (c) 2016 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
//
// Unless r... | pub cursor: Arc<RwLock<Cursor<Vec<u8>>>>,
}
impl OutputBuffer {
fn new() -> Self {
OutputBuffer { cursor: Arc::new(RwLock::new(Cursor::new(Vec::new()))) }
}
}
impl Write for OutputBuffer {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
se... | );
}
#[derive(Clone)]
pub struct OutputBuffer { | random_line_split |
binlink.rs | // Copyright (c) 2016 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
//
// Unless r... | () {
let rootfs = TempDir::new("rootfs").unwrap();
let mut tools = HashMap::new();
tools.insert("bin", vec!["magicate", "hypnoanalyze"]);
let ident = fake_bin_pkg_install("acme/cooltools", tools, rootfs.path());
let dst_path = Path::new("/opt/bin");
let rootfs_src_dir = ... | start_symlinks_binaries | identifier_name |
binlink.rs | // Copyright (c) 2016 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
//
// Unless r... |
}
impl Write for OutputBuffer {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.cursor
.write()
.expect("Cursor lock is poisoned")
.write(buf)
}
fn flush(&mut self) -> io::Result<()> {
self.cursor
... | {
OutputBuffer { cursor: Arc::new(RwLock::new(Cursor::new(Vec::new()))) }
} | identifier_body |
controller.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/. */
extern crate serde_json;
extern crate mio;
use adapters::AdapterManager;
use config_store::ConfigService;
use fox... |
}
}
| {
event_loop.shutdown();
} | conditional_block |
controller.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/. */
extern crate serde_json;
extern crate mio;
use adapters::AdapterManager;
use config_store::ConfigService;
use fox... | if self.shutdown_flag.load(Ordering::Acquire) {
event_loop.shutdown();
}
}
} | type Timeout = ();
type Message = ();
fn tick(&mut self, event_loop: &mut mio::EventLoop<Self>) { | random_line_split |
controller.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/. */
extern crate serde_json;
extern crate mio;
use adapters::AdapterManager;
use config_store::ConfigService;
use fox... | (&mut self, event_loop: &mut mio::EventLoop<Self>) {
if self.shutdown_flag.load(Ordering::Acquire) {
event_loop.shutdown();
}
}
}
| tick | identifier_name |
gpubindgrouplayout.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUBindGroupLayoutBindin... |
}
| {
*self.label.borrow_mut() = value;
} | identifier_body |
gpubindgrouplayout.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUBindGroupLayoutBindin... | }
}
impl GPUBindGroupLayoutMethods for GPUBindGroupLayout {
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
fn GetLabel(&self) -> Option<USVString> {
self.label.borrow().clone()
}
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
fn SetLabel(&self, value: Option... | impl GPUBindGroupLayout {
pub fn id(&self) -> WebGPUBindGroupLayout {
self.bind_group_layout | random_line_split |
gpubindgrouplayout.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::GPUBindGroupLayoutBindin... | (
global: &GlobalScope,
bind_group_layout: WebGPUBindGroupLayout,
label: Option<USVString>,
) -> DomRoot<Self> {
reflect_dom_object(
Box::new(GPUBindGroupLayout::new_inherited(bind_group_layout, label)),
global,
)
}
}
impl GPUBindGroupLayout {
... | new | identifier_name |
mod.rs | // 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, modify, merge,
// publish, distribute, sublicense, and/or s... | // Copyright (c) Carl-Erwin Griffith
// | random_line_split | |
Canonical_plain.rs | endogenous DPQ_P_NW, Y, ZGDP, ZI, ZPAI, ZY, D_GDP_NW, I, PAI, R, RN3M_NW
exogenous EGDP, EI, EPAI, EY
parameters beta_lag, beta_lead, beta_r, gam_lag, gam_y, gyss, iss, lamb_lag,
lamb_lead, lamb_y, paiss, rhogdp, rhoi, rhopai, rhoy, siggdp, sigi, sigpai, sigy
parameters prob_commit
model(linear)
Y=beta_lag*Y... |
DPQ_P_NW=paiss+PAI;
RN3M_NW=iss+I;
ZI=rhoi*ZI(-1)+sigi*EI;
ZPAI=rhopai*ZPAI(-1)+sigpai*EPAI;
ZY=rhoy*ZY(-1)+sigy*EY;
ZGDP=(1-rhogdp)*gyss+rhogdp*ZGDP(-1)+siggdp*EGDP;
// the definition in the model is used in specifying the planner objective
planner_objective{discount = 0.99,commitment... | R=I-PAI(+1);
D_GDP_NW=Y-Y(-1)+ZGDP; | random_line_split |
hex.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | let b = s.as_bytes().to_hex();
bh.iter(|| {
b.from_hex();
});
bh.bytes = b.len() as u64;
}
}
| identifier_body | |
hex.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
assert_eq!("666f 6f6\r\n26172 ".from_hex().unwrap(),
"foobar".as_bytes().to_owned());
}
#[test]
pub fn test_to_hex_all_bytes() {
for i in range(0, 256) {
assert_eq!([i as u8].to_hex(), format!("{:02x}", i as uint));
}
}
#[test]
pub fn... | test_from_hex_ignores_whitespace | identifier_name |
hex.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | self.char_at(idx), idx))
}
modulus += 1;
if modulus == 2 {
modulus = 0;
b.push(buf);
}
}
match modulus {
0 => Ok(b),
_ => Err(~"Invalid input length")
... | buf >>= 4;
continue
}
_ => return Err(format!("Invalid character '{}' at position {}", | random_line_split |
shard_runner.rs | prelude::*;
use internal::ws_impl::{ReceiverExt, SenderExt};
use model::event::{Event, GatewayEvent};
use parking_lot::Mutex;
use serde::Deserialize;
use std::sync::{
mpsc::{
self,
Receiver,
Sender,
TryRecvError
},
Arc
};
use super::super::super::dispatch::{DispatchEvent, dis... | (opt: ShardRunnerOptions<H>) -> Self {
let (tx, rx) = mpsc::channel();
Self {
runner_rx: rx,
runner_tx: tx,
data: opt.data,
event_handler: opt.event_handler,
#[cfg(feature = "framework")]
framework: opt.framework,
manag... | new | identifier_name |
shard_runner.rs | ::prelude::*;
use internal::ws_impl::{ReceiverExt, SenderExt};
use model::event::{Event, GatewayEvent};
use parking_lot::Mutex;
use serde::Deserialize;
use std::sync::{
mpsc::{
self,
Receiver,
Sender,
TryRecvError
},
Arc
};
use super::super::super::dispatch::{DispatchEvent, d... | #[inline]
fn dispatch(&self, event: DispatchEvent) {
dispatch(
event,
#[cfg(feature = "framework")]
&self.framework,
&self.data,
&self.event_handler,
&self.runner_tx,
&self.threadpool,
self.shard.shard_info()... | random_line_split | |
shard_runner.rs | prelude::*;
use internal::ws_impl::{ReceiverExt, SenderExt};
use model::event::{Event, GatewayEvent};
use parking_lot::Mutex;
use serde::Deserialize;
use std::sync::{
mpsc::{
self,
Receiver,
Sender,
TryRecvError
},
Arc
};
use super::super::super::dispatch::{DispatchEvent, dis... |
/// Takes an action that a [`Shard`] has determined should happen and then
/// does it.
///
/// For example, if the shard says that an Identify message needs to be
/// sent, this will do that.
///
/// # Errors
///
/// Returns
fn action(&mut self, action: &ShardAction) -> Result... | {
self.runner_tx.clone()
} | identifier_body |
shard_runner.rs | prelude::*;
use internal::ws_impl::{ReceiverExt, SenderExt};
use model::event::{Event, GatewayEvent};
use parking_lot::Mutex;
use serde::Deserialize;
use std::sync::{
mpsc::{
self,
Receiver,
Sender,
TryRecvError
},
Arc
};
use super::super::super::dispatch::{DispatchEvent, dis... |
} else {
return (None, None, true);
}
}
debug!("Attempting to auto-reconnect");
match self.shard.reconnection_type() {
ReconnectType::Reidentify => return (None, None, false),
... | {
return (None, None, true);
} | conditional_block |
make_in_dir.rs | use prelude::*;
pub fn make_inode_in_dir(fs: &mut Filesystem, dir_ino: u64,
name: &[u8], mode: Mode, attr: FileAttr) -> Result<Inode>
{
let mut dir_inode = try!(get_inode(fs, dir_ino));
if dir_inode.mode.file_type!= FileType::Dir {
return Err(Error::new(format!(
"Inode {} is not a directory", dir_ino))... | file_type: FileType::Symlink,
suid: false, sgid: false, sticky: false,
access_rights: 0o777,
};
let mut inode = try!(make_inode_in_dir(fs, dir_ino, name, mode, attr));
try!(write_link_data(fs, &mut inode, link));
Ok(inode)
}
pub fn make_hardlink_in_dir(fs: &mut Filesystem, dir_ino: u64,
name: &[u... | pub fn make_symlink_in_dir(fs: &mut Filesystem, dir_ino: u64,
name: &[u8], link: &[u8], attr: FileAttr) -> Result<Inode>
{
let mode = Mode { | random_line_split |
make_in_dir.rs | use prelude::*;
pub fn make_inode_in_dir(fs: &mut Filesystem, dir_ino: u64,
name: &[u8], mode: Mode, attr: FileAttr) -> Result<Inode>
{
let mut dir_inode = try!(get_inode(fs, dir_ino));
if dir_inode.mode.file_type!= FileType::Dir {
return Err(Error::new(format!(
"Inode {} is not a directory", dir_ino))... | {
let mut dir_inode = try!(get_inode(fs, dir_ino));
let mut link_inode = try!(get_inode(fs, link_ino));
if dir_inode.mode.file_type != FileType::Dir {
return Err(Error::new(format!("Inode {} is not a directory", dir_ino)));
} else if link_inode.mode.file_type == FileType::Dir {
return Err(Error::new(fo... | identifier_body | |
make_in_dir.rs | use prelude::*;
pub fn make_inode_in_dir(fs: &mut Filesystem, dir_ino: u64,
name: &[u8], mode: Mode, attr: FileAttr) -> Result<Inode>
{
let mut dir_inode = try!(get_inode(fs, dir_ino));
if dir_inode.mode.file_type!= FileType::Dir {
return Err(Error::new(format!(
"Inode {} is not a directory", dir_ino))... | (fs: &mut Filesystem, dir_ino: u64,
name: &[u8], link_ino: u64) -> Result<Inode>
{
let mut dir_inode = try!(get_inode(fs, dir_ino));
let mut link_inode = try!(get_inode(fs, link_ino));
if dir_inode.mode.file_type!= FileType::Dir {
return Err(Error::new(format!("Inode {} is not a directory", dir_ino)));
}... | make_hardlink_in_dir | identifier_name |
dst-deref-mut.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 ... | } | // FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
let mut a = Arr { ptr: Box::new([1, 2, 3]) };
foo(&mut a); | random_line_split |
dst-deref-mut.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() {
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
let mut a = Arr { ptr: Box::new([1, 2, 3]) };
foo(&mut a);
}
| {
let x: &mut [usize] = &mut **arr;
assert!(x[0] == 1);
assert!(x[1] == 2);
assert!(x[2] == 3);
} | identifier_body |
dst-deref-mut.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (&mut self) -> &mut [usize] {
&mut *self.ptr
}
}
pub fn foo(arr: &mut Arr) {
let x: &mut [usize] = &mut **arr;
assert!(x[0] == 1);
assert!(x[1] == 2);
assert!(x[2] == 3);
}
fn main() {
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
let mut a = Arr { ptr: Bo... | deref_mut | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#[macro_use] extern crate quote;
#[macro_use] extern crate syn;
#[macro_use] extern crate synstructure;
decl_deri... | (s: synstructure::Structure) -> quote::Tokens {
let match_body = s.each(|binding| {
Some(quote!(#binding.trace(tracer);))
});
let ast = s.ast();
let name = ast.ident;
let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl();
let mut where_clause = where_clause.unwr... | js_traceable_derive | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#[macro_use] extern crate quote;
#[macro_use] extern crate syn;
#[macro_use] extern crate synstructure;
decl_deri... | let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl();
let mut where_clause = where_clause.unwrap_or(&parse_quote!(where)).clone();
for param in ast.generics.type_params() {
let ident = param.ident;
where_clause.predicates.push(parse_quote!(#ident: ::dom::bindings::t... | random_line_split | |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#[macro_use] extern crate quote;
#[macro_use] extern crate syn;
#[macro_use] extern crate synstructure;
decl_deri... | use ::dom::bindings::trace::JSTraceable;
match *self {
#match_body
}
}
}
};
tokens
}
| {
let match_body = s.each(|binding| {
Some(quote!(#binding.trace(tracer);))
});
let ast = s.ast();
let name = ast.ident;
let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl();
let mut where_clause = where_clause.unwrap_or(&parse_quote!(where)).clone();
for p... | identifier_body |
extension_class_container_impl1.rs | /*
* Swaggy Jenkins
*
* Jenkins API clients generated from Swagger / Open API specification
*
* The version of the OpenAPI document: 1.1.2-pre.0 | * Contact: blah@cliffano.com
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct ExtensionClassContainerImpl1 {
#[serde(rename = "_class", skip_serializing_if = "Option::is_none")]
pub _class: Option<String>,
#[serde(rename ... | random_line_split | |
extension_class_container_impl1.rs | /*
* Swaggy Jenkins
*
* Jenkins API clients generated from Swagger / Open API specification
*
* The version of the OpenAPI document: 1.1.2-pre.0
* Contact: blah@cliffano.com
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct Exten... | () -> ExtensionClassContainerImpl1 {
ExtensionClassContainerImpl1 {
_class: None,
_links: None,
map: None,
}
}
}
| new | identifier_name |
firm.rs | use std::fs::File;
use std::io::{Read, Seek, SeekFrom};
use std::path::{Path, PathBuf};
use ldr;
use mem;
use utils::bytes;
#[derive(Debug, Error)]
pub enum ErrorKind {
Io(::std::io::Error)
}
struct FirmSection {
data_offs: usize,
size: usize,
dst_addr: u32,
}
impl FirmSection {
fn from_header(h... |
file.read_exact(read_buf).unwrap();
controller.write_buf(vaddr, read_buf);
read_amount += read_buf_size;
vaddr += read_buf_size as u32;
}
}
}
fn entrypoint11(&self) -> u32 {
self.entry11
}
fn l... | { break } | conditional_block |
firm.rs | use std::fs::File;
use std::io::{Read, Seek, SeekFrom};
use std::path::{Path, PathBuf};
use ldr;
use mem;
use utils::bytes;
#[derive(Debug, Error)]
pub enum ErrorKind {
Io(::std::io::Error)
}
struct FirmSection {
data_offs: usize,
size: usize,
dst_addr: u32,
}
impl FirmSection {
fn from_header(h... | (filename: &Path) -> Result<Self, ErrorKind> {
let mut file = File::open(filename)?;
let mut header = [0u8; 0x200];
file.read_exact(&mut header)?;
assert!(&header[..4] == b"FIRM");
let entry11: u32 = unsafe { bytes::val_at_offs(&header, 0x8) };
let entry9: u32 = unsafe... | from_file | identifier_name |
firm.rs | use std::fs::File;
use std::io::{Read, Seek, SeekFrom};
use std::path::{Path, PathBuf};
use ldr;
use mem;
use utils::bytes;
#[derive(Debug, Error)]
pub enum ErrorKind {
Io(::std::io::Error)
}
struct FirmSection {
data_offs: usize,
size: usize,
dst_addr: u32,
}
impl FirmSection {
fn from_header(h... |
fn load11(&self, _controller: &mut mem::MemController) {
// Unnecessary because FIRMs on the 3DS can only load into ARM9-accessible memory
}
}
| {
self.entry11
} | identifier_body |
firm.rs | use std::fs::File;
use std::io::{Read, Seek, SeekFrom};
use std::path::{Path, PathBuf};
use ldr;
use mem;
use utils::bytes;
#[derive(Debug, Error)]
pub enum ErrorKind {
Io(::std::io::Error)
}
struct FirmSection {
data_offs: usize,
size: usize,
dst_addr: u32,
}
impl FirmSection {
fn from_header(h... | } | } | random_line_split |
lib.rs | a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Servo's compiler plugin/macro crate
//!
//! Attributes this crate provides:
//!
//! - `#[derive(DenyPublicFields)]` : Forces all fields in a struct/enum to be private
//! - `#[derive(JSTraceable)]` : ... |
declare_lint!(
UNROOTED_MUST_ROOT,
Deny,
"Warn and report usage of unrooted jsmanaged objects"
);
/// Lint for ensuring safe usage of unrooted pointers
///
/// This lint (disable with `-A unrooted-must-root`/`#[allow(unrooted_must_root)]`) ensures that
/// `#[unrooted_must_root_lint::must_root]` values a... | {
let symbols = Symbols::new();
reg.lint_store.register_lints(&[&UNROOTED_MUST_ROOT]);
reg.lint_store
.register_late_pass(move || Box::new(UnrootedPass::new(symbols.clone())));
} | identifier_body |
lib.rs | a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Servo's compiler plugin/macro crate
//!
//! Attributes this crate provides:
//!
//! - `#[derive(DenyPublicFields)]` : Forces all fields in a struct/enum to be private
//! - `#[derive(JSTraceable)]` : ... | }
}
let mut visitor = FnDefVisitor {
symbols: &self.symbols,
cx: cx,
in_new_function: in_new_function,
};
visit::walk_expr(&mut visitor, &body.value);
}
}
struct FnDefVisitor<'a, 'b: 'a, 'tcx: 'a + 'b> {
symbols: &'a Symbols,
... | {
let def_id = cx.tcx.hir().local_def_id(id);
let sig = cx.tcx.type_of(def_id).fn_sig(cx.tcx);
for (arg, ty) in decl.inputs.iter().zip(sig.inputs().skip_binder().iter()) {
if is_unrooted_ty(&self.symbols, cx, ty, false) {
cx.lint(UNROOTED_MUST_ROO... | conditional_block |
lib.rs | a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Servo's compiler plugin/macro crate
//!
//! Attributes this crate provides:
//!
//! - `#[derive(DenyPublicFields)]` : Forces all fields in a struct/enum to be private
//! - `#[derive(JSTraceable)]` : ... | (sym: &Symbols, cx: &LateContext, ty: &ty::TyS, in_new_function: bool) -> bool {
let mut ret = false;
ty.maybe_walk(|t| {
match t.kind {
ty::Adt(did, substs) => {
let has_attr = |did, name| has_lint_attr(sym, &cx.tcx.get_attrs(did), name);
if has_attr(did.did,... | is_unrooted_ty | identifier_name |
lib.rs | If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Servo's compiler plugin/macro crate
//!
//! Attributes this crate provides:
//!
//! - `#[derive(DenyPublicFields)]` : Forces all fields in a struct/enum to be private
//! - `#[derive(JSTraceable)]`... | impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnrootedPass {
/// All structs containing #[unrooted_must_root_lint::must_root] types
/// must be #[unrooted_must_root_lint::must_root] themselves
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
if has_lint_attr(&self.symbols, &... | random_line_split | |
persistent_list.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A persistent, thread-safe singly-linked list.
use std::mem;
use std::sync::Arc;
pub struct PersistentList<T>... | <'a,T> where T: 'a + Send + Sync {
entry: Option<&'a PersistentListEntry<T>>,
}
impl<'a,T> Iterator<&'a T> for PersistentListIterator<'a,T> where T: Send + Sync {
#[inline]
fn next(&mut self) -> Option<&'a T> {
let entry = match self.entry {
None => return None,
Some(entry) ... | PersistentListIterator | identifier_name |
persistent_list.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A persistent, thread-safe singly-linked list.
use std::mem;
use std::sync::Arc;
pub struct PersistentList<T>... |
#[inline]
pub fn front(&self) -> Option<&T> {
self.head.as_ref().map(|head| &head.value)
}
#[inline]
pub fn prepend_elem(&self, value: T) -> PersistentList<T> {
PersistentList {
head: Some(Arc::new(PersistentListEntry {
value: value,
nex... | {
self.length
} | identifier_body |
persistent_list.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A persistent, thread-safe singly-linked list.
use std::mem;
use std::sync::Arc;
pub struct PersistentList<T>... | &'static PersistentListEntry<T>>(entry)
}
}
};
let value = &entry.value;
self.entry = match entry.next {
None => None,
Some(ref entry) => Some(&**entry),
};
Some(value)
}
} | mem::transmute::<&'a PersistentListEntry<T>, | random_line_split |
ranked-routing.rs | #![feature(test, plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
use rocket::config::{Environment, Config};
#[get("/", format = "application/json")]
fn get() -> &'static str { "json" }
#[get("/", format = "text/html")]
fn get2() -> &'static str { "html" }
#[get("/", format = "text/plain")]
fn get3() -> &'... |
#[post("/", format = "text/html")]
fn post2() -> &'static str { "html" }
#[post("/", format = "text/plain")]
fn post3() -> &'static str { "plain" }
fn rocket() -> rocket::Rocket {
let config = Config::new(Environment::Production).unwrap();
rocket::custom(config, false)
.mount("/", routes![get, get2, ... | { "json" } | identifier_body |
ranked-routing.rs | #![feature(test, plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
use rocket::config::{Environment, Config};
#[get("/", format = "application/json")]
fn get() -> &'static str { "json" }
#[get("/", format = "text/html")]
fn get2() -> &'static str { "html" }
#[get("/", format = "text/plain")]
fn get3() -> &'... | #[bench]
fn content_type_format(b: &mut Bencher) {
let client = Client::new(rocket()).unwrap();
let mut requests = vec![];
requests.push(client.post("/").header(ContentType::JSON));
requests.push(client.post("/").header(ContentType::HTML));
requests.push(client.post("/").... | random_line_split | |
ranked-routing.rs | #![feature(test, plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
use rocket::config::{Environment, Config};
#[get("/", format = "application/json")]
fn | () -> &'static str { "json" }
#[get("/", format = "text/html")]
fn get2() -> &'static str { "html" }
#[get("/", format = "text/plain")]
fn get3() -> &'static str { "plain" }
#[post("/", format = "application/json")]
fn post() -> &'static str { "json" }
#[post("/", format = "text/html")]
fn post2() -> &'static str {... | get | identifier_name |
pushrebase.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use anyhow::{anyhow, Error};
use blobrepo::BlobRepo;
use blobstore::Loadable;
use bookmarks::BookmarkName;
use clap_old::{App, Arg, ArgMatc... | let pushrebase_hooks = bookmarks_movement::get_pushrebase_hooks(
&ctx,
&repo,
&bookmark,
&bookmark_attrs,
&repo_config.pushrebase,
)
.map_err(Error::from)?;
let bcs = cs_id
.load(&ctx, &repo.get_blobstore())
.map_err(Error::from)
.await?;
... | {
let ctx = CoreContext::new_with_logger(fb, logger.clone());
let repo: BlobRepo = args::open_repo(fb, &logger, &matches).await?;
let cs_id = sub_matches
.value_of(ARG_CSID)
.ok_or_else(|| anyhow!("{} arg is not specified", ARG_CSID))?;
let cs_id = helpers::csid_resolve(&ctx, &repo, cs... | identifier_body |
pushrebase.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use anyhow::{anyhow, Error};
use blobrepo::BlobRepo;
use blobstore::Loadable;
use bookmarks::BookmarkName;
use clap_old::{App, Arg, ArgMatc... | <'a, 'b>() -> App<'a, 'b> {
SubCommand::with_name(PUSHREBASE)
.about("pushrebases a commit to a bookmark")
.arg(
Arg::with_name(ARG_CSID)
.long(ARG_CSID)
.takes_value(true)
.required(true)
.help("{hg|bonsai} changeset id or bookma... | build_subcommand | identifier_name |
pushrebase.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use anyhow::{anyhow, Error};
use blobrepo::BlobRepo;
use blobstore::Loadable;
use bookmarks::BookmarkName;
use clap_old::{App, Arg, ArgMatc... | let repo: BlobRepo = args::open_repo(fb, &logger, &matches).await?;
let cs_id = sub_matches
.value_of(ARG_CSID)
.ok_or_else(|| anyhow!("{} arg is not specified", ARG_CSID))?;
let cs_id = helpers::csid_resolve(&ctx, &repo, cs_id).await?;
let bookmark = sub_matches
.value_of(ARG_BO... | random_line_split | |
str.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 app_units::Au;
use cssparser::{self, Color, RGBA};
use js::conversions::{FromJSValConvertible, ToJSValConverti... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&**self, f)
}
}
impl PartialEq<str> for DOMString {
fn eq(&self, other: &str) -> bool {
&**self == other
}
}
impl<'a> PartialEq<&'a str> for DOMString {
fn eq(&self, other: &&'a str) -> bool {
&**self == *other
... | fmt | identifier_name |
str.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 app_units::Au;
use cssparser::{self, Color, RGBA};
use js::conversions::{FromJSValConvertible, ToJSValConverti... |
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum LengthOrPercentageOrAuto {
Auto,
Percentage(f32),
Length(Au),
}
/// TODO: this function can be rewritten to return Result<LengthOrPercentage, _>
/// Parses a dimension value per HTML5 § 2.4.4.4. If unparseable, `Auto` is
/// returned.
/// https://html.spec... |
do_parse_integer(input).and_then(|result| {
result.to_u32()
})
}
| identifier_body |
str.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 app_units::Au;
use cssparser::{self, Color, RGBA};
use js::conversions::{FromJSValConvertible, ToJSValConverti... | type Target = str;
#[inline]
fn deref(&self) -> &str {
&*self.inner
}
}
/// Creates a String from the given null-terminated buffer.
/// Panics if the buffer does not contain UTF-8.
pub unsafe fn c_str_to_string(s: *const c_char) -> String {
from_utf8(CStr::from_ptr(s).to_bytes()).unwrap().... |
impl Deref for LowercaseString { | random_line_split |
str.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 app_units::Au;
use cssparser::{self, Color, RGBA};
use js::conversions::{FromJSValConvertible, ToJSValConverti... | }
}
}
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct LowercaseString {
inner: String,
}
impl LowercaseString {
pub fn new(s: &str) -> LowercaseString {
LowercaseString {
inner: s.to_lowercase(),
}
}
}
impl Deref for LowercaseString {
type Target = str;
... | let upper = try!(hex(string[0] as char));
let lower = try!(hex(string[1] as char));
Ok((upper << 4) | lower)
}
| conditional_block |
atlas.rs | use std::collections::HashMap;
use ui::lit::Lit;
#[derive(Serialize, Deserialize)]
pub struct TexmapBucket(pub HashMap<String, Texmap>);
#[derive(Serialize, Deserialize)]
pub struct Texmap(pub HashMap<String, TextureSelection>);
impl Texmap {
pub fn | (name: String) -> Self {
let mut map = HashMap::new();
map.insert(name, TextureSelection::identity());
Texmap(map)
}
}
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
/// A selection in UV space: bottom left is [0.0, 0.0], top right is [1.0, 1.0]
pub struct TextureSelection {
pub min: [Lit; 2],
pu... | new | identifier_name |
atlas.rs | use std::collections::HashMap;
use ui::lit::Lit;
#[derive(Serialize, Deserialize)]
pub struct TexmapBucket(pub HashMap<String, Texmap>);
#[derive(Serialize, Deserialize)]
pub struct Texmap(pub HashMap<String, TextureSelection>);
impl Texmap {
pub fn new(name: String) -> Self {
let mut map = HashMap::new();
m... | size: [Lit::from_part(1.0), Lit::from_part(1.0)]
}
}
} | random_line_split | |
mod.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... | TrieKinds::Fat(ref t) => t.$f_name($($param),*),
}
}
}
impl<'db> Trie for TrieKinds<'db> {
fn root(&self) -> &H256 {
wrapper!(self, root,)
}
fn is_empty(&self) -> bool {
wrapper!(self, is_empty,)
}
fn contains(&self, key: &[u8]) -> Result<bool> {
wrapper!(self, conta... | ($me: ident, $f_name: ident, $($param: ident),*) => {
match *$me {
TrieKinds::Generic(ref t) => t.$f_name($($param),*),
TrieKinds::Secure(ref t) => t.$f_name($($param),*), | random_line_split |
mod.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... | <'db>(&self, db: &'db HashDB, root: &'db H256) -> Result<TrieKinds<'db>> {
match self.spec {
TrieSpec::Generic => Ok(TrieKinds::Generic(TrieDB::new(db, root)?)),
TrieSpec::Secure => Ok(TrieKinds::Secure(SecTrieDB::new(db, root)?)),
TrieSpec::Fat => Ok(TrieKinds::Fat(FatDB::ne... | readonly | identifier_name |
cors.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A partial implementation of CORS
//! For now this library is XHR-specific.
//! For stuff involving `<img>`, `<... |
response
}
/// https://fetch.spec.whatwg.org/#cors-preflight-fetch
fn preflight_fetch(&self) -> CORSResponse {
let error = CORSResponse::new_error();
let mut cors_response = CORSResponse::new();
// Step 1
let mut preflight = self.clone();
preflight.method =... | {
return self.preflight_fetch();
// Everything after this is part of XHR::fetch()
// Expect the organization of code to improve once we have a fetch crate
} | conditional_block |
cors.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A partial implementation of CORS
//! For now this library is XHR-specific.
//! For stuff involving `<img>`, `<... | (&mut self, request: &CORSRequest, method: &Method) -> bool {
self.find_entry_by_method(request, method).is_some()
}
fn match_method_and_update(&mut self,
request: &CORSRequest,
method: &Method,
new_max_age: u3... | match_method | identifier_name |
cors.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A partial implementation of CORS
//! For now this library is XHR-specific.
//! For stuff involving `<img>`, `<... |
fn is_simple_method(m: &Method) -> bool {
match *m {
Method::Get | Method::Head | Method::Post => true,
_ => false,
}
}
/// Perform a CORS check on a header list and CORS request
/// https://fetch.spec.whatwg.org/#cors-check
pub fn allow_cross_origin_request(req: &CORSRequest, headers: &Heade... | {
// FIXME: use h.is::<HeaderType>() when AcceptLanguage and
// ContentLanguage headers exist
match &*h.name().to_ascii_lowercase() {
"accept" | "accept-language" | "content-language" => true,
"content-type" => match h.value() {
Some(&ContentType(Mime(TopLevel::Text, SubLevel::Pl... | identifier_body |
cors.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A partial implementation of CORS
//! For now this library is XHR-specific.
//! For stuff involving `<img>`, `<... | })
}
/// https://fetch.spec.whatwg.org/#concept-cache-match-method
fn match_method(&mut self, request: &CORSRequest, method: &Method) -> bool {
self.find_entry_by_method(request, method).is_some()
}
fn match_method_and_update(&mut self,
request: &CORS... | random_line_split | |
and.rs | // Copyright 2014 Strahinja Val Markovic
//
// 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 ag... |
impl<'a> And<'a> {
pub fn new( expr: &Expression ) -> And {
And { expr: expr }
}
}
impl<'b> Expression for And<'b> {
fn apply<'a>( &self, parse_state: &ParseState<'a> ) ->
Option< ParseResult<'a> > {
match self.expr.apply( parse_state ) {
Some( _ ) => Some( ParseResult::fromParseState( *pa... | random_line_split | |
and.rs | // Copyright 2014 Strahinja Val Markovic
//
// 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 ag... |
}
impl<'b> Expression for And<'b> {
fn apply<'a>( &self, parse_state: &ParseState<'a> ) ->
Option< ParseResult<'a> > {
match self.expr.apply( parse_state ) {
Some( _ ) => Some( ParseResult::fromParseState( *parse_state ) ),
_ => None
}
}
}
#[cfg(test)]
mod tests {
use base;
use ba... | {
And { expr: expr }
} | identifier_body |
and.rs | // Copyright 2014 Strahinja Val Markovic
//
// 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 ag... | () {
assert!( and!( class!( "a-z" ) ).apply( &input_state!( "0" ) ).is_none() );
assert!( and!( lit!( "x" ) ).apply( &input_state!( "y" ) ).is_none() );
}
}
| And_NoMatch | identifier_name |
context.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
#[cfg(target_arch = "x86_64")]
fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
procedure: raw::Procedure, sp: *mut uint) {
extern { fn rust_bootstrap_green_task(); }
// Redefinitions from rt/arch/x86_64/regs.h
static RUSTRT_RSP: uint = 1;
static RUSTRT... | { ~([0, .. 22]) } | identifier_body |
context.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (out_context: &mut Context, in_context: &Context) {
rtdebug!("swapping contexts");
let out_regs: &mut Registers = match out_context {
&Context { regs: ~ref mut r,.. } => r
};
let in_regs: &Registers = match in_context {
&Context { regs: ~ref r,.. } => r
};... | swap | identifier_name |
context.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | unsafe { *sp = 0; }
// ARM uses the same technique as x86_64 to have a landing pad for the start
// of all new green tasks. Neither r1/r2 are saved on a context switch, so
// the shim will copy r3/r4 into r1/r2 and then execute the function in r5
regs[0] = arg as uint; // r0
regs[3... | // The final return address. 0 indicates the bottom of the stack | random_line_split |
asm.rs | use super::BackendTypes;
use crate::mir::operand::OperandRef;
use crate::mir::place::PlaceRef;
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_hir::def_id::DefId;
use rustc_hir::LlvmInlineAsmInner;
use rustc_middle::ty::Instance;
use rustc_span::Span;
use rustc_target::asm::InlineAsmRegOrRegClass;
... | <'tcx, B: BackendTypes +?Sized> {
In {
reg: InlineAsmRegOrRegClass,
value: OperandRef<'tcx, B::Value>,
},
Out {
reg: InlineAsmRegOrRegClass,
late: bool,
place: Option<PlaceRef<'tcx, B::Value>>,
},
InOut {
reg: InlineAsmRegOrRegClass,
late: bool... | InlineAsmOperandRef | identifier_name |
asm.rs | use super::BackendTypes;
use crate::mir::operand::OperandRef;
use crate::mir::place::PlaceRef;
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_hir::def_id::DefId;
use rustc_hir::LlvmInlineAsmInner;
use rustc_middle::ty::Instance;
use rustc_span::Span;
use rustc_target::asm::InlineAsmRegOrRegClass;
... | /// Take an inline assembly expression and splat it out via LLVM
fn codegen_llvm_inline_asm(
&mut self,
ia: &LlvmInlineAsmInner,
outputs: Vec<PlaceRef<'tcx, Self::Value>>,
inputs: Vec<Self::Value>,
span: Span,
) -> bool;
/// Take an inline assembly expression and... | pub trait AsmBuilderMethods<'tcx>: BackendTypes { | random_line_split |
key_templates.rs | // Copyright 2020 The Tink-Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... |
/// Return a [`KeyTemplate`] that generates an AES-CMAC key with the following parameters:
/// - Key size: 32 bytes
pub fn aes_cmac_prf_key_template() -> KeyTemplate {
create_aes_cmac_prf_key_template(32)
}
/// Create a new [`KeyTemplate`] for HMAC using the given parameters.
fn create_hmac_prf_key_template(key... | {
create_hkdf_prf_key_template(32, tink_proto::HashType::Sha256, &[])
} | identifier_body |
key_templates.rs | // Copyright 2020 The Tink-Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | format.encode(&mut serialized_format).unwrap(); // safe: proto-encode
KeyTemplate {
type_url: super::HKDF_PRF_TYPE_URL.to_string(),
output_prefix_type: tink_proto::OutputPrefixType::Raw as i32,
value: serialized_format,
}
}
// Create a new [`KeyTemplate`] for AES-CMAC using the give... | version: super::HKDF_PRF_KEY_VERSION,
};
let mut serialized_format = Vec::new(); | random_line_split |
key_templates.rs | // Copyright 2020 The Tink-Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | () -> KeyTemplate {
create_hkdf_prf_key_template(32, tink_proto::HashType::Sha256, &[])
}
/// Return a [`KeyTemplate`] that generates an AES-CMAC key with the following parameters:
/// - Key size: 32 bytes
pub fn aes_cmac_prf_key_template() -> KeyTemplate {
create_aes_cmac_prf_key_template(32)
}
/// Create a... | hkdf_sha256_prf_key_template | identifier_name |
clone_rope.rs | extern crate ropey;
use std::iter::Iterator;
use ropey::Rope;
const TEXT: &str = include_str!("test_text.txt");
|
// Do identical insertions into both ropes
rope1.insert(432, "Hello ");
rope1.insert(2345, "world! ");
rope1.insert(5256, "How are ");
rope1.insert(53, "you ");
rope1.insert(768, "doing?\r\n");
rope2.insert(432, "Hello ");
rope2.insert(2345, "world! ");
rope2.insert(5256, "How are ... | #[test]
fn clone_rope() {
let mut rope1 = Rope::from_str(TEXT);
let mut rope2 = rope1.clone(); | random_line_split |
clone_rope.rs | extern crate ropey;
use std::iter::Iterator;
use ropey::Rope;
const TEXT: &str = include_str!("test_text.txt");
#[test]
fn clone_rope() | .all(|n| n);
assert_eq!(matches, true);
// Insert something into the clone, and make sure they don't match
// afterwards.
rope2.insert(3891, "I'm doing fine, thanks!");
let matches = Iterator::zip(rope1.chars(), rope2.chars())
.map(|(a, b)| a == b)
.all(|n| n);
assert_eq!(m... | {
let mut rope1 = Rope::from_str(TEXT);
let mut rope2 = rope1.clone();
// Do identical insertions into both ropes
rope1.insert(432, "Hello ");
rope1.insert(2345, "world! ");
rope1.insert(5256, "How are ");
rope1.insert(53, "you ");
rope1.insert(768, "doing?\r\n");
rope2.insert(432,... | identifier_body |
clone_rope.rs | extern crate ropey;
use std::iter::Iterator;
use ropey::Rope;
const TEXT: &str = include_str!("test_text.txt");
#[test]
fn | () {
let mut rope1 = Rope::from_str(TEXT);
let mut rope2 = rope1.clone();
// Do identical insertions into both ropes
rope1.insert(432, "Hello ");
rope1.insert(2345, "world! ");
rope1.insert(5256, "How are ");
rope1.insert(53, "you ");
rope1.insert(768, "doing?\r\n");
rope2.insert(4... | clone_rope | identifier_name |
buttons-attribute.rs | /*
* Copyright (c) 2017 Boucher, Antoni <bouanto@zoho.com>
*
* 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,... | assert_text!(label, 2);
click(inc_button);
assert_text!(label, 3);
click(inc_button);
assert_text!(label, 4);
click(dec_button);
assert_text!(label, 3);
click(dec_button);
assert_text!(label, 2);
click(dec_button);
assert_text!(lab... | random_line_split | |
buttons-attribute.rs | /*
* Copyright (c) 2017 Boucher, Antoni <bouanto@zoho.com>
*
* 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,... |
#[cfg(test)]
mod tests {
use gtk::{prelude::ButtonExt, prelude::LabelExt};
use gtk_test::{assert_label, assert_text};
use relm_test::click;
use crate::Win;
#[test]
fn label_change() {
let (_component, _, widgets) = relm::init_test::<Win>(()).expect("init_test failed");
let i... | {
Win::run(()).expect("Win::run failed");
} | identifier_body |
buttons-attribute.rs | /*
* Copyright (c) 2017 Boucher, Antoni <bouanto@zoho.com>
*
* 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,... | {
#[cfg(test)] Test,
Decrement,
Increment,
Quit,
}
#[widget]
impl Widget for Win {
// The initial model.
fn model() -> Model {
Model {
counter: 0,
}
}
// Update the model according to the message received.
fn update(&mut self, event: Msg) {
matc... | Msg | identifier_name |
release.rs | use std::any::Any;
use input::Button;
use { GenericEvent, RELEASE };
/// The release of a button
pub trait ReleaseEvent {
/// Creates a release event.
fn from_button(button: Button, old_event: &Self) -> Option<Self>;
/// Calls closure if this is a release event.
fn release<U, F>(&self, f: F) -> Option... | (bencher: &mut Bencher) {
use input::{ Button, Input, Key };
let e = Input::Release(Button::Keyboard(Key::S));
let button = Button::Keyboard(Key::A);
bencher.iter(|| {
let _: Option<Input> = ReleaseEvent::from_button(button, &e);
});
}
#[test]
fn test_ev... | bench_input_release | identifier_name |
release.rs | use std::any::Any;
use input::Button;
use { GenericEvent, RELEASE };
/// The release of a button
pub trait ReleaseEvent {
/// Creates a release event.
fn from_button(button: Button, old_event: &Self) -> Option<Self>;
/// Calls closure if this is a release event.
fn release<U, F>(&self, f: F) -> Option... |
fn release<U, F>(&self, mut f: F) -> Option<U>
where F: FnMut(Button) -> U
{
if self.event_id()!= RELEASE {
return None;
}
self.with_args(|any| {
if let Some(&button) = any.downcast_ref::<Button>() {
Some(f(button))
} else {
... | {
GenericEvent::from_args(RELEASE, &button as &Any, old_event)
} | identifier_body |
release.rs | use std::any::Any;
use input::Button;
use { GenericEvent, RELEASE };
/// The release of a button
pub trait ReleaseEvent {
/// Creates a release event.
fn from_button(button: Button, old_event: &Self) -> Option<Self>;
/// Calls closure if this is a release event.
fn release<U, F>(&self, f: F) -> Option... | #[bench]
fn bench_event_release(bencher: &mut Bencher) {
use Event;
use input::{ Button, Key, Input };
let e = Event::Input(Input::Release(Button::Keyboard(Key::S)));
let button = Button::Keyboard(Key::A);
bencher.iter(|| {
let _: Option<Event> = ReleaseEvent... | let y: Option<Event> = x.clone().unwrap().release(|button|
ReleaseEvent::from_button(button, x.as_ref().unwrap())).unwrap();
assert_eq!(x, y);
}
| random_line_split |
release.rs | use std::any::Any;
use input::Button;
use { GenericEvent, RELEASE };
/// The release of a button
pub trait ReleaseEvent {
/// Creates a release event.
fn from_button(button: Button, old_event: &Self) -> Option<Self>;
/// Calls closure if this is a release event.
fn release<U, F>(&self, f: F) -> Option... | else {
panic!("Expected Button")
}
})
}
}
#[cfg(test)]
mod tests {
use super::*;
use test::Bencher;
#[test]
fn test_input_release() {
use input::{ Button, Key, Input };
let e = Input::Release(Button::Keyboard(Key::S));
let button = But... | {
Some(f(button))
} | conditional_block |
matcher_api.rs | // You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See th... |
pub fn matches_possible_number(&self, nationalNumber: &str, numberDesc: PhoneNumberDesc) -> bool {
let nationalNumberPatternMatcher : Matcher = self.regexCache.get_pattern_for_regex(
numberDesc.get_national_number_pattern()).matcher(nationalNumber);
possibleNumberPatternMatcher.matche... | {
let nationalNumberPatternMatcher : Matcher = self.regexCache.get_pattern_for_regex(
numberDesc.get_national_number_pattern()).matcher(nationalNumber);
nationalNumberPatternMatcher.matches() ||
(allowPrefixMatch && nationalNumberPatternMatcher.looking_at());
} | identifier_body |
matcher_api.rs | // You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See th... | (&self, nationalNumber: &str, numberDesc: PhoneNumberDesc) -> bool {
let nationalNumberPatternMatcher : Matcher = self.regexCache.get_pattern_for_regex(
numberDesc.get_national_number_pattern()).matcher(nationalNumber);
possibleNumberPatternMatcher.matches()
}
} | matches_possible_number | identifier_name |
matcher_api.rs | // You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See th... | pub fn matches_national_number(&self, nationalNumber: &str, numberDesc: PhoneNumberDesc,
allowPrefixMatch: bool) -> bool {
let nationalNumberPatternMatcher : Matcher = self.regexCache.get_pattern_for_regex(
numberDesc.get_national_number_pattern()).matcher(nationalNumber);
natio... | random_line_split | |
combinations_with_replacement.rs | use std::fmt;
use super::lazy_buffer::LazyBuffer;
/// An iterator to iterate through all the `n`-length combinations in an iterator, with replacement.
///
/// See [`.combinations_with_replacement()`](../trait.Itertools.html#method.combinations_with_replacement) for more information.
#[derive(Clone)]
pub struct Combin... | <I>(iter: I, k: usize) -> CombinationsWithReplacement<I>
where
I: Iterator,
I::Item: Clone,
{
let indices: Vec<usize> = vec![0; k];
let pool: LazyBuffer<I> = LazyBuffer::new(iter);
CombinationsWithReplacement {
k,
indices,
max_index: 0,
pool,
first: true,
... | combinations_with_replacement | identifier_name |
combinations_with_replacement.rs | use std::fmt;
use super::lazy_buffer::LazyBuffer;
/// An iterator to iterate through all the `n`-length combinations in an iterator, with replacement.
///
/// See [`.combinations_with_replacement()`](../trait.Itertools.html#method.combinations_with_replacement) for more information.
#[derive(Clone)]
pub struct Combin... | ;
}
// Check if we need to consume more from the iterator
// This will run while we increment our first index digit
if self.pool.get_next() {
self.max_index = self.pool.len() - 1;
}
// Work out where we need to update our indices
let mut increment: O... | {
self.first = false;
Some(self.current())
} | conditional_block |
combinations_with_replacement.rs | use std::fmt;
use super::lazy_buffer::LazyBuffer;
/// An iterator to iterate through all the `n`-length combinations in an iterator, with replacement.
///
/// See [`.combinations_with_replacement()`](../trait.Itertools.html#method.combinations_with_replacement) for more information.
#[derive(Clone)]
pub struct Combin... | let mut increment: Option<(usize, usize)> = None;
for (i, indices_int) in self.indices.iter().enumerate().rev() {
if indices_int < &self.max_index {
increment = Some((i, indices_int + 1));
break;
}
}
match increment {
/... | random_line_split | |
combinations_with_replacement.rs | use std::fmt;
use super::lazy_buffer::LazyBuffer;
/// An iterator to iterate through all the `n`-length combinations in an iterator, with replacement.
///
/// See [`.combinations_with_replacement()`](../trait.Itertools.html#method.combinations_with_replacement) for more information.
#[derive(Clone)]
pub struct Combin... | let mut increment: Option<(usize, usize)> = None;
for (i, indices_int) in self.indices.iter().enumerate().rev() {
if indices_int < &self.max_index {
increment = Some((i, indices_int + 1));
break;
}
}
match increment {
/... | {
// If this is the first iteration, return early
if self.first {
// In empty edge cases, stop iterating immediately
return if self.k != 0 && !self.pool.get_next() {
None
// Otherwise, yield the initial state
} else {
self.f... | identifier_body |
mod.rs | /*!
In order to draw, you need to provide a source of indices which is used to link the vertices
together into *primitives*.
There are eleven types of primitives, each one with a corresponding struct:
- `PointsList`
- `LinesList`
- `LinesListAdjacency`
- `LineStrip`
- `LineStripAdjacency`
- `TrianglesList`
- `... |
}
unsafe impl Index for u32 {
fn get_type() -> IndexType {
IndexType::U32
}
}
| {
IndexType::U16
} | identifier_body |
mod.rs | /*!
In order to draw, you need to provide a source of indices which is used to link the vertices
together into *primitives*.
There are eleven types of primitives, each one with a corresponding struct:
- `PointsList`
- `LinesList`
- `LinesListAdjacency`
- `LineStrip`
- `LineStripAdjacency`
- `TrianglesList`
- `... | }
}
}
impl ToGlEnum for IndexType {
fn to_glenum(&self) -> gl::types::GLenum {
*self as gl::types::GLenum
}
}
/// An index from the index buffer.
pub unsafe trait Index: Copy + Send +'static {
/// Returns the `IndexType` corresponding to this type.
fn get_type() -> IndexType;
}
un... | match *self {
IndexType::U8 => mem::size_of::<u8>(),
IndexType::U16 => mem::size_of::<u16>(),
IndexType::U32 => mem::size_of::<u32>(), | random_line_split |
mod.rs | /*!
In order to draw, you need to provide a source of indices which is used to link the vertices
together into *primitives*.
There are eleven types of primitives, each one with a corresponding struct:
- `PointsList`
- `LinesList`
- `LinesListAdjacency`
- `LineStrip`
- `LineStripAdjacency`
- `TrianglesList`
- `... | <'a> {
/// A buffer uploaded in video memory.
IndexBuffer {
/// The buffer.
buffer: BufferViewAnySlice<'a>,
/// Type of indices in the buffer.
data_type: IndexType,
/// Type of primitives contained in the vertex source.
primitives: PrimitiveType,
},
/// U... | IndicesSource | identifier_name |
borrowed-enum.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
// 0b01111100011111000111110001111100 = 2088533116
// 0b0111110001111100 = 31868
// 0b01111100 = 124
let the_a = TheA { x: 0, y: 8970181431921507452 };
let the_a_ref: &ABC = &the_a;
// 0b000100010001000100... | main | identifier_name |
borrowed-enum.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-android: F... | // | random_line_split |
loan_ends_mid_block_pair.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 ... | (_: &mut char) {
}
| capitalize | identifier_name |
loan_ends_mid_block_pair.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 capitalize(_: &mut char) {
}
| {
let mut data = ('a', 'b', 'c');
let c = &mut data.0;
capitalize(c);
data.0 = 'e';
//~^ ERROR (Ast) [E0506]
data.0 = 'f';
//~^ ERROR (Ast) [E0506]
data.0 = 'g';
//~^ ERROR (Ast) [E0506]
} | identifier_body |
loan_ends_mid_block_pair.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 ... | //~| ERROR (Mir) [E0506]
capitalize(c);
}
fn nll_ok() {
let mut data = ('a', 'b', 'c');
let c = &mut data.0;
capitalize(c);
data.0 = 'e';
//~^ ERROR (Ast) [E0506]
data.0 = 'f';
//~^ ERROR (Ast) [E0506]
data.0 = 'g';
//~^ ERROR (Ast) [E0506]
}
fn capitalize(_: &mut char) {
} | random_line_split | |
lib.rs | //! A serialization/deserialization library for [CSA] format.
//!
//! [CSA] format is a plaintext format for recording Shogi games.
//! This library supports parsing CSA-formatted string as well as composing CSA-formatted string from structs.
//! Detail about CSA format is found at http://www.computer-shogi.org/protoco... | //! assert_eq!(game.event, Some("13th World Computer Shogi Championship".to_string()));
//! assert_eq!(game.moves[0], MoveRecord{
//! action: Action::Move(Color::Black, Square::new(2, 7), Square::new(2, 6), PieceType::Pawn),
//! time: Some(Duration::from_secs(12))
//! });
//! ```
//!
//! In contrast, structs c... | //! assert_eq!(game.white_player, Some("YONENAGA".to_string())); | random_line_split |
assets.rs | #[cfg(not(feature="dynamic-assets"))]
mod static_assets {
use std::collections::HashMap;
use futures::Future;
use web::{Resource, ResponseFuture};
// The CSS should be built to a single CSS file at compile time
#[derive(StaticResource)]
#[filename = "assets/themes.css"]
#[mime = "text/css"]... | impl StyleCss {
pub fn resource_name() -> &'static str { "style.css" }
}
pub struct ScriptJs;
impl ScriptJs {
pub fn resource_name() -> &'static str { "script.js" }
}
pub struct SearchJs;
impl SearchJs {
pub fn resource_name() -> &'static str { "search.js" }
}
}... | impl ThemesCss {
pub fn resource_name() -> &'static str { "themes.css" }
}
pub struct StyleCss; | random_line_split |
assets.rs | #[cfg(not(feature="dynamic-assets"))]
mod static_assets {
use std::collections::HashMap;
use futures::Future;
use web::{Resource, ResponseFuture};
// The CSS should be built to a single CSS file at compile time
#[derive(StaticResource)]
#[filename = "assets/themes.css"]
#[mime = "text/css"]... | ;
impl SearchJs {
pub fn resource_name() -> &'static str { "search.js" }
}
}
#[cfg(feature="dynamic-assets")]
pub use self::dynamic_assets::*;
| SearchJs | identifier_name |
assets.rs | #[cfg(not(feature="dynamic-assets"))]
mod static_assets {
use std::collections::HashMap;
use futures::Future;
use web::{Resource, ResponseFuture};
// The CSS should be built to a single CSS file at compile time
#[derive(StaticResource)]
#[filename = "assets/themes.css"]
#[mime = "text/css"]... |
}
pub struct StyleCss;
impl StyleCss {
pub fn resource_name() -> &'static str { "style.css" }
}
pub struct ScriptJs;
impl ScriptJs {
pub fn resource_name() -> &'static str { "script.js" }
}
pub struct SearchJs;
impl SearchJs {
pub fn resource_name() -> &'s... | { "themes.css" } | identifier_body |
main.rs | // Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos.
//
// Serkr is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later ver... |
println!("");
}
#[cfg_attr(feature="clippy", allow(print_stdout))]
fn print_statistics(sw: &Stopwatch) {
println_szs!("Time elapsed (in ms): {}", sw.elapsed_ms());
println_szs!("Initial clauses: {}", get_initial_clauses());
println_szs!("Analyzed clauses: {}", get_iteration_count());
println_szs!... | {
println_szs!("SZS output None for {} : Proof output is not yet supported",
input_file);
} | conditional_block |
main.rs | // Serkr - An automated theorem prover. Copyright (C) 2015-2016 Mikko Aarnos.
//
// Serkr is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later ver... |
fn main() {
let matches = clap::App::new("Serkr")
.version(crate_version!())
.author("Mikko Aarnos <mikko.aarnos@gmail.com>")
.about("An automated theorem prover for first order logic with equality")
.args_from_usage("<INPUT> 'The... | {
println_szs!("Time elapsed (in ms): {}", sw.elapsed_ms());
println_szs!("Initial clauses: {}", get_initial_clauses());
println_szs!("Analyzed clauses: {}", get_iteration_count());
println_szs!(" Trivial: {}", get_trivial_count());
println_szs!(" Forward subsumed: {}", get_forward_subsumed_count... | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.