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
htmlolistelement.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::HTMLOListElementBinding; use dom::bindings::codegen::InheritTypes::HTMLOList...
<'a>(&'a self) -> &'a Reflector { self.htmlelement.reflector() } }
reflector
identifier_name
htmlolistelement.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::HTMLOListElementBinding; use dom::bindings::codegen::InheritTypes::HTMLOList...
} impl HTMLOListElement { pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLOListElement { HTMLOListElement { htmlelement: HTMLElement::new_inherited(HTMLOListElementTypeId, localName, document) } } pub fn new(localName: DOMString, document: &JSRef<...
{ self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLOListElementTypeId)) }
identifier_body
network_settings.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...
}
{ NetworkSettings { name: "".into(), chain: "foundation".into(), network_port: 30303, rpc_enabled: true, rpc_interface: "127.0.0.1".into(), rpc_port: 8545 } }
identifier_body
network_settings.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...
() -> Self { NetworkSettings { name: "".into(), chain: "foundation".into(), network_port: 30303, rpc_enabled: true, rpc_interface: "127.0.0.1".into(), rpc_port: 8545 } } }
default
identifier_name
network_settings.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...
#[derive(Debug, PartialEq, Clone)] pub struct NetworkSettings { /// Node name pub name: String, /// Name of the chain we are connected to pub chain: String, /// Networking port pub network_port: u16, /// Is JSON-RPC server enabled? pub rpc_enabled: bool, /// Interface that JSON-RPC listens on pub rpc_interfac...
// You should have received a copy of the GNU General Public License // along with Parity. If not, see <http://www.gnu.org/licenses/>. //! Structure to hold network settings configured from CLI /// Networking & RPC settings
random_line_split
genimplsource0.rs
struct S; // On déclare le type concret `S`. struct GenericVal<T>(T); // On déclare le type générique `GenericVal`. // Implémentation de GenericVal où nous précisons que cette méthode doit être // implémentée uniquement pour le type `f32`. impl GenericVal<f32> { fn say_hello_f32(&self) -> (){ println!("I'm...
gen_val } } fn main() { let x = Val { val: 3.0 }; let y = GenVal { gen_val: 3i32 }; println!("{}, {}", x.value(), y.value()); GenericVal(1.0).say_hello_f32(); GenericVal(S).say_hello_s(); GenericVal("prout").say_hello(); }
self.
identifier_name
genimplsource0.rs
struct S; // On déclare le type concret `S`. struct GenericVal<T>(T); // On déclare le type générique `GenericVal`. // Implémentation de GenericVal où nous précisons que cette méthode doit être // implémentée uniquement pour le type `f32`. impl GenericVal<f32> { fn say_hello_f32(&self) -> (){ println!("I'm...
GenericVal("prout").say_hello(); }
GenericVal(1.0).say_hello_f32(); GenericVal(S).say_hello_s();
random_line_split
ast.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 std::fmt; pub type OffsetSpan = (usize, usize); #[derive(Debug, Clone, PartialEq)] pub struct Spanned<T> { ...
{ pub maybe_id: Option<String>, pub params: Vec<String>, pub body: Box<StmtNode>, } #[derive(Debug, Clone)] pub enum Expr { Literal(LiteralNode), Identifier(String), Binary(Box<ExprNode>, BinOp, Box<ExprNode>), BinaryLogical(Box<ExprNode>, LogicalBinOp, Box<ExprNode>), Unary(UnOp, Box<...
FnDefExpr
identifier_name
ast.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 std::fmt; pub type OffsetSpan = (usize, usize); #[derive(Debug, Clone, PartialEq)] pub struct Spanned<T> { ...
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { BinOp::Add => write!(f, "+"), BinOp::Sub => write!(f, "-"), BinOp::Mul => write!(f, "*"), BinOp::Div => write!(f, "/"), BinOp::Mod => write!(f, "%"), BinOp::Lt => writ...
impl fmt::Display for BinOp {
random_line_split
mod.rs
pub mod multi; pub mod threshold; use std::cmp::min; use crate::{Levenshtein, Metric}; impl Default for Levenshtein { fn default() -> Self { Levenshtein {} } } impl<T: Eq, R: AsRef<[T]>> Metric<T, R> for Levenshtein { fn distance(a: R, b: R) -> usize
} fn distance<T>(a: &[T], b: &[T]) -> usize where T: Eq, { let a_length = a.len(); let b_length = b.len(); if a_length == 0 { return b_length; } else if b_length == 0 { return a_length; } let (row_items, column_items) = if a_length < b_length { (b, a) } else { (a, b) }; ...
{ distance(a.as_ref(), b.as_ref()) }
identifier_body
mod.rs
pub mod multi; pub mod threshold; use std::cmp::min; use crate::{Levenshtein, Metric}; impl Default for Levenshtein { fn default() -> Self { Levenshtein {} } } impl<T: Eq, R: AsRef<[T]>> Metric<T, R> for Levenshtein { fn distance(a: R, b: R) -> usize { distance(a.as_ref(), b.as_ref()) ...
let (_, column_item0) = column_iter.next().unwrap(); buffer[0] = { let diag = row; if row_item == column_item0 { diag } else { let up = buffer[0]; min(diag, up) + 1 } }; // Row 2+, Column 2+ ...
let mut column_iter = column_items.iter().enumerate(); // Row 2+, Column 1
random_line_split
mod.rs
pub mod multi; pub mod threshold; use std::cmp::min; use crate::{Levenshtein, Metric}; impl Default for Levenshtein { fn default() -> Self { Levenshtein {} } } impl<T: Eq, R: AsRef<[T]>> Metric<T, R> for Levenshtein { fn distance(a: R, b: R) -> usize { distance(a.as_ref(), b.as_ref()) ...
<T>(row_items: &[T], column_items: &[T], buffer: &mut Vec<usize>) where T: Eq, { let row_iter = row_items.iter().enumerate(); for (row, row_item) in row_iter { let mut last_up = buffer[0]; let mut column_iter = column_items.iter().enumerate(); // Row 2+, Column 1 let (_, co...
other_rows
identifier_name
mod.rs
pub mod multi; pub mod threshold; use std::cmp::min; use crate::{Levenshtein, Metric}; impl Default for Levenshtein { fn default() -> Self { Levenshtein {} } } impl<T: Eq, R: AsRef<[T]>> Metric<T, R> for Levenshtein { fn distance(a: R, b: R) -> usize { distance(a.as_ref(), b.as_ref()) ...
else { (a, b) }; let mut buffer = first_row(row_items, column_items); other_rows(row_items, column_items, &mut buffer); *buffer.last().unwrap() } fn first_row<T>(row_items: &[T], column_items: &[T]) -> Vec<usize> where T: Eq, { let columns = column_items.len(); let mut buffer = Vec::with_capa...
{ (b, a) }
conditional_block
status.rs
/* * libgit2 "status" example - shows how to use the status APIs * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without an...
header = false; // Print untracked files for entry in statuses.iter().filter(|e| e.status() == git2::STATUS_WT_NEW) { if!header { println!("\ # Untracked files # (use \"git add <file>...\" to include in what will be committed) #"); header = true; } let fil...
{ changed_in_workdir = true; println!("#"); }
conditional_block
status.rs
/* * libgit2 "status" example - shows how to use the status APIs * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without an...
() { const USAGE: &'static str = " usage: status [options] [--] [<spec>..] Options: -s, --short show short statuses --long show longer statuses (default) --porcelain ?? -b, --branch show branch information -z ...
main
identifier_name
status.rs
/* * libgit2 "status" example - shows how to use the status APIs * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without an...
Ok(()) => {} Err(e) => println!("error: {}", e), } }
random_line_split
status.rs
/* * libgit2 "status" example - shows how to use the status APIs * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without an...
if entry.status().contains(git2::STATUS_IGNORED) { istatus = '!'; wstatus = '!'; } if istatus == '?' && wstatus == '?' { continue } let mut extra = ""; // A commit in a tree is how submodules are stored, so let's go take a // look at its status. ...
{ for entry in statuses.iter().filter(|e| e.status() != git2::STATUS_CURRENT) { let mut istatus = match entry.status() { s if s.contains(git2::STATUS_INDEX_NEW) => 'A', s if s.contains(git2::STATUS_INDEX_MODIFIED) => 'M', s if s.contains(git2::STATUS_INDEX_DELETED) => 'D'...
identifier_body
slice-pat-type-mismatches.rs
fn main() { match "foo".to_string() { ['f', 'o',..] => {} //~^ ERROR expected an array or slice, found `String` _ => { } }; // Note that this one works with default binding modes. match &[0, 1, 2] { [..] => {} }; match &[0, 1, 2] { &[..] =>
// ok }; match [0, 1, 2] { [0] => {}, //~ ERROR pattern requires [0, 1, x @..] => { let a: [_; 1] = x; } [0, 1, 2, 3, x @..] => {} //~ ERROR pattern requires }; match does_not_exist { //~ ERROR cannot find value `does_not_exist` in this scope [] =>...
{}
conditional_block
slice-pat-type-mismatches.rs
fn main() { match "foo".to_string() { ['f', 'o',..] => {} //~^ ERROR expected an array or slice, found `String` _ => { } }; // Note that this one works with default binding modes. match &[0, 1, 2] { [..] => {} }; match &[0, 1, 2] { &[..] => {} // ok ...
[0, 1, x @..] => { let a: [_; 1] = x; } [0, 1, 2, 3, x @..] => {} //~ ERROR pattern requires }; match does_not_exist { //~ ERROR cannot find value `does_not_exist` in this scope [] => {} }; } fn another_fn_to_avoid_suppression() { match Default::default() ...
match [0, 1, 2] { [0] => {}, //~ ERROR pattern requires
random_line_split
slice-pat-type-mismatches.rs
fn main() { match "foo".to_string() { ['f', 'o',..] => {} //~^ ERROR expected an array or slice, found `String` _ => { } }; // Note that this one works with default binding modes. match &[0, 1, 2] { [..] => {} }; match &[0, 1, 2] { &[..] => {} // ok ...
{ match Default::default() { [] => {} //~ ERROR type annotations needed }; }
identifier_body
slice-pat-type-mismatches.rs
fn
() { match "foo".to_string() { ['f', 'o',..] => {} //~^ ERROR expected an array or slice, found `String` _ => { } }; // Note that this one works with default binding modes. match &[0, 1, 2] { [..] => {} }; match &[0, 1, 2] { &[..] => {} // ok }; ...
main
identifier_name
utils.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 rustc::front::map as ast_map; use rustc::lint::{LateContext, LintContext}; use rustc::middle::def; use rustc::...
(map: &ast_map::Map, id: ast::NodeId) -> bool { match map.find(map.get_parent(id)) { Some(ast_map::NodeImplItem(itm)) => { match itm.node { hir::ImplItemKind::Method(ref sig, _) => sig.unsafety == hir::Unsafety::Unsafe, _ => false } }, ...
unsafe_context
identifier_name
utils.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 rustc::front::map as ast_map; use rustc::lint::{LateContext, LintContext}; use rustc::middle::def; use rustc::...
else { false } } else { false } }) }
{ if n.as_str().contains("derive") { true } else { false } }
conditional_block
utils.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 rustc::front::map as ast_map; use rustc::lint::{LateContext, LintContext}; use rustc::middle::def; use rustc::...
pub fn unsafe_context(map: &ast_map::Map, id: ast::NodeId) -> bool { match map.find(map.get_parent(id)) { Some(ast_map::NodeImplItem(itm)) => { match itm.node { hir::ImplItemKind::Method(ref sig, _) => sig.unsafety == hir::Unsafety::Unsafe, _ => false ...
// lint can be aborted.
random_line_split
utils.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 rustc::front::map as ast_map; use rustc::lint::{LateContext, LintContext}; use rustc::middle::def; use rustc::...
pub fn in_derive_expn(cx: &LateContext, span: Span) -> bool { cx.sess().codemap().with_expn_info(span.expn_id, |info| { if let Some(i) = info { if let ExpnFormat::MacroAttribute(n) = i.callee.format { if n.as_str().contains("derive") { ...
{ cx.tcx.with_path(def_id, |iter| iter.map(|elem| elem.name()) .zip(path.iter()).all(|(nm, p)| &nm.as_str() == p)) }
identifier_body
wallet_address.rs
//! Fractal Global Wallet Address //! //! This module holds the Fractal Global wallet address format, along with its parsing error //! representing struct. use std::convert::From; use std::result::Result; use std::error::Error; use std::{fmt, str}; use std::str::FromStr; use rust_base58::{ToBase58, FromBase58}; use r...
/// checksum[0] ^= *b; /// checksum[1] ^= checksum[0]; /// } /// /// assert_eq!(checksum, [0xAD, 0x07]); /// ``` #[derive(Eq, PartialEq, PartialOrd, Ord, Debug, Clone, Copy, RustcEncodable, RustcDecodable)] pub struct WalletAddress { address: [u8; WALLET_ADDRESS_LEN], } impl WalletAddress { /// Creates...
random_line_split
wallet_address.rs
//! Fractal Global Wallet Address //! //! This module holds the Fractal Global wallet address format, along with its parsing error //! representing struct. use std::convert::From; use std::result::Result; use std::error::Error; use std::{fmt, str}; use std::str::FromStr; use rust_base58::{ToBase58, FromBase58}; use r...
let mut checksum = [0u8; 2]; for byte in &bytes[..WALLET_ADDRESS_LEN] { checksum[0] ^= *byte; checksum[1] ^= checksum[0]; } if checksum[0]!= bytes[WALLET_ADDRESS_LEN] || checksum[1]!= bytes[WALLET_ADDRESS_LEN + 1] { Err(WalletAddressParse...
{ return Err(WalletAddressParseError::new(s, "the first byte of the address is not 0x00", None)); }
conditional_block
wallet_address.rs
//! Fractal Global Wallet Address //! //! This module holds the Fractal Global wallet address format, along with its parsing error //! representing struct. use std::convert::From; use std::result::Result; use std::error::Error; use std::{fmt, str}; use std::str::FromStr; use rust_base58::{ToBase58, FromBase58}; use r...
}
{ None }
identifier_body
wallet_address.rs
//! Fractal Global Wallet Address //! //! This module holds the Fractal Global wallet address format, along with its parsing error //! representing struct. use std::convert::From; use std::result::Result; use std::error::Error; use std::{fmt, str}; use std::str::FromStr; use rust_base58::{ToBase58, FromBase58}; use r...
<S: AsRef<str>>(wallet_address: S, error: S, cause: Option<FromBase58Error>) -> WalletAddressParseError { WalletAddressParseError { description: format!("the wallet address {:?} is not a valid Fractal Global wallet \ ...
new
identifier_name
lib.rs
//! MLCR: Machine-Learning-based Cache Replacement //! //! MLCR trains a neural network to "guess" how long time will pass before the cache block is //! accessed again. In other words, it provides a qualified guess to approximate the ideal Bélády's //! algorithm without a time machine. //! //! MLCR is slow, because it ...
} } impl cmp::PartialOrd for Prediction { fn partial_cmp(&self, other: &Prediction) -> Option<cmp::Ordering> { Some(self.cmp(other)) } } impl cmp::Eq for Prediction {} /// An iterator over the coldest (best candidates for replacement) to hotter cache objects. /// /// This iterators from the object...
cmp::Ordering::Greater }
conditional_block
lib.rs
//! MLCR: Machine-Learning-based Cache Replacement //! //! MLCR trains a neural network to "guess" how long time will pass before the cache block is //! accessed again. In other words, it provides a qualified guess to approximate the ideal Bélády's //! algorithm without a time machine. //! //! MLCR is slow, because it ...
-> ConcurrentCache { ConcurrentCache { inner: Mutex::new(Cache::new()), queue: SegQueue::new(), } } /// Lock the inner cache. pub fn lock(&self) -> MutexGuard<Cache> { // Lock the cache tracker. let mut lock = self.inner.lock(); // Commit the...
w()
identifier_name
lib.rs
//! MLCR: Machine-Learning-based Cache Replacement //! //! MLCR trains a neural network to "guess" how long time will pass before the cache block is //! accessed again. In other words, it provides a qualified guess to approximate the ideal Bélády's //! algorithm without a time machine. //! //! MLCR is slow, because it ...
} /// Touch a cache block. /// /// This should be called whenever the object `id` represents is used (read, written, etc.). /// /// This will train the neural network with the new data. pub fn touch(&mut self, id: Id) { { // Get the block we need. let block =...
blocks: HashMap::new(), nn: NN::new(&[5, 6, 1]), clock: 0, }
random_line_split
lib.rs
//! MLCR: Machine-Learning-based Cache Replacement //! //! MLCR trains a neural network to "guess" how long time will pass before the cache block is //! accessed again. In other words, it provides a qualified guess to approximate the ideal Bélády's //! algorithm without a time machine. //! //! MLCR is slow, because it ...
/// A cache operation. enum CacheOperation { /// Create a new cache block with some ID. Insert(Id), /// Remove a cache block. Remove(Id), /// Touch some block. Touch(Id), } /// A concurrent cache tracker. /// /// This has two parts to it: /// /// - A normal cache tracker, protected by a lock....
self.cold().take(self.blocks.len() - to) } }
identifier_body
default_author.rs
/* * Copyright 2013 Brandon Sanderson * * This file is part of Evict-BT. * * Evict-BT 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) ...
_ => {} } 0 } } }
match save_result { Err(e) => println!("Failed to save config: {}", e.description()),
random_line_split
default_author.rs
/* * Copyright 2013 Brandon Sanderson * * This file is part of Evict-BT. * * Evict-BT 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) ...
} } }
{ if args.len() > 1 { println!("default-author usage: evict default-author [new-author]"); 1 }else{ let config = config::Config::load(); if args.len() == 0 { match config.author { Some(author) => println!("{}", author), None => println!("No author set") }; 0 }e...
identifier_body
default_author.rs
/* * Copyright 2013 Brandon Sanderson * * This file is part of Evict-BT. * * Evict-BT 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) ...
(mut args:Vec<String>) -> isize { if args.len() > 1 { println!("default-author usage: evict default-author [new-author]"); 1 }else{ let config = config::Config::load(); if args.len() == 0 { match config.author { Some(author) => println!("{}", author), None => println!("No auth...
default_author
identifier_name
mm.rs
use core::option::Option; use arch::PAGE_SIZE; use World; use titanium::hw; extern { static _pt_start: u8; static _pt_end: u8; } pub struct PageArena { pub start : usize, pub end : usize, pub current : usize, } impl PageArena { pub fn new(start : usize, end : usize) -> PageArena { /...
} } static mut pool : PageArena = PageArena { start: 0, end: 0, current: 0, }; pub fn preinit() -> &'static mut PageArena { let start : usize = &_pt_start as *const u8 as usize; let end : usize = &_pt_end as *const u8 as usize; unsafe { pool.start = start; pool.end = end; ...
{ Option::None }
conditional_block
mm.rs
use core::option::Option; use arch::PAGE_SIZE; use World; use titanium::hw; extern { static _pt_start: u8; static _pt_end: u8; } pub struct PageArena { pub start : usize, pub end : usize, pub current : usize, } impl PageArena { pub fn new(start : usize, end : usize) -> PageArena { /...
(&mut self) -> Option<usize> { if self.current < self.end { let ret = self.current; self.current = ret + PAGE_SIZE; Option::Some(ret) } else { Option::None } } } static mut pool : PageArena = PageArena { start: 0, end: 0, current: ...
get
identifier_name
mm.rs
use core::option::Option; use arch::PAGE_SIZE; use World; use titanium::hw; extern { static _pt_start: u8; static _pt_end: u8; } pub struct PageArena { pub start : usize, pub end : usize, pub current : usize, } impl PageArena { pub fn new(start : usize, end : usize) -> PageArena { /...
let start : usize = &_pt_start as *const u8 as usize; let end : usize = &_pt_end as *const u8 as usize; unsafe { pool.start = start; pool.end = end; pool.current = start; &mut pool } } pub fn init(world : &mut World<hw::Real>) { //let _table = PageTableRoot::new(wor...
pub fn preinit() -> &'static mut PageArena {
random_line_split
csv.rs
extern crate nalgebra; use nalgebra::*; use om::koe::*; use om::cb::*; use tick::*; use push::*; use std::rc::*; /// #Cartesian State Vectors /// This structure represents an orbit using a /// radius vector and a velocity vector. /// It holds a reference to the central body. #[derive(Clone)] pub struct CSV {
pub cb: Rc<CB>, } impl Tick for CSV { fn tick(&self, dt: f64) -> Self { CSV { r: self.r + self.v * dt, cb: self.cb.clone(), ..*self } } } impl Push for CSV { fn push(&self, dv: Vec3<f64>) -> Self { CSV { v: self.v + dv, ...
/// Radius vector. pub r: Vec3<f64>, /// Velocity. pub v: Vec3<f64>, /// Reference to the central body.
random_line_split
csv.rs
extern crate nalgebra; use nalgebra::*; use om::koe::*; use om::cb::*; use tick::*; use push::*; use std::rc::*; /// #Cartesian State Vectors /// This structure represents an orbit using a /// radius vector and a velocity vector. /// It holds a reference to the central body. #[derive(Clone)] pub struct CSV { /// R...
(&self, dt: f64) -> Self { CSV { r: self.r + self.v * dt, cb: self.cb.clone(), ..*self } } } impl Push for CSV { fn push(&self, dv: Vec3<f64>) -> Self { CSV { v: self.v + dv, cb: self.cb.clone(), ..*self } ...
tick
identifier_name
csv.rs
extern crate nalgebra; use nalgebra::*; use om::koe::*; use om::cb::*; use tick::*; use push::*; use std::rc::*; /// #Cartesian State Vectors /// This structure represents an orbit using a /// radius vector and a velocity vector. /// It holds a reference to the central body. #[derive(Clone)] pub struct CSV { /// R...
/// Construct CSV from KOE. pub fn from_koe(koe: KOE) -> CSV { // Mean anomaly let m0 = koe.m0; // Number of iterations for newton_raphson let iterations = 10; // Eccentric anomaly let ea = CSV::newton_raphson(&m0, &koe.e, &iterations); // True anomaly ...
{ CSV { r: r, v: v, cb: cb, } }
identifier_body
dot.rs
//! Generating Graphviz `dot` files from our IR. use super::context::{BindgenContext, ItemId}; use super::traversal::Trace; use std::fs::File; use std::io::{self, Write}; use std::path::Path; /// A trait for anything that can write attributes as `<table>` rows to a dot /// file. pub trait DotAttributes { /// Writ...
ctx, &mut |sub_id: ItemId, edge_kind| { if err.is_some() { return; } match writeln!( &mut dot_file, "{} -> {} [label={:?}, color={}];", id.as_usize(), ...
{ let file = File::create(path)?; let mut dot_file = io::BufWriter::new(file); writeln!(&mut dot_file, "digraph {{")?; let mut err: Option<io::Result<_>> = None; for (id, item) in ctx.items() { let is_allowlisted = ctx.allowlisted_items().contains(&id); writeln!( &mut ...
identifier_body
dot.rs
//! Generating Graphviz `dot` files from our IR. use super::context::{BindgenContext, ItemId}; use super::traversal::Trace; use std::fs::File; use std::io::{self, Write}; use std::path::Path; /// A trait for anything that can write attributes as `<table>` rows to a dot /// file. pub trait DotAttributes { /// Writ...
Err(e) => err = Some(Err(e)), } }, &(), ); if let Some(err) = err { return err; } if let Some(module) = item.as_module() { for child in module.children() { writeln!( ...
{}
conditional_block
dot.rs
//! Generating Graphviz `dot` files from our IR. use super::context::{BindgenContext, ItemId}; use super::traversal::Trace; use std::fs::File; use std::io::{self, Write}; use std::path::Path; /// A trait for anything that can write attributes as `<table>` rows to a dot /// file. pub trait DotAttributes { /// Writ...
} } writeln!(&mut dot_file, "}}")?; Ok(()) }
"{} -> {} [style=dotted, color=gray]", item.id().as_usize(), child.as_usize() )?; }
random_line_split
dot.rs
//! Generating Graphviz `dot` files from our IR. use super::context::{BindgenContext, ItemId}; use super::traversal::Trace; use std::fs::File; use std::io::{self, Write}; use std::path::Path; /// A trait for anything that can write attributes as `<table>` rows to a dot /// file. pub trait DotAttributes { /// Writ...
<P>(ctx: &BindgenContext, path: P) -> io::Result<()> where P: AsRef<Path>, { let file = File::create(path)?; let mut dot_file = io::BufWriter::new(file); writeln!(&mut dot_file, "digraph {{")?; let mut err: Option<io::Result<_>> = None; for (id, item) in ctx.items() { let is_allowliste...
write_dot_file
identifier_name
htmltablerowelement.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 cssparser::RGBA; use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; use d...
else { return -1; }; self.row_index(collection) } } pub trait HTMLTableRowElementLayoutHelpers { fn get_background_color(&self) -> Option<RGBA>; } #[allow(unsafe_code)] impl HTMLTableRowElementLayoutHelpers for LayoutJS<HTMLTableRowElement> { fn get_background_color(&self) -> ...
{ table_section.Rows() }
conditional_block
htmltablerowelement.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 cssparser::RGBA; use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; use d...
// https://html.spec.whatwg.org/multipage/#dom-tr-insertcell fn InsertCell(&self, index: i32) -> Fallible<Root<HTMLElement>> { let node = self.upcast::<Node>(); node.insert_cell_or_row( index, || self.Cells(), || HTMLTableDataCellElement::new(atom!("td"), No...
{ self.cells.or_init(|| { let window = window_from_node(self); let filter = box CellsFilter; HTMLCollection::create(window.r(), self.upcast(), filter) }) }
identifier_body
htmltablerowelement.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 cssparser::RGBA; use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; use d...
table.Rows() } else if let Some(table_section) = parent.downcast::<HTMLTableSectionElement>() { table_section.Rows() } else { return -1; }; self.row_index(collection) } } pub trait HTMLTableRowElementLayoutHelpers { fn get_background_color(&se...
}; let collection = if let Some(table) = parent.downcast::<HTMLTableElement>() {
random_line_split
htmltablerowelement.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 cssparser::RGBA; use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; use d...
(&self) -> Root<HTMLCollection> { self.cells.or_init(|| { let window = window_from_node(self); let filter = box CellsFilter; HTMLCollection::create(window.r(), self.upcast(), filter) }) } // https://html.spec.whatwg.org/multipage/#dom-tr-insertcell fn Ins...
Cells
identifier_name
try_fold.rs
use core::fmt; use core::pin::Pin; use futures_core::future::{FusedFuture, Future, TryFuture}; use futures_core::ready; use futures_core::stream::Stream; use futures_core::task::{Context, Poll}; use pin_project_lite::pin_project; pin_project! { /// Future for the [`try_fold`](super::TryStreamExt::try_fold) method....
} impl<St, Fut, T, F> FusedFuture for TryFold<St, Fut, T, F> where St: Stream, F: FnMut(T, St::Item) -> Fut, Fut: TryFuture<Ok = T>, { fn is_terminated(&self) -> bool { self.accum.is_none() && self.future.is_none() } } impl<St, Fut, T, F> Future for TryFold<St, Fut, T, F> where St: St...
{ Self { stream, f, accum: Some(t), future: None } }
identifier_body
try_fold.rs
use core::fmt; use core::pin::Pin; use futures_core::future::{FusedFuture, Future, TryFuture}; use futures_core::ready; use futures_core::stream::Stream; use futures_core::task::{Context, Poll}; use pin_project_lite::pin_project; pin_project! { /// Future for the [`try_fold`](super::TryStreamExt::try_fold) method....
(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { let mut this = self.project(); Poll::Ready(loop { if let Some(fut) = this.future.as_mut().as_pin_mut() { // we're currently processing a future to produce a new accum value let res = ready!(...
poll
identifier_name
try_fold.rs
use core::fmt; use core::pin::Pin; use futures_core::future::{FusedFuture, Future, TryFuture}; use futures_core::ready; use futures_core::stream::Stream; use futures_core::task::{Context, Poll}; use pin_project_lite::pin_project; pin_project! { /// Future for the [`try_fold`](super::TryStreamExt::try_fold) method....
f: F, accum: Option<T>, #[pin] future: Option<Fut>, } } impl<St, Fut, T, F> fmt::Debug for TryFold<St, Fut, T, F> where St: fmt::Debug, Fut: fmt::Debug, T: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("TryFold") ...
random_line_split
interpret.rs
use parser::{Token, TokenType}; use std::ops::Index; use std::iter; use std::iter::FromIterator; /* This mod contains the interpreter part of Assembunny+. The abbreviated terminology for this mod is "ASMBI", for "ASseMBunny+ Interpreter". One of the functions here is meant to be called directly from main.rs so tha...
pub fn dec(state: &mut AsmbiState, toks: &Vec<Token>) -> Response { // Syntax: dec <register name> try_set!(state.regs.modify(&toks[1], |v| v - 1)) } pub fn dect(state: &mut AsmbiState, toks: &Vec<Token>) -> Response { // Syntax: dect <register name> <value to be eval'd> l...
{ // Syntax: inct <register index> <value to add> let adder = state.regs.parse_token(&toks[2]); try_set!(state.regs.modify(&toks[1], |v| v + adder)) }
identifier_body
interpret.rs
use parser::{Token, TokenType}; use std::ops::Index; use std::iter; use std::iter::FromIterator; /* This mod contains the interpreter part of Assembunny+. The abbreviated terminology for this mod is "ASMBI", for "ASseMBunny+ Interpreter". One of the functions here is meant to be called directly from main.rs so tha...
(capacity: usize) -> AsmbiState { AsmbiState { regs: RegisterMap::new(capacity), ip: 0 } }
new_state
identifier_name
interpret.rs
use parser::{Token, TokenType}; use std::ops::Index; use std::iter; use std::iter::FromIterator; /* This mod contains the interpreter part of Assembunny+. The abbreviated terminology for this mod is "ASMBI", for "ASseMBunny+ Interpreter". One of the functions here is meant to be called directly from main.rs so tha...
} pub fn mul(state: &mut AsmbiState, toks: &Vec<Token>) -> Response { // Syntax: mul <register name> <eval-ue> let multiplier = state.regs.parse_token(&toks[2]); try_set!(state.regs.modify(&toks[1], |v| v * multiplier)) } pub fn div(state: &mut AsmbiState, toks: &Vec<Token>) ->...
random_line_split
transaction_request.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
} #[cfg(test)] mod tests { use std::str::FromStr; use rustc_serialize::hex::FromHex; use serde_json; use v1::types::{U256, H160, BlockNumber}; use super::*; #[test] fn transaction_request_deserialize() { let s = r#"{ "from":"0x0000000000000000000000000000000000000001", "to":"0x00000000000000000000000...
{ helpers::TransactionRequest { from: self.from.into(), to: self.to.map(Into::into), gas_price: self.gas_price.map(Into::into), gas: self.gas.map(Into::into), value: self.value.map(Into::into), data: self.data.map(Into::into), nonce: self.nonce.map(Into::into), min_block: self.min_block.and_th...
identifier_body
transaction_request.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
use std::fmt; /// Transaction request coming from RPC #[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct TransactionRequest { /// Sender pub from: H160, /// Recipient pub to: Option<H160>, /// Gas Price #[serde(rename="gasPrice")] pub gas_pric...
random_line_split
transaction_request.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
() { let s = r#"{ "from":"0xb5f7502a2807cb23615c7456055e1d65b2508625", "to":"", "data":"0x8595bab1", "gas":"0x2fd618", "gasPrice":"0x0ba43b7400" }"#; let deserialized = serde_json::from_str::<TransactionRequest>(s); assert!(deserialized.is_err(), "Should be error because to is empty"); } #[t...
transaction_request_deserialize_error
identifier_name
xrsystem.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::XRSystemBinding::XRSessi...
else { promise.reject_error(Error::Security); return promise; } } if self.pending_or_active_session() { promise.reject_error(Error::InvalidState); return promise; } self.set_pending...
{ warn!("The dom.webxr.unsafe-assume-user-intent preference assumes user intent to enter WebXR."); }
conditional_block
xrsystem.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::XRSystemBinding::XRSessi...
(window: &Window) -> DomRoot<XRSystem> { reflect_dom_object( Box::new(XRSystem::new_inherited(window.pipeline_id())), window, ) } pub fn pending_or_active_session(&self) -> bool { self.pending_immersive_session.get() || self.active_immersive_session.get().is_some...
new
identifier_name
xrsystem.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::XRSystemBinding::XRSessi...
} } impl XRSystemMethods for XRSystem { /// https://immersive-web.github.io/webxr/#dom-xr-issessionsupported fn IsSessionSupported(&self, mode: XRSessionMode) -> Rc<Promise> { // XXXManishearth this should select an XR device first let promise = Promise::new(&self.global()); let mut...
}
random_line_split
xrsystem.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::XRSystemBinding::XRSessi...
/// https://immersive-web.github.io/webxr/#ref-for-eventdef-xrsession-end pub fn end_session(&self, session: &XRSession) { // Step 3 if let Some(active) = self.active_immersive_session.get() { if Dom::from_ref(&*active) == Dom::from_ref(session) { self.active_immers...
{ // XXXManishearth when we support non-immersive (inline) sessions we should // ensure they never reach these codepaths self.pending_immersive_session.set(false); self.active_immersive_session.set(Some(session)) }
identifier_body
mod.rs
// bound region from A that we find it to be associated // with. for (a_br, a_r) in a_map { if tainted.iter().any(|x| x == a_r) { debug!("generalize_region(r0={:?}): \ replacing with {:?}, tainted={:?}", ...
{ debug_assert!(leak_check(infcx, &skol_map, snapshot).is_ok()); debug!("plug_leaks(skol_map={}, value={})", skol_map.repr(infcx.tcx), value.repr(infcx.tcx)); // Compute a mapping from the "taint set" of each skolemized // region back to the `ty::BoundRegion` that it originally ...
identifier_body
mod.rs
())); // Compare types now that bound regions have been replaced. let result = try!(Combineable::combine(self, &a_prime, &b_prime)); // Presuming type comparison succeeds, we need to check // that the skolemized regions do not "leak". match leak_check(self.i...
(infcx: &InferCtxt, debruijn: ty::DebruijnIndex) -> ty::Region { infcx.region_vars.new_bound(debruijn) } } } fn var_ids<'tcx, T: Combine<'tcx>>(combiner: &T, map: &FnvHashMap<ty::BoundRegion, ty::Region>) -> Vec<ty::RegionVid...
fresh_bound_variable
identifier_name
mod.rs
.tcx())); // Compare types now that bound regions have been replaced. let result = try!(Combineable::combine(self, &a_prime, &b_prime)); // Presuming type comparison succeeds, we need to check // that the skolemized regions do not "leak". match leak_check(se...
let mut a_r = None; let mut b_r = None; let mut only_new_vars = true; for r in &tainted { if is_var_in_set(a_vars, *r) { if a_r.is_some() { return fresh_bound_variable(infcx, debruijn); } else...
let tainted = infcx.tainted_regions(snapshot, r0);
random_line_split
intf.rs
//! formatter for unsigned and signed int subs //! unsigned ints: %X %x (hex u64) %o (octal u64) %u (base ten u64) //! signed ints: %i %d (both base ten i64) use std::u64; use std::i64; use super::super::format_field::FormatField; use super::super::formatter::{InPrefix, FormatPrimitive, Base, Formatter, warn_incomplete...
(&self, prim: &FormatPrimitive, field: FormatField) -> String { let mut finalstr: String = String::new(); match prim.prefix { Some(ref prefix) => { finalstr.push_str(&prefix); } None => {} } // integral second fields is zero-padded mini...
primitive_to_str
identifier_name
intf.rs
//! formatter for unsigned and signed int subs //! unsigned ints: %X %x (hex u64) %o (octal u64) %u (base ten u64) //! signed ints: %i %d (both base ten i64) use std::u64; use std::i64; use super::super::format_field::FormatField; use super::super::formatter::{InPrefix, FormatPrimitive, Base, Formatter, warn_incomplete...
} None => {} } finalstr.push_str(&pre_decimal); } None => { panic!("error, format primitives provided to int, will, incidentally under \ correct behavior, always have a pre_dec value."...
{ let mut finalstr: String = String::new(); match prim.prefix { Some(ref prefix) => { finalstr.push_str(&prefix); } None => {} } // integral second fields is zero-padded minimum-width // which gets handled before general minimum...
identifier_body
intf.rs
//! formatter for unsigned and signed int subs //! unsigned ints: %X %x (hex u64) %o (octal u64) %u (base ten u64) //! signed ints: %i %d (both base ten i64) use std::u64; use std::i64; use super::super::format_field::FormatField; use super::super::formatter::{InPrefix, FormatPrimitive, Base, Formatter, warn_incomplete...
} if ret.past_max { break; } } else { ret.check_past_max = true; } } ...
{ // force conversion // to check if its above max. // todo: spin out convert // into fn, call it here to try // read va...
conditional_block
intf.rs
//! formatter for unsigned and signed int subs //! unsigned ints: %X %x (hex u64) %o (octal u64) %u (base ten u64) //! signed ints: %i %d (both base ten i64) use std::u64; use std::i64; use super::super::format_field::FormatField; use super::super::formatter::{InPrefix, FormatPrimitive, Base, Formatter, warn_incomplete...
} else { ret.check_past_max = true; } } } _ => { warn_incomplete_conv(str_in); break; } ...
break; }
random_line_split
issue-3601.rs
// Copyright 2012-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-MI...
{ kind: Box<ElementKind> } enum ElementKind { HTMLImageElement(HTMLImageData) } enum NodeKind { Element(ElementData) } struct NodeData { kind: Box<NodeKind>, } fn main() { let mut id = HTMLImageData { image: None }; let ed = ElementData { kind: box ElementKind::HTMLImageElement(id) }; l...
ElementData
identifier_name
issue-3601.rs
// Copyright 2012-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-MI...
box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => { true } }, _ => panic!("WAT") //~ ERROR unreachable pattern }; }
random_line_split
lib.rs
/** * Copyright (c) 2015 Alex Maslakov, <http://www.gildedhonour.com>, <http://www.alexmaslakov.com> * * 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/...
{ algorithm: Algorithm, ttype: String } impl Header { pub fn new(alg: Algorithm) -> Header { Header { algorithm: alg, ttype: Header::std_type() } } pub fn std_type() -> String { "JWT".to_string() } } #[derive(Clone, Copy)] pub enum Algorithm { HS256, HS384, HS512, RS256 } impl ToStrin...
Header
identifier_name
lib.rs
/** * Copyright (c) 2015 Alex Maslakov, <http://www.gildedhonour.com>, <http://www.alexmaslakov.com> * * 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/...
fn create_hmac<'a, D: Digest + 'a>(digest: D, some_str: String) -> Box<Mac + 'a> { Box::new(Hmac::new(digest, some_str.as_bytes())) } #[cfg(test)] mod tests { extern crate time; use time::Duration; use super::Header; use super::Payload; use super::encode; use super::decode; use super::Algorithm; ...
{ if a.len() != b.len() { return false } let mut res = 0_u8; for (&x, &y) in a.iter().zip(b.iter()) { res |= x ^ y; } res == 0 }
identifier_body
lib.rs
/** * Copyright (c) 2015 Alex Maslakov, <http://www.gildedhonour.com>, <http://www.alexmaslakov.com> * * 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/...
let header_tree = json_to_tree(header_json); let alg = header_tree.get("alg").unwrap(); let header = Header::new(parse_algorithm(alg)); let payload_json = base64_to_json(payload_segment); let payload = json_to_tree(payload_json); (header, payload) } fn parse_algorithm(alg: &str) -> Algorithm { match alg ...
let header_json = base64_to_json(header_segment);
random_line_split
any_error.rs
//! Defines an alias for the type returned by `std::panic::catch_unwind`. // All of this module is `pub(crate)` and should not appear in the C header file // or documentation. use crate::error::error_msg::ErrorMsg; use std::any::Any; /// The error type returned by `std::panic::catch_unwind`. pub(crate) type AnyError...
impl ToErrorMsg for AnyError { /// This works with an `AnyError` taken from `std::panic::catch_unwind`, /// attempts to extract an error message out of it by constructing the /// `ErrorMsg` type, and then converts that to a string, which is passed /// to `update_last_error`. /// /// Note that if...
pub(crate) trait ToErrorMsg { fn into_error_msg(self) -> String; }
random_line_split
any_error.rs
//! Defines an alias for the type returned by `std::panic::catch_unwind`. // All of this module is `pub(crate)` and should not appear in the C header file // or documentation. use crate::error::error_msg::ErrorMsg; use std::any::Any; /// The error type returned by `std::panic::catch_unwind`. pub(crate) type AnyError...
(self) -> String { ErrorMsg::from(self).to_string() } }
into_error_msg
identifier_name
any_error.rs
//! Defines an alias for the type returned by `std::panic::catch_unwind`. // All of this module is `pub(crate)` and should not appear in the C header file // or documentation. use crate::error::error_msg::ErrorMsg; use std::any::Any; /// The error type returned by `std::panic::catch_unwind`. pub(crate) type AnyError...
}
{ ErrorMsg::from(self).to_string() }
identifier_body
tree_gravity.rs
//! Simple integration tests oriented towards gravity computations extern crate acacia; extern crate nalgebra; extern crate quickcheck; use nalgebra::{ApproxEq, Point2, Point3, FloatPoint, Vector2, Vector3, zero, Norm, Origin}; use quickcheck::{TestResult, quickcheck}; use acacia::{Tree, Node, AssociatedData, DataQue...
>(p: (T, T, T)) -> Point3<T> { let (x, y, z) = p; Point3::new(x, y, z) } let test_point = pnt(test_point); // Newton's law of gravity for two point masses (with G = 1) let newton = |(m, p1): (f64, Point3<f64>), p2| { let diff: Vector3<f64> = p1 - p2; ...
t<T
identifier_name
tree_gravity.rs
//! Simple integration tests oriented towards gravity computations extern crate acacia; extern crate nalgebra; extern crate quickcheck; use nalgebra::{ApproxEq, Point2, Point3, FloatPoint, Vector2, Vector3, zero, Norm, Origin}; use quickcheck::{TestResult, quickcheck}; use acacia::{Tree, Node, AssociatedData, DataQue...
).expect("Couldn't construct tree"); let theta = 0.5; // A bit arbitrary but this appears to work let tree_gravity = tree.query_data(|node| { let &(ref center_of_mass, _) = node.data(); let d = FloatPoint::distance(&test_point, center_of_mass); ...
random_line_split
tree_gravity.rs
//! Simple integration tests oriented towards gravity computations extern crate acacia; extern crate nalgebra; extern crate quickcheck; use nalgebra::{ApproxEq, Point2, Point3, FloatPoint, Vector2, Vector3, zero, Norm, Origin}; use quickcheck::{TestResult, quickcheck}; use acacia::{Tree, Node, AssociatedData, DataQue...
// No two stars should be in the same place for i in 0..starfield.len() { for j in 0..i { let (_, pi) = starfield[i]; let (_, pj) = starfield[j]; if pi == pj { return TestResult::discard(); } } ...
return TestResult::discard(); }
conditional_block
tree_gravity.rs
//! Simple integration tests oriented towards gravity computations extern crate acacia; extern crate nalgebra; extern crate quickcheck; use nalgebra::{ApproxEq, Point2, Point3, FloatPoint, Vector2, Vector3, zero, Norm, Origin}; use quickcheck::{TestResult, quickcheck}; use acacia::{Tree, Node, AssociatedData, DataQue...
let test_point = pnt(test_point); // Newton's law of gravity for two point masses (with G = 1) let newton = |(m, p1): (f64, Point3<f64>), p2| { let diff: Vector3<f64> = p1 - p2; let r = diff.norm(); diff * (m / r.powi(3)) }; // Calculate gravity...
let (x, y, z) = p; Point3::new(x, y, z) }
identifier_body
example.rs
use std::iter::FromIterator; pub struct SimpleLinkedList<T> { head: Option<Box<Node<T>>>, len: usize, } struct Node<T> { data: T, next: Option<Box<Node<T>>>, } impl<T> SimpleLinkedList<T> { pub fn new() -> Self { SimpleLinkedList { head: None, len: 0 } } pub fn is_empty(&self) ->...
(&self) -> Option<&T> { self.head.as_ref().map(|node| &node.data) } pub fn rev(self) -> SimpleLinkedList<T> { let mut rev_list = SimpleLinkedList::new(); let mut vec: Vec<_> = self.into(); for t in vec.drain(..).rev() { rev_list.push(t); } rev_list ...
peek
identifier_name
example.rs
use std::iter::FromIterator; pub struct SimpleLinkedList<T> { head: Option<Box<Node<T>>>, len: usize, } struct Node<T> { data: T, next: Option<Box<Node<T>>>, } impl<T> SimpleLinkedList<T> { pub fn new() -> Self { SimpleLinkedList { head: None, len: 0 }
pub fn len(&self) -> usize { self.len } pub fn push(&mut self, element: T) { let node = Box::new(Node::new(element, self.head.take())); self.head = Some(node); self.len += 1; } pub fn pop(&mut self) -> Option<T> { match self.len { 0 => None, ...
} pub fn is_empty(&self) -> bool { self.len == 0 }
random_line_split
bits.rs
//! View bits in memory with turtles //! //! This example uses [@myrrlyn]'s [`bitvec`] crate to turn data into strings of //! bits, and then draws them on the screen. //! //! You are encouraged to change both the data used to seed the turtle, and the //! `bitvec` calls that control how the turtle acts, to see what chan...
// For each bit, the loop puts down the pen to draw a line of the bit's // color, then picks up the pen to add some horizontal spacing between // them. turtle.pen_down(); turtle.forward(BIT_WIDTH); turtle.pen_up(); turtle.forward(BIT_MARGIN); } // Rewind the turt...
turtle.set_pen_color("light grey"); }
conditional_block
bits.rs
//! View bits in memory with turtles //! //! This example uses [@myrrlyn]'s [`bitvec`] crate to turn data into strings of //! bits, and then draws them on the screen. //! //! You are encouraged to change both the data used to seed the turtle, and the //! `bitvec` calls that control how the turtle acts, to see what chan...
le.pen_up(); turtle.left(angle); turtle.forward(BIT_HEIGHT); turtle.right(angle); }
identifier_body
bits.rs
//! View bits in memory with turtles //! //! This example uses [@myrrlyn]'s [`bitvec`] crate to turn data into strings of //! bits, and then draws them on the screen. //! //! You are encouraged to change both the data used to seed the turtle, and the //! `bitvec` calls that control how the turtle acts, to see what chan...
// loops over characters, collecting their start point in the text so that // we can grab the encoded bytes of each one. let mut row_num = 0; for (char_num, (start, codepoint)) in text.char_indices().enumerate() { println!("Character {}: {}", char_num, codepoint); // Each character has a...
random_line_split
bits.rs
//! View bits in memory with turtles //! //! This example uses [@myrrlyn]'s [`bitvec`] crate to turn data into strings of //! bits, and then draws them on the screen. //! //! You are encouraged to change both the data used to seed the turtle, and the //! `bitvec` calls that control how the turtle acts, to see what chan...
mut Turtle, number: f32) { // `bitvec` can look at more than just `u8`. Let's try looking at the bits // that represent a number! // // Some numbers, like `f32`, have special rules for their representation in // bits. `bitvec` only knows about raw bits, so it does not provide direct // support f...
r(turtle: &
identifier_name
tvout.rs
// Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according ...
pub const VP_TV_STANDARD_PAL_G: ULONG = 0x00020000; pub const VP_TV_STANDARD_PAL_60: ULONG = 0x00040000; pub const VP_TV_STANDARD_SECAM_L1: ULONG = 0x00080000; pub const VP_CP_TYPE_APS_TRIGGER: ULONG = 0x0001; pub const VP_CP_TYPE_MACROVISION: ULONG = 0x0002; pub const VP_CP_CMD_ACTIVATE: ULONG = 0x0001; pub const VP_C...
pub const VP_TV_STANDARD_SECAM_K: ULONG = 0x1000; pub const VP_TV_STANDARD_SECAM_K1: ULONG = 0x2000; pub const VP_TV_STANDARD_SECAM_L: ULONG = 0x4000; pub const VP_TV_STANDARD_WIN_VGA: ULONG = 0x8000; pub const VP_TV_STANDARD_NTSC_433: ULONG = 0x00010000;
random_line_split
font.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/. */ //! Animation implementation for various font-related types. use super::{Animate, Procedure, ToAnimatedZero}; use...
} impl ComputeSquaredDistance for FontVariationSettings { #[inline] fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> { FontSettingTagIter::new(self, other)? .map(|r| r.and_then(|(st, ot)| st.compute_squared_distance(&ot))) .sum() } } impl ToAni...
{ FontSettingTagIter::new(self, other)? .map(|r| r.and_then(|(st, ot)| st.animate(&ot, procedure))) .collect::<Result<Vec<ComputedVariationValue>, ()>>() .map(|v| GenericFontSettings(v.into_boxed_slice())) }
identifier_body
font.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/. */ //! Animation implementation for various font-related types. use super::{Animate, Procedure, ToAnimatedZero}; use...
(tags: Vec<&'a ComputedVariationValue>) -> FontSettingTagIterState<'a> { FontSettingTagIterState { index: tags.len(), tags, prev_tag: FontTag(0), } } } /// Iterator for font-variation-settings tag lists /// /// [CSS fonts level 4](https://drafts.csswg.org/css-fon...
new
identifier_name
font.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/. */ //! Animation implementation for various font-related types. use super::{Animate, Procedure, ToAnimatedZero}; use...
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> { FontSettingTagIter::new(self, other)? .map(|r| r.and_then(|(st, ot)| st.compute_squared_distance(&ot))) .sum() } } impl ToAnimatedZero for FontVariationSettings { #[inline] fn to_animated_zer...
impl ComputeSquaredDistance for FontVariationSettings { #[inline]
random_line_split
lib.rs
// Copyright 2012-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-MI...
(&self, sess: &Session) { llvm_util::init(sess); // Make sure llvm is inited } fn print(&self, req: PrintRequest, sess: &Session) { match req { PrintRequest::RelocationModels => { println!("Available relocation models:"); for &(name, _) in back::write...
init
identifier_name
lib.rs
// Copyright 2012-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-MI...
unsafe fn optimize( cgcx: &CodegenContext<Self>, diag_handler: &Handler, module: &ModuleCodegen<Self::Module>, config: &ModuleConfig, timeline: &mut Timeline ) -> Result<(), FatalError> { back::write::optimize(cgcx, diag_handler, module, config, timeline) } ...
{ back::lto::run_thin(cgcx, modules, cached_modules, timeline) }
identifier_body
lib.rs
// Copyright 2012-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-MI...
if!sess.opts.output_types.keys().any(|&i| i == OutputType::Exe || i == OutputType::Metadata) { return Ok(()); } // Run the linker on any artifacts that resulted from the LLVM run. // This should produce either a finished exe...
move || rustc_incremental::save_work_product_index(sess, &dep_graph, work_products)); sess.compile_status()?;
random_line_split
lib.rs
// Copyright 2012-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-MI...
PrintRequest::CodeModels => { println!("Available code models:"); for &(name, _) in back::write::CODE_GEN_MODEL_ARGS.iter(){ println!(" {}", name); } println!(""); } PrintRequest::TlsModels => { ...
{ println!("Available relocation models:"); for &(name, _) in back::write::RELOC_MODEL_ARGS.iter() { println!(" {}", name); } println!(""); }
conditional_block
net.rs
use std::io::net::ip::{SocketAddr, Ipv4Addr, Ipv6Addr}; use libc::{size_t, malloc, sockaddr, sockaddr_in, sockaddr_in6, in_addr, in6_addr, c_int, c_char, socklen_t, AF_INET, AF_INET6}; use std::mem::{size_of, transmute}; use std::string; /* const char * inet_ntop(int af, const void * restrict src, char * restric...
#[cfg(target_os = "linux")] #[cfg(target_os = "android")] fn new_sockaddr_in6(port: u16, addr: in6_addr) -> sockaddr_in6 { sockaddr_in6 { sin6_family: AF_INET6 as u16, sin6_port: port, sin6_flowinfo: 0, sin6_addr: addr, sin6_scope_id: 0, } } #[cfg(target_os = "macos")]...
{ sockaddr_in { sin_len: size_of::<sockaddr_in>() as u8, sin_family: AF_INET as u8, sin_port: port, sin_addr: addr, sin_zero: [0, ..8] } }
identifier_body
net.rs
use std::io::net::ip::{SocketAddr, Ipv4Addr, Ipv6Addr}; use libc::{size_t, malloc, sockaddr, sockaddr_in, sockaddr_in6, in_addr, in6_addr, c_int, c_char, socklen_t, AF_INET, AF_INET6}; use std::mem::{size_of, transmute}; use std::string; /* const char * inet_ntop(int af, const void * restrict src, char * restric...
(port: u16, addr: in6_addr) -> sockaddr_in6 { sockaddr_in6 { sin6_family: AF_INET6 as u16, sin6_port: port, sin6_flowinfo: 0, sin6_addr: addr, sin6_scope_id: 0, } } #[cfg(target_os = "macos")] fn new_sockaddr_in6(port: u16, addr: in6_addr) -> sockaddr_in6 { sockaddr_i...
new_sockaddr_in6
identifier_name
net.rs
use std::io::net::ip::{SocketAddr, Ipv4Addr, Ipv6Addr}; use libc::{size_t, malloc, sockaddr, sockaddr_in, sockaddr_in6, in_addr, in6_addr, c_int, c_char, socklen_t, AF_INET, AF_INET6}; use std::mem::{size_of, transmute}; use std::string; /* const char * inet_ntop(int af, const void * restrict src, char * restric...
, } }; unsafe {string::raw::from_buf(transmute(buf))} }
{ let addr = in6_addr { s6_addr: [a, b, c, d, e, f, g, h] }; let sockaddr = new_sockaddr_in6(port, addr); getnameinfo(transmute(&sockaddr), size_of::<sockaddr_in6>() as socklen_t, buf, hostlen, transmute(0u)...
conditional_block
net.rs
use std::io::net::ip::{SocketAddr, Ipv4Addr, Ipv6Addr}; use libc::{size_t, malloc, sockaddr, sockaddr_in, sockaddr_in6, in_addr, in6_addr, c_int, c_char, socklen_t, AF_INET, AF_INET6}; use std::mem::{size_of, transmute}; use std::string; /* const char * inet_ntop(int af, const void * restrict src, char * restric...
let hostlen = 80; buf = transmute(malloc(hostlen as size_t + 1)); match ip { Ipv4Addr(a, b, c, d) => { let addr = in_addr { s_addr: a as u32 << 24 | b as u32 << 16 | c as u32 << 8 ...
pub fn get_nameinfo(peer_socket: SocketAddr) -> String { let SocketAddr { ip, port } = peer_socket; let buf: *mut i8; let _ = unsafe {
random_line_split