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
lagrange.rs
use gf256::Gf256; use poly::Poly; /// Evaluates an interpolated polynomial at `Gf256::zero()` where /// the polynomial is determined using barycentric Lagrange /// interpolation based on the given `points` in /// the G(2^8) Galois field. pub(crate) fn interpolate_at(k: u8, points: &[(u8, u8)]) -> u8 { barycentric_...
} poly = poly.iter() .zip(coeffs.iter()) .map(|(&old_coeff, &add)| old_coeff + add / prod) .collect(); } Poly::new(poly) } #[cfg(test)] #[allow(trivial_casts)] mod tests { use super::*; use gf256::*; use quickcheck::*; use std; quickchec...
{ prod *= x - x1; let mut prec = Gf256::zero(); coeffs = coeffs .into_iter() .map(|coeff| { let new_coeff = coeff * (-x1) + prec; prec = coeff; new_coeff ...
conditional_block
lagrange.rs
use gf256::Gf256; use poly::Poly; /// Evaluates an interpolated polynomial at `Gf256::zero()` where /// the polynomial is determined using barycentric Lagrange /// interpolation based on the given `points` in /// the G(2^8) Galois field. pub(crate) fn interpolate_at(k: u8, points: &[(u8, u8)]) -> u8 { barycentric_...
assert_ne!(x.poly, 0, "Invalid share x = 0"); let mut coeffs = vec![Gf256::zero(); len]; coeffs[0] = y; let mut prod = Gf256::one(); for &(x1, _) in points { if x!= x1 { prod *= x - x1; let mut prec = Gf256::zero(); co...
let mut poly = vec![Gf256::zero(); len]; for &(x, y) in points {
random_line_split
lagrange.rs
use gf256::Gf256; use poly::Poly; /// Evaluates an interpolated polynomial at `Gf256::zero()` where /// the polynomial is determined using barycentric Lagrange /// interpolation based on the given `points` in /// the G(2^8) Galois field. pub(crate) fn interpolate_at(k: u8, points: &[(u8, u8)]) -> u8
/// Barycentric Lagrange interpolation algorithm from "Polynomial /// Interpolation: Langrange vs Newton" by Wilhelm Werner. Evaluates /// the polynomial at `Gf256::zero()`. #[inline] fn barycentric_interpolate_at(k: usize, points: &[(u8, u8)]) -> u8 { // Compute the barycentric weights `w`. let mut w = vec![...
{ barycentric_interpolate_at(k as usize, points) }
identifier_body
utils.rs
//! General utilities module. use crate::{config::Config, criticality::Criticality}; use anyhow::{Context, Result}; use colored::Colorize; use log::{log_enabled, warn, Level}; use quick_xml::{events::Event, Reader}; use std::{fmt, fs::File, io::BufReader, path::Path, thread::sleep, time::Duration}; /// Prints a warni...
/// Gets a string from the strings XML file. pub fn get_string<L, P>(label: L, config: &Config, package: P) -> Result<Option<String>> where L: AsRef<[u8]>, P: AsRef<str>, { // TODO: Lazy static HashMap. let mut path = config .dist_folder() .join(package.as_ref()) .join("res") ...
{ let mut result = String::new(); for (i, text) in code.as_ref().lines().enumerate() { if i >= (e_line + 5) { break; } else if (s_line >= 5 && i > s_line - 5) || (s_line < 5 && i < s_line + 5) { result.push_str(text); result.push_str("\n"); } } ...
identifier_body
utils.rs
//! General utilities module. use crate::{config::Config, criticality::Criticality}; use anyhow::{Context, Result}; use colored::Colorize; use log::{log_enabled, warn, Level}; use quick_xml::{events::Event, Reader}; use std::{fmt, fs::File, io::BufReader, path::Path, thread::sleep, time::Duration}; /// Prints a warni...
<P: AsRef<Path>>(path: P) -> String { path.as_ref() .file_stem() .expect("expected package name") .to_string_lossy() .into_owned() } /// Gets the code snippet near the start and end lines. /// /// It will return 5 lines above and 5 lines below the vulnerability. #[allow(clippy::nonminim...
get_package_name
identifier_name
utils.rs
//! General utilities module. use crate::{config::Config, criticality::Criticality}; use anyhow::{Context, Result}; use colored::Colorize; use log::{log_enabled, warn, Level}; use quick_xml::{events::Event, Reader}; use std::{fmt, fs::File, io::BufReader, path::Path, thread::sleep, time::Duration}; /// Prints a warni...
L: AsRef<[u8]>, P: AsRef<str>, { // TODO: Lazy static HashMap. let mut path = config .dist_folder() .join(package.as_ref()) .join("res") .join("values-en") .join("strings.xml"); if!path.exists() { path = config .dist_folder() .join(pa...
} /// Gets a string from the strings XML file. pub fn get_string<L, P>(label: L, config: &Config, package: P) -> Result<Option<String>> where
random_line_split
tool_shell.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use cast::GTK_TOOLSHELL; use {Orientation, ReliefStyle, ToolbarStyle}; pub trai...
fn get_relief_style(&self) -> ReliefStyle { unsafe { ffi::gtk_tool_shell_get_relief_style(GTK_TOOLSHELL(self.unwrap_widget())) } } fn get_style(&self) -> ToolbarStyle { unsafe { ffi::gtk_tool_shell_get_style(GTK_TOOLSHELL(self.unwrap_widget())) } ...
{ unsafe { ffi::gtk_tool_shell_get_orientation(GTK_TOOLSHELL(self.unwrap_widget())) } }
identifier_body
tool_shell.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use cast::GTK_TOOLSHELL; use {Orientation, ReliefStyle, ToolbarStyle}; pub trai...
fn get_text_size_group(&self) -> Option<::SizeGroup> { let tmp_pointer = unsafe { ffi::gtk_tool_shell_get_text_size_group(GTK_TOOLSHELL(self.unwrap_widget())) }; if tmp_pointer.is_null() { None } else { Some(::SizeGroup::wrap_pointer(tmp_pointer)) } } }
}
random_line_split
tool_shell.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use cast::GTK_TOOLSHELL; use {Orientation, ReliefStyle, ToolbarStyle}; pub trai...
(&self) -> ToolbarStyle { unsafe { ffi::gtk_tool_shell_get_style(GTK_TOOLSHELL(self.unwrap_widget())) } } fn get_text_alignment(&self) -> f32 { unsafe { ffi::gtk_tool_shell_get_text_alignment(GTK_TOOLSHELL(self.unwrap_widget())) } } fn get_text_o...
get_style
identifier_name
tool_shell.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use cast::GTK_TOOLSHELL; use {Orientation, ReliefStyle, ToolbarStyle}; pub trai...
} }
{ Some(::SizeGroup::wrap_pointer(tmp_pointer)) }
conditional_block
rusti.rs
Program, } // Action to do after reading a :command enum CmdAction { action_none, action_run_line(~str), } /// Run an input string in a Repl, returning the new Repl. fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str], input: ~str) -> (~Program, Option<~jit::Engine>) { // Build so...
fn find_main(crate: @ast::crate, sess: session::Session, f: &fn(&ast::blk)) { for crate.node.module.items.iter().advance |item| { match item.node { ast::item_fn(_, _, _, _, ref blk) => { if item.ident == sess.ident_of("main") { ...
driver::cu_parse, Some(outputs)); crate.expect("parsing should return a crate") }
random_line_split
rusti.rs
}; new_locals.push((s, mutbl)); } to_run.push(s); } } } // run statements with expressions (they have effects) ast::stmt_mac(*) | as...
multiple_functions
identifier_name
rusti.rs
} // Iterate through all of the block's statements, inserting them into // the correct portions of the program for blk.stmts.iter().advance |stmt| { let s = do with_pp(intr) |pp, _| { pprust::print_stmt(pp, *stmt); }; match stmt.node { ast::stmt_decl(d, ...
{ run_program("let a = 2;\n()\n"); run_program(" let a = 3; let b = 4u; assert!((a as uint) + b == 7) "); }
identifier_body
simple.rs
/* Copyright ⓒ 2016 rust-custom-derive contributors. Licensed under the MIT license (see LICENSE or <http://opensource.org /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of <http://www.apache.org/licenses/LICENSE-2.0>), at your option. All files in the project carrying such notice may not be copied, m...
} "# ); }
aeqiws!( parse_item!( then stringify!(), #[doc(hidden)] type Result<T> = ::std::result::Result<T, Error>; ), r#" type { attrs: [ #[doc(hidden)] ], vis: (), name: Result, generics: { ...
identifier_body
simple.rs
/* Copyright ⓒ 2016 rust-custom-derive contributors. Licensed under the MIT license (see LICENSE or <http://opensource.org /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of
#![cfg_attr(feature="parse-generics-poc", feature(plugin))] #![cfg_attr(feature="parse-generics-poc", plugin(parse_generics_poc))] #[macro_use] extern crate parse_generics_shim; #[macro_use] extern crate custom_derive; #[macro_use] extern crate parse_macros; macro_rules! aeqiws { ($lhs:expr, $rhs:expr) => { ...
<http://www.apache.org/licenses/LICENSE-2.0>), at your option. All files in the project carrying such notice may not be copied, modified, or distributed except according to those terms. */
random_line_split
simple.rs
/* Copyright ⓒ 2016 rust-custom-derive contributors. Licensed under the MIT license (see LICENSE or <http://opensource.org /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of <http://www.apache.org/licenses/LICENSE-2.0>), at your option. All files in the project carrying such notice may not be copied, m...
{ aeqiws!( parse_item!( then stringify!(), #[doc(hidden)] type Result<T> = ::std::result::Result<T, Error>; ), r#" type { attrs: [ #[doc(hidden)] ], vis: (), name: Result, generics: { ...
st_simple_type_item()
identifier_name
safi.rs
use core::fmt; /// Unicast [RFC4760]
/// Multicast [RFC4760] pub const SAFI_MULTICAST: Safi = Safi(2); // 3 Reserved [RFC4760] /// Labeled Unicast [RFC3107] pub c...
pub const SAFI_UNICAST: Safi = Safi(1);
random_line_split
safi.rs
use core::fmt; /// Unicast [RFC4760] pub const SAFI_UNICAST: Safi = Safi(1); /// Multicast [RFC4760] pub const SAFI_MULTICAST: Safi = Safi(2); // 3 Reserved ...
(u8); impl From<u8> for Safi { fn from(other: u8) -> Safi { Safi(other) } } impl fmt::Debug for Safi { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.0 { 1 => write!(f, "unicast"), 2 => write!(f, "multicast"), n => write!(f, "unknown({...
Safi
identifier_name
12.integer-to-roman.rs
/* * @lc app=leetcode id=12 lang=rust * * [12] Integer to Roman */ // @lc code=start impl Solution { pub fn int_to_roman(n: i32) -> String { let m = [ "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", "", "C",...
m[n as usize % 10000 / 1000 + 30], m[n as usize % 1000 / 100 + 20], m[n as usize % 100 / 10 + 10], m[n as usize % 10], ]; r.concat() } } // @lc code=end
]; let r = [
random_line_split
12.integer-to-roman.rs
/* * @lc app=leetcode id=12 lang=rust * * [12] Integer to Roman */ // @lc code=start impl Solution { pub fn int_to_roman(n: i32) -> String
} // @lc code=end
{ let m = [ "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", "", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM", "", "M", "MM", "MMM", ]; let r = [ m[n as usize % 10000 ...
identifier_body
12.integer-to-roman.rs
/* * @lc app=leetcode id=12 lang=rust * * [12] Integer to Roman */ // @lc code=start impl Solution { pub fn
(n: i32) -> String { let m = [ "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", "", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM", "", "M", "MM", "MMM", ]; let r = [ m[...
int_to_roman
identifier_name
alife.rs
use super::*; use app::constants::*; use backend::messagebus::Outbox; use backend::obj; use backend::obj::Identified; use backend::obj::Transformable; use backend::world; use backend::world::agent; use backend::world::alert; use backend::world::gen; use backend::world::particle; use backend::world::segment; use backend...
fn import(&mut self, world: &world::World) { self.source = world.feeders().to_vec().into_boxed_slice(); self.eaten = Self::find_eaten_resources( &world.agents(agent::AgentType::Minion), &world.agents(agent::AgentType::Resource), ); self.touched = Self::find_touched_spores(&world.agents(agent::AgentT...
{ self.source = Box::new([]); self.eaten.clear(); self.touched.clear(); }
identifier_body
alife.rs
use super::*; use app::constants::*; use backend::messagebus::Outbox; use backend::obj; use backend::obj::Identified; use backend::obj::Transformable; use backend::world; use backend::world::agent; use backend::world::alert; use backend::world::gen; use backend::world::particle; use backend::world::segment; use backend...
} } } touched } fn update_minions( outbox: &dyn Outbox, dt: Seconds, extent: geometry::Rect, minions: &mut agent::AgentMap, eaten: &StateMap, ) -> MinionEndState { let mut spawns = Vec::new(); let mut corpses = Vec::new(); for agent in minions.values_mut() { if agent.state.is_active()...
{ if agent.gender() != spore.gender() { touched.insert(key.id(), agent.dna().clone()); } }
conditional_block
alife.rs
use super::*; use app::constants::*; use backend::messagebus::Outbox; use backend::obj; use backend::obj::Identified; use backend::obj::Transformable; use backend::world; use backend::world::agent; use backend::world::alert; use backend::world::gen; use backend::world::particle; use backend::world::segment; use backend...
} } } } eaten } fn find_touched_spores(minions: &agent::AgentMap, spores: &agent::AgentMap) -> GeneMap { let mut touched = HashMap::new(); for spore in spores.values().filter(|&a| a.state.is_active() &&!a.state.is_fertilised()) { for segment in spore.segments.iter() { if let Some(key) = se...
if let Some(key) = segment.state.last_touched { if let Some(&agent::Agent { ref state, .. }) = resources.get(&key.id()) { eaten.insert(key.id(), (*state).clone());
random_line_split
alife.rs
use super::*; use app::constants::*; use backend::messagebus::Outbox; use backend::obj; use backend::obj::Identified; use backend::obj::Transformable; use backend::world; use backend::world::agent; use backend::world::alert; use backend::world::gen; use backend::world::particle; use backend::world::segment; use backend...
(&mut self, world: &world::World) { self.source = world.feeders().to_vec().into_boxed_slice(); self.eaten = Self::find_eaten_resources( &world.agents(agent::AgentType::Minion), &world.agents(agent::AgentType::Resource), ); self.touched = Self::find_touched_spores(&world.agents(agent::AgentType::Minion)...
import
identifier_name
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Calculate [specified][specified] and [computed values][computed] from a //! tree of DOM nodes and a set of sty...
<T:'static>(a: &Arc<T>, b: &Arc<T>) -> bool { let a: &T = &**a; let b: &T = &**b; (a as *const T) == (b as *const T) }
arc_ptr_eq
identifier_name
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Calculate [specified][specified] and [computed values][computed] from a //! tree of DOM nodes and a set of sty...
extern crate lazy_static; extern crate libc; #[macro_use] extern crate log; #[allow(unused_extern_crates)] #[macro_use] extern crate matches; extern crate num_integer; extern crate num_traits; #[cfg(feature = "gecko")] extern crate num_cpus; extern crate ordered_float; extern crate parking_lot; extern crate quickersort...
extern crate euclid; extern crate fnv; extern crate heapsize; #[allow(unused_extern_crates)] #[macro_use]
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Calculate [specified][specified] and [computed values][computed] from a //! tree of DOM nodes and a set of sty...
{ let a: &T = &**a; let b: &T = &**b; (a as *const T) == (b as *const T) }
identifier_body
refutable-pattern-errors.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let (1i, (Some(1i), 2i..3i)) = (1i, (None, 2i)); //~^ ERROR refutable pattern in local binding: `(_, _)` not covered }
main
identifier_name
refutable-pattern-errors.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let (1i, (Some(1i), 2i..3i)) = (1i, (None, 2i)); //~^ ERROR refutable pattern in local binding: `(_, _)` not covered }
identifier_body
refutable-pattern-errors.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let (1i, (Some(1i), 2i..3i)) = (1i, (None, 2i)); //~^ ERROR refutable pattern in local binding: `(_, _)` not covered }
//~^ ERROR refutable pattern in function argument: `(_, _)` not covered fn main() {
random_line_split
splitter.rs
use std::rand::random; use std::os; use std::io::File; fn main() { let args: ~[~str] = os::args(); if args.len()!= 2 { println!("Usage: {:s} <inputfile>", args[0]); } else
None => fail!("Error opening message file: {:s}", fname) } } } fn xor(a: &[u8], b: &[u8]) -> ~[u8] { let mut ret = ~[]; for i in range(0, a.len()) { ret.push(a[i] ^ b[i]); } ret } fn split(msg_bytes: &[u8], mut share1: File, mut share2: File) { let mut random_bytes: ~[u8]...
{ let fname = args[1]; let path = Path::new(fname.clone()); let msg_file = File::open(&path); match (msg_file) { Some(mut msg) => { let msg_bytes: ~[u8] = msg.read_to_end(); let share1_file = File::create(&Path::new(fna...
conditional_block
splitter.rs
use std::rand::random; use std::os; use std::io::File; fn main() { let args: ~[~str] = os::args(); if args.len()!= 2 { println!("Usage: {:s} <inputfile>", args[0]); } else { let fname = args[1]; let path = Path::new(fname.clone()); let msg_file = File::open(&path); ...
(a: &[u8], b: &[u8]) -> ~[u8] { let mut ret = ~[]; for i in range(0, a.len()) { ret.push(a[i] ^ b[i]); } ret } fn split(msg_bytes: &[u8], mut share1: File, mut share2: File) { let mut random_bytes: ~[u8] = ~[]; // This is not cryptographically strong randomness! // (For entertainment purp...
xor
identifier_name
splitter.rs
use std::rand::random; use std::os; use std::io::File; fn main() { let args: ~[~str] = os::args(); if args.len()!= 2 { println!("Usage: {:s} <inputfile>", args[0]); } else { let fname = args[1]; let path = Path::new(fname.clone()); let msg_file = File::open(&path); ...
} let encrypted_bytes = xor(msg_bytes, random_bytes); share1.write(random_bytes); share2.write(encrypted_bytes); }
for _ in range(0, msg_bytes.len()) { let random_byte = random(); random_bytes.push(random_byte);
random_line_split
splitter.rs
use std::rand::random; use std::os; use std::io::File; fn main() { let args: ~[~str] = os::args(); if args.len()!= 2 { println!("Usage: {:s} <inputfile>", args[0]); } else { let fname = args[1]; let path = Path::new(fname.clone()); let msg_file = File::open(&path); ...
fn split(msg_bytes: &[u8], mut share1: File, mut share2: File) { let mut random_bytes: ~[u8] = ~[]; // This is not cryptographically strong randomness! // (For entertainment purposes only.) for _ in range(0, msg_bytes.len()) { let random_byte = random(); random_bytes.push(random_byte); } ...
{ let mut ret = ~[]; for i in range(0, a.len()) { ret.push(a[i] ^ b[i]); } ret }
identifier_body
lin4.rs
use russell_lab::{Matrix, Vector}; /// Defines a line (segment) with 4 nodes (cubic functions) /// /// The reference coordinates range from -1 to +1 with the geometry centred @ 0 /// /// # Local IDs of nodes /// /// ```text /// -1 +1 /// @------@-------@------@ --> r /// 0 2 3 1 /...
/// Computes the derivatives of interpolation functions pub fn calc_deriv(deriv: &mut Matrix, ksi: &[f64]) { let r = ksi[0]; deriv[0][0] = 1.0 / 16.0 * (-27.0 * r * r + 18.0 * r + 1.0); deriv[1][0] = 1.0 / 16.0 * (27.0 * r * r + 18.0 * r - 1.0); deriv[2][0] = 1.0 / 16.0 * (81....
{ let r = ksi[0]; interp[0] = (-9.0 * r * r * r + 9.0 * r * r + r - 1.0) / 16.0; interp[1] = (9.0 * r * r * r + 9.0 * r * r - r - 1.0) / 16.0; interp[2] = (27.0 * r * r * r - 9.0 * r * r - 27.0 * r + 9.0) / 16.0; interp[3] = (-27.0 * r * r * r - 9.0 * r * r + 27.0 * r + 9.0) / 1...
identifier_body
lin4.rs
use russell_lab::{Matrix, Vector}; /// Defines a line (segment) with 4 nodes (cubic functions) /// /// The reference coordinates range from -1 to +1 with the geometry centred @ 0 /// /// # Local IDs of nodes /// /// ```text /// -1 +1 /// @------@-------@------@ --> r /// 0 2 3 1 /...
(deriv: &mut Matrix, ksi: &[f64]) { let r = ksi[0]; deriv[0][0] = 1.0 / 16.0 * (-27.0 * r * r + 18.0 * r + 1.0); deriv[1][0] = 1.0 / 16.0 * (27.0 * r * r + 18.0 * r - 1.0); deriv[2][0] = 1.0 / 16.0 * (81.0 * r * r - 18.0 * r - 27.0); deriv[3][0] = 1.0 / 16.0 * (-81.0 * r * r - 1...
calc_deriv
identifier_name
lin4.rs
use russell_lab::{Matrix, Vector}; /// Defines a line (segment) with 4 nodes (cubic functions) /// /// The reference coordinates range from -1 to +1 with the geometry centred @ 0 /// /// # Local IDs of nodes ///
pub struct Lin4 {} impl Lin4 { pub const NDIM: usize = 1; pub const NNODE: usize = 4; pub const NEDGE: usize = 0; pub const NFACE: usize = 0; pub const EDGE_NNODE: usize = 0; pub const FACE_NNODE: usize = 0; pub const FACE_NEDGE: usize = 0; #[rustfmt::skip] pub const NODE_REFERENCE...
/// ```text /// -1 +1 /// @------@-------@------@ --> r /// 0 2 3 1 /// ```
random_line_split
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] #![feature(box_patterns)] #![feature(box_syntax)] #![feature(conservative_impl_trait)] #![fe...
// We can't use stylearc for everything in layout, because the Flow stuff uses // weak references. use style::stylearc::Arc as StyleArc;
{ ::style::ptr_eq::<T>(&**a, &**b) }
identifier_body
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] #![feature(box_patterns)] #![feature(box_syntax)] #![feature(conservative_impl_trait)] #![fe...
<T:'static>(a: &::std::sync::Arc<T>, b: &::std::sync::Arc<T>) -> bool { ::style::ptr_eq::<T>(&**a, &**b) } // We can't use stylearc for everything in layout, because the Flow stuff uses // weak references. use style::stylearc::Arc as StyleArc;
arc_ptr_eq
identifier_name
lib.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] #![feature(box_patterns)] #![feature(box_syntax)] #![feature(conservative_impl_trait)] #![fe...
mod list_item; mod model; mod multicol; pub mod opaque_node; pub mod parallel; mod persistent_list; pub mod query; pub mod sequential; mod table; mod table_caption; mod table_cell; mod table_colgroup; mod table_row; mod table_rowgroup; mod table_wrapper; mod text; pub mod traversal; pub mod webrender_helpers; pub mod w...
mod inline; mod linked_list;
random_line_split
window.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::WindowBinding; use dom::bindings::js::JS; use dom::bindings::trace::Untraceable; use d...
(&self, _cx: *JSContext, _url: DOMString, _argument: Option<JSVal>) -> JSVal { NullValue() } } impl Reflectable for Window { fn reflector<'a>(&'a self) -> &'a Reflector { self.eventtarget.reflector() } fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector { self.eventtarget.m...
ShowModalDialog
identifier_name
window.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::WindowBinding; use dom::bindings::js::JS; use dom::bindings::trace::Untraceable; use d...
pub fn SetName(&self, _name: DOMString) { } pub fn Status(&self) -> DOMString { ~"" } pub fn SetStatus(&self, _status: DOMString) { } pub fn Closed(&self) -> bool { false } pub fn Stop(&self) { } pub fn Focus(&self) { } pub fn Blur(&self) { }...
pub fn Name(&self) -> DOMString { ~"" }
random_line_split
window.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::WindowBinding; use dom::bindings::js::JS; use dom::bindings::trace::Untraceable; use d...
pub fn Status(&self) -> DOMString { ~"" } pub fn SetStatus(&self, _status: DOMString) { } pub fn Closed(&self) -> bool { false } pub fn Stop(&self) { } pub fn Focus(&self) { } pub fn Blur(&self) { } pub fn GetFrameElement(&self) -> Option<JS<El...
{ }
identifier_body
scoped_tls.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/. */ //! Stack-scoped thread-local storage for rayon thread pools. #![allow(unsafe_code)] #![deny(missing_docs)] use...
/// Ensure that the current data this thread owns is initialized, or /// initialize it using `f`. We want ensure() to be fast and inline, and we /// want to inline the memmove that initializes the Option<T>. But we don't /// want to inline space for the entire large T struct in our stack frame. ...
{ let idx = self.pool.current_thread_index().unwrap(); self.slots[idx].borrow_mut() }
identifier_body
scoped_tls.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/. */ //! Stack-scoped thread-local storage for rayon thread pools. #![allow(unsafe_code)] #![deny(missing_docs)] use...
pub fn ensure<F: FnOnce(&mut Option<T>)>(&self, f: F) -> RefMut<T> { let mut opt = self.borrow_mut(); if opt.is_none() { f(opt.deref_mut()); } RefMut::map(opt, |x| x.as_mut().unwrap()) } /// Unsafe access to the slots. This can be used to access the TLS when ...
/// That's why we hand `f` a mutable borrow to write to instead of just /// having it return a T. #[inline(always)]
random_line_split
scoped_tls.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/. */ //! Stack-scoped thread-local storage for rayon thread pools. #![allow(unsafe_code)] #![deny(missing_docs)] use...
RefMut::map(opt, |x| x.as_mut().unwrap()) } /// Unsafe access to the slots. This can be used to access the TLS when /// the caller knows that the pool does not have access to the TLS. pub unsafe fn unsafe_get(&self) -> &[RefCell<Option<T>>] { &self.slots } }
{ f(opt.deref_mut()); }
conditional_block
scoped_tls.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/. */ //! Stack-scoped thread-local storage for rayon thread pools. #![allow(unsafe_code)] #![deny(missing_docs)] use...
(p: &'scope rayon::ThreadPool) -> Self { let count = p.current_num_threads(); let mut v = Vec::with_capacity(count); for _ in 0..count { v.push(RefCell::new(None)); } ScopedTLS { pool: p, slots: v.into_boxed_slice(), } } /// R...
new
identifier_name
bluetoothremotegattserver.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 bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType}; use dom::bindings::codegen::Bindings::Bluet...
pub fn new(global: &GlobalScope, device: &BluetoothDevice) -> Root<BluetoothRemoteGATTServer> { reflect_dom_object(box BluetoothRemoteGATTServer::new_inherited(device), global, BluetoothRemoteGATTServerBinding::Wrap) } fn get_bluetooth_thread(...
{ BluetoothRemoteGATTServer { reflector_: Reflector::new(), device: JS::from_ref(device), connected: Cell::new(false), } }
identifier_body
bluetoothremotegattserver.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 bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType}; use dom::bindings::codegen::Bindings::Bluet...
(&self, service: Option<BluetoothServiceUUID>) -> Rc<Promise> { // TODO: Step 1: Implement the Permission API and the allowedServices BluetoothDevice internal slot. // Step 2. get_gatt_children(self, false, BluetoothUUID::service, service, String::from(self.Device().Id()), ...
GetPrimaryServices
identifier_name
bluetoothremotegattserver.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 bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType}; use dom::bindings::codegen::Bindings::Bluet...
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-device fn Device(&self) -> Root<BluetoothDevice> { Root::from_ref(&self.device) } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connected fn Connected(&self) -> bool { ...
self.connected.set(connected); } } impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
random_line_split
bluetoothremotegattserver.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 bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType}; use dom::bindings::codegen::Bindings::Bluet...
, _ => promise.reject_error(promise_cx, Error::Type("Something went wrong...".to_owned())), } } }
{ let device = self.Device(); if single { promise.resolve_native(promise_cx, &device.get_or_create_service(&services_vec[0], &self)); return; } let mut services = vec!(); for service in services_vec {...
conditional_block
main.rs
// Copyright 2017 The Gfx-rs Developers. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
{}
identifier_body
main.rs
// Copyright 2017 The Gfx-rs Developers. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
() { env_logger::init().unwrap(); let window = winit::WindowBuilder::new() .with_dimensions(1024, 768) .with_title("triangle (Low Level)".to_string()) .build() .unwrap(); // instantiate backend let instance = back::Instance::create(); let physical_devices = instance.enum...
main
identifier_name
main.rs
// Copyright 2017 The Gfx-rs Developers. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
, } } let frame = swap_chain.acquire_frame(); // TODO: rendering let submit = { let mut cmd_buffer = graphics_pool.acquire_command_buffer(); cmd_buffer.finish() }; general_queues[0].submit_graphics(&[submit]); // present fra...
{}
conditional_block
main.rs
// Copyright 2017 The Gfx-rs Developers. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
let frame = swap_chain.acquire_frame(); // TODO: rendering let submit = { let mut cmd_buffer = graphics_pool.acquire_command_buffer(); cmd_buffer.finish() }; general_queues[0].submit_graphics(&[submit]); // present frame swap_chain.prese...
}
random_line_split
settings.rs
// Copyright (C) 2020 Jason Ish // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // ...
pub fn count_of(&self, key: &str) -> u64 { if self.args.occurrences_of(key) > 0 { return self.args.occurrences_of(key); } if self.config.get::<config::Value>(key).is_ok() { return 1; } return 0; } fn set_from_args(&mut self, key: &str) { ...
} } } }
random_line_split
settings.rs
// Copyright (C) 2020 Jason Ish // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // ...
pub fn merge_yaml_str(&mut self, yaml: &str) -> Result<(), config::ConfigError> { let file = config::File::from_str(yaml, config::FileFormat::Yaml); self.config.merge(file)?; Ok(()) } // There is a bit of a dance to get values in the following priority order... // - command li...
{ let config_file = config::File::new(path, config::FileFormat::Yaml); self.config.merge(config_file)?; Ok(()) }
identifier_body
settings.rs
// Copyright (C) 2020 Jason Ish // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // ...
(&mut self, path: &str) -> Result<(), config::ConfigError> { let config_file = config::File::new(path, config::FileFormat::Yaml); self.config.merge(config_file)?; Ok(()) } pub fn merge_yaml_str(&mut self, yaml: &str) -> Result<(), config::ConfigError> { let file = config::File::...
merge_file
identifier_name
settings.rs
// Copyright (C) 2020 Jason Ish // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // ...
} self.config .merge(config::Environment::with_prefix("EVEBOX").separator("_")) .unwrap(); } pub fn merge_file(&mut self, path: &str) -> Result<(), config::ConfigError> { let config_file = config::File::new(path, config::FileFormat::Yaml); self.config.mer...
{ debug!( "Setting EVEBOX_DATABASE_ELASTICSEARCH_URL to {} from ELASTICSEARCH_URL", val ); std::env::set_var("EVEBOX_DATABASE_ELASTICSEARCH_URL", val); }
conditional_block
uievent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::UIEventBin...
event.InitEvent(type_, can_bubble, cancelable); self.view.assign(view); self.detail.set(detail); } } impl Reflectable for UIEvent { fn reflector<'a>(&'a self) -> &'a Reflector { self.event.reflector() } }
{ return; }
conditional_block
uievent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::UIEventBin...
} impl Reflectable for UIEvent { fn reflector<'a>(&'a self) -> &'a Reflector { self.event.reflector() } }
{ let event: JSRef<Event> = EventCast::from_ref(self); if event.dispatching() { return; } event.InitEvent(type_, can_bubble, cancelable); self.view.assign(view); self.detail.set(detail); }
identifier_body
uievent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::UIEventBin...
fn reflector<'a>(&'a self) -> &'a Reflector { self.event.reflector() } }
} } impl Reflectable for UIEvent {
random_line_split
uievent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::UIEventBin...
(self) -> i32 { self.detail.get() } fn InitUIEvent(self, type_: DOMString, can_bubble: bool, cancelable: bool, view: Option<JSRef<Window>>, detail: i32) { let event: JSRef<Event> = EventCast::from_ref...
Detail
identifier_name
lib.rs
extern crate glib; #[macro_use] extern crate gstreamer as gst; extern crate gstreamer_base as gst_base; // extern crate gstreamer_video as gst_video; mod screamrx; #[cfg(not(feature = "screamrx-only"))] mod screamtx;
// Plugin entry point that should register all elements provided by this plugin, // and everything else that this plugin might provide (e.g. typefinders or device providers). fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { #[cfg(not(feature = "screamrx-only"))] screamtx::register(plugin)?;...
#[cfg(not(feature = "screamrx-only"))] mod screamtxbw;
random_line_split
lib.rs
extern crate glib; #[macro_use] extern crate gstreamer as gst; extern crate gstreamer_base as gst_base; // extern crate gstreamer_video as gst_video; mod screamrx; #[cfg(not(feature = "screamrx-only"))] mod screamtx; #[cfg(not(feature = "screamrx-only"))] mod screamtxbw; // Plugin entry point that should register all...
// Static plugin metdata that is directly stored in the plugin shared object and read by GStreamer // upon loading. // Plugin name, plugin description, plugin entry point function, version number of this plugin, // license of the plugin, source package name, binary package name, origin where it comes from // and the ...
{ #[cfg(not(feature = "screamrx-only"))] screamtx::register(plugin)?; #[cfg(not(feature = "screamrx-only"))] screamtxbw::register(plugin)?; screamrx::register(plugin)?; Ok(()) }
identifier_body
lib.rs
extern crate glib; #[macro_use] extern crate gstreamer as gst; extern crate gstreamer_base as gst_base; // extern crate gstreamer_video as gst_video; mod screamrx; #[cfg(not(feature = "screamrx-only"))] mod screamtx; #[cfg(not(feature = "screamrx-only"))] mod screamtxbw; // Plugin entry point that should register all...
(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { #[cfg(not(feature = "screamrx-only"))] screamtx::register(plugin)?; #[cfg(not(feature = "screamrx-only"))] screamtxbw::register(plugin)?; screamrx::register(plugin)?; Ok(()) } // Static plugin metdata that is directly stored in the plugin ...
plugin_init
identifier_name
immutable.rs
// Copyright 2020 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
impl ChunkId for BlobAddress { fn to_data_address(&self) -> DataAddress { DataAddress::Blob(*self) } }
} }
random_line_split
immutable.rs
// Copyright 2020 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
(&self) -> &Self::Id { match self { Blob::Public(ref chunk) => chunk.address(), Blob::Private(ref chunk) => chunk.address(), } } } impl ChunkId for BlobAddress { fn to_data_address(&self) -> DataAddress { DataAddress::Blob(*self) } }
id
identifier_name
immutable.rs
// Copyright 2020 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
} impl ChunkId for BlobAddress { fn to_data_address(&self) -> DataAddress { DataAddress::Blob(*self) } }
{ match self { Blob::Public(ref chunk) => chunk.address(), Blob::Private(ref chunk) => chunk.address(), } }
identifier_body
unboxed-closure-sugar-default.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn test<'a,'b>() { // Parens are equivalent to omitting default in angle. eq::< Foo<(isize,),Output=()>, Foo(isize) >(); // In angle version, we supply something other than the default eq::< Foo<(isize,),isize,Output=()>, Foo(isize) >(); ...
random_line_split
unboxed-closure-sugar-default.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ }
identifier_body
unboxed-closure-sugar-default.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<A:?Sized,B:?Sized>() where A : Eq<B> { } fn test<'a,'b>() { // Parens are equivalent to omitting default in angle. eq::< Foo<(isize,),Output=()>, Foo(isize) >(); // In angle version, we supply something other than the default eq::< Foo<(isize,),isize,Output=()>,...
eq
identifier_name
main.rs
/* Goal: - コンパイルして動作を確認してください - [1]をコメントアウトから戻し、コンパイルしてください - この途中でエラーが出た場合は、それを修正してください - [2]をコメントアウトから戻し、各要素を2乗した値を出力するようにプログラムを変更してください - [3]をコメントアウトから戻し、奇数だけを出力するようにプログラムを変更してください - [4]をコメントアウトから戻し、偶数を2乗した値のみを出力するようにプログラムを修正してください */ fn main() { let range = 1..20; for value in range { println!("{}...
} else { match number % 10 { 1 => "st", 2 => "nd", 3 => "rd", _ => "th", } } } fn hr(){ println!("------------------------------------"); }
/ /* [3] hr(); for value in range { println!("{}{} number is {}", value, ordinal(value), value); } */ /* [4] hr(); for value in range { println!("{}{} number is {}", value, ordinal(value), value); } */ } fn ordinal<'a>(number: usize) -> &'a str { if number == 11 || number ...
identifier_body
main.rs
/* Goal: - コンパイルして動作を確認してください - [1]をコメントアウトから戻し、コンパイルしてください - この途中でエラーが出た場合は、それを修正してください - [2]をコメントアウトから戻し、各要素を2乗した値を出力するようにプログラムを変更してください - [3]をコメントアウトから戻し、奇数だけを出力するようにプログラムを変更してください - [4]をコメントアウトから戻し、偶数を2乗した値のみを出力するようにプログラムを修正してください */ fn main() { let range = 1..20; for value in range { println!("{}...
} */ /* [3] hr(); for value in range { println!("{}{} number is {}", value, ordinal(value), value); } */ /* [4] hr(); for value in range { println!("{}{} number is {}", value, ordinal(value), value); } */ } fn ordinal<'a>(number: usize) -> &'a str { if number == 11 || numb...
identifier_name
main.rs
/* Goal: - コンパイルして動作を確認してください - [1]をコメントアウトから戻し、コンパイルしてください - この途中でエラーが出た場合は、それを修正してください - [2]をコメントアウトから戻し、各要素を2乗した値を出力するようにプログラムを変更してください - [3]をコメントアウトから戻し、奇数だけを出力するようにプログラムを変更してください - [4]をコメントアウトから戻し、偶数を2乗した値のみを出力するようにプログラムを修正してください */ fn main() { let range = 1..20; for value in range { println!("{}...
for value in range { println!("{}{} number is {}", value, ordinal(value), value); } */ } fn ordinal<'a>(number: usize) -> &'a str { if number == 11 || number == 12 { "th" } else { match number % 10 { 1 => "st", 2 => "nd", 3 => "rd", ...
/* [4] hr();
random_line_split
binder.rs
use super::name::Name; use super::term::Term; use super::super::pretty::*; #[derive(Debug, Copy, Clone, PartialEq, Hash, Eq)] pub enum BindingMode { Implicit, Explicit } #[derive(Debug, Clone, PartialEq, Hash, Eq)] pub struct Binder { pub name: Name, pub ty: Box<Term>, pub mode: BindingMode, } i...
// for (ty, g) in binders.iter().group_by(|elt| (&elt.ty, &elt.mode)) { // println!("binder_ty={:?}", ty); // if g.len() == 1{ // ds.push(g[0].pretty()); // } else { // let d = seperate(g.iter().map(|x| x.name.pretty()) // .collect::<Ve...
}
random_line_split
binder.rs
use super::name::Name; use super::term::Term; use super::super::pretty::*; #[derive(Debug, Copy, Clone, PartialEq, Hash, Eq)] pub enum BindingMode { Implicit, Explicit } #[derive(Debug, Clone, PartialEq, Hash, Eq)] pub struct Binder { pub name: Name, pub ty: Box<Term>, pub mode: BindingMode, } i...
pub fn is_implicit(&self) -> bool { match self.mode { BindingMode::Implicit => true, _ => false } } } impl Pretty for Binder { fn pretty(&self) -> Doc { if self.is_implicit() { braces(self.name.pretty() + " : ".pretty() + self.ty.pretty()) ...
{ Binder { name: self.name.clone(), ty: Box::new(self.ty.replace(index, subst)), mode: self.mode.clone(), } }
identifier_body
binder.rs
use super::name::Name; use super::term::Term; use super::super::pretty::*; #[derive(Debug, Copy, Clone, PartialEq, Hash, Eq)] pub enum BindingMode { Implicit, Explicit } #[derive(Debug, Clone, PartialEq, Hash, Eq)] pub struct Binder { pub name: Name, pub ty: Box<Term>, pub mode: BindingMode, } i...
(&self) -> bool { match self.mode { BindingMode::Implicit => true, _ => false } } } impl Pretty for Binder { fn pretty(&self) -> Doc { if self.is_implicit() { braces(self.name.pretty() + " : ".pretty() + self.ty.pretty()) } else { ...
is_implicit
identifier_name
binder.rs
use super::name::Name; use super::term::Term; use super::super::pretty::*; #[derive(Debug, Copy, Clone, PartialEq, Hash, Eq)] pub enum BindingMode { Implicit, Explicit } #[derive(Debug, Clone, PartialEq, Hash, Eq)] pub struct Binder { pub name: Name, pub ty: Box<Term>, pub mode: BindingMode, } i...
else { parens(self.name.pretty() + " : ".pretty() + self.ty.pretty()) } } } // Pretty print a list of binders. Groups binders of the same type pub fn pretty_binders<'a>(binders: &[&'a Binder]) -> Doc<'a> { let mut ds = Vec::new(); for thing in binders.iter() { ds.push(thing.pre...
{ braces(self.name.pretty() + " : ".pretty() + self.ty.pretty()) }
conditional_block
managed-pointer-within-unique-vec.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn zzz() {()}
{ let unique: ~[@i64] = ~[@10, @11, @12, @13]; zzz(); }
identifier_body
managed-pointer-within-unique-vec.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn zzz() {()}
random_line_split
managed-pointer-within-unique-vec.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() {()}
zzz
identifier_name
main.rs
// Copyright 2014 Karl Cheng, other contributors and third parties. // Licensed under the GNU General Public License, version 3 or later. // See the COPYRIGHT.md file at the top-level directory of this // distribution, or go to http://www.gnu.org/licenses/. #![crate_type="dylib"] #![no_std] #![feature(globs)] #![allow...
(bFuncs: *mut NPNetscapeFuncs) -> NPError { return init(bFuncs); } #[no_mangle] #[cfg(not(win32,target_os="macos")] pub extern "system" fn NP_Initialize(bFuncs: *mut NPNetscapeFuncs, pFuncs: *mut NPPluginFuncs) -> NPError { NP_GetEntryPoints(pFuncs); init(bFuncs); } // the second argument is not passed on...
NP_Initialize
identifier_name
main.rs
// Copyright 2014 Karl Cheng, other contributors and third parties. // Licensed under the GNU General Public License, version 3 or later. // See the COPYRIGHT.md file at the top-level directory of this // distribution, or go to http://www.gnu.org/licenses/. #![crate_type="dylib"] #![no_std] #![feature(globs)] #![allow...
// hard to find documentation about this function // according to headers, runs on OSX and Windows // apparently it's equivalent to the second argument to NP_Initialize #[no_mangle] #[cfg(win32)] #[cfg(target_os="macos")] pub extern "system" fn NP_GetEntryPoints(pFuncs: *mut NPPluginFuncs) -> NPError {} fn init(bFun...
{ // no documentation, but from the few examples I've seen "x.x.x" should be fine // C strings must be null-terminated let version = b"0.1.0\0"; unsafe { let version_as_i8: &[i8] = transmute(version); &version_as_i8[0] as *const c_char } }
identifier_body
main.rs
// Copyright 2014 Karl Cheng, other contributors and third parties. // Licensed under the GNU General Public License, version 3 or later. // See the COPYRIGHT.md file at the top-level directory of this // distribution, or go to http://www.gnu.org/licenses/. #![crate_type="dylib"] #![no_std] #![feature(globs)] #![allow...
*/
random_line_split
dragon.rs
// Copyright (c) 2015-2019 William (B.J.) Snow Orvis // // 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 applicab...
} check_init_turtle(0, 0.0); check_init_turtle(1, -PI / 4.0); check_init_turtle(2, -PI / 2.0); check_init_turtle(3, -3.0 * PI / 4.0); check_init_turtle(4, -PI); } }
{ fn check_init_turtle(iteration: u64, expected_angle: f64) { let initial_steps = DragonFractal::new(iteration).init_turtle(); assert_eq!(initial_steps.len(), 3); match initial_steps.get(0) { Some(&TurtleStep::SetPos(point)) => { assert_poi...
identifier_body
dragon.rs
// Copyright (c) 2015-2019 William (B.J.) Snow Orvis // // 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 applicab...
(step: u64) -> Turn { let mut step_without_twos = step; while step_without_twos!= 0 && (step_without_twos % 2) == 0 { step_without_twos /= 2; } if step_without_twos % 4 == 1 { Turn::Left } else { Turn::Right } } /// How many li...
turn_after_step
identifier_name
dragon.rs
// Copyright (c) 2015-2019 William (B.J.) Snow Orvis // // 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 applicab...
if self.curr_step > self.dragon.number_of_steps() { return None; } if self.move_next { self.move_next = false; log::debug!("curr_step: {}, Forward", self.curr_step); Some(TurtleStep::Forward( 1.0 / (self.dragon.lines_between_endpoin...
fn next(&mut self) -> Option<TurtleStep> {
random_line_split
compression.rs
use bytes; use Error; use header::CompressionType; use header::tlv::Tlv; use std::io::Read; pub fn
(reader: &mut Read, length: u16) -> Result<Tlv, Error> { try!(super::check_tlv_length(length, 4)); let flags = try!(bytes::read_u32(reader)); let compression_type = try!(match_compression_flags(flags)); Ok(Tlv::Compression(compression_type)) } fn match_compression_flags(flags: u32) -> Result<Compress...
read_tlv
identifier_name
compression.rs
use bytes; use Error; use header::CompressionType; use header::tlv::Tlv; use std::io::Read; pub fn read_tlv(reader: &mut Read, length: u16) -> Result<Tlv, Error>
fn match_compression_flags(flags: u32) -> Result<CompressionType, Error> { match flags { 0 => Ok(CompressionType::None), 1 => Ok(CompressionType::Gzip), _ => Err(Error::UnknownCompressionType(flags)), } } #[cfg(test)] mod test { use super::*; use Error; use header::Compre...
{ try!(super::check_tlv_length(length, 4)); let flags = try!(bytes::read_u32(reader)); let compression_type = try!(match_compression_flags(flags)); Ok(Tlv::Compression(compression_type)) }
identifier_body
compression.rs
use bytes; use Error; use header::CompressionType; use header::tlv::Tlv; use std::io::Read; pub fn read_tlv(reader: &mut Read, length: u16) -> Result<Tlv, Error> { try!(super::check_tlv_length(length, 4)); let flags = try!(bytes::read_u32(reader)); let compression_type = try!(match_compression_flags(fla...
match result { Err(Error::InvalidTlvSize) => (), _ => panic!("Invalid result: {:#?}", result), } } #[test] fn should_return_error_if_unknown_compression_type() { let mut bytes = vec![]; bytes.write_u32::<LittleEndian>(2).unwrap(); let result...
let result = read_tlv(&mut &bytes[..], 3);
random_line_split
parse_macro_input.rs
/// Parse the input TokenStream of a macro, triggering a compile error if the /// tokens fail to parse. /// /// Refer to the [`parse` module] documentation for more details about parsing /// in Syn. /// /// [`parse` module]: crate::rustdoc_workaround::parse_module /// /// <br> /// /// # Intended usage /// /// This macr...
} //////////////////////////////////////////////////////////////////////////////// // Any other types that we want `parse_macro_input!` to be able to parse. #[cfg(any(feature = "full", feature = "derive"))] use crate::AttributeArgs; #[cfg(any(feature = "full", feature = "derive"))] impl ParseMacroInput for Attribut...
{ <T as Parse>::parse(input) }
identifier_body
parse_macro_input.rs
/// Parse the input TokenStream of a macro, triggering a compile error if the /// tokens fail to parse. /// /// Refer to the [`parse` module] documentation for more details about parsing /// in Syn. /// /// [`parse` module]: crate::rustdoc_workaround::parse_module /// /// <br> /// /// # Intended usage /// /// This macr...
/// # Ok(MyMacroInput {}) /// } /// } /// /// # const IGNORE: &str = stringify! { /// #[proc_macro] /// # }; /// pub fn my_macro(tokens: TokenStream) -> TokenStream { /// let input = parse_macro_input!(tokens as MyMacroInput); /// /// /*... */ /// # "".parse().unwrap() /// } /// ``` #[macro_export(l...
/// /// impl Parse for MyMacroInput { /// fn parse(input: ParseStream) -> Result<Self> { /// /* ... */
random_line_split
parse_macro_input.rs
/// Parse the input TokenStream of a macro, triggering a compile error if the /// tokens fail to parse. /// /// Refer to the [`parse` module] documentation for more details about parsing /// in Syn. /// /// [`parse` module]: crate::rustdoc_workaround::parse_module /// /// <br> /// /// # Intended usage /// /// This macr...
(input: ParseStream) -> Result<Self> { <T as Parse>::parse(input) } } //////////////////////////////////////////////////////////////////////////////// // Any other types that we want `parse_macro_input!` to be able to parse. #[cfg(any(feature = "full", feature = "derive"))] use crate::AttributeArgs; #[cf...
parse
identifier_name
parse_macro_input.rs
/// Parse the input TokenStream of a macro, triggering a compile error if the /// tokens fail to parse. /// /// Refer to the [`parse` module] documentation for more details about parsing /// in Syn. /// /// [`parse` module]: crate::rustdoc_workaround::parse_module /// /// <br> /// /// # Intended usage /// /// This macr...
let value = input.parse()?; metas.push(value); if input.is_empty() { break; } input.parse::<Token![,]>()?; } Ok(metas) } }
{ break; }
conditional_block
trait-default-method-bound-subst.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} impl A<i32> for i32 { } impl<T> A<T> for u32 { } fn f<T, U, V: A<T>>(i: V, j: T, k: U) -> (T, U) { i.g(j, k) } pub fn main () { assert_eq!(f(0, 1, 2), (1, 2)); assert_eq!(f(0, 1, 2), (1, 2)); }
{ (x, y) }
identifier_body
trait-default-method-bound-subst.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { assert_eq!(f(0, 1, 2), (1, 2)); assert_eq!(f(0, 1, 2), (1, 2)); }
main
identifier_name
trait-default-method-bound-subst.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 ...
i.g(j, k) } pub fn main () { assert_eq!(f(0, 1, 2), (1, 2)); assert_eq!(f(0, 1, 2), (1, 2)); }
random_line_split
system_info.rs
use minidump::system_info::{Cpu, Os}; /// Information about the system that produced a `Minidump`. pub struct
{ /// The operating system that produced the minidump pub os: Os, /// A string identifying the version of the operating system /// /// This may look like "5.1.2600 Service Pack 2" or "10.4.8 8L2127", if present pub os_version: Option<String>, /// The CPU on which the dump was produced p...
SystemInfo
identifier_name