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
buffer.rs
/* gl/src/gl_wrapper/buffer.rs, 2017-07-19 Copyright (c) 2017 Juuso Tuononen This file is licensed under Apache License, Version 2.0 or MIT License */ //! Send data to GPU. use super::gl_raw; use self::gl_raw::types::*; use std::mem::size_of; use std::os::raw::c_void; use std::ptr; /// Send static data to GPU...
} } /// Send multiple buffers of data to GPU. /// /// OpenGL 3.3 version of this struct is implemented /// with OpenGL's Vertex Array Object. /// /// OpenGL ES 2.0 does not support Vertex Array Objects, so vertex /// attributes are set for every buffer /// when `draw` method is called if using OpenGL ES version of...
fn drop(&mut self) { unsafe { gl_raw::DeleteBuffers(1, &self.id); }
random_line_split
player_score.rs
extern crate serialize; use self::serialize::json; use error; use json_helpers::{find, get_float, get_i32, get_object, get_string}; // Public #[deriving(Eq, PartialEq, Show)] pub struct PlayerScore { pub added_datetime: String, pub owner_id: i32, pub account_id: i32, pub capital_ships: i32, pub ...
try!(get_i32(try!(find(map, "inventoryscore")))), priority_points: try!(get_i32(try!(find(map, "prioritypoints")))), turn: try!(get_i32(try!(find(map, "turn")))), percent: try!(get_float(try!(find(map, "percent")), 2u)), id: try...
{ let map = try!(get_object(json)); Ok(PlayerScore { added_datetime: try!(get_string(try!(find(map, "dateadded")))), owner_id: try!(get_i32(try!(find(map, "ownerid")))), account_id: try!(get_i32(try!(find(map, "accountid")))), capital_ships: ...
identifier_body
player_score.rs
extern crate serialize; use self::serialize::json; use error; use json_helpers::{find, get_float, get_i32, get_object, get_string}; // Public #[deriving(Eq, PartialEq, Show)] pub struct PlayerScore { pub added_datetime: String, pub owner_id: i32, pub account_id: i32, pub capital_ships: i32, pub ...
(json: &json::Json) -> Result<PlayerScore, error::Error> { let map = try!(get_object(json)); Ok(PlayerScore { added_datetime: try!(get_string(try!(find(map, "dateadded")))), owner_id: try!(get_i32(try!(find(map, "ownerid")))), account_id: try!(get_i32(...
build
identifier_name
player_score.rs
extern crate serialize; use self::serialize::json; use error; use json_helpers::{find, get_float, get_i32, get_object, get_string}; // Public #[deriving(Eq, PartialEq, Show)] pub struct PlayerScore { pub added_datetime: String, pub owner_id: i32, pub account_id: i32, pub capital_ships: i32, pub ...
\"shipchange\": 1,\ \"freighterchange\": 0,\ \"planetchange\": 4,\ \"starbasechange\": 0,\ \"militarychange\": 1099,\ \"inventorychange\": 50,\ \"prioritypointchange\": 0,\ \"percentchange\": -0.73\ }"; let r...
random_line_split
main.rs
extern crate itertools; extern crate num_traits; extern crate smallvec; extern crate rand; pub mod board; pub mod player; use std::time::Duration; use board::{Board, GameState}; use player::Player; fn main() { let mut b = Board::generate(10, 6); let dur = Duration::new(5, 0); let players: [Box<Player>; ...
, GameState::Won => { println!("Won! ({})", b.active()); break; }, } } }
{ println!("Drawn."); break; }
conditional_block
main.rs
extern crate itertools; extern crate num_traits; extern crate smallvec; extern crate rand; pub mod board; pub mod player; use std::time::Duration; use board::{Board, GameState}; use player::Player; fn main()
println!("Won! ({})", b.active()); break; }, } } }
{ let mut b = Board::generate(10, 6); let dur = Duration::new(5, 0); let players: [Box<Player>; 2] = [ Box::new(player::HumanPlayer), //Box::new(player::MCTSPlayer::new(dur)), Box::new(player::MCTSPlayer::new(dur)), ]; println!("{}", b); for p in players.iter().cycle() { ...
identifier_body
main.rs
extern crate itertools; extern crate num_traits; extern crate smallvec; extern crate rand; pub mod board; pub mod player; use std::time::Duration; use board::{Board, GameState}; use player::Player; fn main() { let mut b = Board::generate(10, 6); let dur = Duration::new(5, 0); let players: [Box<Player>; ...
} }
random_line_split
main.rs
extern crate itertools; extern crate num_traits; extern crate smallvec; extern crate rand; pub mod board; pub mod player; use std::time::Duration; use board::{Board, GameState}; use player::Player; fn
() { let mut b = Board::generate(10, 6); let dur = Duration::new(5, 0); let players: [Box<Player>; 2] = [ Box::new(player::HumanPlayer), //Box::new(player::MCTSPlayer::new(dur)), Box::new(player::MCTSPlayer::new(dur)), ]; println!("{}", b); for p in players.iter().cycle()...
main
identifier_name
lib.rs
// ================================================================= // // * WARNING * // // This file is generated! // // Changes made to this file will be overwritten. If changes are // required to the generated code, the service_crategen project // must be updated to g...
)] //! <p>Amazon EMR is a web service that makes it easier to process large amounts of data efficiently. Amazon EMR uses Hadoop processing combined with several AWS services to do tasks such as web indexing, data mining, log file analysis, machine learning, scientific simulation, and data warehouse management.</p> //! ...
random_line_split
mod.rs
//! System bindings for the Fortanix SGX platform //! //! This module contains the facade (aka platform-specific) implementations of //! OS level functionality for Fortanix SGX. #![deny(unsafe_op_in_unsafe_fn)] use crate::io::ErrorKind; use crate::os::raw::c_char; use crate::sync::atomic::{AtomicBool, Ordering}; pub ...
() -> u64 { unsafe { let mut ret: u64 = 0; for _ in 0..10 { if crate::arch::x86_64::_rdrand64_step(&mut ret) == 1 { return ret; } } rtabort!("Failed to obtain random data"); } } } pub fn hashmap_rand...
rdrand64
identifier_name
mod.rs
//! System bindings for the Fortanix SGX platform //! //! This module contains the facade (aka platform-specific) implementations of //! OS level functionality for Fortanix SGX. #![deny(unsafe_op_in_unsafe_fn)] use crate::io::ErrorKind; use crate::os::raw::c_char; use crate::sync::atomic::{AtomicBool, Ordering}; pub ...
else if code == Error::InvalidData as _ { ErrorKind::InvalidData } else if code == Error::TimedOut as _ { ErrorKind::TimedOut } else if code == Error::WriteZero as _ { ErrorKind::WriteZero } else if code == Error::Interrupted as _ { ErrorKind::Interrupted } else if code ...
{ ErrorKind::InvalidInput }
conditional_block
mod.rs
//! System bindings for the Fortanix SGX platform //! //! This module contains the facade (aka platform-specific) implementations of //! OS level functionality for Fortanix SGX. #![deny(unsafe_op_in_unsafe_fn)] use crate::io::ErrorKind; use crate::os::raw::c_char; use crate::sync::atomic::{AtomicBool, Ordering}; pub ...
}
fn try_into_inner(self) -> Result<Inner, Self>;
random_line_split
mod.rs
//! System bindings for the Fortanix SGX platform //! //! This module contains the facade (aka platform-specific) implementations of //! OS level functionality for Fortanix SGX. #![deny(unsafe_op_in_unsafe_fn)] use crate::io::ErrorKind; use crate::os::raw::c_char; use crate::sync::atomic::{AtomicBool, Ordering}; pub ...
} pub fn hashmap_random_keys() -> (u64, u64) { (self::rand::rdrand64(), self::rand::rdrand64()) } pub use crate::sys_common::{AsInner, FromInner, IntoInner}; pub trait TryIntoInner<Inner>: Sized { fn try_into_inner(self) -> Result<Inner, Self>; }
{ unsafe { let mut ret: u64 = 0; for _ in 0..10 { if crate::arch::x86_64::_rdrand64_step(&mut ret) == 1 { return ret; } } rtabort!("Failed to obtain random data"); } }
identifier_body
constellation_msg.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/. */ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling...
{ Initial, Resize, } #[derive(PartialEq, Eq, Copy, Clone, Debug, Deserialize, Serialize)] pub enum KeyState { Pressed, Released, Repeated, } //N.B. Based on the glutin key enum #[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize, HeapSizeOf)] pub enum Key { Space, Apostroph...
WindowSizeType
identifier_name
constellation_msg.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/. */ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling...
/// a namespace for the constellation thread, and also one for every script thread. /// This allows pipeline IDs to be generated by any of those threads without conflicting /// with pipeline IDs created by other script threads or the constellation. The /// constellation is the only code that is responsible for creating...
/// generate the pipeline ID from an iframe element (this simplifies a lot of other /// code that makes use of pipeline IDs). /// /// To achieve this, each pipeline index belongs to a particular namespace. There is
random_line_split
weldr.rs
#[macro_use] extern crate log; extern crate env_logger; extern crate hyper; extern crate weldr; extern crate clap; extern crate tokio_core; extern crate net2; use std::io; use std::net::SocketAddr; use clap::{Arg, App, SubCommand}; use net2::TcpBuilder; use net2::unix::UnixTcpBuilderExt; use tokio_core::reactor::{Co...
() { env_logger::init().expect("Failed to start logger"); let matches = App::new("weldr") .arg( Arg::with_name("admin-ip") .long("admin-ip") .value_name("admin-ip") .takes_value(true) .help( "admin ip and port us...
main
identifier_name
weldr.rs
#[macro_use] extern crate log; extern crate env_logger; extern crate hyper; extern crate weldr; extern crate clap; extern crate tokio_core; extern crate net2; use std::io; use std::net::SocketAddr; use clap::{Arg, App, SubCommand}; use net2::TcpBuilder; use net2::unix::UnixTcpBuilderExt; use tokio_core::reactor::{Co...
Arg::with_name("admin-ip") .long("admin-ip") .value_name("admin-ip") .takes_value(true) .help( "admin ip and port used to issue commands to cluster. default: 0.0.0.0:8687", ), ) .arg( A...
env_logger::init().expect("Failed to start logger"); let matches = App::new("weldr") .arg(
random_line_split
weldr.rs
#[macro_use] extern crate log; extern crate env_logger; extern crate hyper; extern crate weldr; extern crate clap; extern crate tokio_core; extern crate net2; use std::io; use std::net::SocketAddr; use clap::{Arg, App, SubCommand}; use net2::TcpBuilder; use net2::unix::UnixTcpBuilderExt; use tokio_core::reactor::{Co...
else { let mut manager = manager::Manager::new(); manager.listen(internal_addr, handle.clone()); manager.start_workers(5).expect("Failed to start manager"); let health = BackendHealth::new(); let admin_ip = matches.value_of("worker").unwrap_or("0.0.0.0:8687"); let admi...
{ let id = matches.value_of("id").unwrap(); debug!("Spawned worker {}", id); let _result = worker::subscribe(internal_addr, handle, pool.clone()); let listener = setup_listener(ip, &core.handle()).expect("Failed to setup listener"); //weldr::proxy::run(ip, pool, core).expect("Fa...
conditional_block
weldr.rs
#[macro_use] extern crate log; extern crate env_logger; extern crate hyper; extern crate weldr; extern crate clap; extern crate tokio_core; extern crate net2; use std::io; use std::net::SocketAddr; use clap::{Arg, App, SubCommand}; use net2::TcpBuilder; use net2::unix::UnixTcpBuilderExt; use tokio_core::reactor::{Co...
{ let listener = TcpBuilder::new_v4()?; listener.reuse_address(true)?; listener.reuse_port(true)?; let listener = listener.bind(&addr)?; let listener = listener.listen(128)?; let listener = TcpListener::from_listener(listener, &addr, &handle)?; Ok(listener) }
identifier_body
calculator.rs
//! # Simple 4-function calculator //! //! This demonstrates usage of Peresil, and also shows how you can //! write a recursive-descent parser that handles left-associative //! operators. //! //! For an extra wrinkle, input numbers must be integers in the range //! [0, 31]. This allows an opportunity to show how errors...
#[test] fn add_two_numbers() { use Expression::*; assert_eq!(parse("1+2"), Ok(Add(n(1), n(2)))); } #[test] fn add_three_numbers() { use Expression::*; assert_eq!(parse("3+4+5"), Ok(Add(Box::new(Add(n(3), n(4))), n(5)))); } #[test] fn subtract_two_numbers() { use Expression::*; assert_eq!(par...
{ use Expression::*; assert_eq!(parse("1"), Ok(Num(1))); }
identifier_body
calculator.rs
//! # Simple 4-function calculator //! //! This demonstrates usage of Peresil, and also shows how you can //! write a recursive-descent parser that handles left-associative //! operators. //! //! For an extra wrinkle, input numbers must be integers in the range //! [0, 31]. This allows an opportunity to show how errors...
}; let (pt, v) = try_parse!(r.map_err(|_| Error::ExpectedNumber)); let num = v.parse().unwrap(); // Here's where we can raise our own parsing errors. Note that we // kept the point where the number started, in order to give an // accurate error position. if num > 31 { peresil::Pro...
} else { pt.consume_to(Some(digits))
random_line_split
calculator.rs
//! # Simple 4-function calculator //! //! This demonstrates usage of Peresil, and also shows how you can //! write a recursive-descent parser that handles left-associative //! operators. //! //! For an extra wrinkle, input numbers must be integers in the range //! [0, 31]. This allows an opportunity to show how errors...
() { assert_eq!(parse("2*3*4").unwrap().evaluate(), 24); } #[test] fn division_divides() { assert_eq!(parse("9/3/3").unwrap().evaluate(), 1); } #[test] fn all_operators_together() { assert_eq!(parse("3+2-2*9/3").unwrap().evaluate(), -1); } #[test] fn failure_not_a_number() { assert_eq!(parse("cow"), ...
multiplication_multiplies
identifier_name
value_prop_tests.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::values::{prop::layout_and_value_strategy, Value}; use move_core_types::value::MoveValue; use proptest::prelude::*;
let value_deserialized = Value::simple_deserialize(&blob, &layout).expect("must deserialize"); assert!(value.equals(&value_deserialized).unwrap()); let move_value = value.as_move_value(&layout); let blob2 = move_value.simple_serialize().expect("must serialize"); assert_eq!(blob...
proptest! { #[test] fn serializer_round_trip((layout, value) in layout_and_value_strategy()) { let blob = value.simple_serialize(&layout).expect("must serialize");
random_line_split
borrowck-closures-two-mut.rs
// Copyright 2017 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 d() { let mut x = 3; let c1 = to_fn_mut(|| x = 5); let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) //~^ ERROR cannot borrow `x` as mutable more than once //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } fn g() { struct Foo { ...
{ let mut x = 3; let c1 = to_fn_mut(|| x = 5); let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); }
identifier_body
borrowck-closures-two-mut.rs
// Copyright 2017 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 mut x = 3; let c1 = to_fn_mut(|| x = 5); let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) //~^ ERROR cannot borrow `x` as mutable more than once //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } fn g() { struct Foo { ...
d
identifier_name
borrowck-closures-two-mut.rs
// Copyright 2017 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 mut x = 3; let c1 = to_fn_mut(|| x = 5); let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once //~| ERROR cannot borrow `x` as mutable more than once drop((c1, c2)); } fn d() { let mut x = 3; let c1 = to_fn_mut(|| x = 5); let c2 = to_fn_mut(|| { l...
fn c() {
random_line_split
static-methods-in-traits.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 ...
() -> usize { 5 } } } pub fn main() { let x: isize = a::Foo::foo(); let y: usize = a::Foo::foo(); assert_eq!(x, 3); assert_eq!(y, 5); }
foo
identifier_name
static-methods-in-traits.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 main() { let x: isize = a::Foo::foo(); let y: usize = a::Foo::foo(); assert_eq!(x, 3); assert_eq!(y, 5); }
{ 5 }
identifier_body
static-methods-in-traits.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 ...
}
let y: usize = a::Foo::foo(); assert_eq!(x, 3); assert_eq!(y, 5);
random_line_split
mkuutils.rs
#![feature(exit_status)] use std::env; use std::fs::File; use std::io::{Read, Write}; fn main()
util_map.push_str("map.insert(\"sha256sum\", hashsum::uumain);\n"); util_map.push_str("map.insert(\"sha384sum\", hashsum::uumain);\n"); util_map.push_str("map.insert(\"sha512sum\", hashsum::uumain);\n"); hashsum = true; } ...
{ let args : Vec<String> = env::args().collect(); if args.len() < 3 { println!("usage: mkuutils <outfile> <crates>"); env::set_exit_status(1); return; } let mut crates = String::new(); let mut util_map = String::new(); let mut hashsum = false; for prog in args[2..].i...
identifier_body
mkuutils.rs
#![feature(exit_status)] use std::env; use std::fs::File; use std::io::{Read, Write}; fn
() { let args : Vec<String> = env::args().collect(); if args.len() < 3 { println!("usage: mkuutils <outfile> <crates>"); env::set_exit_status(1); return; } let mut crates = String::new(); let mut util_map = String::new(); let mut hashsum = false; for prog in args[2.....
main
identifier_name
mkuutils.rs
#![feature(exit_status)] use std::env; use std::fs::File; use std::io::{Read, Write}; fn main() { let args : Vec<String> = env::args().collect(); if args.len() < 3 { println!("usage: mkuutils <outfile> <crates>"); env::set_exit_status(1); return; } let mut crates = String::new...
"hashsum" | "md5sum" | "sha1sum" | "sha224sum" | "sha256sum" | "sha384sum" | "sha512sum" => { if!hashsum { crates.push_str("extern crate hashsum;\n"); util_map.push_str("map.insert(\"hashsum\", hashsum::uumain);\n"); util_map.push_s...
for prog in args[2..].iter() { match &prog[..] {
random_line_split
main.rs
use std::collections::HashMap; use std::hash::Hash; /// Returns the most common element a collection implementing /// `IntoIterator<Item=T>`, where `T` must implement the `Eq` and `Hash` traits /// /// ``` /// let v1 = vec![1,3,6,6,6,6,7,7,12,12,17]; /// println!("{}", mode(v1)); /// ``` fn mode<I>(items: I) -> Vec<I:...
() { let items = vec![1, 2, 3, 1, 2, 4, 2, 6, 3, 3, 1, 3, 6]; println!("{:?}", mode(&items)); } #[test] fn simple_tests() { let v1 = vec![1, 2, 3, 2, 1]; let mut m1 = mode(v1); m1.sort_unstable(); assert_eq!(m1, vec![1, 2]); let v2: &[u64] = &[0xdeadbeef, 0xba5eba11, 0xdeadbeef]; let m...
main
identifier_name
main.rs
use std::collections::HashMap; use std::hash::Hash; /// Returns the most common element a collection implementing /// `IntoIterator<Item=T>`, where `T` must implement the `Eq` and `Hash` traits /// /// ``` /// let v1 = vec![1,3,6,6,6,6,7,7,12,12,17]; /// println!("{}", mode(v1)); /// ``` fn mode<I>(items: I) -> Vec<I:...
#[test] fn simple_tests() { let v1 = vec![1, 2, 3, 2, 1]; let mut m1 = mode(v1); m1.sort_unstable(); assert_eq!(m1, vec![1, 2]); let v2: &[u64] = &[0xdeadbeef, 0xba5eba11, 0xdeadbeef]; let mut m2 = mode(v2.iter().cloned()); m2.sort_unstable(); assert_eq!(m2, vec![0xdeadbeef]); le...
{ let items = vec![1, 2, 3, 1, 2, 4, 2, 6, 3, 3, 1, 3, 6]; println!("{:?}", mode(&items)); }
identifier_body
main.rs
use std::collections::HashMap; use std::hash::Hash; /// Returns the most common element a collection implementing /// `IntoIterator<Item=T>`, where `T` must implement the `Eq` and `Hash` traits /// /// ``` /// let v1 = vec![1,3,6,6,6,6,7,7,12,12,17];
I::Item: Hash + Eq, { // NOTE: Usually, you wouldn't need to explicitly call `into_iter()` before // looping over a type implementing `IntoIterator`. However, we do it here // because we need to call `size_hint()` on the iterator so we can // preallocate the `HashMap`. let items = items.into_ite...
/// println!("{}", mode(v1)); /// ``` fn mode<I>(items: I) -> Vec<I::Item> where I: IntoIterator,
random_line_split
material_mutation_resolvers.rs
use chrono::prelude::*; use async_graphql::{ FieldResult, ID, Context, }; use eyre::{ Context as _, // eyre, // Result }; // use printspool_json_store::Record as _; use printspool_auth::AuthContext; use printspool_json_store::Record; use crate::{FdmFilament, MaterialTypeGQL, material::{ ...
}; material.update(db).await?; for hooks_provider in material_hooks.iter() { hooks_provider.after_update( &material.id ).await?; } Ok(material) } // log the backtrace which is otherwise lo...
{ let config: FdmFilament = serde_json::from_value(input.model.0)?; MaterialConfigEnum::FdmFilament(Box::new(config)) }
conditional_block
material_mutation_resolvers.rs
use chrono::prelude::*; use async_graphql::{ FieldResult, ID, Context, }; use eyre::{ Context as _, // eyre, // Result }; // use printspool_json_store::Record as _; use printspool_auth::AuthContext; use printspool_json_store::Record; use crate::{FdmFilament, MaterialTypeGQL, material::{ ...
<'ctx>( &self, ctx: &'ctx Context<'_>, input: DeleteMaterialInput ) -> FieldResult<Option<printspool_common::Void>> { let db: &crate::Db = ctx.data()?; let auth: &AuthContext = ctx.data()?; auth.authorize_admins_only()?; let DeleteMaterialInput { material_id...
delete_material
identifier_name
material_mutation_resolvers.rs
use chrono::prelude::*; use async_graphql::{ FieldResult, ID, Context, }; use eyre::{ Context as _, // eyre, // Result }; // use printspool_json_store::Record as _; use printspool_auth::AuthContext; use printspool_json_store::Record; use crate::{FdmFilament, MaterialTypeGQL, material::{ ...
material.insert(db).await?; Ok(material) } #[instrument(skip(self, ctx))] async fn update_material<'ctx>( &self, ctx: &'ctx Context<'_>, input: UpdateMaterialInput, ) -> FieldResult<Material> { let db: &crate::Db = ctx.data()?; let auth: &AuthCo...
deleted_at: None, config, };
random_line_split
triangle.rs
extern mod gl; extern mod glfw; extern mod sgl; use sgl::vertex_buffer::*; use sgl::vertex_array::*; use sgl::shader::*; use sgl::shader_program::*; #[start] fn start(argc: int, argv: **u8, crate_map: *u8) -> int { // Run GLFW on the main thread std::rt::start_on_main_thread(argc, argv, crate_map, main) } fn ...
// Swap buffers window.swap_buffers(); } } }
random_line_split
triangle.rs
extern mod gl; extern mod glfw; extern mod sgl; use sgl::vertex_buffer::*; use sgl::vertex_array::*; use sgl::shader::*; use sgl::shader_program::*; #[start] fn start(argc: int, argv: **u8, crate_map: *u8) -> int { // Run GLFW on the main thread std::rt::start_on_main_thread(argc, argv, crate_map, main) } fn ...
// Load the OpenGL function pointers gl::load_with(glfw::get_proc_address); // Create Vertex Array Object // Create a Vertex Buffer Object and copy the vertex data to it let vbo = VertexBuffer::new(); vbo.set_buffer_data(vertices, ...
{ static vertices: [gl::types::GLfloat, ..6] = [ -0.5, -0.5, 0.5, -0.5, -0.5, 0.5 ]; do glfw::set_error_callback |_, description| { printfln!("GLFW Error: %s", description); } do glfw::start { // Choose a GL profile that is compatible with OS X 10.7+ glf...
identifier_body
triangle.rs
extern mod gl; extern mod glfw; extern mod sgl; use sgl::vertex_buffer::*; use sgl::vertex_array::*; use sgl::shader::*; use sgl::shader_program::*; #[start] fn start(argc: int, argv: **u8, crate_map: *u8) -> int { // Run GLFW on the main thread std::rt::start_on_main_thread(argc, argv, crate_map, main) } fn
() { static vertices: [gl::types::GLfloat,..6] = [ -0.5, -0.5, 0.5, -0.5, -0.5, 0.5 ]; do glfw::set_error_callback |_, description| { printfln!("GLFW Error: %s", description); } do glfw::start { // Choose a GL profile that is compatible with OS X 10.7+ g...
main
identifier_name
os_str.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} #[stable(feature = "rust1", since = "1.0.0")] impl Hash for OsString { #[inline] fn hash<H: Hasher>(&self, state: &mut H) { (&**self).hash(state) } } impl OsStr { /// Coerce directly from a `&str` slice to a `&OsStr` slice. #[stable(feature = "rust1", since = "1.0.0")] pub fn from_s...
{ (&**self).cmp(&**other) }
identifier_body
os_str.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self) -> &OsStr { self } } impl AsOsStr for OsString { fn as_os_str(&self) -> &OsStr { &self[..] } } impl AsOsStr for str { fn as_os_str(&self) -> &OsStr { OsStr::from_str(self) } } impl AsOsStr for String { fn as_os_str(&self) -> &OsStr { OsStr::from_str(&se...
as_os_str
identifier_name
os_str.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
//! //! * In Rust, strings are always valid UTF-8, but may contain zeros. //! //! The types in this module bridge this gap by simultaneously representing Rust //! and platform-native string values, and in particular allowing a Rust string //! to be converted into an "OS" string with no cost. //! //! **Note**: At the mo...
//! //! * On Windows, strings are often arbitrary sequences of non-zero 16-bit //! values, interpreted as UTF-16 when it is valid to do so.
random_line_split
mod.rs
// Copyright 2017 The Xyrosource Team. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except acco...
println!("\ help - Display help quit - Exit the server exit - Exit the server dummy - \ Example command "); }
identifier_body
mod.rs
// Copyright 2017 The Xyrosource Team. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except acco...
impl<T: AsRef<str>> From<T> for InternalCommand { fn from(other: T) -> Self { match other.as_ref().trim() { "" => InternalCommand::Empty, "quit" | "exit" => InternalCommand::Quit, "dummy" => InternalCommand::Entry(Command::Dummy), "help" => InternalCommand::H...
Empty, Invalid, Quit, Help, }
random_line_split
mod.rs
// Copyright 2017 The Xyrosource Team. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except acco...
{ Dummy, } #[derive(Default)] pub struct Console { editor: rustyline::Editor<()>, error: bool, } impl Console { pub fn new() -> Self { Console { editor: rustyline::Editor::<()>::new(), error: false, } } } impl Iterator for Console { type Item = Command...
Command
identifier_name
negamax.rs
//! An implementation of Negamax. //! //! Currently, only the basic alpha-pruning variant is implemented. Further work //! could add advanced features, like history and/or transposition tables. This //! picks randomly among the "best" moves, so that it's non-deterministic. use super::super::interface::*; use rand; use...
} impl<E: Evaluator> Strategy<E::G> for Negamax<E> where <E::G as Game>::S: Clone, <E::G as Game>::M: Copy { fn choose_move(&mut self, s: &<E::G as Game>::S, p: Player) -> Option<<E::G as Game>::M> { let mut best = Evaluation::Worst; let mut moves = [None; 100]; E::G::generat...
{ Negamax { opts: opts, rng: rand::thread_rng(), _eval: PhantomData, } }
identifier_body
negamax.rs
//! An implementation of Negamax. //! //! Currently, only the basic alpha-pruning variant is implemented. Further work //! could add advanced features, like history and/or transposition tables. This //! picks randomly among the "best" moves, so that it's non-deterministic. use super::super::interface::*; use rand; use...
(opts: Options) -> Negamax<E> { Negamax { opts: opts, rng: rand::thread_rng(), _eval: PhantomData, } } } impl<E: Evaluator> Strategy<E::G> for Negamax<E> where <E::G as Game>::S: Clone, <E::G as Game>::M: Copy { fn choose_move(&mut self, s: &<E:...
new
identifier_name
negamax.rs
//! An implementation of Negamax. //! //! Currently, only the basic alpha-pruning variant is implemented. Further work //! could add advanced features, like history and/or transposition tables. This //! picks randomly among the "best" moves, so that it's non-deterministic. use super::super::interface::*; use rand; use...
Some(candidate_moves[self.rng.gen_range(0, candidate_moves.len())]) } } }
None } else {
random_line_split
negamax.rs
//! An implementation of Negamax. //! //! Currently, only the basic alpha-pruning variant is implemented. Further work //! could add advanced features, like history and/or transposition tables. This //! picks randomly among the "best" moves, so that it's non-deterministic. use super::super::interface::*; use rand; use...
} if candidate_moves.is_empty() { None } else { Some(candidate_moves[self.rng.gen_range(0, candidate_moves.len())]) } } }
{ candidate_moves.clear(); candidate_moves.push(m); best = value; }
conditional_block
htmlspanelement.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::HTMLSpanElementBinding; use dom::bindings::js::Root; use dom::bindings::str:...
(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> Root<HTMLSpanElement> { Node::reflect_node(box HTMLSpanElement::new_inherited(local_name, prefix, document), document, HTMLSpanElementBinding::Wrap) ...
new
identifier_name
htmlspanelement.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::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; use html5ever_atoms::LocalName; #[dom_struct] pub struct HTMLSpanElement { htmlelement: HTMLElement } impl HTMLSpanElement { fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLSpanEl...
use dom::bindings::codegen::Bindings::HTMLSpanElementBinding; use dom::bindings::js::Root; use dom::bindings::str::DOMString; use dom::document::Document;
random_line_split
enclaveapi.rs
// Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according ...
}
) -> BOOL;
random_line_split
buffer.rs
use std::cmp; use std::iter; use std::io::{self, Read, BufRead}; pub struct BufReader<R> { inner: R, buf: Vec<u8>, pos: usize, cap: usize, } const INIT_BUFFER_SIZE: usize = 4096; const MAX_BUFFER_SIZE: usize = 8192 + 4096 * 100; impl<R: Read> BufReader<R> { #[inline] pub fn new(rdr: R) -> Buf...
struct SlowRead(u8); impl Read for SlowRead { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { let state = self.0; self.0 += 1; (&match state % 3 { 0 => b"foo", 1 => b"bar", _ => b"baz", }[..]).rea...
use super::BufReader;
random_line_split
buffer.rs
use std::cmp; use std::iter; use std::io::{self, Read, BufRead}; pub struct BufReader<R> { inner: R, buf: Vec<u8>, pos: usize, cap: usize, } const INIT_BUFFER_SIZE: usize = 4096; const MAX_BUFFER_SIZE: usize = 8192 + 4096 * 100; impl<R: Read> BufReader<R> { #[inline] pub fn new(rdr: R) -> Buf...
else { &[] } } #[inline] pub fn into_inner(self) -> R { self.inner } #[inline] pub fn read_into_buf(&mut self) -> io::Result<usize> { self.maybe_reserve(); let v = &mut self.buf; if self.cap < v.capacity() { let nread = try!(self.inner.read(...
{ trace!("slicing {:?}", (self.pos, self.cap, self.buf.len())); &self.buf[self.pos..self.cap] }
conditional_block
buffer.rs
use std::cmp; use std::iter; use std::io::{self, Read, BufRead}; pub struct BufReader<R> { inner: R, buf: Vec<u8>, pos: usize, cap: usize, } const INIT_BUFFER_SIZE: usize = 4096; const MAX_BUFFER_SIZE: usize = 8192 + 4096 * 100; impl<R: Read> BufReader<R> { #[inline] pub fn new(rdr: R) -> Buf...
#[inline] pub fn get_buf(&self) -> &[u8] { if self.pos < self.cap { trace!("slicing {:?}", (self.pos, self.cap, self.buf.len())); &self.buf[self.pos..self.cap] } else { &[] } } #[inline] pub fn into_inner(self) -> R { self.inner } #...
{ &mut self.inner }
identifier_body
buffer.rs
use std::cmp; use std::iter; use std::io::{self, Read, BufRead}; pub struct BufReader<R> { inner: R, buf: Vec<u8>, pos: usize, cap: usize, } const INIT_BUFFER_SIZE: usize = 4096; const MAX_BUFFER_SIZE: usize = 8192 + 4096 * 100; impl<R: Read> BufReader<R> { #[inline] pub fn new(rdr: R) -> Buf...
(u8); impl Read for SlowRead { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { let state = self.0; self.0 += 1; (&match state % 3 { 0 => b"foo", 1 => b"bar", _ => b"baz", }[..]).read(buf) } ...
SlowRead
identifier_name
bare-fn-implements-fn-mut.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(mut x: String, y: String) -> String { x.push_str(&y); x } fn main() { call_f(f); assert_eq!(call_g(g, "foo".to_string(), "bar".to_string()), "foobar"); }
g
identifier_name
bare-fn-implements-fn-mut.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { call_f(f); assert_eq!(call_g(g, "foo".to_string(), "bar".to_string()), "foobar"); }
{ x.push_str(&y); x }
identifier_body
bare-fn-implements-fn-mut.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
assert_eq!(call_g(g, "foo".to_string(), "bar".to_string()), "foobar"); }
random_line_split
deprecation-sanity.rs
// Various checks that deprecation attributes are used correctly mod bogus_attribute_types_1 { #[deprecated(since = "a", note = "a", reason)] //~ ERROR unknown meta item'reason' fn f1() { } #[deprecated(since = "a", note)] //~ ERROR incorrect meta item fn f2() { } #[deprecated(since, note = "a")]...
() { } #[deprecated(since = "a", note(b))] //~ ERROR incorrect meta item fn f5() { } #[deprecated(since(b), note = "a")] //~ ERROR incorrect meta item fn f6() { } #[deprecated(note = b"test")] //~ ERROR literal in `deprecated` value must be a string fn f7() { } #[deprecated("test")] //~ ...
f3
identifier_name
deprecation-sanity.rs
// Various checks that deprecation attributes are used correctly mod bogus_attribute_types_1 { #[deprecated(since = "a", note = "a", reason)] //~ ERROR unknown meta item'reason' fn f1() { } #[deprecated(since = "a", note)] //~ ERROR incorrect meta item fn f2() { } #[deprecated(since, note = "a")]...
fn main() { }
}
random_line_split
input.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 script_traits::MouseButton; use std::path::Path; use std::mem::size_of; use std::mem::transmute; use std::mem...
}; let count = read / size_of::<linux_input_event>(); let events: *mut linux_input_event = unsafe { transmute(buf.as_mut_ptr()) }; let mut tracking_updated = false; for idx in 0..(count as isize) { let event: &linux_input_event = unsafe { transmute(events.offset(idx)...
Err(e) => { println!("Couldn't read device! {}", e); return; }
random_line_split
input.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 script_traits::MouseButton; use std::path::Path; use std::mem::size_of; use std::mem::transmute; use std::mem...
, (EV_ABS, _) => println!("Unknown ABS code {}", event.code), (_, _) => println!("Unknown event type {}", event.evt_type), } } } } pub fn run_input_loop(event_sender: &Sender<WindowEvent>) { let sender = event_sender.clone(); thread::spawn(move || { ...
{ let current_id = slots[current_slot].tracking_id; if current_id != event.value && (current_id == -1 || event.value == -1) { tracking_updated = true; if event.value == -1 { touch_c...
conditional_block
input.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 script_traits::MouseButton; use std::path::Path; use std::mem::size_of; use std::mem::transmute; use std::mem...
{ tracking_id: i32, x: i32, y: i32, } fn dist(x1: i32, x2: i32, y1: i32, y2: i32) -> f32 { let deltaX = (x2 - x1) as f32; let deltaY = (y2 - y1) as f32; (deltaX * deltaX + deltaY * deltaY).sqrt() } fn read_input_device(device_path: &Path, sender: &Sender<WindowEvent>) { ...
InputSlot
identifier_name
input.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 script_traits::MouseButton; use std::path::Path; use std::mem::size_of; use std::mem::transmute; use std::mem...
const EV_SYN: u16 = 0; const EV_ABS: u16 = 3; const EV_REPORT: u16 = 0; const ABS_MT_SLOT: u16 = 0x2F; const ABS_MT_TOUCH_MAJOR: u16 = 0x30; const ABS_MT_TOUCH_MINOR: u16 = 0x31; const ABS_MT_WIDTH_MAJOR: u16 = 0x32; const ABS_MT_WIDTH_MINOR: u16 = 0x33; const ABS_MT_ORIENTATION: u16 = 0x34; const ABS_MT_POSITION_X...
{ ioc(IOC_READ, 'E' as c_int, (0x40 + abs) as i32, size_of::<linux_input_absinfo>() as i32) }
identifier_body
opaque_pointer.rs
#![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] /// <div rustbindgen opaque></div> #[repr(C)] #[repr(align(4))] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct OtherOpaque { pub _bindgen_opaque_blob: u32, } #[test]
assert_eq!( ::std::mem::size_of::<OtherOpaque>(), 4usize, concat!("Size of: ", stringify!(OtherOpaque)) ); assert_eq!( ::std::mem::align_of::<OtherOpaque>(), 4usize, concat!("Alignment of ", stringify!(OtherOpaque)) ); } /// <div rustbindgen opaque></div> ...
fn bindgen_test_layout_OtherOpaque() {
random_line_split
opaque_pointer.rs
#![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] /// <div rustbindgen opaque></div> #[repr(C)] #[repr(align(4))] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct OtherOpaque { pub _bindgen_opaque_blob: u32, } #[test] fn bindgen_test_layout_O...
() { assert_eq!( ::std::mem::size_of::<WithOpaquePtr>(), 16usize, concat!("Size of: ", stringify!(WithOpaquePtr)) ); assert_eq!( ::std::mem::align_of::<WithOpaquePtr>(), 8usize, concat!("Alignment of ", stringify!(WithOpaquePtr)) ); assert_eq!( ...
bindgen_test_layout_WithOpaquePtr
identifier_name
stages.rs
/// A stage number #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] pub struct StageNumber(pub i64); /// Tournament stage type #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "snake_case")] pub enum StageTyp...
{ /// Stage number. pub number: StageNumber, /// Name of this stage. pub name: String, /// Stage type. #[serde(rename = "type")] pub stage_type: StageType, /// Number of participants of this stage. pub size: i64, } /// A list of tournament stages #[derive(Clone, Debug, Eq, Ord, Par...
Stage
identifier_name
stages.rs
/// A stage number #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] pub struct StageNumber(pub i64); /// Tournament stage type #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "snake_case")] pub enum StageTyp...
League, /// Swiss type Swiss, /// Single-elimination type SingleElimination, /// Double-elimination type DoubleElimination, /// Bracket group type BracketGroup, } /// A tournament stage #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] pub...
/// Group type Group, /// League type
random_line_split
htmlscriptelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::ascii::AsciiExt; use dom::attr::Attr; use dom::attr::AttrHelpers; use dom::bindings::codegen::Bindings::...
#[allow(unrooted_must_root)] pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>, creator: ElementCreator) -> Temporary<HTMLScriptElement> { let element = HTMLScriptElement::new_inherited(localName, prefix, document, creator); Node::reflect_node...
{ HTMLScriptElement { htmlelement: HTMLElement::new_inherited(HTMLScriptElementTypeId, localName, prefix, document), already_started: Cell::new(false), parser_inserted: Cell::new(creator == ParserCreated), non_blocking: Cell::new(creator != ParserCreated), ...
identifier_body
htmlscriptelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::ascii::AsciiExt; use dom::attr::Attr; use dom::attr::AttrHelpers; use dom::bindings::codegen::Bindings::...
}
random_line_split
htmlscriptelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::ascii::AsciiExt; use dom::attr::Attr; use dom::attr::AttrHelpers; use dom::bindings::codegen::Bindings::...
(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>, creator: ElementCreator) -> HTMLScriptElement { HTMLScriptElement { htmlelement: HTMLElement::new_inherited(HTMLScriptElementTypeId, localName, prefix, document), already_started: Cell::new(...
new_inherited
identifier_name
closest_points_shape_shape.rs
use na::RealField; use crate::math::{Isometry, Point}; use crate::query::{self, ClosestPoints}; use crate::shape::{Ball, Plane, Segment, Shape}; /// Computes the pair of closest points between two shapes. /// /// Returns `None` if the objects are separated by a distance greater than `max_dist`. pub fn closest_points<...
panic!("No algorithm known to compute a contact point between the given pair of shapes.") } }
{ if let (Some(b1), Some(b2)) = (g1.as_shape::<Ball<N>>(), g2.as_shape::<Ball<N>>()) { let p1 = Point::from(m1.translation.vector); let p2 = Point::from(m2.translation.vector); query::closest_points_ball_ball(&p1, b1, &p2, b2, max_dist) } else if let (Some(s1), Some(s2)) = (g1.as_shape:...
identifier_body
closest_points_shape_shape.rs
use na::RealField; use crate::math::{Isometry, Point}; use crate::query::{self, ClosestPoints}; use crate::shape::{Ball, Plane, Segment, Shape}; /// Computes the pair of closest points between two shapes. /// /// Returns `None` if the objects are separated by a distance greater than `max_dist`. pub fn closest_points<...
else if let Some(c2) = g2.as_composite_shape() { query::closest_points_shape_composite_shape(m1, g1, m2, c2, max_dist) } else { panic!("No algorithm known to compute a contact point between the given pair of shapes.") } }
{ query::closest_points_composite_shape_shape(m1, c1, m2, g2, max_dist) }
conditional_block
closest_points_shape_shape.rs
use na::RealField; use crate::math::{Isometry, Point}; use crate::query::{self, ClosestPoints}; use crate::shape::{Ball, Plane, Segment, Shape}; /// Computes the pair of closest points between two shapes. /// /// Returns `None` if the objects are separated by a distance greater than `max_dist`. pub fn closest_points<...
{ query::closest_points_segment_segment(m1, s1, m2, s2, max_dist) } else if let (Some(p1), Some(s2)) = (g1.as_shape::<Plane<N>>(), g2.as_support_map()) { query::closest_points_plane_support_map(m1, p1, m2, s2, max_dist) } else if let (Some(s1), Some(p2)) = (g1.as_support_map(), g2.as_shape::...
} else if let (Some(s1), Some(s2)) = (g1.as_shape::<Segment<N>>(), g2.as_shape::<Segment<N>>())
random_line_split
closest_points_shape_shape.rs
use na::RealField; use crate::math::{Isometry, Point}; use crate::query::{self, ClosestPoints}; use crate::shape::{Ball, Plane, Segment, Shape}; /// Computes the pair of closest points between two shapes. /// /// Returns `None` if the objects are separated by a distance greater than `max_dist`. pub fn
<N: RealField>( m1: &Isometry<N>, g1: &dyn Shape<N>, m2: &Isometry<N>, g2: &dyn Shape<N>, max_dist: N, ) -> ClosestPoints<N> { if let (Some(b1), Some(b2)) = (g1.as_shape::<Ball<N>>(), g2.as_shape::<Ball<N>>()) { let p1 = Point::from(m1.translation.vector); let p2 = Point::from(m2...
closest_points
identifier_name
lib.rs
#![feature(recover, std_panic, panic_handler, fnbox)] #[macro_use] extern crate lazy_static; pub mod example_group; mod macros; mod util; mod reporter; mod world; mod world_result; mod world_state; mod example; mod example_group_and_block; pub use util::SourceLocation; use std::sync::{Arc, Mutex}; use world::World;...
pub fn describe<F>(description: &str, source_location: SourceLocation, example_group_definition_block: F) where F: Fn(&mut ExampleGroup) + Send +'static { with_world(|world| { world.describe(description, source_location, example_group_definition_block); }); } pub fn descriptor_main() { consuming_...
{ let guard = WORLD.clone(); let mut world_current = guard.lock().unwrap(); let mut world = World::new(); std::mem::swap(&mut world, &mut world_current); blk(world) }
identifier_body
lib.rs
#![feature(recover, std_panic, panic_handler, fnbox)] #[macro_use] extern crate lazy_static; pub mod example_group; mod macros; mod util; mod reporter; mod world; mod world_result; mod world_state; mod example; mod example_group_and_block; pub use util::SourceLocation; use std::sync::{Arc, Mutex}; use world::World;...
}); } pub fn descriptor_main() { consuming_world(|world| world.run()); }
} pub fn describe<F>(description: &str, source_location: SourceLocation, example_group_definition_block: F) where F: Fn(&mut ExampleGroup) + Send + 'static { with_world(|world| { world.describe(description, source_location, example_group_definition_block);
random_line_split
lib.rs
#![feature(recover, std_panic, panic_handler, fnbox)] #[macro_use] extern crate lazy_static; pub mod example_group; mod macros; mod util; mod reporter; mod world; mod world_result; mod world_state; mod example; mod example_group_and_block; pub use util::SourceLocation; use std::sync::{Arc, Mutex}; use world::World;...
<F, T>(blk: F) -> T where F: FnOnce(World) -> T { let guard = WORLD.clone(); let mut world_current = guard.lock().unwrap(); let mut world = World::new(); std::mem::swap(&mut world, &mut world_current); blk(world) } pub fn describe<F>(description: &str, source_location: SourceLocation, example_gr...
consuming_world
identifier_name
main.rs
// Copyright 2015 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...
} gfx_constant_struct!( Locals { blend: i32 = "u_Blend", }); gfx_pipeline!( pipe { vbuf: gfx::VertexBuffer<Vertex> = (), lena: gfx::TextureSampler<[f32; 4]> = "t_Lena", tint: gfx::TextureSampler<[f32; 4]> = "t_Tint", blend: gfx::Global<i32> = "i_Blend", locals: gfx::ConstantBuffer<Locals> = "...
{ Vertex { pos: p, uv: u, } }
identifier_body
main.rs
// Copyright 2015 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...
<R: gfx::Resources>{ bundle: pipe::Bundle<R>, id: u8, } impl<R: gfx::Resources> gfx_app::Application<R> for App<R> { fn new<F: gfx::Factory<R>>(mut factory: F, init: gfx_app::Init<R>) -> Self { use gfx::traits::FactoryExt; let vs = gfx_app::shade::Source { glsl_120: include_byt...
App
identifier_name
main.rs
// Copyright 2015 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...
// data.blend = blend_func.0; // }, // //} fn render<C: gfx::CommandBuffer<R>>(&mut self, encoder: &mut gfx::Encoder<R, C>) { let locals = Locals { blend: self.id as i32 }; encoder.update_constant_buffer(&self.bundle.data.locals, &locals); encoder.c...
random_line_split
parser_test.rs
extern crate l20n; extern crate serde; extern crate serde_json; use std::io::prelude::*; use std::fs::File; use std::io; use std::fs; use l20n::ftl::entries::parser::Parser as EntriesParser; use l20n::ftl::entries::ast::Resource as EntriesResource; fn read_file(path: &str) -> Result<String, io::Error> { let mut ...
let path_len = path.to_str().unwrap().len(); let entries_path = format!("{}.entries.json", &path.to_str().unwrap()[0..(path_len - 4)]); let string = read_file(path.to_str().unwrap()).expect("Failed to read"); let reference_res = read_json_file(&entrie...
{ continue; }
conditional_block
parser_test.rs
extern crate l20n; extern crate serde; extern crate serde_json; use std::io::prelude::*;
use std::fs; use l20n::ftl::entries::parser::Parser as EntriesParser; use l20n::ftl::entries::ast::Resource as EntriesResource; fn read_file(path: &str) -> Result<String, io::Error> { let mut f = try!(File::open(path)); let mut s = String::new(); try!(f.read_to_string(&mut s)); Ok(s) } fn read_json_f...
use std::fs::File; use std::io;
random_line_split
parser_test.rs
extern crate l20n; extern crate serde; extern crate serde_json; use std::io::prelude::*; use std::fs::File; use std::io; use std::fs; use l20n::ftl::entries::parser::Parser as EntriesParser; use l20n::ftl::entries::ast::Resource as EntriesResource; fn read_file(path: &str) -> Result<String, io::Error> { let mut ...
(path: &str) -> Result<EntriesResource, io::Error> { let mut f = try!(File::open(path)); let mut data = String::new(); try!(f.read_to_string(&mut data)); let json = serde_json::from_str(&data).unwrap(); Ok(json) } #[test] fn entries_parser() { let paths = fs::read_dir("./tests/fixtures/parser/...
read_json_file
identifier_name
parser_test.rs
extern crate l20n; extern crate serde; extern crate serde_json; use std::io::prelude::*; use std::fs::File; use std::io; use std::fs; use l20n::ftl::entries::parser::Parser as EntriesParser; use l20n::ftl::entries::ast::Resource as EntriesResource; fn read_file(path: &str) -> Result<String, io::Error> { let mut ...
#[test] fn entries_parser() { let paths = fs::read_dir("./tests/fixtures/parser/ftl/").unwrap(); for p in paths { let path = p.unwrap().path(); if path.extension().unwrap().to_str().unwrap()!= "ftl" || path.to_str().unwrap().contains("errors") { continue; } ...
{ let mut f = try!(File::open(path)); let mut data = String::new(); try!(f.read_to_string(&mut data)); let json = serde_json::from_str(&data).unwrap(); Ok(json) }
identifier_body
too-live-local-in-immovable-gen.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 ...
() { unsafe { static move || { // Tests that the generator transformation finds out that `a` is not live // during the yield expression. Type checking will also compute liveness // and it should also find out that `a` is not live. // The compiler will panic if...
main
identifier_name
too-live-local-in-immovable-gen.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 ...
{ unsafe { static move || { // Tests that the generator transformation finds out that `a` is not live // during the yield expression. Type checking will also compute liveness // and it should also find out that `a` is not live. // The compiler will panic if th...
identifier_body
too-live-local-in-immovable-gen.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // run-pass #![allo...
random_line_split
context_provider.rs
use std::{ cell::{Cell, RefCell}, collections::BTreeMap, rc::Rc, sync::mpsc, }; use dces::prelude::*;
layout::*, localization::Localization, render_object::*, shell::{ShellRequest, WindowRequest}, utils::Point, widget_base::*, }; /// Temporary solution to share dependencies. Will be refactored soon. #[derive(Clone)] pub struct ContextProvider { /// Reference counted cells of render objects....
use super::WindowAdapter; use crate::{ event::*,
random_line_split
context_provider.rs
use std::{ cell::{Cell, RefCell}, collections::BTreeMap, rc::Rc, sync::mpsc, }; use dces::prelude::*; use super::WindowAdapter; use crate::{ event::*, layout::*, localization::Localization, render_object::*, shell::{ShellRequest, WindowRequest}, utils::Point, widget_base::...
( window_sender: mpsc::Sender<WindowRequest>, shell_sender: mpsc::Sender<ShellRequest<WindowAdapter>>, application_name: impl Into<String>, localization: Option<Rc<RefCell<Box<dyn Localization>>>>, ) -> Self { ContextProvider { render_objects: Rc::new(RefCell::new...
new
identifier_name
account_meta.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
<W>(m: &HashMap<util::Address, AccountMeta>, writer: &mut W) -> Result<(), serde_json::Error> where W: Write { serde_json::to_writer(writer, &m.iter().map(|(a, m)| (a.clone().into(), m)).collect::<HashMap<hash::Address, _>>()) } }
write_address_map
identifier_name
account_meta.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
name: String::new(), meta: "{}".to_owned(), uuid: None, } } } impl AccountMeta { /// Read a hash map of Address -> AccountMeta. pub fn read_address_map<R>(reader: R) -> Result<HashMap<util::Address, AccountMeta>, serde_json::Error> where R: Read { serde_json::from_reader(reader).map(|ok: HashMap<hash::...
impl Default for AccountMeta { fn default() -> Self { AccountMeta {
random_line_split
account_meta.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
}
{ serde_json::to_writer(writer, &m.iter().map(|(a, m)| (a.clone().into(), m)).collect::<HashMap<hash::Address, _>>()) }
identifier_body
fallible_impl_from.rs
use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::{is_expn_of, match_panic_def_id, method_chain_args}; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::map::Map;
declare_clippy_lint! { /// ### What it does /// Checks for impls of `From<..>` that contain `panic!()` or `unwrap()` /// /// ### Why is this bad? /// `TryFrom` should be used if there's a possibility of failure. /// /// ### Example /// ```rust /// struct Foo(i32); /// /// //...
use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{sym, Span};
random_line_split
fallible_impl_from.rs
use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::{is_expn_of, match_panic_def_id, method_chain_args}; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::map::Map; use rustc_middle::ty; use r...
(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) { // check for `impl From<???> for..` if_chain! { if let hir::ItemKind::Impl(impl_) = &item.kind; if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(item.def_id); if cx.tcx.is_diagnostic_item(sym::From, i...
check_item
identifier_name
fallible_impl_from.rs
use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::{is_expn_of, match_panic_def_id, method_chain_args}; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::map::Map; use rustc_middle::ty; use r...
} fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[hir::ImplItemRef]) { use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::{Expr, ExprKind, ImplItemKind, QPath}; struct FindPanicUnwrap<'a, 'tcx> { lcx: &'a LateContext<'tcx>, typeck_r...
{ // check for `impl From<???> for ..` if_chain! { if let hir::ItemKind::Impl(impl_) = &item.kind; if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(item.def_id); if cx.tcx.is_diagnostic_item(sym::From, impl_trait_ref.def_id); then { lint...
identifier_body
fallible_impl_from.rs
use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::{is_expn_of, match_panic_def_id, method_chain_args}; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::map::Map; use rustc_middle::ty; use r...
// and check sub-expressions intravisit::walk_expr(self, expr); } fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> { NestedVisitorMap::None } } for impl_item in impl_items { if_chain! { if impl_item.ident.name == sy...
{ let reciever_ty = self.typeck_results.expr_ty(&arglists[0][0]).peel_refs(); if is_type_diagnostic_item(self.lcx, reciever_ty, sym::Option) || is_type_diagnostic_item(self.lcx, reciever_ty, sym::Result) { self.result.push(expr.span...
conditional_block