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 |
|---|---|---|---|---|
default.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... | (cx: &ExtCtxt,
span: Span,
mitem: @MetaItem,
in_items: ~[@Item])
-> ~[@Item] {
let trait_def = TraitDef {
cx: cx, span: span,
path: Path::new(~["std", "default", "Default"]),
additional_bounds: ~[],
... | expand_deriving_default | identifier_name |
default.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... | Named(ref fields) => {
let default_fields = fields.map(|&(ident, span)| {
cx.field_imm(span, ident, default_call(span))
});
cx.expr_struct_ident(span, substr.type_ident, default_fields)
}
}
... | {
let default_ident = ~[
cx.ident_of("std"),
cx.ident_of("default"),
cx.ident_of("Default"),
cx.ident_of("default")
];
let default_call = |span| cx.expr_call_global(span, default_ident.clone(), ~[]);
return match *substr.fields {
StaticStruct(_, ref summary) => {... | identifier_body |
metric.rs | /*
Copyright 2015 Google Inc. All rights reserved.
Copyright 2017 Jihyun Yu. All rights reserved.
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
Unl... |
/// min_level returns the minimum level such that the metric is at most
/// the given value, or maxLevel (30) if there is no such level.
///
/// For example, MINLevel(0.1) returns the minimum level such that all cell diagonal
/// lengths are 0.1 or smaller. The returned value is always a valid lev... | {
// return math.Ldexp(m.Deriv, -m.Dim*level)
ldexp(self.deriv, -1 * (self.dim as i32) * (level as i32))
} | identifier_body |
metric.rs | /*
Copyright 2015 Google Inc. All rights reserved.
Copyright 2017 Jihyun Yu. All rights reserved.
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
Unl... | else if level < 0 {
0
} else {
level as u64
}
}
/// max_level returns the maximum level such that the metric is at least
/// the given value, or zero if there is no such level.
///
/// For example, MAXLevel(0.1) returns the maximum level such that all cells ... | {
MAX_LEVEL
} | conditional_block |
metric.rs | /*
Copyright 2015 Google Inc. All rights reserved.
Copyright 2017 Jihyun Yu. All rights reserved.
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
Unl... | let level = -ilogb(val / self.deriv) >> u64::from(self.dim - 1);
if level > (MAX_LEVEL as i32) {
MAX_LEVEL
} else if level < 0 {
0
} else {
level as u64
}
}
/// max_level returns the maximum level such that the metric is at least
/... | pub fn min_level(&self, val: f64) -> u64 {
if val < 0. {
return MAX_LEVEL;
}
| random_line_split |
metric.rs | /*
Copyright 2015 Google Inc. All rights reserved.
Copyright 2017 Jihyun Yu. All rights reserved.
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
Unl... | (&self, val: f64) -> u64 {
if val < 0. {
return MAX_LEVEL;
}
let level = -ilogb(val / self.deriv) >> u64::from(self.dim - 1);
if level > (MAX_LEVEL as i32) {
MAX_LEVEL
} else if level < 0 {
0
} else {
level as u64
}... | min_level | identifier_name |
sort.rs | use std::collections::BTreeMap;
use std::convert::AsRef;
pub struct Sorter;
// ToDo: merge with Indexing?
impl Sorter {
pub fn sort<T, R>(values: R) -> Vec<T>
where
T: Clone + Ord,
R: AsRef<Vec<T>>,
{
let values: &Vec<T> = values.as_ref();
// Clone all elements
l... |
#[test]
fn test_sort_by_int_float() {
let (keys, vals) = Sorter::sort_by(&vec![3, 2, 1, 4, 1], &vec![1.1, 2.1, 3.1, 4.1, 5.1]);
assert_eq!(keys, vec![1, 1, 2, 3, 4]);
assert_eq!(vals, vec![3.1, 5.1, 2.1, 1.1, 4.1]);
}
}
| {
let (keys, vals) = Sorter::sort_by(&vec![3, 3, 1, 1, 1], &vec![1, 2, 3, 4, 5]);
assert_eq!(keys, vec![1, 1, 1, 3, 3]);
assert_eq!(vals, vec![3, 4, 5, 1, 2]);
} | identifier_body |
sort.rs | use std::collections::BTreeMap;
use std::convert::AsRef;
pub struct Sorter;
// ToDo: merge with Indexing?
impl Sorter {
pub fn sort<T, R>(values: R) -> Vec<T>
where
T: Clone + Ord,
R: AsRef<Vec<T>>,
{
let values: &Vec<T> = values.as_ref();
// Clone all elements
l... | }
(indexer, sorted)
}
/// Sort values by key returning sorted key and values
pub fn sort_by<T, U>(keys: &Vec<T>, values: &Vec<U>) -> (Vec<T>, Vec<U>)
where
T: Clone + Ord,
U: Clone,
{
let mut map: BTreeMap<T, Vec<U>> = BTreeMap::new();
for (k, v) in... | sorted.push(k.clone());
indexer.push(loc);
} | random_line_split |
sort.rs | use std::collections::BTreeMap;
use std::convert::AsRef;
pub struct Sorter;
// ToDo: merge with Indexing?
impl Sorter {
pub fn sort<T, R>(values: R) -> Vec<T>
where
T: Clone + Ord,
R: AsRef<Vec<T>>,
{
let values: &Vec<T> = values.as_ref();
// Clone all elements
l... | () {
let (indexer, sorted) = Sorter::argsort(&Vec::<i64>::new());
assert_eq!(indexer, vec![]);
assert_eq!(sorted, vec![]);
}
#[test]
fn test_argsort_int() {
let (indexer, sorted) = Sorter::argsort(&vec![2, 2, 2, 3, 3]);
assert_eq!(indexer, vec![0, 1, 2, 3, 4]);
... | test_argsort_empty | identifier_name |
letter_frequency.rs | // http://rosettacode.org/wiki/Letter_frequency
#![cfg_attr(not(test), feature(io))]
#[cfg(not(test))]
use std::fs::File;
#[cfg(not(test))]
use std::io::{BufReader, Read};
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
fn count_chars<T>(chars: T) -> HashMap<char, usize>
... | for letter in chars {
match map.entry(letter) {
Vacant(entry) => { entry.insert(1); },
Occupied(mut entry) => { *entry.get_mut() += 1; }
};
}
map
}
#[cfg(not(test))]
fn main() {
let file = File::open("resources/unixdict.txt").unwrap();
let reader = BufReader:... | {
let mut map: HashMap<char, usize> = HashMap::new(); | random_line_split |
letter_frequency.rs | // http://rosettacode.org/wiki/Letter_frequency
#![cfg_attr(not(test), feature(io))]
#[cfg(not(test))]
use std::fs::File;
#[cfg(not(test))]
use std::io::{BufReader, Read};
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
fn count_chars<T>(chars: T) -> HashMap<char, usize>
... | () {
let map = count_chars("aaaabbbbc".chars());
assert!(map.len() == 3);
assert!(map[&'a'] == 4);
assert!(map[&'b'] == 4);
assert!(map[&'c'] == 1);
}
| test_basic | identifier_name |
letter_frequency.rs | // http://rosettacode.org/wiki/Letter_frequency
#![cfg_attr(not(test), feature(io))]
#[cfg(not(test))]
use std::fs::File;
#[cfg(not(test))]
use std::io::{BufReader, Read};
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
fn count_chars<T>(chars: T) -> HashMap<char, usize>
... |
#[cfg(not(test))]
fn main() {
let file = File::open("resources/unixdict.txt").unwrap();
let reader = BufReader::new(file);
println!("{:?}", count_chars(reader.chars().map(|c| c.unwrap())));
}
#[test]
fn test_empty() {
let map = count_chars("".chars());
assert!(map.len() == 0);
}
#[test]
fn test... | {
let mut map: HashMap<char, usize> = HashMap::new();
for letter in chars {
match map.entry(letter) {
Vacant(entry) => { entry.insert(1); },
Occupied(mut entry) => { *entry.get_mut() += 1; }
};
}
map
} | identifier_body |
letter_frequency.rs | // http://rosettacode.org/wiki/Letter_frequency
#![cfg_attr(not(test), feature(io))]
#[cfg(not(test))]
use std::fs::File;
#[cfg(not(test))]
use std::io::{BufReader, Read};
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
fn count_chars<T>(chars: T) -> HashMap<char, usize>
... | ,
Occupied(mut entry) => { *entry.get_mut() += 1; }
};
}
map
}
#[cfg(not(test))]
fn main() {
let file = File::open("resources/unixdict.txt").unwrap();
let reader = BufReader::new(file);
println!("{:?}", count_chars(reader.chars().map(|c| c.unwrap())));
}
#[test]
fn test_empty(... | { entry.insert(1); } | conditional_block |
simple_earley.rs | use bongo::grammar::{
build, BaseElementTypes, Elem, Grammar, NonTerminal, ProdElement, Terminal,
};
use bongo::parsers::earley::parse;
use bongo::parsers::{tree::TreeOwner, Token};
use bongo::start_grammar::wrap_grammar_with_start;
use bongo::utils::Name;
fn main() | ProdElement::new_with_name(
Name::new("contents"),
Elem::NonTerm(a_nt.clone()),
),
ProdElement::new_empty(Elem::Term(rp_t.clone())),
],
);
});
})
.unwrap();
let g = wrap_grammar_with_start(g).unwrap();
eprintln!("Grammar: {}", g.to_pretty(... | {
let a_nt = NonTerminal::new("a");
let lp_t = Terminal::new("LPAREN");
let rp_t = Terminal::new("RPAREN");
let v_t = Terminal::new("VALUE");
let g: Grammar<BaseElementTypes> = build(&a_nt, |b| {
b.add_rule(&a_nt, |br| {
br.add_prod_with_elems(
&Name::new("value"),
(),
vec![P... | identifier_body |
simple_earley.rs | use bongo::grammar::{
build, BaseElementTypes, Elem, Grammar, NonTerminal, ProdElement, Terminal,
};
use bongo::parsers::earley::parse;
use bongo::parsers::{tree::TreeOwner, Token};
use bongo::start_grammar::wrap_grammar_with_start;
use bongo::utils::Name;
fn main() {
let a_nt = NonTerminal::new("a");
let lp_t =... | )
.add_prod_with_elems(
&Name::new("parens"),
(),
vec![
ProdElement::new_empty(Elem::Term(lp_t.clone())),
ProdElement::new_with_name(
Name::new("contents"),
Elem::NonTerm(a_nt.clone()),
),
ProdElement::new_empty(Elem::Ter... | Elem::Term(v_t.clone()),
)], | random_line_split |
simple_earley.rs | use bongo::grammar::{
build, BaseElementTypes, Elem, Grammar, NonTerminal, ProdElement, Terminal,
};
use bongo::parsers::earley::parse;
use bongo::parsers::{tree::TreeOwner, Token};
use bongo::start_grammar::wrap_grammar_with_start;
use bongo::utils::Name;
fn | () {
let a_nt = NonTerminal::new("a");
let lp_t = Terminal::new("LPAREN");
let rp_t = Terminal::new("RPAREN");
let v_t = Terminal::new("VALUE");
let g: Grammar<BaseElementTypes> = build(&a_nt, |b| {
b.add_rule(&a_nt, |br| {
br.add_prod_with_elems(
&Name::new("value"),
(),
vec... | main | identifier_name |
main.rs | fn main() {
let s1 = gives_ownership(); // gives_ownership 将返回值
// 转移给 s1
let s2 = String::from("hello"); // s2 进入作用域
let s3 = takes_and_gives_back(s2); // s2 被移动到
// takes_and_gives_back 中,
... | identifier_body | ||
main.rs | fn main() {
let s1 = gives_ownership(); // gives_ownership 将返回值
// 转移给 s1
let s2 = String::from("hello"); // s2 进入作用域
let s3 = takes_and_gives_back(s2); // s2 被移动到
// takes_and_gives_back 中,
... | identifier_name | ||
main.rs | fn main() {
let s1 = gives_ownership(); // gives_ownership 将返回值
// 转移给 s1
let s2 = String::from("hello"); // s2 进入作用域
let s3 = takes_and_gives_back(s2); // s2 被移动到
// takes_and_gives_back 中,
... | let some_string = String::from("yours"); // some_string 进入作用域.
some_string // 返回 some_string
// 并移出给调用的函数
//
}
// takes_and_gives_back 将传入字符串并返回该值
fn takes_and_gives_back(a_string: String) ... |
fn gives_ownership() -> String { // gives_ownership 会将
// 返回值移动给
// 调用它的函数
| random_line_split |
lib.rs | //! Nursery for slog-rs
//!
//! This crate is forever unstable, and contains things that
//! at a given moment are useful but not final.
#![warn(missing_docs)]
extern crate slog;
use slog::*;
use std::result;
/// `Drain` that switches destination of error
///
/// Logs everything to drain `D1`, but in case of it repo... | /// Create `Failover`
pub fn new(drain1: D1, drain2: D2) -> Self {
Failover {
drain1: drain1,
drain2: drain2,
}
}
}
impl<D1, D2, E2, O> Drain for Failover<D1, D2>
where
D1 : Drain<Ok = O>,
D2 : Drain<Ok = O>,
{
type Ok = O;
type Err = D2::Err;
... | random_line_split | |
lib.rs | //! Nursery for slog-rs
//!
//! This crate is forever unstable, and contains things that
//! at a given moment are useful but not final.
#![warn(missing_docs)]
extern crate slog;
use slog::*;
use std::result;
/// `Drain` that switches destination of error
///
/// Logs everything to drain `D1`, but in case of it repo... | <D1: Drain, D2: Drain>
{
drain1: D1,
drain2: D2,
}
impl<D1: Drain, D2: Drain, O> Failover<D1, D2>
where
D1 : Drain<Ok = O>,
D2 : Drain<Ok = O>,
{
/// Create `Failover`
pub fn new(drain1: D1, drain2: D2) -> Self {
Failover {
drain1: drain1,
drain2: drain2,
... | Failover | identifier_name |
lib.rs | //! Nursery for slog-rs
//!
//! This crate is forever unstable, and contains things that
//! at a given moment are useful but not final.
#![warn(missing_docs)]
extern crate slog;
use slog::*;
use std::result;
/// `Drain` that switches destination of error
///
/// Logs everything to drain `D1`, but in case of it repo... |
}
/// Failover logging to secondary drain on primary's failure
///
/// Create `Failover` drain
pub fn failover<D1: Drain, D2: Drain, O>(d1: D1, d2: D2) -> Failover<D1, D2>
where
D1 : Drain<Ok = O>,
D2 : Drain<Ok = O>,
{
Failover::new(d1, d2)
}
| {
match self.drain1.log(info, logger_values) {
Ok(ok) => Ok(ok),
Err(_) => self.drain2.log(info, logger_values),
}
} | identifier_body |
deriving-cmp-generic-struct-enum.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | // option. This file may not be copied, modified, or distributed
// except according to those terms.
// no-pretty-expanded FIXME #15189
// pretty-expanded FIXME #23616
#[derive(PartialEq, Eq, PartialOrd, Ord)]
enum ES<T> {
ES1 { x: T },
ES2 { x: T, y: T }
}
pub fn main() {
let (es11, es12, es21, es22) ... | // 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 | random_line_split |
deriving-cmp-generic-struct-enum.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 ... | let eq = i == j;
let (lt, le) = (i < j, i <= j);
let (gt, ge) = (i > j, i >= j);
// PartialEq
assert_eq!(*es1 == *es2, eq);
assert_eq!(*es1!= *es2,!eq);
// PartialOrd
assert_eq!(*es1 < *es2, lt);
assert_eq!(*es... | {
let (es11, es12, es21, es22) = (ES::ES1 {
x: 1
}, ES::ES1 {
x: 2
}, ES::ES2 {
x: 1,
y: 1
}, ES::ES2 {
x: 1,
y: 2
});
// in order for both PartialOrd and Ord
let ess = [es11, es12, es21, es22];
for (i, es1) in ess.iter().enumerate() {
... | identifier_body |
deriving-cmp-generic-struct-enum.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 ... | () {
let (es11, es12, es21, es22) = (ES::ES1 {
x: 1
}, ES::ES1 {
x: 2
}, ES::ES2 {
x: 1,
y: 1
}, ES::ES2 {
x: 1,
y: 2
});
// in order for both PartialOrd and Ord
let ess = [es11, es12, es21, es22];
for (i, es1) in ess.iter().enumerate() {... | main | identifier_name |
expr-if-fail.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 x = if false { fail!() } else { 10 }; assert!((x == 10)); }
fn test_else_fail() {
let x = if true { 10 } else { fail!() };
assert!((x == 10));
}
fn test_elseif_fail() {
let x = if false { 0 } else if false { fail!() } else { 10 };
assert!((x == 10));
}
pub fn main() { test_if_fail(); test_el... | test_if_fail | identifier_name |
expr-if-fail.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 ... |
fn test_else_fail() {
let x = if true { 10 } else { fail!() };
assert!((x == 10));
}
fn test_elseif_fail() {
let x = if false { 0 } else if false { fail!() } else { 10 };
assert!((x == 10));
}
pub fn main() { test_if_fail(); test_else_fail(); test_elseif_fail(); }
| { let x = if false { fail!() } else { 10 }; assert!((x == 10)); } | identifier_body |
expr-if-fail.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 | // option. This file may not be copied, modified, or distributed
// except according to those terms.
fn test_if_fail() { let x = if false { fail!() } else { 10 }; assert!((x == 10)); }
fn test_else_fail() {
let x = if true { 10 } else { fail!() };
assert!((x == 10));
}
fn test_elseif_fail() {
let x = if ... | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | random_line_split |
expr-if-fail.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 ... | else { fail!() };
assert!((x == 10));
}
fn test_elseif_fail() {
let x = if false { 0 } else if false { fail!() } else { 10 };
assert!((x == 10));
}
pub fn main() { test_if_fail(); test_else_fail(); test_elseif_fail(); }
| { 10 } | conditional_block |
closure-syntax.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 ... | <T>() {}
trait Bar1 {}
impl Bar1 for proc() {}
trait Bar2 {}
impl Bar2 for proc(): Send {}
trait Bar3 {}
impl<'b> Bar3 for <'a>|&'a int|: 'b + Send -> &'a int {}
trait Bar4 {}
impl Bar4 for proc<'a>(&'a int) -> &'a int {}
struct Foo<'a> {
a: ||: 'a,
b: ||:'static,
c: <'b>||: 'a,
d: ||: 'a + Share,
... | foo | identifier_name |
closure-syntax.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 ... |
struct Foo<'a> {
a: ||: 'a,
b: ||:'static,
c: <'b>||: 'a,
d: ||: 'a + Share,
e: <'b>|int|: 'a + Share -> &'b f32,
f: proc(),
g: proc():'static + Share,
h: proc<'b>(int): Share -> &'b f32,
}
fn f<'a>(a: &'a int, f: <'b>|&'b int| -> &'b int) -> &'a int {
f(a)
}
fn g<'a>(a: &'a int, ... | random_line_split | |
closure-syntax.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 ... |
trait Bar1 {}
impl Bar1 for proc() {}
trait Bar2 {}
impl Bar2 for proc(): Send {}
trait Bar3 {}
impl<'b> Bar3 for <'a>|&'a int|: 'b + Send -> &'a int {}
trait Bar4 {}
impl Bar4 for proc<'a>(&'a int) -> &'a int {}
struct Foo<'a> {
a: ||: 'a,
b: ||:'static,
c: <'b>||: 'a,
d: ||: 'a + Share,
e: <... | {} | identifier_body |
main.rs | extern crate piston; // piston core
extern crate graphics; // piston graphics
extern crate glutin_window; // opengl context creation
extern crate opengl_graphics; // opengl binding
//extern crate find_folder; // for finding our assets folder.
extern crate time;
extern crate rand;
extern crate ncollide; // 2d/3d/nd co... | let opengl = OpenGL::V3_2;
let (width, height) = (1280, 720);
// Create an Glutin window.
let mut window: Window = WindowSettings::new("Snake Game", [width, height])
.opengl(opengl)
.exit_on_esc(true)
.vsync(true)
.fullscreen(false)
.build()
.unwrap();
//... | random_line_split | |
main.rs | extern crate piston; // piston core
extern crate graphics; // piston graphics
extern crate glutin_window; // opengl context creation
extern crate opengl_graphics; // opengl binding
//extern crate find_folder; // for finding our assets folder.
extern crate time;
extern crate rand;
extern crate ncollide; // 2d/3d/nd co... |
if let Some(u) = e.update_args() {
// Simulate lag:
// std::thread::sleep(std::time::Duration::new(0, 1000_000_00));
app.update(&u);
}
}
}
| {
app.render(&r);
} | conditional_block |
main.rs | extern crate piston; // piston core
extern crate graphics; // piston graphics
extern crate glutin_window; // opengl context creation
extern crate opengl_graphics; // opengl binding
//extern crate find_folder; // for finding our assets folder.
extern crate time;
extern crate rand;
extern crate ncollide; // 2d/3d/nd co... | (&mut self, args: &RenderArgs) {
if self.should_render {
self.window_rect = Vector2::new(args.width, args.height);
use graphics::*;
const BLACK: [f32; 4] = [0.0, 0.0, 0.0, 1.0];
let world_state = &self.world_state;
let viewport = args.viewport();
... | render | identifier_name |
main.rs | extern crate piston; // piston core
extern crate graphics; // piston graphics
extern crate glutin_window; // opengl context creation
extern crate opengl_graphics; // opengl binding
//extern crate find_folder; // for finding our assets folder.
extern crate time;
extern crate rand;
extern crate ncollide; // 2d/3d/nd co... |
}
fn main() {
// Change this to OpenGL::V2_1 if not working.
let opengl = OpenGL::V3_2;
let (width, height) = (1280, 720);
// Create an Glutin window.
let mut window: Window = WindowSettings::new("Snake Game", [width, height])
.opengl(opengl)
.exit_on_esc(true)
.vsync(true)... | {
self.world_state.window_rect = self.window_rect;
self.world_state.update(args);
} | identifier_body |
unit-return.rs | // aux-build:unit-return.rs
#![crate_name = "foo"]
extern crate unit_return;
// @has 'foo/fn.f0.html' '//*[@class="rust fn"]' 'F: FnMut(u8) + Clone'
pub fn f0<F: FnMut(u8) + Clone>(f: F) {}
| // @has 'foo/fn.f1.html' '//*[@class="rust fn"]' 'F: FnMut(u16) + Clone'
pub fn f1<F: FnMut(u16) -> () + Clone>(f: F) {}
// @has 'foo/fn.f2.html' '//*[@class="rust fn"]' 'F: FnMut(u32) + Clone'
pub use unit_return::f2;
// @has 'foo/fn.f3.html' '//*[@class="rust fn"]' 'F: FnMut(u64) + Clone'
pub use unit_return::f3; | random_line_split | |
unit-return.rs | // aux-build:unit-return.rs
#![crate_name = "foo"]
extern crate unit_return;
// @has 'foo/fn.f0.html' '//*[@class="rust fn"]' 'F: FnMut(u8) + Clone'
pub fn f0<F: FnMut(u8) + Clone>(f: F) |
// @has 'foo/fn.f1.html' '//*[@class="rust fn"]' 'F: FnMut(u16) + Clone'
pub fn f1<F: FnMut(u16) -> () + Clone>(f: F) {}
// @has 'foo/fn.f2.html' '//*[@class="rust fn"]' 'F: FnMut(u32) + Clone'
pub use unit_return::f2;
// @has 'foo/fn.f3.html' '//*[@class="rust fn"]' 'F: FnMut(u64) + Clone'
pub use unit_return::f3;... | {} | identifier_body |
unit-return.rs | // aux-build:unit-return.rs
#![crate_name = "foo"]
extern crate unit_return;
// @has 'foo/fn.f0.html' '//*[@class="rust fn"]' 'F: FnMut(u8) + Clone'
pub fn f0<F: FnMut(u8) + Clone>(f: F) {}
// @has 'foo/fn.f1.html' '//*[@class="rust fn"]' 'F: FnMut(u16) + Clone'
pub fn | <F: FnMut(u16) -> () + Clone>(f: F) {}
// @has 'foo/fn.f2.html' '//*[@class="rust fn"]' 'F: FnMut(u32) + Clone'
pub use unit_return::f2;
// @has 'foo/fn.f3.html' '//*[@class="rust fn"]' 'F: FnMut(u64) + Clone'
pub use unit_return::f3;
| f1 | identifier_name |
astconv.rs | expected {} but found {}",
expected_num_region_params,
supplied_num_region_params));
}
match anon_regions {
Ok(v) => opt_vec::from(v),
Err(()) => opt_vec::from(vec::from_fn(expected_num_region_params,
... | }
_ => {
tcx.sess.span_fatal(ast_ty.span,
format!("found value name used as a type: {:?}", a_def)); | random_line_split | |
astconv.rs | `.
*/
let tcx = this.tcx();
// If the type is parameterized by the this region, then replace this
// region with the current anon region binding (in other words,
// whatever & would get replaced with).
let expected_num_region_params = decl_generics.region_param_defs.len();
let supplied_nu... |
ast::TyPtr(ref mt) => {
ty::mk_ptr(tcx, ast_mt_to_mt(this, rscope, mt))
}
ast::TyRptr(ref region, ref mt) => {
let r = opt_ast_region_to_region(this, rscope, ast_ty.span, region);
debug!("ty_rptr r={}", r.repr(this.tcx()));
mk_pointer(this, rscope, mt, ty::vstore_slice... | {
tcx.sess.span_err(ast_ty.span, "bare `[]` is not a type");
// return /something/ so they can at least get more errors
ty::mk_vec(tcx, ast_ty_to_mt(this, rscope, ty), ty::vstore_uniq)
} | conditional_block |
astconv.rs | `.
*/
let tcx = this.tcx();
// If the type is parameterized by the this region, then replace this
// region with the current anon region binding (in other words,
// whatever & would get replaced with).
let expected_num_region_params = decl_generics.region_param_defs.len();
let supplied_nu... | <AC:AstConv, RS:RegionScope>(
this: &AC, rscope: &RS, mt: &ast::MutTy) -> ty::mt {
ty::mt {ty: ast_ty_to_ty(this, rscope, mt.ty), mutbl: mt.mutbl}
}
// Handle @, ~, and & being able to mean strs and vecs.
// If a_seq_ty is a str or a vec, make it an str/vec.
// Also handle first-class ... | ast_mt_to_mt | identifier_name |
astconv.rs | I`.
*/
let tcx = this.tcx();
// If the type is parameterized by the this region, then replace this
// region with the current anon region binding (in other words,
// whatever & would get replaced with).
let expected_num_region_params = decl_generics.region_param_defs.len();
let supplied_n... |
pub fn ast_path_to_ty<AC:AstConv,RS:RegionScope>(
this: &AC,
rscope: &RS,
did: ast::DefId,
path: &ast::Path)
-> ty_param_substs_and_ty
{
// Look up the polytype of the item and then substitute the provided types
// for any type/region parameters.
let ty::ty_param_subst... | {
let trait_def =
this.get_trait_def(trait_def_id);
let substs =
ast_path_substs(
this,
rscope,
&trait_def.generics,
self_ty,
path);
let trait_ref =
@ty::TraitRef {def_id: trait_def_id,
substs: substs}... | identifier_body |
animation.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! CSS transitions and animations.
use flow::{self, Flow};
use incremental::{self, RestyleDamage};
use clock_ti... | fragment.style = new_style
});
let base = flow::mut_base(flow);
base.restyle_damage.insert(damage);
for kid in base.children.iter_mut() {
recalc_style_for_animation(kid, animation)
}
}
/// Handles animation updates.
pub fn tick_all_animations(layout_task: &LayoutTask, rw_data: &mu... | {
#![allow(unsafe_code)] // #6376
let mut damage = RestyleDamage::empty();
flow.mutate_fragments(&mut |fragment| {
if fragment.node.id() != animation.node {
return
}
let now = clock_ticks::precise_time_s() as f32;
let mut progress = (now - animation.start_time) /... | identifier_body |
animation.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! CSS transitions and animations.
use flow::{self, Flow};
use incremental::{self, RestyleDamage};
use clock_ti... | } else {
animation_state = AnimationState::AnimationsPresent;
}
rw_data.constellation_chan
.0
.send(Msg::ChangeRunningAnimationsState(pipeline_id, animation_state))
.unwrap();
}
/// Recalculates style for an animation. This does *not* run with the DOM lock held.
pub ... | }
let animation_state;
if rw_data.running_animations.is_empty() {
animation_state = AnimationState::NoAnimationsPresent; | random_line_split |
animation.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! CSS transitions and animations.
use flow::{self, Flow};
use incremental::{self, RestyleDamage};
use clock_ti... | (new_animations_sender: &Sender<Animation>,
node: OpaqueNode,
old_style: &ComputedValues,
new_style: &mut ComputedValues) {
for i in 0..new_style.get_animation().transition_property.0.len() {
... | start_transitions_if_applicable | identifier_name |
animation.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! CSS transitions and animations.
use flow::{self, Flow};
use incremental::{self, RestyleDamage};
use clock_ti... |
if progress <= 0.0 {
return
}
let mut new_style = fragment.style.clone();
animation.property_animation.update(&mut *unsafe { new_style.make_unique() }, progress);
damage.insert(incremental::compute_damage(&Some(fragment.style.clone()), &new_style));
fragment... | {
progress = 1.0
} | conditional_block |
labels.rs | use std::fs::File;
use std::io::{Read, Seek, SeekFrom, self};
use std::iter;
use std::ops::{Index, Range};
use std::path::Path;
use byteorder::{BigEndian, ReadBytesExt};
use cast::From as _0;
use linalg::prelude::*;
/// Labels corresponding to a set of images
pub struct Labels {
data: Vec<u8>,
num_classes: u3... |
let num_classes = u32::from_(*buf.iter().max().unwrap_or(&0)) + 1;
Ok(Labels {
data: buf,
num_classes: num_classes,
size: end - start,
})
}
/// Returns the number of classes
pub fn num_classes(&self) -> u32 {
self.num_classes
}
... | {
/// Magic number expected in the header
const MAGIC: u32 = 2049;
assert!(start < end);
let mut file = try!(File::open(path));
// Parse the header: MAGIC NLABELS
assert_eq!(try!(file.read_u32::<BigEndian>()), MAGIC);
let nlabels = try!(file.read_u32::<BigEndia... | identifier_body |
labels.rs | use std::fs::File;
use std::io::{Read, Seek, SeekFrom, self};
use std::iter;
use std::ops::{Index, Range};
use std::path::Path;
use byteorder::{BigEndian, ReadBytesExt};
use cast::From as _0;
use linalg::prelude::*;
/// Labels corresponding to a set of images
pub struct Labels {
data: Vec<u8>,
num_classes: u3... |
for (mut r, &label) in m.rows_mut().zip(&self.data) {
r[u32::from_(label)] = 1.;
}
m
}
}
impl Index<u32> for Labels {
type Output = u8;
fn index(&self, i: u32) -> &u8 {
&self.data[usize::from_(i)]
}
} | random_line_split | |
labels.rs | use std::fs::File;
use std::io::{Read, Seek, SeekFrom, self};
use std::iter;
use std::ops::{Index, Range};
use std::path::Path;
use byteorder::{BigEndian, ReadBytesExt};
use cast::From as _0;
use linalg::prelude::*;
/// Labels corresponding to a set of images
pub struct Labels {
data: Vec<u8>,
num_classes: u3... | <P>(path: P, subset: Range<u32>) -> io::Result<Labels> where P: AsRef<Path> {
Labels::load_(path.as_ref(), subset)
}
fn load_(path: &Path, Range { start, end }: Range<u32>) -> io::Result<Labels> {
/// Magic number expected in the header
const MAGIC: u32 = 2049;
assert!(start < ... | load | identifier_name |
content_length.rs | use std::fmt;
use header::{Header, parsing};
/// `Content-Length` header, defined in
/// [RFC7230](http://tools.ietf.org/html/rfc7230#section-3.3.2)
///
/// When a message does not have a `Transfer-Encoding` header field, a
/// Content-Length header field can provide the anticipated size, as a
/// decimal number of ... | ///
/// let mut headers = Headers::new();
/// headers.set(ContentLength(1024u64));
/// ```
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct ContentLength(pub u64);
impl Header for ContentLength {
#[inline]
fn header_name() -> &'static str {
"Content-Length"
}
fn parse_header(raw: &[Vec<u8>]... | /// * `3495`
///
/// # Example
/// ```
/// use hyper::header::{Headers, ContentLength}; | random_line_split |
content_length.rs | use std::fmt;
use header::{Header, parsing};
/// `Content-Length` header, defined in
/// [RFC7230](http://tools.ietf.org/html/rfc7230#section-3.3.2)
///
/// When a message does not have a `Transfer-Encoding` header field, a
/// Content-Length header field can provide the anticipated size, as a
/// decimal number of ... | () -> &'static str {
"Content-Length"
}
fn parse_header(raw: &[Vec<u8>]) -> ::Result<ContentLength> {
// If multiple Content-Length headers were sent, everything can still
// be alright if they all contain the same value, and all parse
// correctly. If not, then it's an error.
... | header_name | identifier_name |
content_length.rs | use std::fmt;
use header::{Header, parsing};
/// `Content-Length` header, defined in
/// [RFC7230](http://tools.ietf.org/html/rfc7230#section-3.3.2)
///
/// When a message does not have a `Transfer-Encoding` header field, a
/// Content-Length header field can provide the anticipated size, as a
/// decimal number of ... |
}
impl fmt::Display for ContentLength {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}
__hyper__deref!(ContentLength => u64);
__hyper_generate_header_serialization!(ContentLength);
__hyper__tm!(ContentLength, tests {
// Testcase from RFC
... | {
fmt::Display::fmt(&self.0, f)
} | identifier_body |
router.rs |
use std::fmt;
use std::error::Error;
use std::fmt::Display;
use std::io::Read;
use std::io;
use tiny_http::{Request, Method, StatusCode};
use rustc_serialize::json;
use rustc_serialize::json::Json;
use url_parser;
use url_parser::UrlResource;
use std::io::Cursor;
use tiny_http::Response;
use api;
use context::Con... | () {
let response = request_router(&Method::Post, UrlResource::from_resource("/foo").unwrap());
assert!(http::response_string(response) == http::response_string(ok("foobar")));
}
#[test]
fn test_vector_match() {
let v = vec!("foo", "bar", "baz");
match ("fish", &v[..]) {
(_, []) ... | test_routing | identifier_name |
router.rs |
use std::fmt;
use std::error::Error;
use std::fmt::Display;
use std::io::Read;
use std::io;
use tiny_http::{Request, Method, StatusCode};
use rustc_serialize::json;
use rustc_serialize::json::Json;
use url_parser;
use url_parser::UrlResource;
use std::io::Cursor;
use tiny_http::Response;
use api;
use context::Con... |
}
impl From<json::ParserError> for RequestError {
fn from(err: json::ParserError) -> RequestError {
RequestError::JsonParseError(err)
}
}
impl From<url_parser::UrlParseError> for RequestError {
fn from(err: url_parser::UrlParseError) -> RequestError {
RequestError::UrlParseError(err)
}
... | {
RequestError::ReadError(err)
} | identifier_body |
router.rs | use std::fmt;
use std::error::Error;
use std::fmt::Display;
use std::io::Read;
use std::io;
use tiny_http::{Request, Method, StatusCode};
use rustc_serialize::json;
use rustc_serialize::json::Json;
use url_parser;
use url_parser::UrlResource;
use std::io::Cursor;
use tiny_http::Response;
use api;
use context::Cont... | RequestError::UrlParseError(ref err) => err.description(),
RequestError::UnknownResource => "Unknown url",
RequestError::UnsupportedMethod => "Unsupported Method",
}
}
}
impl From<io::Error> for RequestError {
fn from(err: io::Error) -> RequestError {
RequestE... | match *self {
RequestError::ReadError(ref err) => err.description(),
RequestError::JsonParseError(ref err) => err.description(), | random_line_split |
lib.rs | //! This library implements basic processing of JavaScript sourcemaps.
//!
//! # Installation
//!
//! The crate is called sourcemap and you can depend on it via cargo:
//!
//! ```toml
//! [dependencies]
//! sourcemap = "*"
//! ```
//!
//! If you want to use the git version:
//!
//! ```toml
//! [dependencies.sourcemap]
... | //! }";
//! let sm = SourceMap::from_reader(input).unwrap();
//! let token = sm.lookup_token(0, 0).unwrap(); // line-number and column
//! println!("token: {}", token);
//! ```
//!
//! # Features
//!
//! Functionality of the crate can be turned on and off by feature flags. This is the
//! current list of feature flags... | //! \"sources\":[\"coolstuff.js\"],
//! \"names\":[\"x\",\"alert\"],
//! \"mappings\":\"AAAA,GAAIA,GAAI,EACR,IAAIA,GAAK,EAAG,CACVC,MAAM\" | random_line_split |
assign_ops2.rs | #[allow(unused_assignments)]
#[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
fn main() {
let mut a = 5;
a += a + 1;
a += 1 + a;
a -= a - 1;
a *= a * 99;
a *= 42 * a;
a /= a / 2;
a %= a % 5;
a &= a & 1;
a *= a * a;
a = a * a * a;
a = a * 42 * a;
a =... |
}
fn cow_add_assign() {
use std::borrow::Cow;
let mut buf = Cow::Owned(String::from("bar"));
let cows = Cow::Borrowed("foo");
// this can be linted
buf = buf + cows.clone();
// this should not as cow<str> Add is not commutative
buf = cows + buf;
println!("{}", buf);
}
| {
*self = *self * rhs
} | identifier_body |
assign_ops2.rs | #[allow(unused_assignments)]
#[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
fn main() {
let mut a = 5;
a += a + 1;
a += 1 + a;
a -= a - 1;
a *= a * 99;
a *= 42 * a;
a /= a / 2;
a %= a % 5;
a &= a & 1;
a *= a * a;
a = a * a * a;
a = a * 42 * a;
a =... | () {
use std::borrow::Cow;
let mut buf = Cow::Owned(String::from("bar"));
let cows = Cow::Borrowed("foo");
// this can be linted
buf = buf + cows.clone();
// this should not as cow<str> Add is not commutative
buf = cows + buf;
println!("{}", buf);
}
| cow_add_assign | identifier_name |
assign_ops2.rs | #[allow(unused_assignments)]
#[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
fn main() {
let mut a = 5;
a += a + 1;
a += 1 + a;
a -= a - 1;
a *= a * 99;
a *= 42 * a;
a /= a / 2;
a %= a % 5;
a &= a & 1;
a *= a * a;
a = a * a * a;
a = a * 42 * a;
a =... | #[derive(Copy, Clone, Debug, PartialEq)]
pub struct Wrap(i64);
impl Mul<i64> for Wrap {
type Output = Self;
fn mul(self, rhs: i64) -> Self {
Wrap(self.0 * rhs)
}
}
impl MulAssign<i64> for Wrap {
fn mul_assign(&mut self, rhs: i64) {
*self = *self * rhs
}
}
fn cow_add_assign() {
... | random_line_split | |
lib.rs | #![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(private_no_mangle_fns)]
#![feature(proc_macro)]
#![cfg_attr(feature = "strict", deny(warnings))]
#![feature(global_allocator)]
#![feature(concat_idents)]
#[macro_use]
extern crate lazy_static;
extern crate base64 as base64_crate;
extern crate libc;
... | () {
cmds::initial_keys();
}
include!(concat!(env!("OUT_DIR"), "/c_exports.rs"));
#[cfg(test)]
pub use functions::{lispsym, make_string, make_unibyte_string, Fcons, Fsignal};
| rust_initial_keys | identifier_name |
lib.rs | #![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(private_no_mangle_fns)]
#![feature(proc_macro)]
#![cfg_attr(feature = "strict", deny(warnings))]
#![feature(global_allocator)]
#![feature(concat_idents)]
#[macro_use]
extern crate lazy_static;
extern crate base64 as base64_crate;
extern crate libc;
... | mod keyboard;
mod keymap;
mod lists;
mod marker;
mod math;
mod minibuf;
mod multibyte;
mod numbers;
mod obarray;
mod objects;
mod process;
mod strings;
mod symbols;
mod threads;
mod util;
mod vectors;
mod windows;
#[cfg(all(not(test), target_os = "macos"))]
use alloc_unexecmacosx::OsxUnexecAlloc;
#[cfg(all(not(test),... | mod hashtable;
mod indent;
mod interactive; | random_line_split |
lib.rs | #![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(private_no_mangle_fns)]
#![feature(proc_macro)]
#![cfg_attr(feature = "strict", deny(warnings))]
#![feature(global_allocator)]
#![feature(concat_idents)]
#[macro_use]
extern crate lazy_static;
extern crate base64 as base64_crate;
extern crate libc;
... |
include!(concat!(env!("OUT_DIR"), "/c_exports.rs"));
#[cfg(test)]
pub use functions::{lispsym, make_string, make_unibyte_string, Fcons, Fsignal};
| {
cmds::initial_keys();
} | identifier_body |
problem2.rs | /// Represents a matrix in row-major order
pub type Matrix = Vec<Vec<f32>>;
/// Computes the product of the inputs `mat1` and `mat2`.
pub fn | (mat1: &Matrix, mat2: &Matrix) -> Matrix {
assert!(mat1.len()!= 0 && mat2.len()!= 0);
assert!(mat1[0].len()!= 0 && mat2[0].len()!= 0);
assert_eq!(mat1[0].len(), mat2.len());
println!("{:?}", mat1);
println!("{:?}", mat2);
let mut product = vec![vec![0.; mat2[0].len()]; mat1.len()];
for i in... | mat_mult | identifier_name |
problem2.rs | /// Represents a matrix in row-major order
pub type Matrix = Vec<Vec<f32>>;
/// Computes the product of the inputs `mat1` and `mat2`.
pub fn mat_mult(mat1: &Matrix, mat2: &Matrix) -> Matrix {
assert!(mat1.len()!= 0 && mat2.len()!= 0);
assert!(mat1[0].len()!= 0 && mat2[0].len()!= 0);
assert_eq!(mat1[0].len(... | } | product | random_line_split |
problem2.rs | /// Represents a matrix in row-major order
pub type Matrix = Vec<Vec<f32>>;
/// Computes the product of the inputs `mat1` and `mat2`.
pub fn mat_mult(mat1: &Matrix, mat2: &Matrix) -> Matrix | {
assert!(mat1.len() != 0 && mat2.len() != 0);
assert!(mat1[0].len() != 0 && mat2[0].len() != 0);
assert_eq!(mat1[0].len(), mat2.len());
println!("{:?}", mat1);
println!("{:?}", mat2);
let mut product = vec![vec![0.; mat2[0].len()]; mat1.len()];
for i in 0..mat1.len() {
for j in 0..... | identifier_body | |
lib.rs | // Copyright 2015 Brendan Zabarauskas and the gl-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 b... | let _: raw::c_uint = gl::CreateProgram();
gl::CompileShader(5);
gl::GetActiveUniformBlockiv(
0,
0,
gl::UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER,
std::ptr::null_mut(),
);
}
}
#[test]
fn test_fallback_works() {
fn loader(name: &st... |
pub fn compile_test_symbols_exist() {
unsafe {
gl::Clear(gl::COLOR_BUFFER_BIT); | random_line_split |
lib.rs | // Copyright 2015 Brendan Zabarauskas and the gl-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 b... | {
fn loader(name: &str) -> *const raw::c_void {
match name {
"glGenFramebuffers" => 0 as *const raw::c_void,
"glGenFramebuffersEXT" => 42 as *const raw::c_void,
name => panic!("test tried to load {} unexpectedly!", name),
}
};
gl::GenFramebuffers::load_wi... | identifier_body | |
lib.rs | // Copyright 2015 Brendan Zabarauskas and the gl-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 b... | (name: &str) -> *const raw::c_void {
match name {
"glGenFramebuffers" => 0 as *const raw::c_void,
"glGenFramebuffersEXT" => 42 as *const raw::c_void,
name => panic!("test tried to load {} unexpectedly!", name),
}
};
gl::GenFramebuffers::load_with(loader);
... | loader | identifier_name |
int_macros.rs | // Copyright 2012-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-MI... | // calling the `Bounded::max_value` function.
#[stable(feature = "rust1", since = "1.0.0")]
pub const MAX: $T =!MIN;
) } | #[stable(feature = "rust1", since = "1.0.0")]
pub const MIN: $T = (-1 as $T) << (BITS - 1);
// FIXME(#9837): Compute MIN like this so the high bits that shouldn't exist are 0.
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of | random_line_split |
safe.rs | // Copyright 2012-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-MI... | //! The `DepGraphSafe` trait
use hir::BodyId;
use hir::def_id::DefId;
use syntax::ast::NodeId;
use ty::TyCtxt;
/// The `DepGraphSafe` trait is used to specify what kinds of values
/// are safe to "leak" into a task. The idea is that this should be
/// only be implemented for things like the tcx as well as various id
... | // option. This file may not be copied, modified, or distributed
// except according to those terms.
| random_line_split |
safe.rs | // Copyright 2012-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-MI... | <T>(pub T);
impl<T> DepGraphSafe for AssertDepGraphSafe<T> {
}
| AssertDepGraphSafe | identifier_name |
compressor.rs | /*
* Copyright 2021 Google LLC
*
* 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 agreed to i... | use snap::read::FrameDecoder;
use snap::write::FrameEncoder;
/// A trait that provides a compression and decompression strategy for this filter.
/// Conversion takes place on a mutable Vec, to ensure the most performant compression or
/// decompression operation can occur.
pub(crate) trait Compressor {
/// Compres... | * limitations under the License.
*/
use std::io;
| random_line_split |
compressor.rs | /*
* Copyright 2021 Google LLC
*
* 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 agreed to i... | (&self, contents: &mut Vec<u8>) -> io::Result<()> {
let input = std::mem::take(contents);
let mut rdr = FrameDecoder::new(input.as_slice());
io::copy(&mut rdr, contents)?;
Ok(())
}
}
| decode | identifier_name |
operation.rs | #[repr(u32)]
#[derive(Debug, Clone, Copy)]
pub enum | {
/**
* The default storage mode. This constant was added in version 2.6.2 for
* the sake of maintaining a default storage mode, eliminating the need
* for simple storage operations to explicitly define operation.
* Behaviorally it is identical to Set
* in that it will make the server unco... | Operation | identifier_name |
operation.rs | #[repr(u32)]
#[derive(Debug, Clone, Copy)]
pub enum Operation {
/**
* The default storage mode. This constant was added in version 2.6.2 for
* the sake of maintaining a default storage mode, eliminating the need
* for simple storage operations to explicitly define operation.
* Behaviorally it is... |
/** Unconditionally store the item in the cluster */
Set = 3,
/**
* Rather than setting the contents of the entire document, take the value
* specified in value and _append_ it to the existing bytes in
* the value.
*/
Append = 4,
/**
* Like Append, but prepends the new va... | * Will cause the operation to fail _unless_ the key already exists in the
* cluster.
*/
Replace = 2, | random_line_split |
mod.rs | use self::api_request_processor::ApiReply;
use crate::commands::CommandHelpers;
use crate::entity::EntityRef;
use crate::entity::Realm;
use crate::player_output::PlayerOutput;
use crate::sessions::SessionOutput;
mod api_request_processor;
mod entity_create_command;
mod entity_delete_command;
mod entity_list_command;
m... | let reply = serde_json::to_value(reply).unwrap();
let mut output: Vec<PlayerOutput> = Vec::new();
push_session_output!(output, player_ref, SessionOutput::Json(reply));
output
})
} | Ok(reply) => reply,
Err(error) => error,
},
_ => ApiReply::new_error("", 403, "Forbidden"),
}; | random_line_split |
mod.rs | use self::api_request_processor::ApiReply;
use crate::commands::CommandHelpers;
use crate::entity::EntityRef;
use crate::entity::Realm;
use crate::player_output::PlayerOutput;
use crate::sessions::SessionOutput;
mod api_request_processor;
mod entity_create_command;
mod entity_delete_command;
mod entity_list_command;
m... | <F>(
f: F,
) -> Box<dyn Fn(&mut Realm, EntityRef, CommandHelpers) -> Vec<PlayerOutput>>
where
F: Fn(&mut Realm, CommandHelpers) -> Result<ApiReply, ApiReply> +'static,
{
Box::new(move |realm, player_ref, helpers| {
let reply = match realm.player(player_ref) {
Some(player) if player.is_ad... | wrap_api_request | identifier_name |
mod.rs | use self::api_request_processor::ApiReply;
use crate::commands::CommandHelpers;
use crate::entity::EntityRef;
use crate::entity::Realm;
use crate::player_output::PlayerOutput;
use crate::sessions::SessionOutput;
mod api_request_processor;
mod entity_create_command;
mod entity_delete_command;
mod entity_list_command;
m... | {
Box::new(move |realm, player_ref, helpers| {
let reply = match realm.player(player_ref) {
Some(player) if player.is_admin() => match f(realm, helpers) {
Ok(reply) => reply,
Err(error) => error,
},
_ => ApiReply::new_error("", 403, "Forbid... | identifier_body | |
lock_button.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | pub fn get_permission(&self) -> Option<Permission> {
let tmp_pointer = unsafe { ffi::gtk_lock_button_get_permission(GTK_LOCKBUTTON(self.pointer)) };
if tmp_pointer.is_null() {
None
} else {
Some(GlibContainer::wrap(tmp_pointer))
}
}
pub fn set_permis... | let tmp_pointer = unsafe { ffi::gtk_lock_button_new(permission.unwrap()) };
check_pointer!(tmp_pointer, LockButton)
}
| identifier_body |
lock_button.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | }
pub fn set_permission(&self, permission: &Permission) {
unsafe { ffi::gtk_lock_button_set_permission(GTK_LOCKBUTTON(self.pointer), permission.unwrap()) }
}
}
impl_drop!(LockButton);
impl_TraitWidget!(LockButton);
impl gtk::ContainerTrait for LockButton {}
impl gtk::ButtonTrait for LockButton {}
... | Some(GlibContainer::wrap(tmp_pointer))
}
| conditional_block |
lock_button.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | self) -> Option<Permission> {
let tmp_pointer = unsafe { ffi::gtk_lock_button_get_permission(GTK_LOCKBUTTON(self.pointer)) };
if tmp_pointer.is_null() {
None
} else {
Some(GlibContainer::wrap(tmp_pointer))
}
}
pub fn set_permission(&self, permission: &Pe... | t_permission(& | identifier_name |
lock_button.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | //! A container for arranging buttons
use gtk::cast::GTK_LOCKBUTTON;
use gtk::{self, ffi};
use glib::Permission;
use glib::GlibContainer;
/// GtkLockButton — A widget to unlock or lock privileged operations
struct_Widget!(LockButton);
impl LockButton {
pub fn new(permission: &Permission) -> Option<LockButton> {
... | // You should have received a copy of the GNU Lesser General Public License
// along with rgtk. If not, see <http://www.gnu.org/licenses/>.
| random_line_split |
main.rs | // Import Crate Module with shapes
use traits_shapes::shapes;
// use traits_shapes::shapes::HasArea;
// Compile and link to the 'hello_world' Crate so its Modules may be used in main.rs
extern crate traits_shapes;
// Traits are defined similar to the 'impl' keyword that is used to call a function
// with method synta... | };
let my_square = shapes::Square {
x: 0.0f64,
y: 0.0f64,
side: 1.0f64,
};
// print_area is now Generic and ensures only correct Types are passed in
shapes::print_area(my_circle); // outputs 3.141593
shapes::print_area(my_square); // outputs 1
shapes::print_area(5); // outputs 5
} | fn main() {
let my_circle = shapes::Circle {
x: 0.0f64,
y: 0.0f64,
radius: 1.0f64, | random_line_split |
main.rs | // Import Crate Module with shapes
use traits_shapes::shapes;
// use traits_shapes::shapes::HasArea;
// Compile and link to the 'hello_world' Crate so its Modules may be used in main.rs
extern crate traits_shapes;
// Traits are defined similar to the 'impl' keyword that is used to call a function
// with method synta... | () {
let my_circle = shapes::Circle {
x: 0.0f64,
y: 0.0f64,
radius: 1.0f64,
};
let my_square = shapes::Square {
x: 0.0f64,
y: 0.0f64,
side: 1.0f64,
};
// print_area is now Generic and ensures only correct Types are passed in
shapes::print_area(my_circle); // outputs 3... | main | identifier_name |
main.rs | // Import Crate Module with shapes
use traits_shapes::shapes;
// use traits_shapes::shapes::HasArea;
// Compile and link to the 'hello_world' Crate so its Modules may be used in main.rs
extern crate traits_shapes;
// Traits are defined similar to the 'impl' keyword that is used to call a function
// with method synta... | {
let my_circle = shapes::Circle {
x: 0.0f64,
y: 0.0f64,
radius: 1.0f64,
};
let my_square = shapes::Square {
x: 0.0f64,
y: 0.0f64,
side: 1.0f64,
};
// print_area is now Generic and ensures only correct Types are passed in
shapes::print_area(my_circle); // outputs 3.14... | identifier_body | |
collection.rs | use cobalt_config::Frontmatter;
use cobalt_config::SortOrder;
use liquid;
use crate::error::*;
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)]
pub struct Collection {
pub title: kstring::KString,
pub slug: kstring::KString,
pub description: Option<kstring::KString>,
pub dir: cobalt_config::Re... | (&self) -> liquid::Object {
let mut attributes: liquid::Object = vec![
(
"title".into(),
liquid::model::Value::scalar(self.title.clone()),
),
(
"slug".into(),
liquid::model::Value::scalar(self.slug.clone()),
... | attributes | identifier_name |
collection.rs | use cobalt_config::Frontmatter;
use cobalt_config::SortOrder;
use liquid;
use crate::error::*;
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)]
pub struct Collection {
pub title: kstring::KString,
pub slug: kstring::KString,
pub description: Option<kstring::KString>,
pub dir: cobalt_config::Re... |
if let Some(jsonfeed) = self.jsonfeed.as_ref() {
attributes.insert(
"jsonfeed".into(),
liquid::model::Value::scalar(jsonfeed.as_str().to_owned()),
);
}
attributes
}
}
| {
attributes.insert(
"rss".into(),
liquid::model::Value::scalar(rss.as_str().to_owned()),
);
} | conditional_block |
collection.rs | use cobalt_config::Frontmatter;
use cobalt_config::SortOrder;
use liquid;
use crate::error::*;
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)]
pub struct Collection {
pub title: kstring::KString,
pub slug: kstring::KString,
pub description: Option<kstring::KString>,
pub dir: cobalt_config::Re... | attributes.insert(
"jsonfeed".into(),
liquid::model::Value::scalar(jsonfeed.as_str().to_owned()),
);
}
attributes
}
} | "rss".into(),
liquid::model::Value::scalar(rss.as_str().to_owned()),
);
}
if let Some(jsonfeed) = self.jsonfeed.as_ref() { | random_line_split |
lib.rs | // DO NOT EDIT!
// This file was generated automatically from'src/mako/api/lib.rs.mako'
// DO NOT EDIT!
//! This documentation was generated from *AdSense Host* crate version *0.1.8+20150617*, where *20150617* is the exact revision of the *adsensehost:v4.1* schema built by the [mako](http://www.makotemplates.org/) cod... | //! let r = hub.accounts().adunits_get(...).doit()
//! let r = hub.accounts().get(...).doit()
//! let r = hub.accounts().adunits_list(...).doit()
//! let r = hub.accounts().adunits_get_ad_code(...).doit()
//! let r = hub.accounts().reports_generate(...).doit()
//! let r = hub.accounts().adunits_delete(...).doit()
//! l... | //! Or specifically ...
//!
//! ```ignore | random_line_split |
borrowck-borrow-mut-base-ptr-in-aliasable-loc.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 ... |
fn foo3(t0: &mut &mut isize) {
let t1 = &mut *t0;
let p: &isize = &**t0; //~ ERROR cannot borrow
**t1 = 22;
}
fn foo4(t0: & &mut isize) {
let x: &mut isize = &mut **t0; //~ ERROR cannot borrow
*x += 1;
}
fn main() {
}
| {
let t1 = t0;
let p: &isize = &**t0;
**t1 = 22; //~ ERROR cannot assign
} | identifier_body |
borrowck-borrow-mut-base-ptr-in-aliasable-loc.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 ... | // Example from src/middle/borrowck/doc.rs
fn foo(t0: & &mut isize) {
let t1 = t0;
let p: &isize = &**t0;
**t1 = 22; //~ ERROR cannot assign
}
fn foo3(t0: &mut &mut isize) {
let t1 = &mut *t0;
let p: &isize = &**t0; //~ ERROR cannot borrow
**t1 = 22;
}
fn foo4(t0: & &mut isize) {
let x: ... | // except according to those terms.
// Test that attempt to reborrow an `&mut` pointer in an aliasable
// location yields an error.
// | random_line_split |
borrowck-borrow-mut-base-ptr-in-aliasable-loc.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 ... | (t0: &mut &mut isize) {
let t1 = &mut *t0;
let p: &isize = &**t0; //~ ERROR cannot borrow
**t1 = 22;
}
fn foo4(t0: & &mut isize) {
let x: &mut isize = &mut **t0; //~ ERROR cannot borrow
*x += 1;
}
fn main() {
}
| foo3 | identifier_name |
cabi_x86.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 ... | 2 => RetValue(Type::i16(ccx)),
4 => RetValue(Type::i32(ccx)),
8 => RetValue(Type::i64(ccx)),
_ => RetPointer
}
}
_ => {
RetPointer
}
};
match strategy {
... | {
let mut arg_tys = Vec::new();
let ret_ty;
if !ret_def {
ret_ty = ArgType::direct(Type::void(ccx), None, None, None);
} else if rty.kind() == Struct {
// Returning a structure. Most often, this will use
// a hidden first argument. On some platforms, though,
// small str... | identifier_body |
cabi_x86.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 ... |
for &t in atys.iter() {
let ty = match t.kind() {
Struct => {
let size = llsize_of_alloc(ccx, t);
if size == 0 {
ArgType::ignore(t)
} else {
ArgType::indirect(t, Some(ByValAttribute))
}
... | {
ret_ty = ArgType::direct(rty, None, None, None);
} | conditional_block |
cabi_x86.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. | // 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.
use syntax::abi::{OsWin32, OsMacos};
use lib::llvm::*;
use super::cabi::*;
use super::c... | //
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | random_line_split |
cabi_x86.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 ... | { RetValue(Type), RetPointer }
let strategy = match ccx.sess().targ_cfg.os {
OsWin32 | OsMacos => {
match llsize_of_alloc(ccx, rty) {
1 => RetValue(Type::i8(ccx)),
2 => RetValue(Type::i16(ccx)),
4 => RetValue(Type::i32(ccx)... | Strategy | identifier_name |
image.rs | extern crate piston_window;
extern crate find_folder;
use piston_window::*; | .exit_on_esc(true)
.opengl(opengl)
.build()
.unwrap();
let assets = find_folder::Search::ParentsThenKids(3, 3)
.for_folder("assets").unwrap();
let rust_logo = assets.join("rust.png");
let rust_logo = Texture::from_path(
&mut *window.factory.borrow_mut(),
... |
fn main() {
let opengl = OpenGL::V3_2;
let window: PistonWindow =
WindowSettings::new("piston: image", [300, 300]) | random_line_split |
image.rs | extern crate piston_window;
extern crate find_folder;
use piston_window::*;
fn main() | clear([1.0; 4], g);
image(&rust_logo, c.transform, g);
});
}
}
| {
let opengl = OpenGL::V3_2;
let window: PistonWindow =
WindowSettings::new("piston: image", [300, 300])
.exit_on_esc(true)
.opengl(opengl)
.build()
.unwrap();
let assets = find_folder::Search::ParentsThenKids(3, 3)
.for_folder("assets").unwrap();
let rus... | identifier_body |
image.rs | extern crate piston_window;
extern crate find_folder;
use piston_window::*;
fn | () {
let opengl = OpenGL::V3_2;
let window: PistonWindow =
WindowSettings::new("piston: image", [300, 300])
.exit_on_esc(true)
.opengl(opengl)
.build()
.unwrap();
let assets = find_folder::Search::ParentsThenKids(3, 3)
.for_folder("assets").unwrap();
let rust_... | main | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.