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
unix.rs
/* * This file is part of the uutils coreutils package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use std::io::{Result, Error}; use ::libc; use self::c_types::{c_passwd, getpwuid};...
{ // Get effective user id let uid = geteuid(); // Try to find username for uid let passwd: *const c_passwd = getpwuid(uid); if passwd.is_null() { return Err(Error::last_os_error()) } // Extract username from passwd struct let pw_name: *const libc::c_char = (*passwd).pw_name; ...
identifier_body
p035.rs
//! [Problem 35](https://projecteuler.net/problem=35) solver. #![warn(bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results)] #[macro_use(problem)] extern crate common; extern crate integer; extern crate prime; use integer::Integer; use prime::PrimeSet; ...
} }
} #[test] fn below100() { assert_eq!(13, super::compute(100));
random_line_split
p035.rs
//! [Problem 35](https://projecteuler.net/problem=35) solver. #![warn(bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results)] #[macro_use(problem)] extern crate common; extern crate integer; extern crate prime; use integer::Integer; use prime::PrimeSet; ...
() { assert_eq!(13, super::compute(100)); } }
below100
identifier_name
p035.rs
//! [Problem 35](https://projecteuler.net/problem=35) solver. #![warn(bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results)] #[macro_use(problem)] extern crate common; extern crate integer; extern crate prime; use integer::Integer; use prime::PrimeSet; ...
} true } fn compute(limit: u64) -> usize { let ps = PrimeSet::new(); ps.iter() .take_while(|&p| p < limit) .filter(|&n| is_circular_prime(&ps, n)) .count() } fn solve() -> String { compute(1000000).to_string() } problem!("55", solve); #[cfg(test)] mod tests { use prime...
{ return false; }
conditional_block
p035.rs
//! [Problem 35](https://projecteuler.net/problem=35) solver. #![warn(bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results)] #[macro_use(problem)] extern crate common; extern crate integer; extern crate prime; use integer::Integer; use prime::PrimeSet; ...
fn solve() -> String { compute(1000000).to_string() } problem!("55", solve); #[cfg(test)] mod tests { use prime::PrimeSet; #[test] fn is_circular_prime() { let ps = PrimeSet::new(); assert_eq!(true, super::is_circular_prime(&ps, 197)); assert_eq!(false, super::is_circular_pr...
{ let ps = PrimeSet::new(); ps.iter() .take_while(|&p| p < limit) .filter(|&n| is_circular_prime(&ps, n)) .count() }
identifier_body
lib.rs
// Copyright (C) 2019 Sajeer Ahamed <ahamedsajeer.15.15@cse.mrt.ac.lk> // Copyright (C) 2019 Sebastian Dröge <sebastian@centricular.com> // // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> //! Extracts release for [GStreamer](https://gstreamer.freedesktop.org) plugin meta...
crate_dir: path::PathBuf) -> Option<String> { let mut cargo_toml = crate_dir; cargo_toml.push("Cargo.toml"); let metadata = fs::metadata(&cargo_toml).ok()?; let mtime = metadata.modified().ok()?; let unix_time = mtime.duration_since(SystemTime::UNIX_EPOCH).ok()?; let dt = chrono::Utc.timestamp(...
argo_mtime_date(
identifier_name
lib.rs
// Copyright (C) 2019 Sajeer Ahamed <ahamedsajeer.15.15@cse.mrt.ac.lk> // Copyright (C) 2019 Sebastian Dröge <sebastian@centricular.com> // // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> //! Extracts release for [GStreamer](https://gstreamer.freedesktop.org) plugin meta...
/// /// - If extracted from a git repository, sets the `COMMIT_ID` environment variable to the short /// commit id of the latest commit and the `BUILD_REL_DATE` environment variable to the date of the /// commit. /// /// - If not, `COMMIT_ID` will be set to the string `RELEASE` and the /// `BUILD_REL_DATE` variab...
/// place as the `Cargo.toml`, or one directory up to allow for Cargo workspaces. If no /// git repository is found, we assume this is a release.
random_line_split
lib.rs
// Copyright (C) 2019 Sajeer Ahamed <ahamedsajeer.15.15@cse.mrt.ac.lk> // Copyright (C) 2019 Sebastian Dröge <sebastian@centricular.com> // // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> //! Extracts release for [GStreamer](https://gstreamer.freedesktop.org) plugin meta...
println!("cargo:rustc-env=BUILD_REL_DATE={}", commit_date); } fn cargo_mtime_date(crate_dir: path::PathBuf) -> Option<String> { let mut cargo_toml = crate_dir; cargo_toml.push("Cargo.toml"); let metadata = fs::metadata(&cargo_toml).ok()?; let mtime = metadata.modified().ok()?; let unix_time = ...
let crate_dir = path::PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set")); let mut repo_dir = crate_dir.clone(); // First check for a git repository in the manifest directory and if there // is none try one directory up in case we're in a Cargo workspace let ...
identifier_body
timer.rs
use libc::{uint32_t, c_void}; use std::marker::PhantomData; use std::mem; use sys::timer as ll; use TimerSubsystem; impl TimerSubsystem { /// Constructs a new timer using the boxed closure `callback`. /// /// The timer is started immediately, it will be cancelled either: /// /// * when the timer i...
(&mut self, ms: u32) { // Google says this is probably not thread-safe (TODO: prove/disprove this). unsafe { ll::SDL_Delay(ms) } } pub fn performance_counter(&self) -> u64 { unsafe { ll::SDL_GetPerformanceCounter() } } pub fn performance_frequency(&self) -> u64 { unsafe...
delay
identifier_name
timer.rs
use libc::{uint32_t, c_void}; use std::marker::PhantomData; use std::mem; use sys::timer as ll; use TimerSubsystem; impl TimerSubsystem { /// Constructs a new timer using the boxed closure `callback`. /// /// The timer is started immediately, it will be cancelled either: /// /// * when the timer i...
fn test_timer_can_be_recreated() { use std::sync::{Arc, Mutex}; let sdl_context = ::sdl::init().unwrap(); let timer_subsystem = sdl_context.timer().unwrap(); let local_num = Arc::new(Mutex::new(0)); let timer_num = local_num.clone(); // run the timer once and reclaim its closure let timer_...
#[cfg(test)]
random_line_split
timer.rs
use libc::{uint32_t, c_void}; use std::marker::PhantomData; use std::mem; use sys::timer as ll; use TimerSubsystem; impl TimerSubsystem { /// Constructs a new timer using the boxed closure `callback`. /// /// The timer is started immediately, it will be cancelled either: /// /// * when the timer i...
else { 0 } })); ::std::thread::sleep_ms(250); // tick the timer at least 10 times w/ 200ms of "buffer" let num = local_num.lock().unwrap(); // read the number back assert_eq!(*num, 9); // it should have incremented at least 10 times... } #[cfg(test)] fn test_timer_runs_at...
{ *num += 1; 20 }
conditional_block
timer.rs
use libc::{uint32_t, c_void}; use std::marker::PhantomData; use std::mem; use sys::timer as ll; use TimerSubsystem; impl TimerSubsystem { /// Constructs a new timer using the boxed closure `callback`. /// /// The timer is started immediately, it will be cancelled either: /// /// * when the timer i...
#[cfg(test)] fn test_timer_runs_multiple_times() { use std::sync::{Arc, Mutex}; let sdl_context = ::sdl::init().unwrap(); let timer_subsystem = sdl_context.timer().unwrap(); let local_num = Arc::new(Mutex::new(0)); let timer_num = local_num.clone(); let _timer = timer_subsystem.add_timer(20...
{ unsafe { let f: *mut Box<Fn() -> u32> = mem::transmute(param); (*f)() as uint32_t } }
identifier_body
automata.rs
// Transition table for a language consisting of strings having even number of zeroes ( that includes having no zeroes as well ) //____________ //S1 | 1 -> S1 //S1 | 0 -> S2 //S2 | 0 -> S1 //S2 | 1 -> S2 //------------ /*#[derive(Debug)] enum STATE { S0, S1, S2, }*/
const S0:&'static str = "S0"; const S1:&'static str = "S1"; const S2:&'static str = "S2"; fn assert_state(state:&'static str,desired:&'static str) -> bool { state == desired } #[allow(unused_assignments)] fn dfa(s:&String) -> bool { let mut state = S0; // initializing the dfa to the start state with any...
pub mod even_zeros_dfa {
random_line_split
automata.rs
// Transition table for a language consisting of strings having even number of zeroes ( that includes having no zeroes as well ) //____________ //S1 | 1 -> S1 //S1 | 0 -> S2 //S2 | 0 -> S1 //S2 | 1 -> S2 //------------ /*#[derive(Debug)] enum STATE { S0, S1, S2, }*/ pub mod even_zeros_dfa { const S0:&'...
} #[test] fn test_dfa() { let string = "100".to_string(); if dfa(&string) { println!("Language accepted by the dfa"); }else { println!("Language not recognized"); } } }
{println!("Language not recognized");}
conditional_block
automata.rs
// Transition table for a language consisting of strings having even number of zeroes ( that includes having no zeroes as well ) //____________ //S1 | 1 -> S1 //S1 | 0 -> S2 //S2 | 0 -> S1 //S2 | 1 -> S2 //------------ /*#[derive(Debug)] enum STATE { S0, S1, S2, }*/ pub mod even_zeros_dfa { const S0:&'...
#[allow(unused_assignments)] fn dfa(s:&String) -> bool { let mut state = S0; // initializing the dfa to the start state with any symbol if s.len() > 0 {state=S1;} else {return false;} for i in s.chars() { if i=='1' && assert_state(&state,S1) {state = S1;} else if i=='0' && asse...
{ state == desired }
identifier_body
automata.rs
// Transition table for a language consisting of strings having even number of zeroes ( that includes having no zeroes as well ) //____________ //S1 | 1 -> S1 //S1 | 0 -> S2 //S2 | 0 -> S1 //S2 | 1 -> S2 //------------ /*#[derive(Debug)] enum STATE { S0, S1, S2, }*/ pub mod even_zeros_dfa { const S0:&'...
() { let string = "100".to_string(); if dfa(&string) { println!("Language accepted by the dfa"); }else { println!("Language not recognized"); } } }
test_dfa
identifier_name
util.rs
#![allow(dead_code)] //! Utility functions for operating on vectors in shading coordinates use cgmath::prelude::*; use cgmath::Vector3; use crate::float::*; /// Check if the vectors are in the same hemisphere pub fn same_hemisphere(w1: Vector3<Float>, w2: Vector3<Float>) -> bool { w1.z * w2.z > 0.0 } /// Reflec...
(vec: Vector3<Float>) -> Float { sin2_t(vec) / cos2_t(vec) }
tan2_t
identifier_name
util.rs
#![allow(dead_code)] //! Utility functions for operating on vectors in shading coordinates use cgmath::prelude::*; use cgmath::Vector3; use crate::float::*; /// Check if the vectors are in the same hemisphere pub fn same_hemisphere(w1: Vector3<Float>, w2: Vector3<Float>) -> bool { w1.z * w2.z > 0.0 } /// Reflec...
pub fn sin_t(vec: Vector3<Float>) -> Float { sin2_t(vec).sqrt() } pub fn tan2_t(vec: Vector3<Float>) -> Float { sin2_t(vec) / cos2_t(vec) }
{ 1.0 - cos2_t(vec) }
identifier_body
util.rs
#![allow(dead_code)] //! Utility functions for operating on vectors in shading coordinates use cgmath::prelude::*; use cgmath::Vector3; use crate::float::*; /// Check if the vectors are in the same hemisphere pub fn same_hemisphere(w1: Vector3<Float>, w2: Vector3<Float>) -> bool { w1.z * w2.z > 0.0 } /// Reflec...
let cos_tt = (1.0 - sin2_tt).sqrt(); Some(-w * eta + (eta * cos_ti - cos_tt) * wh) } /// Refract w around the shading normal (0, 0, 1) pub fn refract_n(w: Vector3<Float>, eta_mat: Float) -> Option<Vector3<Float>> { // Make sure normal is in the same hemisphere as w let n = w.z.signum() * Vector3::unit...
{ return None; }
conditional_block
util.rs
#![allow(dead_code)] //! Utility functions for operating on vectors in shading coordinates use cgmath::prelude::*; use cgmath::Vector3; use crate::float::*; /// Check if the vectors are in the same hemisphere pub fn same_hemisphere(w1: Vector3<Float>, w2: Vector3<Float>) -> bool { w1.z * w2.z > 0.0 } /// Reflec...
if sin2_tt >= 1.0 { return None; } let cos_tt = (1.0 - sin2_tt).sqrt(); Some(-w * eta + (eta * cos_ti - cos_tt) * wh) } /// Refract w around the shading normal (0, 0, 1) pub fn refract_n(w: Vector3<Float>, eta_mat: Float) -> Option<Vector3<Float>> { // Make sure normal is in the same hemisp...
// Total internal reflection
random_line_split
camera.rs
//! Camera structure and manipulation functions. use gl; use gl::types::*; use cgmath; use cgmath::{Matrix3, Matrix4, One, Vector3, Point3, EuclideanSpace}; use std::f32::consts::PI; use yaglw::gl_context::GLContext; use yaglw::shader::Shader; /// T representation as 3 distinct matrices, as well as a position + two r...
impl T { #[allow(missing_docs)] pub fn projection_matrix(&self) -> Matrix4<GLfloat> { self.fov * self.rotation * self.translation } #[allow(missing_docs)] pub fn translate_to(&mut self, p: Point3<f32>) { self.position = p; self.translation = Matrix4::from_translation(-p.to_vec()); } /// Ro...
{ T { position : Point3::new(0.0, 0.0, 0.0), lateral_rotation : 0.0, vertical_rotation : 0.0, translation : Matrix4::one(), rotation : Matrix4::one(), fov : Matrix4::one(), } }
identifier_body
camera.rs
//! Camera structure and manipulation functions. use gl; use gl::types::*; use cgmath; use cgmath::{Matrix3, Matrix4, One, Vector3, Point3, EuclideanSpace}; use std::f32::consts::PI; use yaglw::gl_context::GLContext; use yaglw::shader::Shader; /// T representation as 3 distinct matrices, as well as a position + two r...
/// Changes the camera pitch by `r` radians. Positive is up. /// Angles that "flip around" (i.e. looking too far up or down) /// are sliently rejected. pub fn rotate_vertical(&mut self, r: GLfloat) { let new_rotation = self.vertical_rotation + r; if new_rotation < -PI / 2.0 || new_rotation > PI /...
self.lateral_rotation = self.lateral_rotation + r; self.rotate(&Vector3::new(0.0, 1.0, 0.0), r); }
random_line_split
camera.rs
//! Camera structure and manipulation functions. use gl; use gl::types::*; use cgmath; use cgmath::{Matrix3, Matrix4, One, Vector3, Point3, EuclideanSpace}; use std::f32::consts::PI; use yaglw::gl_context::GLContext; use yaglw::shader::Shader; /// T representation as 3 distinct matrices, as well as a position + two r...
self.vertical_rotation = new_rotation; let axis = Matrix3::from_axis_angle( Vector3::new(0.0, 1.0, 0.0), cgmath::Rad(self.lateral_rotation), ); let axis = axis * (&Vector3::new(1.0, 0.0, 0.0)); self.rotate(&axis, r); } } /// Set a shader's projection matrix to match tha...
{ return }
conditional_block
camera.rs
//! Camera structure and manipulation functions. use gl; use gl::types::*; use cgmath; use cgmath::{Matrix3, Matrix4, One, Vector3, Point3, EuclideanSpace}; use std::f32::consts::PI; use yaglw::gl_context::GLContext; use yaglw::shader::Shader; /// T representation as 3 distinct matrices, as well as a position + two r...
(&mut self, p: Point3<f32>) { self.position = p; self.translation = Matrix4::from_translation(-p.to_vec()); } /// Rotate about a given vector, by `r` radians. fn rotate(&mut self, v: &Vector3<f32>, r: f32) { let mat = Matrix3::from_axis_angle(*v, -cgmath::Rad(r)); let mat = Matrix4::new( ...
translate_to
identifier_name
modulo_one.rs
#![warn(clippy::modulo_one)] #![allow(clippy::no_effect, clippy::unnecessary_operation)] static STATIC_ONE: usize = 2 - 1; static STATIC_NEG_ONE: i64 = 1 - 2; fn main()
{ 10 % 1; 10 % -1; 10 % 2; i32::MIN % (-1); // also caught by rustc const ONE: u32 = 1 * 1; const NEG_ONE: i64 = 1 - 2; const INT_MIN: i64 = i64::MIN; 2 % ONE; 5 % STATIC_ONE; // NOT caught by lint 2 % NEG_ONE; 5 % STATIC_NEG_ONE; // NOT caught by lint INT_MIN % NEG_ONE...
identifier_body
modulo_one.rs
#![warn(clippy::modulo_one)] #![allow(clippy::no_effect, clippy::unnecessary_operation)] static STATIC_ONE: usize = 2 - 1; static STATIC_NEG_ONE: i64 = 1 - 2; fn
() { 10 % 1; 10 % -1; 10 % 2; i32::MIN % (-1); // also caught by rustc const ONE: u32 = 1 * 1; const NEG_ONE: i64 = 1 - 2; const INT_MIN: i64 = i64::MIN; 2 % ONE; 5 % STATIC_ONE; // NOT caught by lint 2 % NEG_ONE; 5 % STATIC_NEG_ONE; // NOT caught by lint INT_MIN % NEG_...
main
identifier_name
modulo_one.rs
#![warn(clippy::modulo_one)] #![allow(clippy::no_effect, clippy::unnecessary_operation)] static STATIC_ONE: usize = 2 - 1; static STATIC_NEG_ONE: i64 = 1 - 2; fn main() {
i32::MIN % (-1); // also caught by rustc const ONE: u32 = 1 * 1; const NEG_ONE: i64 = 1 - 2; const INT_MIN: i64 = i64::MIN; 2 % ONE; 5 % STATIC_ONE; // NOT caught by lint 2 % NEG_ONE; 5 % STATIC_NEG_ONE; // NOT caught by lint INT_MIN % NEG_ONE; // also caught by rustc INT_MIN %...
10 % 1; 10 % -1; 10 % 2;
random_line_split
range_expansion.rs
// http://rosettacode.org/wiki/Range_expansion extern crate regex; #[cfg(not(test))] fn main() { let range = "-6,-3-1,3-5,7-11,14,15,17-20"; println!("Expanded range: {:?}", expand_range(range)); } // Expand a string containing numbers and ranges, into a vector of numbers fn expand_range(range: &str) -> Vec<i...
assert!(expand_range(range) == vec![1, 2, 3, 4, 5, 6]); }
let range = "one-five,six";
random_line_split
range_expansion.rs
// http://rosettacode.org/wiki/Range_expansion extern crate regex; #[cfg(not(test))] fn main() { let range = "-6,-3-1,3-5,7-11,14,15,17-20"; println!("Expanded range: {:?}", expand_range(range)); } // Expand a string containing numbers and ranges, into a vector of numbers fn expand_range(range: &str) -> Vec<i...
(item: &str) -> Vec<isize> { use regex::Regex; // Handle the case of a single number for cap in Regex::new(r"^(-?\d+)$").unwrap().captures_iter(item) { return vec![cap.at(0).and_then(|s| s.parse().ok()).unwrap()] } // Handle the case of a range for cap in Regex::new(r"^(-?\d+)-(-?\d+)$"...
expand_item
identifier_name
range_expansion.rs
// http://rosettacode.org/wiki/Range_expansion extern crate regex; #[cfg(not(test))] fn main() { let range = "-6,-3-1,3-5,7-11,14,15,17-20"; println!("Expanded range: {:?}", expand_range(range)); } // Expand a string containing numbers and ranges, into a vector of numbers fn expand_range(range: &str) -> Vec<i...
// Expand a single element, which can be a number or a range. fn expand_item(item: &str) -> Vec<isize> { use regex::Regex; // Handle the case of a single number for cap in Regex::new(r"^(-?\d+)$").unwrap().captures_iter(item) { return vec![cap.at(0).and_then(|s| s.parse().ok()).unwrap()] } ...
{ let mut result = vec![]; for item in range.split(',') { result.extend(expand_item(item).into_iter()); } result }
identifier_body
ioreg.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Ben Gamari <bgamari@gmail.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/LICENSE-2...
::new(MacItems { items: items }) } } impl MacResult for MacItems { fn make_items(self: Box<MacItems>) -> Option<SmallVector<P<ast::Item>>> { Some(SmallVector::many(self.items.clone())) } }
sult+'static> { Box
conditional_block
ioreg.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Ben Gamari <bgamari@gmail.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/LICENSE-2...
one())) } }
>> { Some(SmallVector::many(self.items.cl
identifier_body
ioreg.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Ben Gamari <bgamari@gmail.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/LICENSE-2...
-> Box<MacResult+'static> { match parser::Parser::new(cx, tts).parse_ioregs() { Some(group) => { let mut builder = builder::Builder::new(); let items = builder.emit_items(cx, group); MacItems::new(items) }, None => { panic!(); } } } pub struct MacItems { items...
enTree])
identifier_name
ioreg.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Ben Gamari <bgamari@gmail.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/LICENSE-2...
} impl MacResult for MacItems { fn make_items(self: Box<MacItems>) -> Option<SmallVector<P<ast::Item>>> { Some(SmallVector::many(self.items.clone())) } }
pub fn new(items: Vec<P<ast::Item>>) -> Box<MacResult+'static> { Box::new(MacItems { items: items }) }
random_line_split
math.rs
//! Various methods for computing with vectors. use std::ops::{Add, Rem}; use vecmath::{self, traits::Float}; pub use vecmath::{ mat2x3_inv as invert, row_mat2x3_mul as multiply, row_mat2x3_transform_pos2 as transform_pos, row_mat2x3_transform_vec2 as transform_vec, vec2_add as add, vec2_cast as cast, vec...
use vecmath::traits::{FromPrimitive, Zero}; let _0: T = Zero::zero(); let _05: T = FromPrimitive::from_f64(0.5); let _3: T = FromPrimitive::from_f64(3.0); let n = polygon.len(); let mut sum = _0; let (mut cx, mut cy) = (_0, _0); for i in 0..n { let qx = polygon[i][0]; le...
{
random_line_split
math.rs
//! Various methods for computing with vectors. use std::ops::{Add, Rem}; use vecmath::{self, traits::Float}; pub use vecmath::{ mat2x3_inv as invert, row_mat2x3_mul as multiply, row_mat2x3_transform_pos2 as transform_pos, row_mat2x3_transform_vec2 as transform_vec, vec2_add as add, vec2_cast as cast, vec...
let len = len.sqrt(); let c = x / len; let s = y / len; [[c, -s, _0], [s, c, _0]] } /// Create a scale matrix. #[inline(always)] pub fn scale<T>(sx: T, sy: T) -> Matrix2d<T> where T: Float, { use vecmath::traits::Zero; let _0: T = Zero::zero(); [[sx, _0, _0], [_0, sy, _0]] } /// Cre...
{ return identity(); }
conditional_block
math.rs
//! Various methods for computing with vectors. use std::ops::{Add, Rem}; use vecmath::{self, traits::Float}; pub use vecmath::{ mat2x3_inv as invert, row_mat2x3_mul as multiply, row_mat2x3_transform_pos2 as transform_pos, row_mat2x3_transform_vec2 as transform_vec, vec2_add as add, vec2_cast as cast, vec...
#[cfg(test)] mod test_triangle { use super::*; #[test] fn test_triangle() { // Triangle counter clock-wise. let tri_1 = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]; // Triangle clock-wise. let tri_2 = [[0.0, 0.0], [1.0, 1.0], [1.0, 0.0]]; let (x, y) = (0.5, 0.25); ...
{ use vecmath::traits::Zero; let _0 = Zero::zero(); let ax = triangle[0][0]; let ay = triangle[0][1]; let bx = triangle[1][0]; let by = triangle[1][1]; let cx = triangle[2][0]; let cy = triangle[2][1]; let ab_side = line_side([ax, ay, bx, by], [cx, cy]); ab_side <= _0 }
identifier_body
math.rs
//! Various methods for computing with vectors. use std::ops::{Add, Rem}; use vecmath::{self, traits::Float}; pub use vecmath::{ mat2x3_inv as invert, row_mat2x3_mul as multiply, row_mat2x3_transform_pos2 as transform_pos, row_mat2x3_transform_vec2 as transform_vec, vec2_add as add, vec2_cast as cast, vec...
<T>(polygon: Polygon<'_, T>) -> Vec2d<T> where T: Float, { let (_, res) = area_centroid(polygon); res } /// Returns a number that tells which side it is relative to a line. /// /// Computes the cross product of the vector that gives the line /// with the vector between point and starting point of line. ///...
centroid
identifier_name
scoping_rules_lifetimes_structs.rs
// A type `Borrowed` which houses a reference to an // `i32`. The reference to `i32` must outlive `Borrowed`. #[derive(Debug)] struct Borrowed<'a>(&'a i32); // Similarly, both references here must outlive this structure. #[derive(Debug)] struct NamedBorrowed<'a> { x: &'a i32, y: &'a i32, } // An enum which is...
println!("x is borrowed in {:?}", single); println!("x and y are borrowed in {:?}", double); println!("x is borrowed in {:?}", reference); println!("y is *not* borrowed in {:?}", number); }
let reference = Either::Ref(&x); let number = Either::Num(y);
random_line_split
scoping_rules_lifetimes_structs.rs
// A type `Borrowed` which houses a reference to an // `i32`. The reference to `i32` must outlive `Borrowed`. #[derive(Debug)] struct Borrowed<'a>(&'a i32); // Similarly, both references here must outlive this structure. #[derive(Debug)] struct NamedBorrowed<'a> { x: &'a i32, y: &'a i32, } // An enum which is...
<'a> { Num(i32), Ref(&'a i32), } pub fn main() { let x = 18; let y = 15; let single = Borrowed(&x); let double = NamedBorrowed { x: &x, y: &y }; let reference = Either::Ref(&x); let number = Either::Num(y); println!("x is borrowed in {:?}", single); println!("x and y are bo...
Either
identifier_name
report.rs
use rustc_serialize::json; #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct ReportContent { pub domains: Option<Vec<String>>, pub definitions: Option<Vec<String>>, } #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct
{ pub report: super::MetadataObjectBody<ReportContent>, } impl Report { pub fn object(&self) -> &super::MetadataObjectBody<ReportContent> { &self.report } } impl super::MetadataObjectGetter<ReportContent> for Report { fn object(&self) -> &super::MetadataObjectBody<ReportContent> { &se...
Report
identifier_name
report.rs
use rustc_serialize::json; #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct ReportContent { pub domains: Option<Vec<String>>, pub definitions: Option<Vec<String>>, } #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct Report { pub report: super::MetadataObjectBody<ReportCo...
i += 1; } (0, None) } }
{ return (i, Some(item.clone())); }
conditional_block
report.rs
use rustc_serialize::json; #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct ReportContent { pub domains: Option<Vec<String>>, pub definitions: Option<Vec<String>>, } #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct Report { pub report: super::MetadataObjectBody<ReportCo...
impl super::MetadataQuery<super::MetadataQueryBody<Report>> { pub fn find_by_identifier(&self, identifier: &String) -> (u32, Option<Report>) { let mut i: u32 = 0; for item in self.objects().items().into_iter() { if item.object().meta().identifier().as_ref().unwrap() == identifier { ...
random_line_split
report.rs
use rustc_serialize::json; #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct ReportContent { pub domains: Option<Vec<String>>, pub definitions: Option<Vec<String>>, } #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct Report { pub report: super::MetadataObjectBody<ReportCo...
} impl super::MetadataObjectGetter<ReportContent> for Report { fn object(&self) -> &super::MetadataObjectBody<ReportContent> { &self.object() } } impl Into<String> for Report { fn into(self) -> String { format!("{}\n", json::as_pretty_json(&self).to_string()) } } pub const NAME: &'st...
{ &self.report }
identifier_body
version.rs
/* automatically generated by rust-bindgen */ pub const R_VERSION: u32 = 197635;
pub const R_MINOR: &'static [u8; 4usize] = b"4.3\0"; pub const R_STATUS: &'static [u8; 1usize] = b"\0"; pub const R_YEAR: &'static [u8; 5usize] = b"2017\0"; pub const R_MONTH: &'static [u8; 3usize] = b"11\0"; pub const R_DAY: &'static [u8; 3usize] = b"30\0"; pub const R_SVN_REVISION: u32 = 73796;
pub const R_NICK: &'static [u8; 17usize] = b"Kite-Eating Tree\0"; pub const R_MAJOR: &'static [u8; 2usize] = b"3\0";
random_line_split
context.rs
use ::handle::{Handle,HandleMut}; /// A `libgphoto2` library context. pub struct Context { context: *mut ::gphoto2::GPContext, } impl Context { /// Creates a new context. pub fn new() -> ::Result<Context> { let ptr = unsafe { ::gphoto2::gp_context_new() }; if!ptr.is_null() { O...
} } impl Drop for Context { fn drop(&mut self) { unsafe { ::gphoto2::gp_context_unref(self.context); } } } #[doc(hidden)] impl Handle<::gphoto2::GPContext> for Context { unsafe fn as_ptr(&self) -> *const ::gphoto2::GPContext { self.context } } #[doc(hidden)] i...
{ Err(::error::from_libgphoto2(::gphoto2::GP_ERROR_NO_MEMORY)) }
conditional_block
context.rs
use ::handle::{Handle,HandleMut}; /// A `libgphoto2` library context. pub struct Context { context: *mut ::gphoto2::GPContext, } impl Context { /// Creates a new context. pub fn new() -> ::Result<Context> { let ptr = unsafe { ::gphoto2::gp_context_new() }; if!ptr.is_null() { O...
} #[doc(hidden)] impl Handle<::gphoto2::GPContext> for Context { unsafe fn as_ptr(&self) -> *const ::gphoto2::GPContext { self.context } } #[doc(hidden)] impl HandleMut<::gphoto2::GPContext> for Context { unsafe fn as_mut_ptr(&mut self) -> *mut ::gphoto2::GPContext { self.context } }
{ unsafe { ::gphoto2::gp_context_unref(self.context); } }
identifier_body
context.rs
use ::handle::{Handle,HandleMut}; /// A `libgphoto2` library context. pub struct Context { context: *mut ::gphoto2::GPContext, } impl Context { /// Creates a new context. pub fn new() -> ::Result<Context> { let ptr = unsafe { ::gphoto2::gp_context_new() }; if!ptr.is_null() { O...
(&self) -> *const ::gphoto2::GPContext { self.context } } #[doc(hidden)] impl HandleMut<::gphoto2::GPContext> for Context { unsafe fn as_mut_ptr(&mut self) -> *mut ::gphoto2::GPContext { self.context } }
as_ptr
identifier_name
context.rs
use ::handle::{Handle,HandleMut}; /// A `libgphoto2` library context. pub struct Context { context: *mut ::gphoto2::GPContext, } impl Context { /// Creates a new context. pub fn new() -> ::Result<Context> { let ptr = unsafe { ::gphoto2::gp_context_new() }; if!ptr.is_null() { O...
unsafe { ::gphoto2::gp_context_unref(self.context); } } } #[doc(hidden)] impl Handle<::gphoto2::GPContext> for Context { unsafe fn as_ptr(&self) -> *const ::gphoto2::GPContext { self.context } } #[doc(hidden)] impl HandleMut<::gphoto2::GPContext> for Context { unsaf...
fn drop(&mut self) {
random_line_split
resource.rs
//! Configure the process resource limits. use cfg_if::cfg_if; use crate::errno::Errno; use crate::Result; pub use libc::rlim_t; use std::mem; cfg_if! { if #[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))]{ use libc::{__rlimit_resource_t, rlimit, RLIM_INFINITY}; } else i...
#[cfg_attr(docsrs, doc(cfg(all())))] /// The maximum size (in bytes) of the swap space that may be reserved /// or used by all of this user id's processes. RLIMIT_SWAP, #[cfg(target_os = "freebsd")] #[cfg_attr(docsrs, doc(cfg(all())))] /// An alias for RLIMIT_AS....
/// The maximum size (in bytes) of socket buffer usage for this user. RLIMIT_SBSIZE, #[cfg(target_os = "freebsd")]
random_line_split
resource.rs
//! Configure the process resource limits. use cfg_if::cfg_if; use crate::errno::Errno; use crate::Result; pub use libc::rlim_t; use std::mem; cfg_if! { if #[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))]{ use libc::{__rlimit_resource_t, rlimit, RLIM_INFINITY}; } else i...
resource: Resource, soft_limit: Option<rlim_t>, hard_limit: Option<rlim_t>, ) -> Result<()> { let new_rlim = rlimit { rlim_cur: soft_limit.unwrap_or(RLIM_INFINITY), rlim_max: hard_limit.unwrap_or(RLIM_INFINITY), }; cfg_if! { if #[cfg(all(target_os = "linux", any(target_env ...
limit(
identifier_name
resource.rs
//! Configure the process resource limits. use cfg_if::cfg_if; use crate::errno::Errno; use crate::Result; pub use libc::rlim_t; use std::mem; cfg_if! { if #[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))]{ use libc::{__rlimit_resource_t, rlimit, RLIM_INFINITY}; } else i...
/ Set the current processes resource limits /// /// # Parameters /// /// * `resource`: The [`Resource`] that we want to set the limits of. /// * `soft_limit`: The value that the kernel enforces for the corresponding /// resource. Note: `None` input will be replaced by constant `RLIM_INFINITY`. /// * `hard_limit`: The...
let mut old_rlim = mem::MaybeUninit::<rlimit>::uninit(); cfg_if! { if #[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))]{ let res = unsafe { libc::getrlimit(resource as __rlimit_resource_t, old_rlim.as_mut_ptr()) }; } else { let res = unsafe {...
identifier_body
table_cell.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! CSS table formatting contexts. #![deny(unsafe_block)] use block::{BlockFlow, MarginsMayNotCollapse, WidthAnd...
/// Minimum/preferred widths set by this function are used in automatic table layout calculation. fn bubble_widths(&mut self, ctx: &mut LayoutContext) { self.block_flow.bubble_widths(ctx); let specified_width = MaybeAuto::from_style(self.block_flow.fragment.style().get_box().width, ...
{ &mut self.block_flow }
identifier_body
table_cell.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! CSS table formatting contexts. #![deny(unsafe_block)] use block::{BlockFlow, MarginsMayNotCollapse, WidthAnd...
<'a>(&'a mut self) -> &'a Fragment { &self.block_flow.fragment } pub fn mut_fragment<'a>(&'a mut self) -> &'a mut Fragment { &mut self.block_flow.fragment } /// Assign height for table-cell flow. /// /// TODO(#2015, pcwalton): This doesn't handle floats right. /// /// i...
fragment
identifier_name
table_cell.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! CSS table formatting contexts. #![deny(unsafe_block)] use block::{BlockFlow, MarginsMayNotCollapse, WidthAnd...
} /// Recursively (top-down) determines the actual width of child contexts and fragments. When /// called on this context, the context has had its width set by the parent table row. fn assign_widths(&mut self, ctx: &mut LayoutContext) { debug!("assign_widths({}): assigning width for flow", "ta...
{ self.block_flow.base.intrinsic_widths.preferred_width = self.block_flow.base.intrinsic_widths.minimum_width; }
conditional_block
table_cell.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! CSS table formatting contexts. #![deny(unsafe_block)] use block::{BlockFlow, MarginsMayNotCollapse, WidthAnd...
}
}
random_line_split
lib.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #![deny(warnings)] #![deny(rust_2018_idioms)] #![deny(clippy::all)] #![allow(clippy::large_enum_variant)] mod char_constants; mod ...
(source: &str, file: FileKey) -> SyntaxResult<TypeAnnotation> { let parser = Parser::new(source, file); parser.parse_type() }
parse_type
identifier_name
lib.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #![deny(warnings)] #![deny(rust_2018_idioms)] #![deny(clippy::all)] #![allow(clippy::large_enum_variant)] mod char_constants; mod ...
mod token_kind; pub use source::GraphQLSource; pub use syntax_error::{SyntaxError, SyntaxErrorKind, SyntaxErrorWithSource}; pub use syntax_node::*; use crate::parser::Parser; use common::FileKey; pub fn parse(source: &str, file: FileKey) -> SyntaxResult<Document> { let parser = Parser::new(source, file); pars...
mod parser; mod source; mod syntax_error; mod syntax_node;
random_line_split
lib.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #![deny(warnings)] #![deny(rust_2018_idioms)] #![deny(clippy::all)] #![allow(clippy::large_enum_variant)] mod char_constants; mod ...
pub fn parse_type(source: &str, file: FileKey) -> SyntaxResult<TypeAnnotation> { let parser = Parser::new(source, file); parser.parse_type() }
{ let parser = Parser::new(source, file); parser.parse_document() }
identifier_body
color_matrix.rs
use cssparser::Parser; use markup5ever::{expanded_name, local_name, namespace_url, ns}; use nalgebra::{Matrix3, Matrix4x5, Matrix5, Vector5}; use crate::document::AcquiredNodes; use crate::drawing_ctx::DrawingCtx; use crate::element::{ElementResult, SetAttributes}; use crate::error::*; use crate::node::{CascadedValues...
}; self.params.matrix = new_matrix; } } Ok(()) } } impl ColorMatrix { pub fn render( &self, bounds_builder: BoundsBuilder, ctx: &FilterContext, acquired_nodes: &mut AcquiredNodes<'_>, draw_ctx: &mut DrawingCt...
{ let degrees: f64 = attr.parse(value)?; ColorMatrix::hue_rotate_matrix(degrees.to_radians()) }
conditional_block
color_matrix.rs
use cssparser::Parser; use markup5ever::{expanded_name, local_name, namespace_url, ns}; use nalgebra::{Matrix3, Matrix4x5, Matrix5, Vector5}; use crate::document::AcquiredNodes; use crate::drawing_ctx::DrawingCtx; use crate::element::{ElementResult, SetAttributes}; use crate::error::*; use crate::node::{CascadedValues...
"matrix" => OperationType::Matrix, "saturate" => OperationType::Saturate, "hueRotate" => OperationType::HueRotate, "luminanceToAlpha" => OperationType::LuminanceToAlpha, )?) } }
parser,
random_line_split
color_matrix.rs
use cssparser::Parser; use markup5ever::{expanded_name, local_name, namespace_url, ns}; use nalgebra::{Matrix3, Matrix4x5, Matrix5, Vector5}; use crate::document::AcquiredNodes; use crate::drawing_ctx::DrawingCtx; use crate::element::{ElementResult, SetAttributes}; use crate::error::*; use crate::node::{CascadedValues...
(&mut self, attrs: &Attributes) -> ElementResult { self.params.in1 = self.base.parse_one_input(attrs)?; // First, determine the operation type. let mut operation_type = Default::default(); for (attr, value) in attrs .iter() .filter(|(attr, _)| attr.expanded() == ex...
set_attributes
identifier_name
color_matrix.rs
use cssparser::Parser; use markup5ever::{expanded_name, local_name, namespace_url, ns}; use nalgebra::{Matrix3, Matrix4x5, Matrix5, Vector5}; use crate::document::AcquiredNodes; use crate::drawing_ctx::DrawingCtx; use crate::element::{ElementResult, SetAttributes}; use crate::error::*; use crate::node::{CascadedValues...
} #[rustfmt::skip] impl SetAttributes for FeColorMatrix { fn set_attributes(&mut self, attrs: &Attributes) -> ElementResult { self.params.in1 = self.base.parse_one_input(attrs)?; // First, determine the operation type. let mut operation_type = Default::default(); for (attr, value)...
{ ColorMatrix { in1: Default::default(), color_interpolation_filters: Default::default(), // nalgebra's Default for Matrix5 is all zeroes, so we actually need this :( matrix: Matrix5::identity(), } }
identifier_body
diagnostic.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 ...
pub fn ice_msg(msg: &str) -> ~str { format!("internal compiler error: {}\nThis message reflects a bug in the Rust compiler. \ \nWe would appreciate a bug report: {}", msg, BUG_REPORT_URL) } pub fn mk_span_handler(handler: @mut handler, cm: @codemap::CodeMap) -> @mut span_handler { ...
} }
random_line_split
diagnostic.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 ...
{ err_count: uint, emit: @Emitter, } struct CodemapT { handler: @mut handler, cm: @codemap::CodeMap, } impl span_handler for CodemapT { fn span_fatal(@mut self, sp: Span, msg: &str) ->! { self.handler.emit(Some((self.cm, sp)), msg, fatal); fail!(); } fn span_err(@mut self,...
HandlerT
identifier_name
diagnostic.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 ...
#[deriving(Eq)] pub enum level { fatal, error, warning, note, } fn diagnosticstr(lvl: level) -> ~str { match lvl { fatal => ~"error", error => ~"error", warning => ~"warning", note => ~"note" } } fn diagnosticcolor(lvl: level) -> term::color::Color { match...
{ let emit: @Emitter = match emitter { Some(e) => e, None => @DefaultEmitter as @Emitter }; @mut HandlerT { err_count: 0, emit: emit, } as @mut handler }
identifier_body
edition-keywords-2015-2015.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() {}
main
identifier_name
edition-keywords-2015-2015.rs
// Copyright 2018 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 ...
mod one_async { produces_async! {} // OK } mod two_async { produces_async_raw! {} // OK } fn main() {}
{ let mut async = 1; // OK let mut r#async = 1; // OK r#async = consumes_async!(async); // OK // r#async = consumes_async!(r#async); // ERROR, not a match // r#async = consumes_async_raw!(async); // ERROR, not a match r#async = consumes_async_raw!(r#async); // OK if passes_ident!(async) ==...
identifier_body
edition-keywords-2015-2015.rs
// Copyright 2018 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 ...
// OK one_async::async(); // OK one_async::r#async(); // OK two_async::async(); // OK two_async::r#async(); // OK } mod one_async { produces_async! {} // OK } mod two_async { produces_async_raw! {} // OK } fn main() {}
{}
conditional_block
edition-keywords-2015-2015.rs
// Copyright 2018 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
#![allow(unused_mut)] #![allow(unused_assignments)] #![allow(unused_variables)] // edition:2015 // aux-build:edition-kw-macro-2015.rs #[macro_use] extern crate edition_kw_macro_2015; pub fn check_async() { let mut async = 1; // OK let mut r#async = 1; // OK r#async = consumes_async!(async); // OK //...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
font_metrics.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/. */ //! Access to font metrics from the style system. #![deny(missing_docs)] use Atom; use app_units::Au; use euclid...
{ /// The x-height of the font. pub x_height: Au, /// The zero advance. pub zero_advance_measure: Size2D<Au>, } /// The result for querying font metrics for a given font family. #[derive(Debug, PartialEq, Clone)] pub enum FontMetricsQueryResult { /// The font is available, but we may or may not ha...
FontMetrics
identifier_name
font_metrics.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/. */ //! Access to font metrics from the style system. #![deny(missing_docs)] use Atom; use app_units::Au; use euclid...
/// A trait used to represent something capable of providing us font metrics. pub trait FontMetricsProvider: Send + Sync + fmt::Debug { /// Obtain the metrics for given font family. /// /// TODO: We could make this take the full list, I guess, and save a few /// virtual calls in the case we are repeated...
}
random_line_split
workqueue.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! A work queue for scheduling units of work across threads in a fork-join fashion. //! //! Data associated with ...
<QueueData:'static, WorkData:'static + Send> { /// Tells the worker to start work. Start(Worker<WorkUnit<QueueData, WorkData>>, *mut AtomicUsize, *const QueueData), /// Tells the worker to stop. It can be restarted again with a `WorkerMsg::Start`. Stop, /// Tells the worker to measure the heap size ...
WorkerMsg
identifier_name
workqueue.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! A work queue for scheduling units of work across threads in a fork-join fashion. //! //! Data associated with ...
} } sleep_microseconds(back_off_sleep); back_off_sleep += BACKOFF_INCREMENT_IN_US; i = 0 } else { ...
Ok(WorkerMsg::Exit) => return, Ok(_) => panic!("unexpected message"), _ => {}
random_line_split
poll.rs
use std::fmt; use error::MioResult; use io::IoHandle; use os; use os::token::Token; use os::event; pub struct Poll { selector: os::Selector, events: os::Events } impl Poll { pub fn new() -> MioResult<Poll> { Ok(Poll { selector: try!(os::Selector::new()), events: os::Events:...
} pub struct EventsIterator<'a> { events: &'a os::Events, index: usize } impl<'a> Iterator for EventsIterator<'a> { type Item = event::IoEvent; fn next(&mut self) -> Option<event::IoEvent> { if self.index == self.events.len() { None } else { self.index += 1; ...
{ write!(fmt, "Poll") }
identifier_body
poll.rs
use std::fmt; use error::MioResult; use io::IoHandle; use os; use os::token::Token; use os::event; pub struct Poll { selector: os::Selector, events: os::Events } impl Poll { pub fn
() -> MioResult<Poll> { Ok(Poll { selector: try!(os::Selector::new()), events: os::Events::new() }) } pub fn register<H: IoHandle>(&mut self, io: &H, token: Token, interest: event::Interest, opts: event::PollOpt) -> MioResult<()> { debug!("registering with polle...
new
identifier_name
poll.rs
use std::fmt; use error::MioResult;
use os::event; pub struct Poll { selector: os::Selector, events: os::Events } impl Poll { pub fn new() -> MioResult<Poll> { Ok(Poll { selector: try!(os::Selector::new()), events: os::Events::new() }) } pub fn register<H: IoHandle>(&mut self, io: &H, token: ...
use io::IoHandle; use os; use os::token::Token;
random_line_split
poll.rs
use std::fmt; use error::MioResult; use io::IoHandle; use os; use os::token::Token; use os::event; pub struct Poll { selector: os::Selector, events: os::Events } impl Poll { pub fn new() -> MioResult<Poll> { Ok(Poll { selector: try!(os::Selector::new()), events: os::Events:...
else { self.index += 1; Some(self.events.get(self.index - 1)) } } }
{ None }
conditional_block
mod.rs
//! Contains all of the currently completed standard bots/searchers/AIs. //! //! These are mostly for example purposes, to see how one can create a chess AI. extern crate rand; pub mod minimax; pub mod parallel_minimax; pub mod alphabeta; pub mod jamboree; pub mod iterative_parallel_mvv_lva; use core::piece_move::*;...
(board: Board, _depth: u16) -> BitMove { let moves = board.generate_moves(); moves[rand::random::<usize>() % moves.len()] } } impl Searcher for AlphaBetaSearcher { fn name() -> &'static str { "AlphaBeta Searcher" } fn best_move(board: Board, depth: u16) -> BitMove { let...
best_move
identifier_name
mod.rs
//! Contains all of the currently completed standard bots/searchers/AIs. //! //! These are mostly for example purposes, to see how one can create a chess AI. extern crate rand; pub mod minimax; pub mod parallel_minimax; pub mod alphabeta; pub mod jamboree; pub mod iterative_parallel_mvv_lva; use core::piece_move::*;...
/// Searcher that randomly chooses a move. The fastest, yet dumbest, searcher we have to offer. pub struct RandomBot {} /// Searcher that uses a MiniMax algorithm to search for a best move. pub struct MiniMaxSearcher {} /// Searcher that uses a MiniMax algorithm to search for a best move, but does so in parallel. pub...
struct BoardWrapper<'a> { b: &'a mut Board }
random_line_split
mod.rs
//! Contains all of the currently completed standard bots/searchers/AIs. //! //! These are mostly for example purposes, to see how one can create a chess AI. extern crate rand; pub mod minimax; pub mod parallel_minimax; pub mod alphabeta; pub mod jamboree; pub mod iterative_parallel_mvv_lva; use core::piece_move::*;...
fn best_move(board: Board, depth: u16) -> BitMove { minimax::minimax( &mut board.shallow_clone(), depth).bit_move } } impl Searcher for ParallelMiniMaxSearcher { fn name() -> &'static str { "Parallel Searcher" } fn best_move(board: Board, depth: u16) -> BitMove { parall...
{ "Simple Searcher" }
identifier_body
camera.rs
use cgmath::Ortho; use glium::uniforms::{AsUniformValue, UniformValue}; use transform::Transform; use types::{Scalar, Mat4}; /// Orthogonal 2D Camera. pub struct Camera2D { pub transform: Transform, matrix: Mat4, } impl Camera2D { pub fn new(width: u32, height: u32) -> Camera2D
fn build_matrix(width: u32, height: u32, transform: &Mat4) -> Mat4 { let (w, h) = (width as Scalar, height as Scalar); let ortho = Ortho { left: 0.0, right: w, bottom: 0.0, top: h, near: -1.0, far: 1.0, }; Mat4...
{ let transform = Transform::new(); Camera2D { matrix: Camera2D::build_matrix(width, height, &transform.matrix), transform: transform, } }
identifier_body
camera.rs
use cgmath::Ortho; use glium::uniforms::{AsUniformValue, UniformValue}; use transform::Transform; use types::{Scalar, Mat4}; /// Orthogonal 2D Camera. pub struct Camera2D { pub transform: Transform, matrix: Mat4, } impl Camera2D { pub fn new(width: u32, height: u32) -> Camera2D { let transform =...
}
random_line_split
camera.rs
use cgmath::Ortho; use glium::uniforms::{AsUniformValue, UniformValue}; use transform::Transform; use types::{Scalar, Mat4}; /// Orthogonal 2D Camera. pub struct Camera2D { pub transform: Transform, matrix: Mat4, } impl Camera2D { pub fn
(width: u32, height: u32) -> Camera2D { let transform = Transform::new(); Camera2D { matrix: Camera2D::build_matrix(width, height, &transform.matrix), transform: transform, } } fn build_matrix(width: u32, height: u32, transform: &Mat4) -> Mat4 { let (w, ...
new
identifier_name
touch.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 euclid::point::TypedPoint2D; use euclid::scale_factor::ScaleFactor; use gfx_traits::DevicePixel; use script_tr...
pub fn on_touch_down(&mut self, id: TouchId, point: TypedPoint2D<f32, DevicePixel>) { let point = TouchPoint::new(id, point); self.active_touch_points.push(point); self.state = match self.state { Nothing => WaitingForScript, Touching | Panning => P...
{ TouchHandler { state: Nothing, active_touch_points: Vec::new(), } }
identifier_body
touch.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 euclid::point::TypedPoint2D; use euclid::scale_factor::ScaleFactor; use gfx_traits::DevicePixel; use script_tr...
pub fn on_touch_up(&mut self, id: TouchId, _point: TypedPoint2D<f32, DevicePixel>) -> TouchAction { match self.active_touch_points.iter().position(|t| t.id == id) { Some(i) => { self.active_touch_points.swap_remove(i); } None => { ...
random_line_split
touch.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 euclid::point::TypedPoint2D; use euclid::scale_factor::ScaleFactor; use gfx_traits::DevicePixel; use script_tr...
(&mut self, id: TouchId, point: TypedPoint2D<f32, DevicePixel>) { let point = TouchPoint::new(id, point); self.active_touch_points.push(point); self.state = match self.state { Nothing => WaitingForScript, Touching | Panning => Pinching, Waiti...
on_touch_down
identifier_name
ez_rpc.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // 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, inc...
} } _ => {panic!()} }; return client; } } pub struct EzRpcServer { tcp_listener : ::std::net::TcpListener, } impl EzRpcServer { pub fn new<A: ::std::net::ToSocketAddrs>(bind_address : A) -> ::std::io::Result<EzRpcServer> { let tcp_listener...
{ panic!() }
conditional_block
ez_rpc.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // 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, inc...
; impl Server for EmptyCap { fn dispatch_call(&mut self, _interface_id : u64, _method_id : u16, context : ::capnp::capability::CallContext<::capnp::any_pointer::Reader, ::capnp::any_pointer::Builder>) { context.fail("Attem...
EmptyCap
identifier_name
ez_rpc.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // 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, inc...
} _ => {panic!()} }; return client; } } pub struct EzRpcServer { tcp_listener : ::std::net::TcpListener, } impl EzRpcServer { pub fn new<A: ::std::net::ToSocketAddrs>(bind_address : A) -> ::std::io::Result<EzRpcServer> { let tcp_listener = try!(::std::net:...
payload.get_content().get_as_capability::<T>().unwrap() } _ => { panic!() } }
random_line_split
lib.rs
//! Functionality for working with SIMD registers and instructions. //! //! [Source](https://github.com/huonw/simd), [crates.io](https://crates.io/crates/simd) #![feature(trace_macros, link_llvm_intrinsics, simd_ffi, core)] extern crate simdty; extern crate llvmint; use std::mem; pub use convert::bitcast...
<T: maths::sqrt::Sqrt>(x: T) -> T { x.sqrt() } /// Return a platform-specific approximation to the reciprocal-square /// root of `x`. #[inline] pub fn rsqrt<T: maths::sqrt::RSqrt>(x: T) -> T { x.rsqrt() }
sqrt
identifier_name
lib.rs
//! Functionality for working with SIMD registers and instructions. //! //! [Source](https://github.com/huonw/simd), [crates.io](https://crates.io/crates/simd) #![feature(trace_macros, link_llvm_intrinsics, simd_ffi, core)] extern crate simdty; extern crate llvmint; use std::mem; pub use convert::bitcast...
let vsize = mem::size_of::<Self>(); let esize = mem::size_of::<Self::Item>(); assert!(vsize % esize == 0); vsize / esize } } /// SIMD vectors which can be separated into two SIMD vectors of half /// the size with the same elements. pub unsafe trait HalfVector: Vector { type Hal...
/// Return the number of items in `self`. #[inline(always)] fn count(_: Option<Self>) -> usize {
random_line_split
lib.rs
//! Functionality for working with SIMD registers and instructions. //! //! [Source](https://github.com/huonw/simd), [crates.io](https://crates.io/crates/simd) #![feature(trace_macros, link_llvm_intrinsics, simd_ffi, core)] extern crate simdty; extern crate llvmint; use std::mem; pub use convert::bitcast...
} /// SIMD vectors which can be merged with another of the same type to /// create one of double the length with the same elements. pub unsafe trait DoubleVector: Vector { type Double /*: Vector<Item = Self::Item>*/; /// Concatenate the elements of `self` and `other` into a single /// SIMD vector. fn ...
{ self.split().1 }
identifier_body
to_bits.rs
use malachite_base::num::logic::traits::{BitAccess, SignificantBits}; use malachite_nz::integer::Integer; pub fn to_bits_asc_naive(n: &Integer) -> Vec<bool> { let mut bits = Vec::new(); if *n == 0 { return bits; } for i in 0..n.significant_bits() { bits.push(n.get_bit(i)); } let...
{ let mut bits = Vec::new(); if *n == 0 { return bits; } let significant_bits = n.significant_bits(); let last_bit = n.get_bit(significant_bits - 1); if last_bit != (*n < 0) { bits.push(!last_bit); } for i in (0..significant_bits).rev() { bits.push(n.get_bit(i)); ...
identifier_body
to_bits.rs
use malachite_base::num::logic::traits::{BitAccess, SignificantBits}; use malachite_nz::integer::Integer; pub fn to_bits_asc_naive(n: &Integer) -> Vec<bool> { let mut bits = Vec::new(); if *n == 0 { return bits; } for i in 0..n.significant_bits() { bits.push(n.get_bit(i)); } let...
bits } pub fn to_bits_desc_naive(n: &Integer) -> Vec<bool> { let mut bits = Vec::new(); if *n == 0 { return bits; } let significant_bits = n.significant_bits(); let last_bit = n.get_bit(significant_bits - 1); if last_bit!= (*n < 0) { bits.push(!last_bit); } for i in...
{ bits.push(!last_bit); }
conditional_block
to_bits.rs
use malachite_base::num::logic::traits::{BitAccess, SignificantBits}; use malachite_nz::integer::Integer; pub fn to_bits_asc_naive(n: &Integer) -> Vec<bool> { let mut bits = Vec::new(); if *n == 0 { return bits; } for i in 0..n.significant_bits() { bits.push(n.get_bit(i)); } let...
(n: &Integer) -> Vec<bool> { let mut bits = Vec::new(); if *n == 0 { return bits; } let significant_bits = n.significant_bits(); let last_bit = n.get_bit(significant_bits - 1); if last_bit!= (*n < 0) { bits.push(!last_bit); } for i in (0..significant_bits).rev() { ...
to_bits_desc_naive
identifier_name
to_bits.rs
use malachite_base::num::logic::traits::{BitAccess, SignificantBits}; use malachite_nz::integer::Integer; pub fn to_bits_asc_naive(n: &Integer) -> Vec<bool> { let mut bits = Vec::new(); if *n == 0 { return bits; } for i in 0..n.significant_bits() { bits.push(n.get_bit(i)); } let...
pub fn to_bits_desc_naive(n: &Integer) -> Vec<bool> { let mut bits = Vec::new(); if *n == 0 { return bits; } let significant_bits = n.significant_bits(); let last_bit = n.get_bit(significant_bits - 1); if last_bit!= (*n < 0) { bits.push(!last_bit); } for i in (0..signific...
random_line_split
main.rs
//! Requires the 'framework' feature flag be enabled in your project's //! `Cargo.toml`. //! //! This can be enabled by specifying the feature in the dependency section: //! //! ```toml //! [dependencies.serenity] //! git = "https://github.com/serenity-rs/serenity.git" //! features = ["framework", "standard_framework"]...
} #[group] #[commands(multiply, ping, quit)] struct General; #[tokio::main] async fn main() { // This will load the environment variables located at `./.env`, relative to // the CWD. See `./.env.example` for an example on how to structure this. dotenv::dotenv().expect("Failed to load.env file"); // ...
{ info!("Resumed"); }
identifier_body
main.rs
//! Requires the 'framework' feature flag be enabled in your project's //! `Cargo.toml`. //! //! This can be enabled by specifying the feature in the dependency section: //! //! ```toml //! [dependencies.serenity] //! git = "https://github.com/serenity-rs/serenity.git" //! features = ["framework", "standard_framework"]...
(&self, _: Context, ready: Ready) { info!("Connected as {}", ready.user.name); } async fn resume(&self, _: Context, _: ResumedEvent) { info!("Resumed"); } } #[group] #[commands(multiply, ping, quit)] struct General; #[tokio::main] async fn main() { // This will load the environment va...
ready
identifier_name
main.rs
//! Requires the 'framework' feature flag be enabled in your project's //! `Cargo.toml`. //! //! This can be enabled by specifying the feature in the dependency section: //! //! ```toml //! [dependencies.serenity] //! git = "https://github.com/serenity-rs/serenity.git"
use commands::{math::*, meta::*, owner::*}; use serenity::{ async_trait, client::bridge::gateway::ShardManager, framework::{standard::macros::group, StandardFramework}, http::Http, model::{event::ResumedEvent, gateway::Ready}, prelude::*, }; use tracing::{error, info}; use tracing_subscriber::{...
//! features = ["framework", "standard_framework"] //! ``` mod commands; use std::{collections::HashSet, env, sync::Arc};
random_line_split