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
template.rs
use Renderable; use context::Context; use filters::{size, upcase, minus, plus, replace, times, divided_by, ceil, floor, round}; use error::Result; pub struct Template { pub elements: Vec<Box<Renderable>>, } impl Renderable for Template { fn render(&self, context: &mut Context) -> Result<Option<String>> { ...
}
{ Template { elements: elements } }
identifier_body
template.rs
use Renderable; use context::Context; use filters::{size, upcase, minus, plus, replace, times, divided_by, ceil, floor, round}; use error::Result; pub struct
{ pub elements: Vec<Box<Renderable>>, } impl Renderable for Template { fn render(&self, context: &mut Context) -> Result<Option<String>> { context.add_filter("size", Box::new(size)); context.add_filter("upcase", Box::new(upcase)); context.add_filter("minus", Box::new(minus)); c...
Template
identifier_name
lib.rs
// Copyright (c) 2015 by Michael Neumann // 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. All files in the project carrying such // notice may not be copied...
() -> Command { Command::new("make") } #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd", target_os = "bitrig"))] pub fn bsd_make() -> Command { Command::new("make") }
gnu_make
identifier_name
lib.rs
// Copyright (c) 2015 by Michael Neumann // 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. All files in the project carrying such // notice may not be copied...
target_os = "bitrig"))] pub fn bsd_make() -> Command { Command::new("make") }
target_os = "bitrig")))] pub fn gnu_make() -> Command { Command::new("make") } #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd",
random_line_split
lib.rs
// Copyright (c) 2015 by Michael Neumann // 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. All files in the project carrying such // notice may not be copied...
#[cfg(not(any(target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd", target_os = "bitrig")))] pub fn gnu_make() -> Command { Command::new("make") } #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd", targ...
{ Command::new("gmake") }
identifier_body
pit.rs
//! Programmable Interval Timer //! Generates interrupts prelude!(); use ::ioports::*; use ::interrupts::pic; static mut COMMAND_PORT: IOPort<(), u8> = IOPort::new(0x43); static mut DATA_PORT: IOPort<(), u8> = IOPort::new(0x40); pub unsafe fn start_periodical(init: u16) { // (channel: 0)_(initial bytes: both)_(...
#[allow(unused)] pub fn lock_interrupt() { pic::lock_interrupt(0); }
{ pic::unlock_interrupt(0); }
identifier_body
pit.rs
//! Programmable Interval Timer //! Generates interrupts prelude!(); use ::ioports::*; use ::interrupts::pic; static mut COMMAND_PORT: IOPort<(), u8> = IOPort::new(0x43); static mut DATA_PORT: IOPort<(), u8> = IOPort::new(0x40); pub unsafe fn start_periodical(init: u16) { // (channel: 0)_(initial bytes: both)_(...
() { pic::lock_interrupt(0); }
lock_interrupt
identifier_name
pit.rs
//! Programmable Interval Timer //! Generates interrupts prelude!(); use ::ioports::*; use ::interrupts::pic; static mut COMMAND_PORT: IOPort<(), u8> = IOPort::new(0x43); static mut DATA_PORT: IOPort<(), u8> = IOPort::new(0x40); pub unsafe fn start_periodical(init: u16) { // (channel: 0)_(initial bytes: both)_(...
pub fn unlock_interrupt() { pic::unlock_interrupt(0); } #[allow(unused)] pub fn lock_interrupt() { pic::lock_interrupt(0); }
DATA_PORT.write((init >> 8) as u8); // hi byte }
random_line_split
const-fn-destructuring-arg.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 ...
a + b //~^ ERROR let bindings in constant functions are unstable //~| ERROR let bindings in constant functions are unstable } fn main() {}
b //~^ ERROR arguments of constant functions can only be immutable by-value bindings ): (u32, u32)) -> u32 {
random_line_split
const-fn-destructuring-arg.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 ...
{}
identifier_body
const-fn-destructuring-arg.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
outline.mako.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/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% from data import Method %> <% data.new_style_struct("Out...
(pub specified::Length); pub mod computed_value { use app_units::Au; pub type T = Au; } pub use super::border_top_width::get_initial_value; impl ToComputedValue for SpecifiedValue { type ComputedValue = computed_value::T; #[inline] fn to_computed_value(&self, con...
SpecifiedValue
identifier_name
outline.mako.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/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% from data import Method %> <% data.new_style_struct("Out...
} #[derive(Debug, Clone, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(pub specified::Length); pub mod computed_value { use app_units::Au; pub type T = Au; } pub use super::border_top_width::get_initial_value; impl ToComputedVa...
{ let &SpecifiedValue(length) = self; length.has_viewport_percentage() }
identifier_body
outline.mako.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/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% from data import Method %> <% data.new_style_struct("Out...
} } </%helpers:longhand> // The -moz-outline-radius-* properties are non-standard and not on a standards track. // TODO: Should they animate? % for corner in ["topleft", "topright", "bottomright", "bottomleft"]: ${helpers.predefined_type("-moz-outline-radius-" + corner, "BorderRadiusSize", "com...
} #[inline] fn from_computed_value(computed: &computed_value::T) -> Self { SpecifiedValue(ToComputedValue::from_computed_value(computed))
random_line_split
mod.rs
/* * This file is part of Master Password. * * Master Password is free software: you can redistribute it and/or modify * Mit under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Master Pass...
site_counter, site_variant, site_context) } _ => None, } }
site_name, site_type,
random_line_split
mod.rs
/* * This file is part of Master Password. * * Master Password is free software: you can redistribute it and/or modify * Mit under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Master Pass...
(master_key: &[u8; KEY_LENGTH], site_name: &str, site_type: &SiteType, site_counter: &i32, site_variant: &SiteVariant, site_context: &str, algo: &str) ...
password_for_site
identifier_name
mod.rs
/* * This file is part of Master Password. * * Master Password is free software: you can redistribute it and/or modify * Mit under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Master Pass...
pub fn password_for_site(master_key: &[u8; KEY_LENGTH], site_name: &str, site_type: &SiteType, site_counter: &i32, site_variant: &SiteVariant, site_context: &str, algo:...
{ match algo { "0" | "1" | "2" | "3" => mpw_v3::master_key(full_name, master_password, site_variant), "next" => mpw_next::master_key(full_name, master_password, site_variant), _ => None, } }
identifier_body
isomorphism.rs
use std::marker; use fixedbitset::FixedBitSet; use super::{ EdgeType, Incoming, }; use super::graph::{ Graph, IndexType, NodeIndex, }; use super::visit::GetAdjacencyMatrix; #[derive(Debug)] struct Vf2State<Ty, Ix> { /// The current mapping M(s) of nodes from G0 → G1 and G1 → G0, /// NodeI...
None => break, // no more candidates Some(ix) => NodeIndex::new(ix), }; debug_assert!(nx.index() >= start); } first = false; let nodes = [nx, mx]; // Check syntactic feasibility of mapping by ensuring adjacencies // of nx ...
OpenList::Other => st[0].next_rest_index(start), }.map(|c| c + start); // compensate for start offset. nx = match cand0 {
random_line_split
isomorphism.rs
use std::marker; use fixedbitset::FixedBitSet; use super::{ EdgeType, Incoming, }; use super::graph::{ Graph, IndexType, NodeIndex, }; use super::visit::GetAdjacencyMatrix; #[derive(Debug)] struct Vf2State<Ty, Ix> { /// The current mapping M(s) of nodes from G0 → G1 and G1 → G0, /// NodeI...
} /// Find the next (least) node in the Tout set. pub fn next_out_index(&self, from_index: usize) -> Option<usize> { self.out[from_index..].iter() .enumerate() .filter(|&(index, elt)| *elt > 0 && self.mapping[from_index + index] == NodeIndex::end()) ...
for ix in g.neighbors_directed(from, Incoming) { if self.ins[ix.index()] == s { self.ins[ix.index()] = 0; self.ins_size -= 1; } } }
conditional_block
isomorphism.rs
use std::marker; use fixedbitset::FixedBitSet; use super::{ EdgeType, Incoming, }; use super::graph::{ Graph, IndexType, NodeIndex, }; use super::visit::GetAdjacencyMatrix; #[derive(Debug)] struct Vf2State<Ty, Ix> { /// The current mapping M(s) of nodes from G0 → G1 and G1 → G0, /// NodeI...
let mut open_list = OpenList::Out; let mut to_index; let mut from_index = None; // Try the out list to_index = st[1].next_out_index(0); if to_index.is_some() { from_index = st[0].next_out_index(0); open_list = OpenList::Out; } // Try the in list if to_index.is_none...
let g = [g0, g1]; let graph_indices = 0..2; let end = NodeIndex::end(); // if all are mapped -- we are done and have an iso if st[0].is_complete() { return Some(true) } // A "depth first" search of a valid mapping from graph 1 to graph 2 // F(s, n, m) -- evaluate state s and add...
identifier_body
isomorphism.rs
use std::marker; use fixedbitset::FixedBitSet; use super::{ EdgeType, Incoming, }; use super::graph::{ Graph, IndexType, NodeIndex, }; use super::visit::GetAdjacencyMatrix; #[derive(Debug)] struct Vf2State<Ty, Ix> { /// The current mapping M(s) of nodes from G0 → G1 and G1 → G0, /// NodeI...
E>(&mut self, from: NodeIndex<Ix>, g: &Graph<N, E, Ty, Ix>) { let s = self.generation; self.generation -= 1; // undo (n, m) mapping self.mapping[from.index()] = NodeIndex::end(); // unmark in ins and outs for ix in g.neighbors(from) { ...
mapping<N,
identifier_name
regions-variance-invariant-use-covariant.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 ...
f: &'a mut &'a isize } fn use_<'b>(c: Invariant<'b>) { // For this assignment to be legal, Invariant<'b> <: Invariant<'static>. // Since 'b <='static, this would be true if Invariant were covariant // with respect to its parameter 'a. let _: Invariant<'static> = c; //~ ERROR mismatched types } f...
struct Invariant<'a> {
random_line_split
regions-variance-invariant-use-covariant.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 ...
() { }
main
identifier_name
projection-no-regions-fn.rs
// compile-flags:-Zborrowck=mir -Zverbose #![allow(warnings)] trait Anything { } impl<T> Anything for T { } fn no_region<'a, T>(mut x: T) -> Box<dyn Anything + 'a> where T: Iterator, { Box::new(x.next()) //~^ ERROR the associated type `<T as Iterator>::Item` may not live long enough
fn correct_region<'a, T>(mut x: T) -> Box<dyn Anything + 'a> where T: 'a + Iterator, { Box::new(x.next()) } fn wrong_region<'a, 'b, T>(mut x: T) -> Box<dyn Anything + 'a> where T: 'b + Iterator, { Box::new(x.next()) //~^ ERROR the associated type `<T as Iterator>::Item` may not live long enough } ...
}
random_line_split
projection-no-regions-fn.rs
// compile-flags:-Zborrowck=mir -Zverbose #![allow(warnings)] trait Anything { } impl<T> Anything for T { } fn no_region<'a, T>(mut x: T) -> Box<dyn Anything + 'a> where T: Iterator, { Box::new(x.next()) //~^ ERROR the associated type `<T as Iterator>::Item` may not live long enough } fn correct_region...
<'a, 'b, T>(mut x: T) -> Box<dyn Anything + 'a> where T: 'b + Iterator, 'b: 'a, { Box::new(x.next()) } fn main() {}
outlives_region
identifier_name
projection-no-regions-fn.rs
// compile-flags:-Zborrowck=mir -Zverbose #![allow(warnings)] trait Anything { } impl<T> Anything for T { } fn no_region<'a, T>(mut x: T) -> Box<dyn Anything + 'a> where T: Iterator, { Box::new(x.next()) //~^ ERROR the associated type `<T as Iterator>::Item` may not live long enough } fn correct_region...
{}
identifier_body
bytes.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
}
{ let deserialized: Bytes = serde_json::from_str(r#""""#).unwrap(); assert_eq!(deserialized, Bytes(Vec::new())); }
identifier_body
bytes.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...
struct BytesVisitor; impl Visitor for BytesVisitor { type Value = Bytes; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!(formatter, "a 0x-prefixed, hex-encoded vector of bytes") } fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> where E: Error { if value.is_empty() { ...
where D: Deserializer { deserializer.deserialize(BytesVisitor) } }
random_line_split
bytes.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...
else if value.len() >= 2 && &value[0..2] == "0x" && value.len() & 1 == 0 { Ok(Bytes::new(FromHex::from_hex(&value[2..]).map_err(|_| Error::custom("invalid hex"))?)) } else { Err(Error::custom("invalid format")) } } fn visit_string<E>(self, value: String) -> Result<Self::Value, E> where E: Error { self.v...
{ warn!( target: "deprecated", "Deserializing empty string as empty bytes. This is a non-standard behaviour that will be removed in future versions. Please update your code to send `0x` instead!" ); Ok(Bytes::new(Vec::new())) }
conditional_block
bytes.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...
<E>(self, value: String) -> Result<Self::Value, E> where E: Error { self.visit_str(value.as_ref()) } } #[cfg(test)] mod tests { use super::*; use serde_json; use rustc_serialize::hex::FromHex; #[test] fn test_bytes_serialize() { let bytes = Bytes("0123456789abcdef".from_hex().unwrap()); let serialized = ...
visit_string
identifier_name
console.rs
use front::stdlib::value::{Value, ResultValue, to_value, from_value}; use front::stdlib::function::Function; use std::io::stdio::stderr; use time::{now, strftime}; /// Print a javascript value to the standard output stream pub fn log(args:Vec<Value>, _:Value, _:Value, _:Value) -> ResultValue { let args : Vec<String...
(args:Vec<Value>, _:Value, _:Value, _:Value) -> ResultValue { let args : Vec<String> = args.iter().map(|x|from_value::<String>(*x).unwrap()).collect(); match writeln!(&mut stderr().unwrap(), "{}: {}", strftime("%X", &now()), args.connect(" ")) { Ok(_) => Ok(Value::undefined()), Err(io_error) => ...
error
identifier_name
console.rs
use front::stdlib::value::{Value, ResultValue, to_value, from_value}; use front::stdlib::function::Function; use std::io::stdio::stderr; use time::{now, strftime}; /// Print a javascript value to the standard output stream pub fn log(args:Vec<Value>, _:Value, _:Value, _:Value) -> ResultValue { let args : Vec<String...
/// Create a new `console` object pub fn _create(global : Value) -> Value { js!(global, { "log": Function::make(log, ["object"]), "error": Function::make(error, ["error"]), "exception": Function::make(error, ["error"]) }) } /// Initialise the global object with the `console` object pub ...
{ let args : Vec<String> = args.iter().map(|x|from_value::<String>(*x).unwrap()).collect(); match writeln!(&mut stderr().unwrap(), "{}: {}", strftime("%X", &now()), args.connect(" ")) { Ok(_) => Ok(Value::undefined()), Err(io_error) => Err(to_value(io_error.to_string())) } }
identifier_body
console.rs
use front::stdlib::function::Function; use std::io::stdio::stderr; use time::{now, strftime}; /// Print a javascript value to the standard output stream pub fn log(args:Vec<Value>, _:Value, _:Value, _:Value) -> ResultValue { let args : Vec<String> = args.iter().map(|x|from_value::<String>(*x).unwrap()).collect(); ...
use front::stdlib::value::{Value, ResultValue, to_value, from_value};
random_line_split
progressevent.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::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindi...
); { let event = ev.upcast::<Event>(); event.init_event(type_, bool::from(can_bubble), bool::from(cancelable)); } ev } pub fn Constructor( global: &GlobalScope, type_: DOMString, init: &ProgressEventBinding::ProgressEventInit, )...
)), global, ProgressEventBinding::Wrap,
random_line_split
progressevent.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::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindi...
pub fn new( global: &GlobalScope, type_: Atom, can_bubble: EventBubbles, cancelable: EventCancelable, length_computable: bool, loaded: u64, total: u64, ) -> DomRoot<ProgressEvent> { let ev = reflect_dom_object( Box::new(ProgressEvent::...
{ reflect_dom_object( Box::new(ProgressEvent::new_inherited(false, 0, 0)), global, ProgressEventBinding::Wrap, ) }
identifier_body
progressevent.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::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindi...
(&self) -> u64 { self.loaded } // https://xhr.spec.whatwg.org/#dom-progressevent-total fn Total(&self) -> u64 { self.total } // https://dom.spec.whatwg.org/#dom-event-istrusted fn IsTrusted(&self) -> bool { self.event.IsTrusted() } }
Loaded
identifier_name
intrinsic_3dlut.rs
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by app...
gDims.y = rsAllocationGetDimY(gCube); gDims.z = rsAllocationGetDimZ(gCube); gDims.w = 0; gCoordMul = (float4)(1.f / 255.f) * convert_float4(gDims - 1); } uchar4 __attribute__((kernel)) root(uchar4 in) { float4 baseCoord = convert_float4(in) * gCoordMul; int4 coord1 = convert_int4(floor(baseCoor...
void setCube(rs_allocation c) { gCube = c; gDims.x = rsAllocationGetDimX(gCube);
random_line_split
fs.rs
extern crate fuse; extern crate libc; extern crate slice_cast; extern crate time; use backend::Backend; use self::libc::c_int; use wfs::entry::FileEntry; /// Number of total blocks in FS const TOTAL_BLOCKS: usize = 16834; /// Block indicating end of data const BLOCK_FINAL: u16 = 0xfffe; /// Block indicating no such b...
fn read_dir<'a>(&self, data: &'a[u8]) -> &'a[FileEntry] { unsafe { slice_cast::cast(&data) } } fn chain_length(&self, ino: u64) -> usize { let mut i: usize = 0; let mut cur = ino as usize; while self.fat[cur - 2]!= BLOCK_FINAL { cur = self.fat[cur - 2] as usize;...
} Ok(()) }
random_line_split
fs.rs
extern crate fuse; extern crate libc; extern crate slice_cast; extern crate time; use backend::Backend; use self::libc::c_int; use wfs::entry::FileEntry; /// Number of total blocks in FS const TOTAL_BLOCKS: usize = 16834; /// Block indicating end of data const BLOCK_FINAL: u16 = 0xfffe; /// Block indicating no such b...
(&mut self, _req: &fuse::Request, ino: u64, reply: fuse::ReplyAttr) { match ino { 1 => { reply.attr(&TTL_TIMESEC, &self.produce_dir_attr(ino)); } _ => reply.error(libc::ENOENT), }; } /** * Check the availability of file system resouces. ...
getattr
identifier_name
fs.rs
extern crate fuse; extern crate libc; extern crate slice_cast; extern crate time; use backend::Backend; use self::libc::c_int; use wfs::entry::FileEntry; /// Number of total blocks in FS const TOTAL_BLOCKS: usize = 16834; /// Block indicating end of data const BLOCK_FINAL: u16 = 0xfffe; /// Block indicating no such b...
Ok(()) } /** * Load the File Allocation Table into memory */ fn load_fat(&mut self) -> Result<(), c_int> { unsafe { let block_buf: &mut[u8] = slice_cast::cast_mut(&mut self.fat); if let Err(_) = self.backend.read(BLOCK_TABLE_OFFSET, block_buf) { ...
{ // Panic because this method cannot return error states. panic!("Invalid magic number"); }
conditional_block
fs.rs
extern crate fuse; extern crate libc; extern crate slice_cast; extern crate time; use backend::Backend; use self::libc::c_int; use wfs::entry::FileEntry; /// Number of total blocks in FS const TOTAL_BLOCKS: usize = 16834; /// Block indicating end of data const BLOCK_FINAL: u16 = 0xfffe; /// Block indicating no such b...
fn chain_length(&self, ino: u64) -> usize { let mut i: usize = 0; let mut cur = ino as usize; while self.fat[cur - 2]!= BLOCK_FINAL { cur = self.fat[cur - 2] as usize; i += 1; } return i; } fn produce_dir_attr(&self, ino: u64) -> fuse::File...
{ unsafe { slice_cast::cast(&data) } }
identifier_body
raster.rs
//! Path rasterization. use crate::{gpu::GpuVertex, Result, P2}; use lyon_path::Builder; use lyon_tessellation::{ BuffersBuilder, FillAttributes, FillOptions, FillTessellator, LineJoin, StrokeAttributes, StrokeOptions, StrokeTessellator, VertexBuffers, }; use palette::LinSrgba; /// The method by which the ras...
( builder: Builder, method: Method, color: LinSrgba, ) -> Result<(Vec<GpuVertex>, Vec<u32>)> { match method { Method::Fill => { let ctor = |v: P2, _: FillAttributes| -> P2 { v }; let mut buffers: VertexBuffers<P2, u32> = VertexBuffers::new(); let mut buffers_b...
raster_path
identifier_name
raster.rs
//! Path rasterization. use crate::{gpu::GpuVertex, Result, P2}; use lyon_path::Builder; use lyon_tessellation::{ BuffersBuilder, FillAttributes, FillOptions, FillTessellator, LineJoin, StrokeAttributes, StrokeOptions, StrokeTessellator, VertexBuffers, }; use palette::LinSrgba; /// The method by which the ras...
.expect("TODO: wrap error"); Ok(( buffers .vertices .into_iter() .map(|v| GpuVertex { vpos: [v.x, v.y], vcol: [ color.color.red, ...
.with_tolerance(0.05), &mut buffers_builder, )
random_line_split
raster.rs
//! Path rasterization. use crate::{gpu::GpuVertex, Result, P2}; use lyon_path::Builder; use lyon_tessellation::{ BuffersBuilder, FillAttributes, FillOptions, FillTessellator, LineJoin, StrokeAttributes, StrokeOptions, StrokeTessellator, VertexBuffers, }; use palette::LinSrgba; /// The method by which the ras...
.vertices .into_iter() .map(|v| GpuVertex { vpos: [v.x, v.y], vcol: [ color.color.red, color.color.green, color.color.blue, ...
{ match method { Method::Fill => { let ctor = |v: P2, _: FillAttributes| -> P2 { v }; let mut buffers: VertexBuffers<P2, u32> = VertexBuffers::new(); let mut buffers_builder = BuffersBuilder::new(&mut buffers, ctor); let mut tessellator = FillTessellator::new...
identifier_body
eval_type.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use std::fmt; /// Function implementations' parameter data types. /// /// It is similar to the `EvalType` in TiDB, but doesn't provide type `Timestamp`, which is /// handled by the same type as `DateTime` here, instead of a new type. Also, `String` is...
#[test] fn test_fieldtype_to_evaltype() { let cases = vec![ (Unspecified, None), (Tiny, Some(EvalType::Int)), (Short, Some(EvalType::Int)), (Long, Some(EvalType::Int)), (Float, Some(EvalType::Real)), (Double, Some(EvalType::Real)),...
use std::convert::TryFrom;
random_line_split
eval_type.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use std::fmt; /// Function implementations' parameter data types. /// /// It is similar to the `EvalType` in TiDB, but doesn't provide type `Timestamp`, which is /// handled by the same type as `DateTime` here, instead of a new type. Also, `String` is...
(self) -> crate::FieldTypeTp { match self { EvalType::Int => crate::FieldTypeTp::LongLong, EvalType::Real => crate::FieldTypeTp::Double, EvalType::Decimal => crate::FieldTypeTp::NewDecimal, EvalType::Bytes => crate::FieldTypeTp::String, EvalType::DateT...
into_certain_field_type_tp_for_test
identifier_name
eval_type.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use std::fmt; /// Function implementations' parameter data types. /// /// It is similar to the `EvalType` in TiDB, but doesn't provide type `Timestamp`, which is /// handled by the same type as `DateTime` here, instead of a new type. Also, `String` is...
(NewDecimal, Some(EvalType::Decimal)), (Enum, Some(EvalType::Enum)), (Set, None), (TinyBlob, Some(EvalType::Bytes)), (MediumBlob, Some(EvalType::Bytes)), (LongBlob, Some(EvalType::Bytes)), (Blob, Some(EvalType::Bytes)), (Var...
{ let cases = vec![ (Unspecified, None), (Tiny, Some(EvalType::Int)), (Short, Some(EvalType::Int)), (Long, Some(EvalType::Int)), (Float, Some(EvalType::Real)), (Double, Some(EvalType::Real)), (Null, Some(EvalType::Bytes)), ...
identifier_body
field-destruction-order.rs
// run-pass #![allow(dead_code)] #![allow(non_upper_case_globals)] // In theory, it doesn't matter what order destructors are run in for rust // because we have explicit ownership of values meaning that there's no need to // run one before another. With unsafe code, however, there may be a safe // interface which reli...
; struct B; struct C { a: A, b: B, } static mut hit: bool = false; impl Drop for A { fn drop(&mut self) { unsafe { assert!(!hit); hit = true; } } } impl Drop for B { fn drop(&mut self) { unsafe { assert!(hit); } } } pub fn m...
A
identifier_name
field-destruction-order.rs
// run-pass #![allow(dead_code)] #![allow(non_upper_case_globals)] // In theory, it doesn't matter what order destructors are run in for rust // because we have explicit ownership of values meaning that there's no need to // run one before another. With unsafe code, however, there may be a safe // interface which reli...
} } impl Drop for B { fn drop(&mut self) { unsafe { assert!(hit); } } } pub fn main() { let _c = C { a: A, b: B }; }
fn drop(&mut self) { unsafe { assert!(!hit); hit = true; }
random_line_split
info_base.rs
use super::{imports::Imports, *}; use crate::{codegen::Visibility, library, version::Version}; #[derive(Debug, Default)] pub struct InfoBase { pub full_name: String, pub type_id: library::TypeId, pub name: String, pub functions: Vec<functions::Info>, pub specials: special_functions::Infos, pub ...
pub fn functions(&self) -> Vec<&functions::Info> { self.functions .iter() .filter(|f| f.status.need_generate() && f.kind == library::FunctionKind::Function) .collect() } }
}
random_line_split
info_base.rs
use super::{imports::Imports, *}; use crate::{codegen::Visibility, library, version::Version}; #[derive(Debug, Default)] pub struct InfoBase { pub full_name: String, pub type_id: library::TypeId, pub name: String, pub functions: Vec<functions::Info>, pub specials: special_functions::Infos, pub ...
(&self) -> Vec<&functions::Info> { self.functions .iter() .filter(|f| f.status.need_generate() && f.kind == library::FunctionKind::Function) .collect() } }
functions
identifier_name
x86_64_fuchsia.rs
use crate::spec::{SanitizerSet, StackProbeType, Target}; pub fn target() -> Target
{ let mut base = super::fuchsia_base::opts(); base.cpu = "x86-64".to_string(); base.max_atomic_width = Some(64); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.supported_sanitizers = SanitizerSet::ADDRESS; Targ...
identifier_body
x86_64_fuchsia.rs
use crate::spec::{SanitizerSet, StackProbeType, Target}; pub fn target() -> Target { let mut base = super::fuchsia_base::opts(); base.cpu = "x86-64".to_string(); base.max_atomic_width = Some(64); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = St...
pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" .to_string(), arch: "x86_64".to_string(), options: base, } }
llvm_target: "x86_64-fuchsia".to_string(),
random_line_split
x86_64_fuchsia.rs
use crate::spec::{SanitizerSet, StackProbeType, Target}; pub fn
() -> Target { let mut base = super::fuchsia_base::opts(); base.cpu = "x86-64".to_string(); base.max_atomic_width = Some(64); // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved base.stack_probes = StackProbeType::Call; base.supported_sanitizers = SanitizerSet::ADDRE...
target
identifier_name
radionodelist.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 crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use crate::dom::bin...
, } } } } // FIXME: This shouldn't need to be implemented here since NodeList (the parent of // RadioNodeList) implements IndexedGetter. // https://github.com/servo/servo/issues/5875 // // https://dom.spec.whatwg.org/#dom-nodelist-item fn IndexedGetter(&s...
{}
conditional_block
radionodelist.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 crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use crate::dom::bin...
pub fn new_simple_list<T>(window: &Window, iter: T) -> DomRoot<RadioNodeList> where T: Iterator<Item = DomRoot<Node>>, { RadioNodeList::new( window, NodeListType::Simple(iter.map(|r| Dom::from_ref(&*r)).collect()), ) } // FIXME: This shouldn't need ...
{ reflect_dom_object( Box::new(RadioNodeList::new_inherited(list_type)), window, RadioNodeListBinding::Wrap, ) }
identifier_body
radionodelist.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 crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use crate::dom::bin...
(window: &Window, list_type: NodeListType) -> DomRoot<RadioNodeList> { reflect_dom_object( Box::new(RadioNodeList::new_inherited(list_type)), window, RadioNodeListBinding::Wrap, ) } pub fn new_simple_list<T>(window: &Window, iter: T) -> DomRoot<RadioNodeList>...
new
identifier_name
radionodelist.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 crate::dom::bindings::codegen::Bindings::RadioNodeListBinding::RadioNodeListMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::htmlinputelement::{...
use crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use crate::dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; use crate::dom::bindings::codegen::Bindings::RadioNodeListBinding;
random_line_split
variance-intersection-of-ref-and-opt-ref.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 ...
(field1: &i32, field2: Option<&i32>) -> i32 { let list = List { field1: field1, field2: field2 }; *list.field1 + list.field2.cloned().unwrap_or(0) } fn main() { let x = 22; let y = Some(3); let z = None; assert_eq!(foo(&x, y.as_ref()), 25); assert_eq!(foo(&x, z.as_ref()), 22); }
foo
identifier_name
variance-intersection-of-ref-and-opt-ref.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 ...
fn main() { let x = 22; let y = Some(3); let z = None; assert_eq!(foo(&x, y.as_ref()), 25); assert_eq!(foo(&x, z.as_ref()), 22); }
{ let list = List { field1: field1, field2: field2 }; *list.field1 + list.field2.cloned().unwrap_or(0) }
identifier_body
variance-intersection-of-ref-and-opt-ref.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 ...
fn foo(field1: &i32, field2: Option<&i32>) -> i32 { let list = List { field1: field1, field2: field2 }; *list.field1 + list.field2.cloned().unwrap_or(0) } fn main() { let x = 22; let y = Some(3); let z = None; assert_eq!(foo(&x, y.as_ref()), 25); assert_eq!(foo(&x, z.as_ref()), 22); }
field1: &'l i32, field2: Option<&'l i32>, }
random_line_split
macro_parser.rs
macro invocation is now over, `bb_eis` with items that are waiting on //! a Rust nonterminal like `$e:expr`, and `next_eis` with items that are waiting //! on a particular token. Most of the logic concerns moving the · through the //! repetitions indicated by Kleene stars. It only advances or calls out to the //! real...
{ match tok { token::Eof => "unexpected end of macro invocation".to_string(), _ => format!("no rules expected the token `{}`", pprust::token_to_string(&tok)), } } /// Perform a token equality check, ignoring syntax context (that is, an unhygienic comparison) fn token_name_eq(t1 : &Token, t2 : &...
Token) -> String
identifier_name
macro_parser.rs
the macro invocation is now over, `bb_eis` with items that are waiting on //! a Rust nonterminal like `$e:expr`, and `next_eis` with items that are waiting //! on a particular token. Most of the logic concerns moving the · through the //! repetitions indicated by Kleene stars. It only advances or calls out to the //! ...
quality check, ignoring syntax context (that is, an unhygienic comparison) fn token_name_eq(t1 : &Token, t2 : &Token) -> bool { if let (Some(id1), Some(id2)) = (t1.ident(), t2.ident()) { id1.name == id2.name } else if let (&token::Lifetime(id1), &token::Lifetime(id2)) = (t1, t2) { id1.name == id...
token::Eof => "unexpected end of macro invocation".to_string(), _ => format!("no rules expected the token `{}`", pprust::token_to_string(&tok)), } } /// Perform a token e
identifier_body
macro_parser.rs
//! the macro invocation is now over, `bb_eis` with items that are waiting on //! a Rust nonterminal like `$e:expr`, and `next_eis` with items that are waiting //! on a particular token. Most of the logic concerns moving the · through the //! repetitions indicated by Kleene stars. It only advances or calls out to the /...
// I bet this is a perf problem: we're preemptively // doing a lot of array work that will get thrown away // most of the time. // Only touch the binders we have actually bound for idx in ei.match_lo..ei.match_hi { ...
let mut new_pos = ei.up.clone().unwrap(); // update matches (the MBE "parse tree") by appending // each tree as a subtree.
random_line_split
macro_parser.rs
the macro invocation is now over, `bb_eis` with items that are waiting on //! a Rust nonterminal like `$e:expr`, and `next_eis` with items that are waiting //! on a particular token. Most of the logic concerns moving the · through the //! repetitions indicated by Kleene stars. It only advances or calls out to the //! ...
cupied(..) => { return Err((sp, format!("duplicated bind name: {}", bind_name))) } } } TokenTree::Token(..) => (), } Ok(()) } let mut ret_val = HashMap::new(); for m in ms { match n_rec(sess, m, res...
spot.insert(res.next().unwrap()); } Oc
conditional_block
type-alias-enum-variants-pass.rs
// run-pass // Check that it is possible to resolve, in the value namespace, // to an `enum` variant through a type alias. This includes `Self`. // Type qualified syntax `<Type>::Variant` also works when syntactically valid. #[derive(Debug, PartialEq, Eq)] enum Foo { Bar(i32), Baz { i: i32 }, Qux, } type...
() -> Self { let x = Self::Bar(3); assert_eq!(x, <Self>::Bar(3)); check_pat!(x, Self::Bar(3)); x } fn baz() -> Self { let x = Self::Baz { i: 42 }; check_pat!(x, Self::Baz { i: 42 }); x } fn qux() -> Self { let x = Self::Qux; asser...
bar
identifier_name
type-alias-enum-variants-pass.rs
// run-pass // Check that it is possible to resolve, in the value namespace, // to an `enum` variant through a type alias. This includes `Self`. // Type qualified syntax `<Type>::Variant` also works when syntactically valid. #[derive(Debug, PartialEq, Eq)] enum Foo { Bar(i32), Baz { i: i32 }, Qux, } type...
}
random_line_split
type-alias-enum-variants-pass.rs
// run-pass // Check that it is possible to resolve, in the value namespace, // to an `enum` variant through a type alias. This includes `Self`. // Type qualified syntax `<Type>::Variant` also works when syntactically valid. #[derive(Debug, PartialEq, Eq)] enum Foo { Bar(i32), Baz { i: i32 }, Qux, } type...
} fn main() { let bar = Foo::Bar(1); assert_eq!(bar, FooAlias::Bar(1)); assert_eq!(bar, <FooAlias>::Bar(1)); check_pat!(bar, FooAlias::Bar(1)); let baz = FooAlias::Baz { i: 2 }; assert_eq!(baz, Foo::Baz { i: 2 }); check_pat!(baz, FooAlias::Baz { i: 2 }); let qux = Foo::Qux; asser...
{ let x = Self::Qux; assert_eq!(x, <Self>::Qux); check_pat!(x, Self::Qux); check_pat!(x, <Self>::Qux); x }
identifier_body
tests.rs
extern crate existent; use existent::{When, Unless}; macro_rules! basic_tests( ($($name:ident - $exp:expr),+) => ( mod test_unless { use existent::Unless; $( #[test] fn $name() { assert_eq!(Some($exp), $exp.unless(false)); ...
let mut bar = 1; assert_eq!(Some(42), (|| expensive_computation(bar)).do_unless(false)); assert_eq!(None, (|| expensive_computation(bar)).do_unless(true)); bar = 2; assert_eq!(Some(84), (|| expensive_computation(bar)).do_when(true)); assert_eq!(None, (|| expensive_computation(bar)).do_when(fa...
{ 42 * bar }
identifier_body
tests.rs
extern crate existent; use existent::{When, Unless}; macro_rules! basic_tests( ($($name:ident - $exp:expr),+) => ( mod test_unless { use existent::Unless; $( #[test] fn $name() { assert_eq!(Some($exp), $exp.unless(false)); ...
() { fn unless<'a>(s: &'a str) -> Option<&'a str> { s.unless(false) } fn when<'a>(s: &'a str) -> Option<&'a str> { s.when(true) } let x = "Abandoning".to_string(); let ys = { let y = &x[..]; unless(y) }; assert_eq!(Some(&*x), ys); let ys = { ...
lifetimes_work
identifier_name
tests.rs
extern crate existent; use existent::{When, Unless}; macro_rules! basic_tests( ($($name:ident - $exp:expr),+) => ( mod test_unless { use existent::Unless; $( #[test] fn $name() { assert_eq!(Some($exp), $exp.unless(false)); ...
assert_eq!(None, Unless::unless(Foo(6), true)); assert_eq!(Some(Foo(7)), Unless::unless(Foo(7), false)); assert_eq!(None, Foo(8).when(true)); assert_eq!(None, Foo(3).when(false)); assert_eq!(Some(Foo(52)), Foo(2).unless(true)); assert_eq!(Some(Foo(52)), Foo(1).unless(false)); } #[test] fn lazy...
random_line_split
almost_prime.rs
// http://rosettacode.org/wiki/Almost_prime fn is_kprime(mut n: usize, k: usize) -> bool { let mut p = 2; let mut f = 0; while f < k && p * p <= n { while 0 == n % p { n /= p; f += 1; } p += 1; } f + (n > 1) as usize == k } fn get_kprimes(k: usize,...
#[test] fn k_equals_4() { assert!(get_kprimes(4, 10) == [16, 24, 36, 40, 54, 56, 60, 81, 84, 88]); } #[test] fn k_equals_5() { assert!(get_kprimes(5, 10) == [32, 48, 72, 80, 108, 112, 120, 162, 168, 176]); } }
{ assert!(get_kprimes(3, 10) == [8, 12, 18, 20, 27, 28, 30, 42, 44, 45]); }
identifier_body
almost_prime.rs
// http://rosettacode.org/wiki/Almost_prime fn
(mut n: usize, k: usize) -> bool { let mut p = 2; let mut f = 0; while f < k && p * p <= n { while 0 == n % p { n /= p; f += 1; } p += 1; } f + (n > 1) as usize == k } fn get_kprimes(k: usize, amount: usize) -> Vec<usize> { (2..) .filter(...
is_kprime
identifier_name
almost_prime.rs
// http://rosettacode.org/wiki/Almost_prime fn is_kprime(mut n: usize, k: usize) -> bool { let mut p = 2; let mut f = 0; while f < k && p * p <= n { while 0 == n % p { n /= p; f += 1; } p += 1; } f + (n > 1) as usize == k } fn get_kprimes(k: usize,...
}
random_line_split
wrapper.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 core::nonzero::NonZero; use dom::bindings::reflector::DomObject; use dom::bindings::root::{DomRoot, MutNullabl...
() -> TypedWebGLExtensionWrapper<T> { TypedWebGLExtensionWrapper { extension: MutNullableDom::new(None) } } } impl<T> WebGLExtensionWrapper for TypedWebGLExtensionWrapper<T> where T: WebGLExtension + JSTraceable + HeapSizeOf +'static { #[allow(unsafe_co...
new
identifier_name
wrapper.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 core::nonzero::NonZero; use dom::bindings::reflector::DomObject; use dom::bindings::root::{DomRoot, MutNullabl...
fn as_any<'a>(&'a self) -> &'a Any { self } } impl<T> TypedWebGLExtensionWrapper<T> where T: WebGLExtension + JSTraceable + HeapSizeOf +'static { pub fn dom_object(&self) -> Option<DomRoot<T::Extension>> { self.extension.get() } }
{ T::name() }
identifier_body
wrapper.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 core::nonzero::NonZero; use dom::bindings::reflector::DomObject; use dom::bindings::root::{DomRoot, MutNullabl...
#[must_root] #[derive(HeapSizeOf, JSTraceable)] pub struct TypedWebGLExtensionWrapper<T: WebGLExtension> { extension: MutNullableDom<T::Extension> } /// Typed WebGL Extension implementation. /// Exposes the exact MutNullableDom<DOMObject> type defined by the extension. impl<T: WebGLExtension> TypedWebGLExtensionWr...
fn as_any(&self) -> &Any; }
random_line_split
wrapper.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 core::nonzero::NonZero; use dom::bindings::reflector::DomObject; use dom::bindings::root::{DomRoot, MutNullabl...
unsafe { NonZero::new_unchecked(extension.reflector().get_jsobject().get()) } } fn is_supported(&self, ext: &WebGLExtensions) -> bool { self.is_enabled() || T::is_supported(ext) } fn is_enabled(&self) -> bool { self.extension.get().is_some() } fn e...
{ self.enable(ext); }
conditional_block
effects.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/. */ //! Generic types for CSS values related to effects. use std::fmt::{self, Write}; use style_traits::values::{CssW...
Ok(()) } }
{ dest.write_str(" inset")?; }
conditional_block
effects.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/. */ //! Generic types for CSS values related to effects. use std::fmt::{self, Write}; use style_traits::values::{CssW...
BlurShapeLength: ToCss, ShapeLength: ToCss, { fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: Write, { { let mut writer = SequenceWriter::new(&mut *dest, " "); writer.item(&self.base)?; writer.item(&self.spread)?; } ...
impl<Color, SizeLength, BlurShapeLength, ShapeLength> ToCss for BoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength> where Color: ToCss, SizeLength: ToCss,
random_line_split
effects.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/. */ //! Generic types for CSS values related to effects. use std::fmt::{self, Write}; use style_traits::values::{CssW...
<Color, SizeLength, ShapeLength> { /// Color. pub color: Color, /// Horizontal radius. pub horizontal: SizeLength, /// Vertical radius. pub vertical: SizeLength, /// Blur radius. pub blur: ShapeLength, } impl<Color, SizeLength, BlurShapeLength, ShapeLength> ToCss for BoxShadow<Color...
SimpleShadow
identifier_name
mod.rs
use std::fmt; use std::sync::Arc; use std::net::{TcpStream, ToSocketAddrs}; use std::io::prelude::*; use std::process::{exit, Command}; use std::path::PathBuf; use my_daemonize; #[macro_use] mod toml; mod cmd; mod proxy_config; mod running_config; use self::cmd::{parse_cmds, check_and_set_from_args, check_and_set_se...
fn get_all_ips() -> Option<String> { let cmd = if cfg!(windows) { "ipconfig" } else { "ifconfig" }; let output = try_opt!(Command::new(cmd).output().ok()); String::from_utf8(output.stdout).ok() } fn check_ip(ip: &str) -> bool { if let Some(ips) = get_all_ips() { ips.f...
{ let addr = try_opt!((host, 80).to_socket_addrs().ok().and_then(|mut addrs| addrs.next())); let mut conn = try_opt!(TcpStream::connect(addr).ok()); let r = format!("GET {} HTTP/1.1\r\nHost: {}\r\n\r\n", path, host); try_opt!(conn.write_all(r.as_bytes()).ok()); let mut s = String::new(); try_opt...
identifier_body
mod.rs
use std::fmt; use std::sync::Arc; use std::net::{TcpStream, ToSocketAddrs}; use std::io::prelude::*; use std::process::{exit, Command}; use std::path::PathBuf; use my_daemonize; #[macro_use] mod toml; mod cmd; mod proxy_config; mod running_config; use self::cmd::{parse_cmds, check_and_set_from_args, check_and_set_se...
fn get_external_ip() -> ConfigResult<String> { const HOST_PATHS: &'static [(&'static str, &'static str)] = &[("ident.me", "/"), ("icanhazip.com", "/")]; let mut external_ip = None; for host_path in HOST_PATHS { let ip = echo_ip(host...
random_line_split
mod.rs
use std::fmt; use std::sync::Arc; use std::net::{TcpStream, ToSocketAddrs}; use std::io::prelude::*; use std::process::{exit, Command}; use std::path::PathBuf; use my_daemonize; #[macro_use] mod toml; mod cmd; mod proxy_config; mod running_config; use self::cmd::{parse_cmds, check_and_set_from_args, check_and_set_se...
else { // TODO: share ssserver server (check 0.0.0.0 & 127.0.0.1) if args.is_present("share_server") { exit(0); } } // setup from input and save it if no default config if let Some(input) = args.value_of("input") { let mut proxy_conf = ProxyConfig::default(); ...
{ if let Some(server_conf) = args.value_of("add_server") { let mut tmp = Arc::make_mut(&mut conf.proxy_conf); tmp.base64_decode(server_conf)?; append_to_default_config(tmp); exit(0); } // TODO: share sslocal server according mode if args.is...
conditional_block
mod.rs
use std::fmt; use std::sync::Arc; use std::net::{TcpStream, ToSocketAddrs}; use std::io::prelude::*; use std::process::{exit, Command}; use std::path::PathBuf; use my_daemonize; #[macro_use] mod toml; mod cmd; mod proxy_config; mod running_config; use self::cmd::{parse_cmds, check_and_set_from_args, check_and_set_se...
(ip: &str) -> bool { if let Some(ips) = get_all_ips() { ips.find(ip).is_some() } else { false } }
check_ip
identifier_name
dig.rs
extern crate argparse; extern crate domain; extern crate tokio_core; use std::error; use std::result; use std::str::FromStr; use domain::bits::message::{MessageBuf, RecordSection}; use domain::bits::name::{DNameBuf, DNameSlice}; use domain::iana::{Class, Rtype}; use domain::resolv::{ResolvConf, Resolver}; //--------...
(&self) -> Result<Rtype> { if self.qtype.is_empty() { Ok(if self.name.is_empty() { Rtype::Ns } else { Rtype::A }) } else { Ok(try!(Rtype::from_str(&self.qtype))) } } fn qclass(&self) -> Result<Class> { Ok(Class::In) } fn conf(&self) -...
qtype
identifier_name
dig.rs
extern crate argparse; extern crate domain; extern crate tokio_core; use std::error; use std::result; use std::str::FromStr; use domain::bits::message::{MessageBuf, RecordSection}; use domain::bits::name::{DNameBuf, DNameSlice}; use domain::iana::{Class, Rtype}; use domain::resolv::{ResolvConf, Resolver}; //--------...
println!(";; ANSWER SECTION"); print_records(&mut answer); println!(""); } let mut authority = answer.next_section().unwrap().unwrap(); if response.counts().nscount() > 0 { println!(";; AUTHORITY SECTION"); print_records(&mut authority); println!(""); } ...
random_line_split
dig.rs
extern crate argparse; extern crate domain; extern crate tokio_core; use std::error; use std::result; use std::str::FromStr; use domain::bits::message::{MessageBuf, RecordSection}; use domain::bits::name::{DNameBuf, DNameSlice}; use domain::iana::{Class, Rtype}; use domain::resolv::{ResolvConf, Resolver}; //--------...
else { Ok(try!(Rtype::from_str(&self.qtype))) } } fn qclass(&self) -> Result<Class> { Ok(Class::In) } fn conf(&self) -> &ResolvConf { &self.conf } } //------------ Error and Result --------------------------------------------- type Error = Box<error::Error>;...
{ Ok(if self.name.is_empty() { Rtype::Ns } else { Rtype::A }) }
conditional_block
lib.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. */ #![allow(non_camel_case_types)] use std::cell::RefCell; use std::path::Path; use ::revlogindex::RevlogIndex; use cpython::*; use cpython_...
py_class!(class revlogindex |py| { data index: RefCell<RevlogIndex>; def __new__(_cls, changelogipath: String, nodemappath: String) -> PyResult<Self> { let changelogipath = Path::new(&changelogipath); let nodemappath = Path::new(&nodemappath); let index = RevlogIndex::new(&changelogip...
{ let name = [package, "revlogindex"].join("."); let m = PyModule::new(py, &name)?; m.add_class::<revlogindex>(py)?; Ok(m) }
identifier_body
lib.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. */ #![allow(non_camel_case_types)] use std::cell::RefCell; use std::path::Path; use ::revlogindex::RevlogIndex; use cpython::*; use cpython_...
(py: Python, package: &str) -> PyResult<PyModule> { let name = [package, "revlogindex"].join("."); let m = PyModule::new(py, &name)?; m.add_class::<revlogindex>(py)?; Ok(m) } py_class!(class revlogindex |py| { data index: RefCell<RevlogIndex>; def __new__(_cls, changelogipath: String, nodemapp...
init_module
identifier_name
lib.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. */ #![allow(non_camel_case_types)] use std::cell::RefCell; use std::path::Path; use ::revlogindex::RevlogIndex; use cpython::*; use cpython_...
/// Calculate `heads(ancestors(revs))`. def headsancestors(&self, revs: Vec<u32>) -> PyResult<Vec<u32>> { let revlog = self.index(py).borrow(); Ok(revlog.headsancestors(revs).map_pyerr(py)?) } /// Given public and draft head revision numbers, calculate the "phase sets". /// Return (...
}
random_line_split
performance.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
use dom::bindings::codegen::Bindings::PerformanceBinding; use dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceMethods; use dom::bindings::js::{JS, Root}; use dom::bindings::num::Finite; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::performancetiming::PerformanceTiming; use do...
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
random_line_split
performance.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::PerformanceBinding; use dom::bindings::codegen::Bindings::PerformanceBinding...
(window: &Window, navigation_start: u64, navigation_start_precise: f64) -> Root<Performance> { reflect_dom_object(box Performance::new_inherited(window, navigation_start, ...
new
identifier_name
performance.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::PerformanceBinding; use dom::bindings::codegen::Bindings::PerformanceBinding...
} impl PerformanceMethods for Performance { // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html#performance-timing-attribute fn Timing(&self) -> Root<PerformanceTiming> { Root::from_ref(&*self.timing) } // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HighR...
{ reflect_dom_object(box Performance::new_inherited(window, navigation_start, navigation_start_precise), window, PerformanceBinding::Wrap) ...
identifier_body
set.rs
matset!(set1, &["a", "a"], "a", 0, 1); matset!(set2, &["a", "a"], "ba", 0, 1); matset!(set3, &["a", "b"], "a", 0); matset!(set4, &["a", "b"], "b", 1); matset!(set5, &["a|b", "b|a"], "b", 0, 1); matset!(set6, &["foo", "oo"], "foo", 0, 1); matset!(set7, &["^foo", "bar$"], "foo", 0); matset!(set8, &["^foo", "bar$"], "foo ...
{ let set = regex_set!(&["ab", "b"]); let text = text!("ba"); assert!(set.matches(text).matched(1)); assert!(set.matches(text).matched(1)); }
identifier_body
set.rs
matset!(set1, &["a", "a"], "a", 0, 1); matset!(set2, &["a", "a"], "ba", 0, 1); matset!(set3, &["a", "b"], "a", 0); matset!(set4, &["a", "b"], "b", 1); matset!(set5, &["a|b", "b|a"], "b", 0, 1); matset!(set6, &["foo", "oo"], "foo", 0, 1); matset!(set7, &["^foo", "bar$"], "foo", 0); matset!(set8, &["^foo", "bar$"], "foo ...
() { let set = regex_set!(&["ab", "b"]); let text = text!("ba"); assert!(set.matches(text).matched(1)); assert!(set.matches(text).matched(1)); }
regression_subsequent_matches
identifier_name
set.rs
matset!(set1, &["a", "a"], "a", 0, 1); matset!(set2, &["a", "a"], "ba", 0, 1); matset!(set3, &["a", "b"], "a", 0); matset!(set4, &["a", "b"], "b", 1); matset!(set5, &["a|b", "b|a"], "b", 0, 1); matset!(set6, &["foo", "oo"], "foo", 0, 1); matset!(set7, &["^foo", "bar$"], "foo", 0); matset!(set8, &["^foo", "bar$"], "foo ...
#[test] fn regression_subsequent_matches() { let set = regex_set!(&["ab", "b"]); let text = text!("ba"); assert!(set.matches(text).matched(1)); assert!(set.matches(text).matched(1)); }
nomatset!(nset3, { let xs: &[&str] = &[]; xs }, "a"); // See: https://github.com/rust-lang-nursery/regex/issues/187
random_line_split
error_meta.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 std::pin::Pin; pub struct ErrorMeta<E> { /// Errors that were captured pub errors: Vec<E>, /// Extra erorrs that were obs...
(&self) -> u64 { // NOTE: unwrap is safe since we if we have all those elements in a Vec, we're going to be // able to fit that into a u64. let n: u64 = self.errors.len().try_into().unwrap(); n + self.extra_error_count } } pub trait ErrorMetaProvider<E> { fn report_errors(self: ...
error_count
identifier_name
error_meta.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 std::pin::Pin; pub struct ErrorMeta<E> { /// Errors that were captured pub errors: Vec<E>, /// Extra erorrs that were obs...
pub fn one_error(e: E) -> Self { Self { errors: vec![e], extra_error_count: 0, } } pub fn error_count(&self) -> u64 { // NOTE: unwrap is safe since we if we have all those elements in a Vec, we're going to be // able to fit that into a u64. ...
{ Self { errors: Vec::new(), extra_error_count: 0, } }
identifier_body
error_meta.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates.
use std::pin::Pin; pub struct ErrorMeta<E> { /// Errors that were captured pub errors: Vec<E>, /// Extra erorrs that were observed but not captured. pub extra_error_count: u64, } impl<E> ErrorMeta<E> { pub fn new() -> Self { Self { errors: Vec::new(), extra_error_...
* * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */
random_line_split