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 |
|---|---|---|---|---|
htmllinkelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::Parser as CssParser;
use document_loader::LoadType;
use dom::attr::Attr;
use dom::bindings::cell::D... | self.handle_favicon_url(rel.as_ref().unwrap(), &attr.value(), &sizes);
}
},
&atom!("sizes") => {
if is_favicon(&rel) {
if let Some(ref href) = get_attr(self.upcast(), &atom!("href")) {
self.handle_fav... | &atom!("href") => {
if string_is_stylesheet(&rel) {
self.handle_stylesheet_url(&attr.value());
} else if is_favicon(&rel) {
let sizes = get_attr(self.upcast(), &atom!("sizes")); | random_line_split |
htmllinkelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::Parser as CssParser;
use document_loader::LoadType;
use dom::attr::Attr;
use dom::bindings::cell::D... |
impl VirtualMethods for HTMLLinkElement {
fn super_type(&self) -> Option<&VirtualMethods> {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
... | {
match *value {
Some(ref value) => {
value.split(HTML_SPACE_CHARACTERS)
.any(|s| s.eq_ignore_ascii_case("icon") || s.eq_ignore_ascii_case("apple-touch-icon"))
},
None => false,
}
} | identifier_body |
htmllinkelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::Parser as CssParser;
use document_loader::LoadType;
use dom::attr::Attr;
use dom::bindings::cell::D... | (&self, tree_in_doc: bool) {
if let Some(ref s) = self.super_type() {
s.bind_to_tree(tree_in_doc);
}
if tree_in_doc {
let element = self.upcast();
let rel = get_attr(element, &atom!("rel"));
let href = get_attr(element, &atom!("href"));
... | bind_to_tree | identifier_name |
timer_scheduler.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 ipc_channel::ipc::{self, IpcSender};
use script_traits::{TimerEvent, TimerEventRequest, TimerSchedulerMsg};
us... |
}
impl Eq for ScheduledEvent {}
impl PartialEq for ScheduledEvent {
fn eq(&self, other: &ScheduledEvent) -> bool {
self as *const ScheduledEvent == other as *const ScheduledEvent
}
}
impl TimerScheduler {
pub fn start() -> IpcSender<TimerSchedulerMsg> {
let (req_ipc_sender, req_ipc_receiv... | {
Some(self.cmp(other))
} | identifier_body |
timer_scheduler.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 ipc_channel::ipc::{self, IpcSender};
use script_traits::{TimerEvent, TimerEventRequest, TimerSchedulerMsg};
us... | ;
struct ScheduledEvent {
request: TimerEventRequest,
for_time: Instant,
}
impl Ord for ScheduledEvent {
fn cmp(&self, other: &ScheduledEvent) -> cmp::Ordering {
self.for_time.cmp(&other.for_time).reverse()
}
}
impl PartialOrd for ScheduledEvent {
fn partial_cmp(&self, other: &ScheduledEv... | TimerScheduler | identifier_name |
timer_scheduler.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 ipc_channel::ipc::{self, IpcSender};
use script_traits::{TimerEvent, TimerEventRequest, TimerSchedulerMsg};
us... | // We maintain a priority queue of future events, sorted by due time.
let mut scheduled_events = BinaryHeap::<ScheduledEvent>::new();
loop {
let now = Instant::now();
// Dispatch any events whose due time is past
... | random_line_split | |
d3d11on12.rs | // Copyright © 2017 winapi-rs developers
// 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, modi... | ppResources: *mut *mut ID3D11Resource,
NumResources: UINT,
) -> (),
}}
DEFINE_GUID!{IID_ID3D11On12Device,
0x85611e73, 0x70a9, 0x490e, 0x96, 0x14, 0xa9, 0xe3, 0x02, 0x77, 0x79, 0x04} | fn AcquireWrappedResources( | random_line_split |
tree.rs |
use ai;
use ai::value;
use ai::StatelessAI;
use game;
use game::Position2;
pub fn recursive_judgement(
state: &game::State,
my_color: game::Color,
depth: u8,
value_function: value::Simple,
) -> i32 {
if depth == 0 ||!state.victory_state.active() {
value_function.value_of(state, my_color)... | else {
values.min()
}.unwrap()
}
}
pub struct TreeJudgementAI {
search_depth: u8,
value_function: value::Simple,
}
impl TreeJudgementAI {
pub fn new(depth: u8, value_function: value::Simple) -> TreeJudgementAI {
TreeJudgementAI {
search_depth: depth,
... | {
values.max()
} | conditional_block |
tree.rs |
use ai;
use ai::value;
use ai::StatelessAI;
use game;
use game::Position2;
pub fn recursive_judgement(
state: &game::State,
my_color: game::Color,
depth: u8,
value_function: value::Simple,
) -> i32 {
if depth == 0 ||!state.victory_state.active() {
value_function.value_of(state, my_color)... |
}
impl StatelessAI for TreeJudgementAI {
fn action(&self, state: &game::State) -> Position2 {
let my_color = state.current_color;
let graded_actions = state.legal_actions().map(|action| {
let mut new_state = state.clone();
new_state.execute(action);
let value =... | {
TreeJudgementAI {
search_depth: depth,
value_function,
}
} | identifier_body |
tree.rs | use ai;
use ai::value;
use ai::StatelessAI;
use game;
use game::Position2;
pub fn recursive_judgement(
state: &game::State,
my_color: game::Color,
depth: u8,
value_function: value::Simple,
) -> i32 {
if depth == 0 ||!state.victory_state.active() {
value_function.value_of(state, my_color)
... | let value = recursive_judgement(&new_state, my_color, depth - 1, value_function);
value
});
if state.current_color == my_color {
values.max()
} else {
values.min()
}.unwrap()
}
}
pub struct TreeJudgementAI {
search_depth: u8,
... | random_line_split | |
tree.rs |
use ai;
use ai::value;
use ai::StatelessAI;
use game;
use game::Position2;
pub fn | (
state: &game::State,
my_color: game::Color,
depth: u8,
value_function: value::Simple,
) -> i32 {
if depth == 0 ||!state.victory_state.active() {
value_function.value_of(state, my_color)
} else {
let values = state.legal_actions().map(|action| {
let mut new_state = s... | recursive_judgement | identifier_name |
postoffice.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use crate::{agent_error::ImlAgentError, env};
use std::collections::BTreeSet;
use std::iter::FromIterator;
use tokio::{fs, io::AsyncWriteExt};
async fn write_config(r... | () -> Result<BTreeSet<String>, ImlAgentError> {
let conf_file = env::get_var("POSTMAN_CONF_PATH");
Ok(fs::read_to_string(conf_file)
.await?
.lines()
.map(|s| s.to_string())
.collect())
}
pub async fn route_add(mailbox: String) -> Result<(), ImlAgentError> {
let mut conf = read_c... | read_config | identifier_name |
postoffice.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use crate::{agent_error::ImlAgentError, env};
use std::collections::BTreeSet;
use std::iter::FromIterator;
use tokio::{fs, io::AsyncWriteExt};
async fn write_config(r... | {
let mut conf = read_config().await?;
if conf.remove(&mailbox) {
write_config(conf).await
} else {
Ok(())
}
} | identifier_body | |
postoffice.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use crate::{agent_error::ImlAgentError, env};
use std::collections::BTreeSet;
use std::iter::FromIterator;
use tokio::{fs, io::AsyncWriteExt};
async fn write_config(r... | Ok(())
}
async fn read_config() -> Result<BTreeSet<String>, ImlAgentError> {
let conf_file = env::get_var("POSTMAN_CONF_PATH");
Ok(fs::read_to_string(conf_file)
.await?
.lines()
.map(|s| s.to_string())
.collect())
}
pub async fn route_add(mailbox: String) -> Result<(), ImlAgent... | let rt: Vec<String> = Vec::from_iter(routes);
file.write_all(rt.join("\n").as_bytes()).await?;
file.write(b"\n").await?; | random_line_split |
postoffice.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use crate::{agent_error::ImlAgentError, env};
use std::collections::BTreeSet;
use std::iter::FromIterator;
use tokio::{fs, io::AsyncWriteExt};
async fn write_config(r... | else {
Ok(())
}
}
| {
write_config(conf).await
} | conditional_block |
3_16_exercise_springs.rs | // The Nature of Code
// Daniel Shiffman
// http://natureofcode.com
//
// Example 3-16: Exercise Springs
use nannou::prelude::*;
fn main() {
nannou::app(model).update(update).run();
}
// Spring Type describes an anchor point that can connect to "Bob" objects via a spring
// Thank you: http://www.myphysicslab.com/... |
fn drag(&mut self, mx: f32, my: f32) {
if self.dragging {
self.position.x = mx + self.drag_offset.x;
self.position.y = my - self.drag_offset.y;
}
}
}
struct Model {
b1: Bob,
b2: Bob,
b3: Bob,
s1: Spring,
s2: Spring,
s3: Spring,
}
fn model(app: ... | {
self.dragging = false;
} | identifier_body |
3_16_exercise_springs.rs | // The Nature of Code
// Daniel Shiffman
// http://natureofcode.com
//
// Example 3-16: Exercise Springs
use nannou::prelude::*;
fn main() {
nannou::app(model).update(update).run();
}
// Spring Type describes an anchor point that can connect to "Bob" objects via a spring
// Thank you: http://www.myphysicslab.com/... | (&self, draw: &Draw, a: &Bob, b: &Bob) {
draw.line()
.start(a.position)
.end(b.position)
.color(BLACK)
.stroke_weight(2.0);
}
}
struct Bob {
position: Point2,
velocity: Vector2,
acceleration: Vector2,
mass: f32,
damping: f32,
drag_offset: ... | display | identifier_name |
3_16_exercise_springs.rs | // The Nature of Code
// Daniel Shiffman
// http://natureofcode.com | // Example 3-16: Exercise Springs
use nannou::prelude::*;
fn main() {
nannou::app(model).update(update).run();
}
// Spring Type describes an anchor point that can connect to "Bob" objects via a spring
// Thank you: http://www.myphysicslab.com/spring2d.html
struct Spring {
// Rest length and spring constant
... | // | random_line_split |
3_16_exercise_springs.rs | // The Nature of Code
// Daniel Shiffman
// http://natureofcode.com
//
// Example 3-16: Exercise Springs
use nannou::prelude::*;
fn main() {
nannou::app(model).update(update).run();
}
// Spring Type describes an anchor point that can connect to "Bob" objects via a spring
// Thank you: http://www.myphysicslab.com/... |
}
fn stop_dragging(&mut self) {
self.dragging = false;
}
fn drag(&mut self, mx: f32, my: f32) {
if self.dragging {
self.position.x = mx + self.drag_offset.x;
self.position.y = my - self.drag_offset.y;
}
}
}
struct Model {
b1: Bob,
b2: Bob,
... | {
self.dragging = true;
self.drag_offset.x = self.position.x - mx;
self.drag_offset.y = self.position.y - my;
} | conditional_block |
auth.rs | use std::os;
pub enum Credentials {
BasicCredentials(String, String)
}
impl<'r> Credentials {
pub fn aws_access_key_id(&'r self) -> &'r str {
match *self {
BasicCredentials(ref key, _) => key.as_slice()
}
}
pub fn aws_secret_access_key(&'r self) -> &'r str {
match *self {
BasicCredent... |
}
| {
match (os::getenv("AWS_ACCESS_KEY_ID"), os::getenv("AWS_SECRET_ACCESS_KEY")) {
(Some(key), Some(secret)) => Ok(BasicCredentials(key, secret)),
_ => Err("Could not find AWS credentials".to_string())
}
} | identifier_body |
auth.rs | use std::os;
| impl<'r> Credentials {
pub fn aws_access_key_id(&'r self) -> &'r str {
match *self {
BasicCredentials(ref key, _) => key.as_slice()
}
}
pub fn aws_secret_access_key(&'r self) -> &'r str {
match *self {
BasicCredentials(_, ref secret) => secret.as_slice()
}
}
}
pub trait Credentials... | pub enum Credentials {
BasicCredentials(String, String)
}
| random_line_split |
auth.rs | use std::os;
pub enum Credentials {
BasicCredentials(String, String)
}
impl<'r> Credentials {
pub fn aws_access_key_id(&'r self) -> &'r str {
match *self {
BasicCredentials(ref key, _) => key.as_slice()
}
}
pub fn | (&'r self) -> &'r str {
match *self {
BasicCredentials(_, ref secret) => secret.as_slice()
}
}
}
pub trait CredentialsProvider {
fn get_credentials(&mut self) -> Result<Credentials,String>;
}
pub struct DefaultCredentialsProvider;
impl CredentialsProvider for DefaultCredentialsProvider {
fn get_c... | aws_secret_access_key | identifier_name |
checkerboard.rs | use crate::noise_fns::NoiseFn;
/// Noise function that outputs a checkerboard pattern.
///
/// This noise function can take one input, size, and outputs 2<sup>size</sup>-sized
/// blocks of alternating values. The values of these blocks alternate between
/// -1.0 and 1.0.
///
/// This noise function is not very useful... | () -> Self {
Self {
size: 1 << Checkerboard::DEFAULT_SIZE,
}
}
}
// These impl's should be made generic over Point, but there is no higher Point
// type. Keep the code the same anyway.
impl NoiseFn<[f64; 2]> for Checkerboard {
fn get(&self, point: [f64; 2]) -> f64 {
calculat... | default | identifier_name |
checkerboard.rs | use crate::noise_fns::NoiseFn;
/// Noise function that outputs a checkerboard pattern.
///
/// This noise function can take one input, size, and outputs 2<sup>size</sup>-sized
/// blocks of alternating values. The values of these blocks alternate between
/// -1.0 and 1.0.
///
/// This noise function is not very useful... |
}
| {
1.0
} | conditional_block |
checkerboard.rs | use crate::noise_fns::NoiseFn;
/// Noise function that outputs a checkerboard pattern.
///
/// This noise function can take one input, size, and outputs 2<sup>size</sup>-sized
/// blocks of alternating values. The values of these blocks alternate between
/// -1.0 and 1.0.
///
/// This noise function is not very useful... | }
}
}
// These impl's should be made generic over Point, but there is no higher Point
// type. Keep the code the same anyway.
impl NoiseFn<[f64; 2]> for Checkerboard {
fn get(&self, point: [f64; 2]) -> f64 {
calculate_checkerboard(&point, self.size)
}
}
impl NoiseFn<[f64; 3]> for Checkerbo... | fn default() -> Self {
Self {
size: 1 << Checkerboard::DEFAULT_SIZE, | random_line_split |
checkerboard.rs | use crate::noise_fns::NoiseFn;
/// Noise function that outputs a checkerboard pattern.
///
/// This noise function can take one input, size, and outputs 2<sup>size</sup>-sized
/// blocks of alternating values. The values of these blocks alternate between
/// -1.0 and 1.0.
///
/// This noise function is not very useful... | {
let result = point
.iter()
.map(|&a| a.floor() as usize)
.fold(0, |a, b| (a & size) ^ (b & size));
if result > 0 {
-1.0
} else {
1.0
}
} | identifier_body | |
expr-match-struct.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 ... | (&self, other: &mood) -> bool {
((*self) as uint) == ((*other) as uint)
}
fn ne(&self, other: &mood) -> bool {!(*self).eq(other) }
}
fn test_tag() {
let rs = match true { true => { mood::happy } false => { mood::sad } };
assert_eq!(rs, mood::happy);
}
pub fn main() { test_rec(); test_tag(); }
| eq | identifier_name |
expr-match-struct.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() { test_rec(); test_tag(); }
| {
let rs = match true { true => { mood::happy } false => { mood::sad } };
assert_eq!(rs, mood::happy);
} | identifier_body |
expr-match-struct.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(Show)]
enum mood { happy, sad, }
impl PartialEq for mood {
fn eq(&self, other: &mood) -> bool {
((*self) as uint) == ((*other) as uint)
}
fn ne(&self, other: &mood) -> bool {!(*self).eq(other) }
}
fn test_tag() {
let rs = match true { true => { mood::happy } false => { mood::sad } ... | assert_eq!(rs.i, 100);
} | random_line_split |
threads.rs | //! Threading code.
use std::mem;
use remacs_macros::lisp_fn;
use remacs_sys::{current_thread, thread_state};
use buffers::LispBufferRef;
use lisp::{ExternalPtr, LispObject};
use lisp::defsubr;
pub type ThreadStateRef = ExternalPtr<thread_state>;
pub struct ThreadState {}
impl ThreadState {
pub fn current_buf... |
/// Return t if THREAD is alive, or nil if it has exited.
#[lisp_fn]
pub fn thread_alive_p(thread: ThreadStateRef) -> bool {
thread.is_alive()
}
include!(concat!(env!("OUT_DIR"), "/threads_exports.rs"));
| {
thread.name()
} | identifier_body |
threads.rs | //! Threading code.
use std::mem;
use remacs_macros::lisp_fn;
use remacs_sys::{current_thread, thread_state};
use buffers::LispBufferRef;
use lisp::{ExternalPtr, LispObject};
use lisp::defsubr;
pub type ThreadStateRef = ExternalPtr<thread_state>;
pub struct ThreadState {}
impl ThreadState {
pub fn current_buf... | (thread: ThreadStateRef) -> bool {
thread.is_alive()
}
include!(concat!(env!("OUT_DIR"), "/threads_exports.rs"));
| thread_alive_p | identifier_name |
threads.rs | //! Threading code.
use std::mem;
use remacs_macros::lisp_fn;
use remacs_sys::{current_thread, thread_state};
use buffers::LispBufferRef;
use lisp::{ExternalPtr, LispObject};
use lisp::defsubr;
pub type ThreadStateRef = ExternalPtr<thread_state>;
pub struct ThreadState {}
impl ThreadState {
pub fn current_buf... | #[lisp_fn]
pub fn thread_name(thread: ThreadStateRef) -> LispObject {
thread.name()
}
/// Return t if THREAD is alive, or nil if it has exited.
#[lisp_fn]
pub fn thread_alive_p(thread: ThreadStateRef) -> bool {
thread.is_alive()
}
include!(concat!(env!("OUT_DIR"), "/threads_exports.rs")); | }
/// Return the name of the THREAD.
/// The name is the same object that was passed to `make-thread'. | random_line_split |
bad-lit-suffixes.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 ... | () {}
extern
"C"suffix //~ ERROR ABI spec with a suffix is invalid
{}
fn main() {
""suffix; //~ ERROR str literal with a suffix is invalid
b""suffix; //~ ERROR binary str literal with a suffix is invalid
r#""#suffix; //~ ERROR str literal with a suffix is invalid
br#""#suffix; //~ ERROR binary str... | foo | identifier_name |
bad-lit-suffixes.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 ... | 1234i1024; //~ ERROR invalid width `1024` for integer literal
1234f1024; //~ ERROR invalid width `1024` for float literal
1234.5f1024; //~ ERROR invalid width `1024` for float literal
1234suffix; //~ ERROR invalid suffix `suffix` for numeric literal
0b101suffix; //~ ERROR invalid suffix `suffix` fo... | 1234u1024; //~ ERROR invalid width `1024` for integer literal | random_line_split |
bad-lit-suffixes.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 ... |
extern
"C"suffix //~ ERROR ABI spec with a suffix is invalid
{}
fn main() {
""suffix; //~ ERROR str literal with a suffix is invalid
b""suffix; //~ ERROR binary str literal with a suffix is invalid
r#""#suffix; //~ ERROR str literal with a suffix is invalid
br#""#suffix; //~ ERROR binary str lite... | {} | identifier_body |
generic-fn.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 mut x = 62;
let mut y = 63;
let a = 'a';
let mut b = 'b';
let p: Triple = Triple {x: 65, y: 66, z: 67};
let mut q: Triple = Triple {x: 68, y: 69, z: 70};
y = id::<int>(x);
debug!(y);
assert!((x == y));
b = id::<char>(a);
debug!(b);
assert!((a == b));
... | random_line_split | |
generic-fn.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 mut x = 62;
let mut y = 63;
let a = 'a';
let mut b = 'b';
let p: Triple = Triple {x: 65, y: 66, z: 67};
let mut q: Triple = Triple {x: 68, y: 69, z: 70};
y = id::<int>(x);
debug!(y);
assert!((x == y));
b = id::<char>(a);
debug!(b);
assert!((a == b));
q = id::<Tr... | identifier_body | |
generic-fn.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 mut x = 62;
let mut y = 63;
let a = 'a';
let mut b = 'b';
let p: Triple = Triple {x: 65, y: 66, z: 67};
let mut q: Triple = Triple {x: 68, y: 69, z: 70};
y = id::<int>(x);
debug!(y);
assert!((x == y));
b = id::<char>(a);
debug!(b);
assert!((a == b));
q = id::... | main | identifier_name |
physics.rs | //inherited mutability: player is mutable if let is mutable
//todo: Test in ticks
// Implement player acceleration based on ticks between inputs.
// Potentially ticks holding a button and ticks not
// Rotation accel/vel
use game;
use std::cmp::{max, min};
pub use self::collision::collide;
#[deriving(... | p.rotation += PI / 20.0;
}
if p.rot == Right{
p.rotation -= PI / 20.0;
}
}
pub fn accel(p: &mut game::Player){ //mut player:&mut player would allow to play w/ pointer
let (acc, amod) = accel_compute(p.dir, p.accel, p.accel_mod);
if p.velocity >= -0.15 && p.velocity <= 0.15 {
... | pub fn rotate(p: &mut game::Player){
use std::f32::consts::PI;
if p.rot == Left{ | random_line_split |
physics.rs | //inherited mutability: player is mutable if let is mutable
//todo: Test in ticks
// Implement player acceleration based on ticks between inputs.
// Potentially ticks holding a button and ticks not
// Rotation accel/vel
use game;
use std::cmp::{max, min};
pub use self::collision::collide;
#[deriving(... | () {
let a = Vector2::new(1f32, 1f32);
let b = Vector2::new(-1f32, -1f32);
let c = Vector2::new(-1f32, 1f32);
let d = Vector2::new(1f32, -1f32);
assert_eq!(intersect((a, b), (c, d)), Some(Vector2::new(0f32, 0f32)));
}
/// Determines if two Sprites collide, assuming tha... | test_intersect | identifier_name |
physics.rs | //inherited mutability: player is mutable if let is mutable
//todo: Test in ticks
// Implement player acceleration based on ticks between inputs.
// Potentially ticks holding a button and ticks not
// Rotation accel/vel
use game;
use std::cmp::{max, min};
pub use self::collision::collide;
#[deriving(... | let pairs = [(0, 1), (1, 2), (2, 3), (3, 0)]; // which indices form lines we care about?
let &Sprite {x, y, width, height,.. } = a;
let apoints = [
amat.mul_v(&Vector2::new(x, y)),
amat.mul_v(&Vector2::new(x + width, y)),
amat.mul_v(&Vector2::new(x + width, y... | {
// make lists of points making up each sprite, transformed with the
// rotation
let mut arot = a.rot;
let mut brot = b.rot;
// make sure their slopes aren't NaN :(
if arot % (PI / 4.0) == 0.0 {
arot += 0.01;
}
if brot % (PI / 4.0) == 0.0 ... | identifier_body |
physics.rs | //inherited mutability: player is mutable if let is mutable
//todo: Test in ticks
// Implement player acceleration based on ticks between inputs.
// Potentially ticks holding a button and ticks not
// Rotation accel/vel
use game;
use std::cmp::{max, min};
pub use self::collision::collide;
#[deriving(... |
}
}
None
}
#[test]
fn test_intersect() {
let a = Vector2::new(1f32, 1f32);
let b = Vector2::new(-1f32, -1f32);
let c = Vector2::new(-1f32, 1f32);
let d = Vector2::new(1f32, -1f32);
assert_eq!(intersect((a, b), (c, d)), Some(Vector2::ne... | {
debug!("It's within the first line's y values");
if y >= min(b1.y, b2.y) && y <= max(b1.y, b2.y) {
debug!("It's within the second line's y values");
return Some(Vector2::new(x, y));
}
} | conditional_block |
cmp.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | impl Ord for Ordering {
#[inline]
fn lt(&self, other: &Ordering) -> bool { (*self as int) < (*other as int) }
}
macro_rules! totalord_impl(
($t:ty) => {
impl TotalOrd for $t {
#[inline]
fn cmp(&self, other: &$t) -> Ordering {
if *self < *other { Less }
... | }
| random_line_split |
cmp.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
}
/// Trait for equality comparisons where `a == b` and `a!= b` are strict inverses.
pub trait TotalEq {
fn equals(&self, other: &Self) -> bool;
}
macro_rules! totaleq_impl(
($t:ty) => {
impl TotalEq for $t {
#[inline]
fn equals(&self, other: &$t) -> bool { *self == *other }
... | { !self.eq(other) } | identifier_body |
cmp.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (&self, other: &Self) -> bool {!self.eq(other) }
}
/// Trait for equality comparisons where `a == b` and `a!= b` are strict inverses.
pub trait TotalEq {
fn equals(&self, other: &Self) -> bool;
}
macro_rules! totaleq_impl(
($t:ty) => {
impl TotalEq for $t {
#[inline]
fn equals(... | ne | identifier_name |
static-mut-not-pat.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | // except according to those terms.
// Constants (static variables) can be used to match in patterns, but mutable
// statics cannot. This ensures that there's some form of error if this is
// attempted.
static mut a: int = 3;
fn main() {
// If they can't be matched against, then it's possible to capture the same... | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed | random_line_split |
static-mut-not-pat.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
// If they can't be matched against, then it's possible to capture the same
// name as a variable, hence this should be an unreachable pattern situation
// instead of spitting out a custom error about some identifier collisions
// (we should allow shadowing)
match 4i {
a => {} //~ ERROR... | main | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
extern crate gfx_traits;
extern crate ipc_channel;
#[macro_use]
extern crate log;
extern crate malloc_size_of;
#[m... | (&self) -> Option<u64> {
self.time_to_interactive.get()
}
pub fn needs_tti(&self) -> bool {
self.get_tti().is_none()
}
}
impl ProgressiveWebMetric for InteractiveMetrics {
fn get_navigation_start(&self) -> Option<u64> {
self.navigation_start
}
fn set_navigation_start(&... | get_tti | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
extern crate gfx_traits;
extern crate ipc_channel;
#[macro_use]
extern crate log;
extern crate malloc_size_of;
#[m... |
}
fn set_metric<U: ProgressiveWebMetric>(
pwm: &U,
metadata: Option<TimerMetadata>,
metric_type: ProgressiveWebMetricType,
category: ProfilerCategory,
attr: &Cell<Option<u64>>,
metric_time: Option<u64>,
url: &ServoUrl,
) {
let navigation_start = match pwm.get_navigation_start() {
... | {
*self as f64 / 1000000.
} | identifier_body |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
extern crate gfx_traits;
extern crate ipc_channel;
#[macro_use]
extern crate log;
extern crate malloc_size_of;
#[m... | pub fn get_dom_content_loaded(&self) -> Option<u64> {
self.dom_content_loaded.get()
}
pub fn get_main_thread_available(&self) -> Option<u64> {
self.main_thread_available.get()
}
// can set either dlc or tti first, but both must be set to actually calc metric
// when the second ... | if self.main_thread_available.get().is_none() {
self.main_thread_available.set(Some(time));
}
}
| random_line_split |
browsercontext.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::js::{JS, JSRef, Temporary};
use dom::bindings::trace::Traceable;
use dom::bindings::utils::Refl... | (&mut self) {
let win = self.active_window().root();
let page = win.deref().page();
let js_info = page.js_info();
let handler = js_info.as_ref().unwrap().dom_static.windowproxy_handler;
assert!(handler.deref().is_not_null());
let parent = win.deref().reflector().get_jso... | create_window_proxy | identifier_name |
browsercontext.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::js::{JS, JSRef, Temporary};
use dom::bindings::trace::Traceable;
use dom::bindings::utils::Refl... |
pub fn active_window(&self) -> Temporary<Window> {
let doc = self.active_document().root();
Temporary::new(doc.deref().window.clone())
}
pub fn window_proxy(&self) -> *mut JSObject {
assert!(self.window_proxy.deref().is_not_null());
*self.window_proxy
}
fn create_... | {
Temporary::new(self.history[self.active_index].document.clone())
} | identifier_body |
browsercontext.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::js::{JS, JSRef, Temporary};
use dom::bindings::trace::Traceable;
use dom::bindings::utils::Refl... | use dom::window::Window;
use js::jsapi::JSObject;
use js::glue::{WrapperNew, CreateWrapperProxyHandler, ProxyTraps};
use js::rust::with_compartment;
use libc::c_void;
use std::ptr;
#[allow(raw_pointer_deriving)]
#[deriving(Encodable)]
pub struct BrowserContext {
history: Vec<SessionHistoryEntry>,
active_inde... | random_line_split | |
htmlmodelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::HTMLModElementBinding;
use crate::dom::bindings::root::DomRoot;
use ... | {
htmlelement: HTMLElement,
}
impl HTMLModElement {
fn new_inherited(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> HTMLModElement {
HTMLModElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
}
... | HTMLModElement | identifier_name |
htmlmodelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::HTMLModElementBinding;
use crate::dom::bindings::root::DomRoot;
use ... | prefix: Option<Prefix>,
document: &Document,
) -> HTMLModElement {
HTMLModElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
}
}
#[allow(unrooted_must_root)]
pub fn new(
local_name: LocalName,
prefix: Option<Prefi... | random_line_split | |
htmlmodelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::HTMLModElementBinding;
use crate::dom::bindings::root::DomRoot;
use ... |
}
| {
Node::reflect_node(
Box::new(HTMLModElement::new_inherited(local_name, prefix, document)),
document,
HTMLModElementBinding::Wrap,
)
} | identifier_body |
term.rs | use std::time::Duration;
use std::thread;
use std::sync::mpsc;
use std::io::{self, BufRead};
fn main() | let _ = tx.send(());
// let mut line = String::new();
// let stdin = io::stdin();
// for _ in 0..4 {
// let _ = stdin.lock().read_line(&mut line);
// let _ = tx.send(());
// }
} | {
println!("Press enter to wake up the child thread");
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
loop {
println!("Suspending...");
match rx.try_recv() {
Ok(_) => {
println!("Terminating.");
break;
... | identifier_body |
term.rs | use std::time::Duration;
use std::thread;
use std::sync::mpsc;
use std::io::{self, BufRead};
fn main() {
println!("Press enter to wake up the child thread");
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
loop {
println!("Suspending..."); | Ok(_) => {
println!("Terminating.");
break;
}
Err(_) => {
println!("Working...");
thread::sleep(Duration::from_millis(500));
}
}
}
});
thread::slee... | match rx.try_recv() { | random_line_split |
term.rs | use std::time::Duration;
use std::thread;
use std::sync::mpsc;
use std::io::{self, BufRead};
fn | () {
println!("Press enter to wake up the child thread");
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
loop {
println!("Suspending...");
match rx.try_recv() {
Ok(_) => {
println!("Terminating.");
break;
... | main | identifier_name |
term.rs | use std::time::Duration;
use std::thread;
use std::sync::mpsc;
use std::io::{self, BufRead};
fn main() {
println!("Press enter to wake up the child thread");
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
loop {
println!("Suspending...");
match rx.try_recv() {
... |
Err(_) => {
println!("Working...");
thread::sleep(Duration::from_millis(500));
}
}
}
});
thread::sleep(Duration::from_millis(50000));
let _ = tx.send(());
// let mut line = String::new();
// let stdin... | {
println!("Terminating.");
break;
} | conditional_block |
logging.rs | //! Module implementing logging for the application.
//!
//! This includes setting up log filtering given a verbosity value,
//! as well as defining how the logs are being formatted to stderr.
use std::borrow::Cow;
use std::collections::HashMap;
use std::env;
use std::io;
use ansi_term::{Colour, Style};
use isatty;
u... | () -> String {
let utc_now = time::now().to_utc();
let mut logtime = format!("{}", utc_now.rfc3339()); // E.g.: 2012-02-22T14:53:18Z
// Insert millisecond count before the Z.
let millis = utc_now.tm_nsec / NANOS_IN_MILLISEC;
logtime.pop();
format!("{}.{:04}Z", logtime, millis)
}
const NANOS_I... | format_log_time | identifier_name |
logging.rs | //! Module implementing logging for the application.
//!
//! This includes setting up log filtering given a verbosity value,
//! as well as defining how the logs are being formatted to stderr.
use std::borrow::Cow;
use std::collections::HashMap;
use std::env;
use std::io;
use ansi_term::{Colour, Style};
use isatty;
u... |
}
| {
assert_eq!(NEGATIVE_VERBOSITY_LEVELS[0], POSITIVE_VERBOSITY_LEVELS[0]);
assert!(NEGATIVE_VERBOSITY_LEVELS.contains(&FilterLevel::Off),
"Verbosity levels don't allow to turn logging off completely");
} | identifier_body |
logging.rs | //! Module implementing logging for the application.
//!
//! This includes setting up log filtering given a verbosity value,
//! as well as defining how the logs are being formatted to stderr.
use std::borrow::Cow;
use std::collections::HashMap;
use std::env;
use std::io;
use ansi_term::{Colour, Style};
use isatty;
u... | Level::Info.as_usize() => Colour::Green.normal(),
Level::Warning.as_usize() => Colour::Yellow.normal(),
Level::Error.as_usize() => Colour::Red.normal(),
Level::Critical.as_usize() => Colour::Purple.normal(),
};
/// ANSI terminal style for the prefix (timestamp etc.) of a fine lo... |
lazy_static! {
/// Map of log levels to their ANSI terminal styles.
// (Level doesn't implement Hash so it has to be usize).
static ref TTY_LEVEL_STYLES: HashMap<usize, Style> = hashmap!{ | random_line_split |
kvstore.rs | //! test was move from base (it could not compile in base since its trait just change
//! (bidirectional dependency))
//! TODO seems pretty useless : remove??
use keyval::KeyVal;
use node::{Node,NodeID};
use peer::{Peer,Shadow};
use std::cmp::Eq;
use std::cmp::PartialEq;
use keyval::{Attachment,SettableAttachment};
u... | (&self) -> <Self::Shadow as Shadow>::ShadowMode {
self.0.default_auth_mode()
}
fn default_message_mode(&self) -> <Self::Shadow as Shadow>::ShadowMode {
self.0.default_message_mode()
}
fn default_header_mode(&self) -> <Self::Shadow as Shadow>::ShadowMode {
self.0.default_header_mode(... | default_auth_mode | identifier_name |
kvstore.rs | //! test was move from base (it could not compile in base since its trait just change
//! (bidirectional dependency))
//! TODO seems pretty useless : remove??
use keyval::KeyVal;
use node::{Node,NodeID};
use peer::{Peer,Shadow};
use std::cmp::Eq;
use std::cmp::PartialEq; | use rustc_serialize::{Encodable, Encoder, Decoder};
// Testing only nodeK, with key different from id
#[derive(RustcDecodable,RustcEncodable,Debug,Clone)]
struct NodeK2(Node,String);
impl Eq for NodeK2 {}
impl PartialEq<NodeK2> for NodeK2 {
fn eq(&self, other: &NodeK2) -> bool {
other.0 == self.0 && oth... |
use keyval::{Attachment,SettableAttachment};
| random_line_split |
_1_advanced_lighting.rs | #![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
extern crate glfw;
use self::glfw::{Context, Key, Action};
extern crate gl;
use self::gl::types::*;
use std::ptr;
use std::mem;
use std::os::raw::c_void;
use std::ffi::CStr;
use common::{process_events, loadTexture};
use shader::Shader;
use camera::Camera;... |
}
| {
*blinnKeyPressed = false;
} | conditional_block |
_1_advanced_lighting.rs | #![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
extern crate glfw;
use self::glfw::{Context, Key, Action};
extern crate gl;
use self::gl::types::*;
use std::ptr;
use std::mem;
use std::os::raw::c_void;
use std::ffi::CStr;
use common::{process_events, loadTexture};
use shader::Shader;
use camera::Camera;... | glfw.window_hint(glfw::WindowHint::ContextVersion(3, 3));
glfw.window_hint(glfw::WindowHint::OpenGlProfile(glfw::OpenGlProfileHint::Core));
#[cfg(target_os = "macos")]
glfw.window_hint(glfw::WindowHint::OpenGlForwardCompat(true));
// glfw window creation
// --------------------
let (mut win... | {
let mut blinn = false;
let mut blinnKeyPressed = false;
let mut camera = Camera {
Position: Point3::new(0.0, 0.0, 3.0),
..Camera::default()
};
let mut firstMouse = true;
let mut lastX: f32 = SCR_WIDTH as f32 / 2.0;
let mut lastY: f32 = SCR_HEIGHT as f32 / 2.0;
// tim... | identifier_body |
_1_advanced_lighting.rs | #![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
extern crate glfw;
use self::glfw::{Context, Key, Action};
extern crate gl;
use self::gl::types::*;
use std::ptr;
use std::mem;
use std::os::raw::c_void;
use std::ffi::CStr;
use common::{process_events, loadTexture};
use shader::Shader;
use camera::Camera;... | while!window.should_close() {
// per-frame time logic
// --------------------
let currentFrame = glfw.get_time() as f32;
deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame;
// events
// -----
process_events(&events, &mut firstMouse, &mut l... | let lightPos = vec3(0.0, 0.0, 0.0);
// render loop
// ----------- | random_line_split |
_1_advanced_lighting.rs | #![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
extern crate glfw;
use self::glfw::{Context, Key, Action};
extern crate gl;
use self::gl::types::*;
use std::ptr;
use std::mem;
use std::os::raw::c_void;
use std::ffi::CStr;
use common::{process_events, loadTexture};
use shader::Shader;
use camera::Camera;... | (window: &mut glfw::Window, deltaTime: f32, camera: &mut Camera, blinn: &mut bool, blinnKeyPressed: &mut bool) {
if window.get_key(Key::Escape) == Action::Press {
window.set_should_close(true)
}
if window.get_key(Key::W) == Action::Press {
camera.ProcessKeyboard(FORWARD, deltaTime);
}
... | processInput | identifier_name |
unpin_chat_message.rs | use crate::requests::*;
use crate::types::*;
///Use this method to unpin a message in a supergroup or a channel.
/// The bot must be an administrator in the chat for this to work
/// and must have the ‘can_pin_messages’ admin right in the
/// supergroup or ‘can_edit_messages’ admin right in the channel.
#[derive(Debug... | hat_id: ChatRef,
}
impl Request for UnpinChatMessage {
type Type = JsonRequestType<Self>;
type Response = JsonTrueToUnitResponse;
fn serialize(&self) -> Result<HttpRequest, Error> {
Self::Type::serialize(RequestUrl::method("unpinChatMessage"), self)
}
}
impl UnpinChatMessage {
fn new<C>(c... | tMessage {
c | identifier_name |
unpin_chat_message.rs | use crate::requests::*;
use crate::types::*;
///Use this method to unpin a message in a supergroup or a channel.
/// The bot must be an administrator in the chat for this to work
/// and must have the ‘can_pin_messages’ admin right in the
/// supergroup or ‘can_edit_messages’ admin right in the channel.
#[derive(Debug... | } | } | random_line_split |
puntata.rs | use crate::die::Die;
use std::{collections::HashSet, fmt};
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct Puntata {
value: Die,
count: i32,
}
impl Puntata {
pub fn new(count: i32, value: i32) -> Self {
Puntata {
value: Die::new(value),
count,
}
}
pu... | (total_dices: i32, p: Puntata, is_palifico: bool) -> Vec<Puntata> {
let mut v = (p.count..total_dices)
.flat_map(|v| {
let px = p.with_count(v);
least_gt_puntate(px, is_palifico)
})
.collect::<HashSet<_>>();
if!is_palifico || p.is_lama() {
for i in p.count.... | all_gt_puntate | identifier_name |
puntata.rs | use crate::die::Die;
use std::{collections::HashSet, fmt};
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct Puntata {
value: Die,
count: i32,
}
impl Puntata {
pub fn new(count: i32, value: i32) -> Self {
Puntata {
value: Die::new(value),
count,
}
}
pu... |
v.into_iter().collect()
} | v.insert(p); | random_line_split |
puntata.rs | use crate::die::Die;
use std::{collections::HashSet, fmt};
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct Puntata {
value: Die,
count: i32,
}
impl Puntata {
pub fn new(count: i32, value: i32) -> Self {
Puntata {
value: Die::new(value),
count,
}
}
pu... | else {
puntate.push(Puntata::new_lama(p.count + 1));
for i in 2..7 {
puntate.push(Puntata::new(p.count * 2 + 1, i));
}
}
if is_palifico {
puntate.retain(|pv| pv.value == p.value)
}
puntate
}
pub fn all_gt_puntate(total_dices: i32, p: Puntata, is_palifico:... | {
for i in (p.value.get_value() + 1)..7 {
puntate.push(Puntata::new(p.count, i));
}
for i in 2..7 {
puntate.push(Puntata::new(p.count + 1, i));
}
puntate.push(Puntata::new_lama((p.count + 1) / 2));
} | conditional_block |
puntata.rs | use crate::die::Die;
use std::{collections::HashSet, fmt};
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct Puntata {
value: Die,
count: i32,
}
impl Puntata {
pub fn new(count: i32, value: i32) -> Self {
Puntata {
value: Die::new(value),
count,
}
}
pu... |
pub fn get_value(self) -> i32 {
self.value.get_value()
}
pub fn get_count(self) -> i32 {
self.count
}
pub fn is_lama(self) -> bool {
self.value.is_lama()
}
pub fn with_count(self, count: i32) -> Self {
Puntata {
value: Die::new(self.value.get_... | {
Puntata {
value: Die::new_lama(),
count,
}
} | identifier_body |
htmldataelement.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::HTMLDataElementBinding;
use dom::bindings::js::Root;
use dom::document::Docu... |
}
| {
let element = HTMLDataElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLDataElementBinding::Wrap)
} | identifier_body |
htmldataelement.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::HTMLDataElementBinding;
use dom::bindings::js::Root;
use dom::document::Docu... | (localName: DOMString,
prefix: Option<DOMString>,
document: &Document) -> HTMLDataElement {
HTMLDataElement {
htmlelement: HTMLElement::new_inherited(localName, prefix, document)
}
}
#[allow(unrooted_must_root)]
pub fn new(localName: DOM... | new_inherited | identifier_name |
htmldataelement.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::HTMLDataElementBinding;
use dom::bindings::js::Root;
use dom::document::Docu... | htmlelement: HTMLElement
}
impl HTMLDataElement {
fn new_inherited(localName: DOMString,
prefix: Option<DOMString>,
document: &Document) -> HTMLDataElement {
HTMLDataElement {
htmlelement: HTMLElement::new_inherited(localName, prefix, document)
... | pub struct HTMLDataElement { | random_line_split |
transport.rs | use std::io::{self, Read, Write};
use std::net::{Shutdown, SocketAddr};
use std::time::Duration;
use std::u32;
use byteorder::{BigEndian, ByteOrder};
use bytes::{BufMut, Bytes, BytesMut, IntoBuf};
use futures::{Async, Future, Poll};
use prost::{decode_length_delimiter, length_delimiter_len, Message};
use tokio::net::{... | (duration: Duration) -> u32 {
let millis = duration
.as_secs()
.saturating_mul(1000)
.saturating_add(u64::from(duration.subsec_nanos()) / 1_000_000);
if millis > u64::from(u32::MAX) {
u32::MAX
} else {
millis as u32
}
}
| duration_to_ms | identifier_name |
transport.rs | use std::io::{self, Read, Write};
use std::net::{Shutdown, SocketAddr};
use std::time::Duration;
use std::u32;
use byteorder::{BigEndian, ByteOrder};
use bytes::{BufMut, Bytes, BytesMut, IntoBuf};
use futures::{Async, Future, Poll};
use prost::{decode_length_delimiter, length_delimiter_len, Message};
use tokio::net::{... |
/// Flushes bytes from send buffer to the stream.
///
/// Based on tokio-io's [`FramedWrite`][1].
/// [1]: https://github.com/tokio-rs/tokio-io/blob/0.1.3/src/framed_write.rs#L202-L225
///
/// An error return indicates a fatal error.
fn poll_flush(&mut self) -> Result<Async<()>, io::Error>... | {
self.recv_buf.reserve(at_least);
while at_least > 0 {
let n = unsafe {
let n = try_nb!(self.stream.read(self.recv_buf.bytes_mut()));
self.recv_buf.advance_mut(n);
n
};
at_least = at_least.saturating_sub(n);
... | identifier_body |
transport.rs | use std::io::{self, Read, Write};
use std::net::{Shutdown, SocketAddr};
use std::time::Duration;
use std::u32;
use byteorder::{BigEndian, ByteOrder};
use bytes::{BufMut, Bytes, BytesMut, IntoBuf};
use futures::{Async, Future, Poll};
use prost::{decode_length_delimiter, length_delimiter_len, Message};
use tokio::net::{... | service: &str,
method: &str,
required_feature_flags: &[u32],
body: &RequestBody,
timeout: Option<Duration>,
) -> Result<(), Error> {
let result = || -> Result<(), Error> {
// Set the header fields.
self.request_header.call_id = call_id;
... | call_id: i32, | random_line_split |
helper_objects.rs | //! Defines some structs, enums, and constants mainly useful for passing information around
//! over the FFI and over threads.
use std::collections::HashMap;
use std::sync::Mutex;
use libc::{c_char, c_void, uint64_t, c_double, c_int};
use futures::sync::mpsc::UnboundedSender;
use futures::Stream;
use futures::stream:... | {
pub command: ServerCommand,
pub payload: *mut c_void,
}
pub struct FXCMNative {
pub settings_hash: HashMap<String, String>,
pub server_environment: *mut c_void,
pub raw_rx: Option<BoxStream<(u64, BrokerResult), ()>>,
pub tickstream_obj: Mutex<Tickstream>,
}
// TODO: Move to Util
#[derive(De... | ClientMessage | identifier_name |
helper_objects.rs | //! Defines some structs, enums, and constants mainly useful for passing information around
//! over the FFI and over threads.
use std::collections::HashMap;
use std::sync::Mutex;
use libc::{c_char, c_void, uint64_t, c_double, c_int};
use futures::sync::mpsc::UnboundedSender;
use futures::Stream;
use futures::stream:... | impl CSymbolTick {
/// Converts a CSymbolTick into a Tick given the amount of decimal places precision.
pub fn to_tick(&self, decimals: usize) -> Tick {
let multiplier = 10usize.pow(decimals as u32) as f64;
let bid_pips = self.bid * multiplier;
let ask_pips = self.ask * multiplier;
... | pub bid: c_double,
pub ask: c_double,
}
| random_line_split |
mod.rs | //! Resource data implementations.
//!
//! This module will eventually contain implementations for the record data
//! for all defined resource record types.
//!
//! The types are named identically to the [`Rtype`] variant they implement.
//! They are grouped into submodules for the RFCs they are defined in. All
//! ty... | }
}
/// Parsed versions of all record data types.
///
/// This module defines or re-exports type aliases for all record data
/// types that use parsed domain names and references to bytes slices where
/// applicable. For convenience, it also includes re-exports for those types
/// that are not in fact generic.
///
... | let mut parser = parser.clone();
let len = parser.remaining();
let data = parser.parse_bytes(len).unwrap();
generic::fmt(data, f)
}
| conditional_block |
mod.rs | //! Resource data implementations.
//!
//! This module will eventually contain implementations for the record data
//! for all defined resource record types.
//!
//! The types are named identically to the [`Rtype`] variant they implement.
//! They are grouped into submodules for the RFCs they are defined in. All
//! ty... | /// Parsed versions of all record data types.
///
/// This module defines or re-exports type aliases for all record data
/// types that use parsed domain names and references to bytes slices where
/// applicable. For convenience, it also includes re-exports for those types
/// that are not in fact generic.
///
/// Use ... | match try!(fmt_master_data(rtype, parser, f)) {
Some(res) => Ok(res),
None => {
let mut parser = parser.clone();
let len = parser.remaining();
let data = parser.parse_bytes(len).unwrap();
generic::fmt(data, f)
}
}
}
| identifier_body |
mod.rs | //! Resource data implementations.
//!
//! This module will eventually contain implementations for the record data
//! for all defined resource record types.
//!
//! The types are named identically to the [`Rtype`] variant they implement.
//! They are grouped into submodules for the RFCs they are defined in. All
//! ty... | type: ::iana::Rtype, parser: &mut ::bits::Parser,
f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
match try!(fmt_master_data(rtype, parser, f)) {
Some(res) => Ok(res),
None => {
let mut parser = parser.clone();
let len = parser.remaining();
... | t_rdata(r | identifier_name |
mod.rs | //! Resource data implementations.
//!
//! This module will eventually contain implementations for the record data
//! for all defined resource record types.
//!
//! The types are named identically to the [`Rtype`] variant they implement.
//! They are grouped into submodules for the RFCs they are defined in. All
//! ty... | // arrow and the name of the type on the right. If the type is generic, use
// the owned version.
//
// The macro creates the re-export of the record data type.
master_types!{
rfc1035::{
A => A,
Cname => Cname<DNameBuf>,
Hinfo => Hinfo<CharStrBuf>,
Mb => Mb<DNameBuf>,
Md => M... | //
// Include all record types that can occur in master files. Place the name of
// the variant (identical to the type name) on the left side of the double | random_line_split |
lib.rs | #![feature(const_fn)]
#![feature(drop_types_in_const)]
#![feature(proc_macro)]
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate bootstrap_rs as bootstrap;
extern crate fiber;
use fiber::FiberId;
use std::cell::RefCell;
use std::collections::HashMap;... | {
/// Human-readable name for the event.
name: &'static str,
/// Event category.
cat: String,
/// Event phase (i.e. the event type).
ph: &'static str,
/// Timestamp in microseconds.
ts: i64,
/// Process ID for the event.
pid: usize,
/// Thread ID for the event.
tid:... | Event | identifier_name |
lib.rs | #![feature(const_fn)]
#![feature(drop_types_in_const)]
#![feature(proc_macro)]
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate bootstrap_rs as bootstrap;
extern crate fiber;
use fiber::FiberId;
use std::cell::RefCell;
use std::collections::HashMap;... |
pub fn with_budget(name: &'static str, _budget: Duration) -> Stopwatch {
// TODO: We should actually do something with the budget, right?
Stopwatch::new(name)
}
}
impl Drop for Stopwatch {
fn drop(&mut self) {
with_context(|stack| {
let stopwatch = stack.pop().expect("... | {
push_event(Event {
name: name,
cat: String::new(),
ph: "B",
ts: platform::timestamp(),
tid: platform::thread_id(),
pid: 0, // TODO: Do we care about tracking process ID?
});
with_context(|stack| {
stack.push(S... | identifier_body |
lib.rs | #![feature(const_fn)]
#![feature(drop_types_in_const)]
#![feature(proc_macro)]
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate bootstrap_rs as bootstrap;
extern crate fiber;
use fiber::FiberId;
use std::cell::RefCell;
use std::collections::HashMap;... | write!(formatter, "{}m {}s {}.{}ms", mins, secs, millis, micros)
} else if secs > 0 {
write!(formatter, "{}s {}.{}ms", secs, millis, micros)
} else {
write!(formatter, "{}.{}ms", millis, micros)
}
}
} | if mins > 0 { | random_line_split |
lib.rs | #![feature(const_fn)]
#![feature(drop_types_in_const)]
#![feature(proc_macro)]
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate bootstrap_rs as bootstrap;
extern crate fiber;
use fiber::FiberId;
use std::cell::RefCell;
use std::collections::HashMap;... | else {
write!(formatter, "{}.{}ms", millis, micros)
}
}
}
| {
write!(formatter, "{}s {}.{}ms", secs, millis, micros)
} | conditional_block |
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... | vertex Vertex {
pos: [f32; 2] = "a_Pos",
color: [f32; 3] = "a_Color",
}
pipeline pipe {
vbuf: gfx::VertexBuffer<Vertex> = (),
out: gfx::RenderTarget<ColorFormat> = "Target0",
}
}
const TRIANGLE: [Vertex; 3] = [
Vertex { pos: [ -0.5, -0.5 ], color: [1.0, 0.0, 0.0] },... | pub type ColorFormat = gfx::format::Rgba8;
pub type DepthFormat = gfx::format::DepthStencil;
gfx_defines!{ | random_line_split |
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... | () {
let builder = glutin::WindowBuilder::new()
.with_title("Triangle example".to_string())
.with_dimensions(1024, 768)
.with_vsync();
let (window, mut device, mut factory, main_color, _main_depth) =
gfx_window_glutin::init::<ColorFormat, DepthFormat>(builder);
let mut encoder: ... | main | 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... | // loop over events
for event in window.poll_events() {
match event {
glutin::Event::KeyboardInput(_, _, Some(glutin::VirtualKeyCode::Escape)) |
glutin::Event::Closed => break'main,
_ => {},
}
}
// draw a frame
... | {
let builder = glutin::WindowBuilder::new()
.with_title("Triangle example".to_string())
.with_dimensions(1024, 768)
.with_vsync();
let (window, mut device, mut factory, main_color, _main_depth) =
gfx_window_glutin::init::<ColorFormat, DepthFormat>(builder);
let mut encoder: ... | identifier_body |
gamma.rs | use err::ErrMsg;
use RGSLRng;
#[derive(Debug, Clone)]
pub struct Gamma {
a: f64,
b: f64,
}
impl Gamma {
pub fn new(a: f64, b: f64) -> Result<Gamma, ()> {
if a <= 0.0 || b <= 0.0 {
return Err(());
}
Ok(Gamma { a, b })
}
#[inline]
pub fn pdf(&self, x: f64) -... |
#[inline]
fn inverse_cdf(&self, x: f64) -> f64 {
use rgsl::randist::gamma::gamma_Pinv;
if x.is_sign_negative() {
panic!(ErrMsg::PositiveReal.panic_msg_with_arg(&self));
}
gamma_Pinv(x, self.a, self.b)
}
}
| {
use rgsl::randist::gamma::gamma_P;
if x.is_sign_negative() {
panic!(ErrMsg::PositiveReal.panic_msg_with_arg(&self));
}
gamma_P(x, self.a, self.b)
} | identifier_body |
gamma.rs | use err::ErrMsg;
use RGSLRng;
#[derive(Debug, Clone)]
pub struct | {
a: f64,
b: f64,
}
impl Gamma {
pub fn new(a: f64, b: f64) -> Result<Gamma, ()> {
if a <= 0.0 || b <= 0.0 {
return Err(());
}
Ok(Gamma { a, b })
}
#[inline]
pub fn pdf(&self, x: f64) -> f64 {
use rgsl::randist::gamma::gamma_pdf;
gamma_pdf... | Gamma | identifier_name |
gamma.rs | use err::ErrMsg;
use RGSLRng;
#[derive(Debug, Clone)]
pub struct Gamma {
a: f64,
b: f64,
}
impl Gamma {
pub fn new(a: f64, b: f64) -> Result<Gamma, ()> {
if a <= 0.0 || b <= 0.0 {
return Err(());
}
Ok(Gamma { a, b })
}
#[inline]
pub fn pdf(&self, x: f64) -... | use super::{Sample, CDF};
impl Sample for Gamma {
#[inline]
fn sample(&self, rng: &mut RGSLRng) -> f64 {
use rgsl::randist::gamma::gamma;
gamma(rng.get_gen(), self.a, self.b)
}
}
impl CDF for Gamma {
#[inline]
fn cdf(&self, x: f64) -> f64 {
use rgsl::randist::gamma::gamma_... | }
}
| random_line_split |
gamma.rs | use err::ErrMsg;
use RGSLRng;
#[derive(Debug, Clone)]
pub struct Gamma {
a: f64,
b: f64,
}
impl Gamma {
pub fn new(a: f64, b: f64) -> Result<Gamma, ()> {
if a <= 0.0 || b <= 0.0 {
return Err(());
}
Ok(Gamma { a, b })
}
#[inline]
pub fn pdf(&self, x: f64) -... |
gamma_Pinv(x, self.a, self.b)
}
}
| {
panic!(ErrMsg::PositiveReal.panic_msg_with_arg(&self));
} | conditional_block |
regex.rs | // Copyright (c) 2018 The predicates-rs Project Developers.
//
// 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 distr... |
}
}
impl reflection::PredicateReflection for RegexMatchesPredicate {
fn parameters<'a>(&'a self) -> Box<dyn Iterator<Item = reflection::Parameter<'a>> + 'a> {
let params = vec![reflection::Parameter::new("count", &self.count)];
Box::new(params.into_iter())
}
}
impl fmt::Display for RegexM... | {
None
} | conditional_block |
regex.rs | // Copyright (c) 2018 The predicates-rs Project Developers.
//
// 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 distr... | (&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let palette = crate::Palette::current();
write!(
f,
"{}.{}({})",
palette.var.paint("var"),
palette.description.paint("is_match"),
palette.expected.paint(&self.re),
)
}
}
/// Crea... | fmt | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.