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
main.rs
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn
() { println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1, 101); println!("The secret number is: {}", secret_number); loop { println!("Please input your guess."); let mut guess = String::new(); io::stdin().read_line(&mut guess) .expect("Failed to read line"); ...
main
identifier_name
main.rs
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1, 101); println!("The secret number is: {}", secret_number); loop { println!("Please input your guess.");
let guess: u32 = match guess.trim().parse() { Ok(num) => num, Err(_) => continue, }; match guess.cmp(&secret_number) { Ordering::Less => println!("Too small!"), Ordering::Greater => println!("Too big!"), Ordering::Equal => { println!("You win!"); break; ...
let mut guess = String::new(); io::stdin().read_line(&mut guess) .expect("Failed to read line"); println!("You guessed {}", guess);
random_line_split
main.rs
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn main()
Ordering::Less => println!("Too small!"), Ordering::Greater => println!("Too big!"), Ordering::Equal => { println!("You win!"); break; } } } }
{ println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1, 101); println!("The secret number is: {}", secret_number); loop { println!("Please input your guess."); let mut guess = String::new(); io::stdin().read_line(&mut guess) .expect("Failed to read line"); p...
identifier_body
player.rs
use rd::util::types::*; use rd::actor::Actor; pub struct Player { position: usize, experience: Experience, exp_to_level_up: Experience, level: Level, hp: Health, max_hp: Health, attack: Attack, } pub const MAX_LEVEL: Level = 10; const EXP_PER_LEVEL: Experience = 5; const HP_PER_LEVEL: Heal...
(&self) -> Experience { self.experience } pub fn get_exp_needed_to_level_up(&self) -> Experience { self.exp_to_level_up } pub fn grant_exp(&mut self, exp: Experience) { self.experience += exp; dbg!("Granted {} EXP.", exp); if self.levelled_past_max() { ...
get_exp
identifier_name
player.rs
use rd::util::types::*; use rd::actor::Actor; pub struct Player { position: usize, experience: Experience, exp_to_level_up: Experience, level: Level, hp: Health, max_hp: Health, attack: Attack, } pub const MAX_LEVEL: Level = 10; const EXP_PER_LEVEL: Experience = 5; const HP_PER_LEVEL: Heal...
while self.experience >= self.exp_to_level_up { self.level_up(); self.exp_to_level_up += EXP_PER_LEVEL; } } #[cfg(test)] pub fn damage(&mut self, damage_points: Health) { self.hp -= damage_points; } fn level_up(&mut self) { self.level += 1;...
{ self.experience -= self.exp_to_level_up; self.restore_full_hp(); return; }
conditional_block
player.rs
use rd::util::types::*; use rd::actor::Actor; pub struct Player { position: usize, experience: Experience, exp_to_level_up: Experience, level: Level, hp: Health, max_hp: Health, attack: Attack, } pub const MAX_LEVEL: Level = 10; const EXP_PER_LEVEL: Experience = 5; const HP_PER_LEVEL: Heal...
pub fn spawn_at(spawn_point: MapIndex) -> Player { Player { position: spawn_point, experience: 0, exp_to_level_up: EXP_PER_LEVEL, level: 1, hp: 10, max_hp: 10, attack: 5, } } pub fn move_to(&mut self, tile: ...
self.position } } impl Player {
random_line_split
player.rs
use rd::util::types::*; use rd::actor::Actor; pub struct Player { position: usize, experience: Experience, exp_to_level_up: Experience, level: Level, hp: Health, max_hp: Health, attack: Attack, } pub const MAX_LEVEL: Level = 10; const EXP_PER_LEVEL: Experience = 5; const HP_PER_LEVEL: Heal...
pub fn get_exp(&self) -> Experience { self.experience } pub fn get_exp_needed_to_level_up(&self) -> Experience { self.exp_to_level_up } pub fn grant_exp(&mut self, exp: Experience) { self.experience += exp; dbg!("Granted {} EXP.", exp); if self.levelled_p...
{ self.position = tile; dbg!("Player moved to {}", tile); }
identifier_body
path.rs
extern crate url; use url::percent_encoding::percent_decode; use regex; use json::{JsonValue, ToJson}; lazy_static! { pub static ref MATCHER: regex::Regex = regex::Regex::new(r":([a-z][a-z_]*)").unwrap(); } pub struct Path { regex: regex::Regex, pub path: String, pub params: Vec<String> } pub fn nor...
() { let path = Path::parse(":id", true).unwrap(); assert!(match path.is_match("550e8400-e29b-41d4-a716-446655440000") { Some(captures) => captures.name("id").unwrap() == "550e8400-e29b-41d4-a716-446655440000", None => false }); }
parse_and_match_single_val
identifier_name
path.rs
extern crate url; use url::percent_encoding::percent_decode; use regex; use json::{JsonValue, ToJson}; lazy_static! { pub static ref MATCHER: regex::Regex = regex::Regex::new(r":([a-z][a-z_]*)").unwrap(); } pub struct Path { regex: regex::Regex, pub path: String, pub params: Vec<String> } pub fn nor...
} #[test] fn parse_and_match_single_val() { let path = Path::parse(":id", true).unwrap(); assert!(match path.is_match("550e8400-e29b-41d4-a716-446655440000") { Some(captures) => captures.name("id").unwrap() == "550e8400-e29b-41d4-a716-446655440000", None => false }); }
assert!(match path.is_match("") { Some(captures) => captures.at(0).unwrap() == "", None => false });
random_line_split
path.rs
extern crate url; use url::percent_encoding::percent_decode; use regex; use json::{JsonValue, ToJson}; lazy_static! { pub static ref MATCHER: regex::Regex = regex::Regex::new(r":([a-z][a-z_]*)").unwrap(); } pub struct Path { regex: regex::Regex, pub path: String, pub params: Vec<String> } pub fn nor...
let regex = match regex::Regex::new(&regex_body) { Ok(re) => re, Err(err) => return Err(format!("{}", err)) }; let mut params = vec![]; for capture in MATCHER.captures_iter(path) { params.push(capture.at(1).unwrap_or("").to_string()); } ...
{ regex_body = regex_body + "$"; }
conditional_block
path.rs
extern crate url; use url::percent_encoding::percent_decode; use regex; use json::{JsonValue, ToJson}; lazy_static! { pub static ref MATCHER: regex::Regex = regex::Regex::new(r":([a-z][a-z_]*)").unwrap(); } pub struct Path { regex: regex::Regex, pub path: String, pub params: Vec<String> } pub fn nor...
#[test] fn parse_and_match_root() { let path = Path::parse("", true).unwrap(); assert!(match path.is_match("") { Some(captures) => captures.at(0).unwrap() == "", None => false }); } #[test] fn parse_and_match_single_val() { let path = Path::parse(":id", true).unwrap(); assert!(mat...
{ let path = Path::parse(":user_id/messages/:message_id", true).unwrap(); assert!(match path.is_match("1920/messages/100500") { Some(captures) => { captures.name("user_id").unwrap() == "1920" && captures.name("message_id").unwrap() == "100500" } None => false ...
identifier_body
mod.rs
mod eloop; pub(crate) use self::eloop::EventLoop; thread_local!(pub(crate) static CURRENT_LOOP: EventLoop = EventLoop::new().unwrap()); mod gate; pub use self::gate::Gate; mod timer; pub use self::timer::{PeriodicTimer, Timer}; mod wheel; use self::wheel::Wheel; mod sleep; pub use self::sleep::*; mod timeout; pub...
{ CURRENT_LOOP.with(|eloop| unsafe { eloop.as_mut() }.spawn(task)) }
identifier_body
mod.rs
mod eloop; pub(crate) use self::eloop::EventLoop; thread_local!(pub(crate) static CURRENT_LOOP: EventLoop = EventLoop::new().unwrap()); mod gate; pub use self::gate::Gate; mod timer; pub use self::timer::{PeriodicTimer, Timer}; mod wheel; use self::wheel::Wheel; mod sleep; pub use self::sleep::*; mod timeout; pub...
pub fn spawn(task: Task) { CURRENT_LOOP.with(|eloop| unsafe { eloop.as_mut() }.spawn(task)) }
random_line_split
mod.rs
mod eloop; pub(crate) use self::eloop::EventLoop; thread_local!(pub(crate) static CURRENT_LOOP: EventLoop = EventLoop::new().unwrap()); mod gate; pub use self::gate::Gate; mod timer; pub use self::timer::{PeriodicTimer, Timer}; mod wheel; use self::wheel::Wheel; mod sleep; pub use self::sleep::*; mod timeout; pub...
(task: Task) { CURRENT_LOOP.with(|eloop| unsafe { eloop.as_mut() }.spawn(task)) }
spawn
identifier_name
sha2.rs
FixedBuffer { /// Input a vector of bytes. If the buffer becomes full, process it with the provided /// function and then clear the buffer. fn input<F>(&mut self, input: &[u8], func: F) where F: FnMut(&[u8]); /// Reset the buffer. fn reset(&mut self); /// Zero the buffer up until the ...
output_str: "ef537f25c895bfa78252\ 6529a9b63d97aa631564d5d789c2b765448c8635fb6c".to_string() }); let tests = wikipedia_tests;
random_line_split
sha2.rs
self) -> (Self, Self); } impl ToBits for u64 { fn to_bits(self) -> (u64, u64) { return (self >> 61, self << 3); } } /// Adds the specified number of bytes to the bit count. panic!() if this would cause numeric /// overflow. fn add_bytes_to_bits<T: Int + ToBits>(bits: T, bytes: T) -> T { let (new_h...
(&mut self, data: &[u8]) { fn ch(x: u32, y: u32, z: u32) -> u32 { ((x & y) ^ ((!x) & z)) } fn maj(x: u32, y: u32, z: u32) -> u32 { ((x & y) ^ (x & z) ^ (y & z)) } fn sum0(x: u32) -> u32 { ((x >> 2) | (x << 30)) ^ ((x >> 13) | (x << 19)) ^ ((x...
process_block
identifier_name
access_control_allow_methods.rs
use method::Method; header! { #[doc="`Access-Control-Allow-Methods` header, part of"] #[doc="[CORS](http://www.w3.org/TR/cors/#access-control-allow-methods-response-header)"] #[doc=""] #[doc="The `Access-Control-Allow-Methods` header indicates, as part of the"] #[doc="response to a preflight reques...
#[doc="```"] #[doc="use hyper::header::{Headers, AccessControlAllowMethods};"] #[doc="use hyper::method::Method;"] #[doc=""] #[doc="let mut headers = Headers::new();"] #[doc="headers.set("] #[doc=" AccessControlAllowMethods(vec![Method::Get])"] #[doc=");"] #[doc="```"] #[doc="...
#[doc="# Example values"] #[doc="* `PUT, DELETE, XMODIFY`"] #[doc=""] #[doc="# Examples"]
random_line_split
issue-2356.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...
(other:usize) { whiskers = 4; //~^ ERROR cannot find value `whiskers` purr_louder(); //~^ ERROR cannot find function `purr_louder` } } fn main() { self += 1; //~^ ERROR expected value, found module `self` }
grow_older
identifier_name
issue-2356.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...
} fn purr(&self) { grow_older(); //~^ ERROR cannot find function `grow_older` shave(); //~^ ERROR cannot find function `shave` } fn burn_whiskers(&mut self) { whiskers = 0; //~^ ERROR cannot find value `whiskers` } pub fn grow_older(other:usize) { whiskers = 4; //~^ ERROR...
{ //~^ ERROR expected value, found module `self` println!("MEOW"); }
conditional_block
issue-2356.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...
} impl Groom for cat { fn shave(other: usize) { whiskers -= other; //~^ ERROR cannot find value `whiskers` shave(4); //~^ ERROR cannot find function `shave` purr(); //~^ ERROR cannot find function `purr` } } impl cat { fn static_method() {} fn purr_louder() { static_metho...
{ default(); //~^ ERROR cannot find function `default` loop {} }
identifier_body
issue-2356.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...
impl Default for cat { fn default() -> Self { default(); //~^ ERROR cannot find function `default` loop {} } } impl Groom for cat { fn shave(other: usize) { whiskers -= other; //~^ ERROR cannot find value `whiskers` shave(4); //~^ ERROR cannot find function `shave` purr(); //~...
//~^ ERROR cannot find function `clone` loop {} } }
random_line_split
callee.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 ...
}; span_err!(tcx.sess, span, E0174, "explicit use of unboxed closure method `{}` is experimental", method); span_help!(tcx.sess, span, "add `#![feature(unboxed_closures)]` to the crate attributes to enable"); } }
{ let tcx = ccx.tcx; let did = Some(trait_id); let li = &tcx.lang_items; if did == li.drop_trait() { span_err!(tcx.sess, span, E0040, "explicit use of destructor method"); } else if !tcx.sess.features.borrow().unboxed_closures { // the #[feature(unboxed_closures)] feature isn't ...
identifier_body
callee.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 ...
(ccx: &CrateCtxt, span: Span, trait_id: ast::DefId) { let tcx = ccx.tcx; let did = Some(trait_id); let li = &tcx.lang_items; if did == li.drop_trait() { span_err!(tcx.sess, span, E0040, "explicit use of destructor method"); } else if!tcx.sess.features.borrow().unboxed_closures { // ...
check_legal_trait_for_method_call
identifier_name
callee.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 ...
else if!tcx.sess.features.borrow().unboxed_closures { // the #[feature(unboxed_closures)] feature isn't // activated so we need to enforce the closure // restrictions. let method = if did == li.fn_trait() { "call" } else if did == li.fn_mut_trait() { "ca...
{ span_err!(tcx.sess, span, E0040, "explicit use of destructor method"); }
conditional_block
callee.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 ...
if did == li.drop_trait() { span_err!(tcx.sess, span, E0040, "explicit use of destructor method"); } else if!tcx.sess.features.borrow().unboxed_closures { // the #[feature(unboxed_closures)] feature isn't // activated so we need to enforce the closure // restrictions. l...
let did = Some(trait_id); let li = &tcx.lang_items;
random_line_split
cmp.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::cmp::Ordering::{self, Less, Equal, Greater}; // impl Ord for str { // #[inline] // fn cmp(&self, other: &str) -> Ordering { // for (s_b, o_b) in self.bytes().zip(other.bytes()) { // ...
() { let x: &str = "日"; // '\u{65e5}' let other: &str = "月"; // '\u{6708}' let result: Ordering = x.cmp(other); assert_eq!(result, Less); } #[test] fn cmp_test2() { let x: &str = "天"; // '\u{5929}' let other: &str = "地"; // '\u{5730}' let result: Ordering = x.cmp(other); assert_eq!(result, Greate...
cmp_test1
identifier_name
cmp.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::cmp::Ordering::{self, Less, Equal, Greater}; // impl Ord for str { // #[inline] // fn cmp(&self, other: &str) -> Ordering { // for (s_b, o_b) in self.bytes().zip(other.bytes()) { // ...
"人"; let other: &str = "人種"; let result: Ordering = x.cmp(other); assert_eq!(result, Less); } }
identifier_body
cmp.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::cmp::Ordering::{self, Less, Equal, Greater}; // impl Ord for str { // #[inline] // fn cmp(&self, other: &str) -> Ordering { // for (s_b, o_b) in self.bytes().zip(other.bytes()) { // ...
let other: &str = "人"; let result: Ordering = x.cmp(other); assert_eq!(result, Greater); } #[test] fn cmp_test5() { let x: &str = "人"; let other: &str = "人種"; let result: Ordering = x.cmp(other); assert_eq!(result, Less); } }
random_line_split
util.rs
use std::str; use nom::{self, InputLength, IResult, Needed}; pub fn fixed_length_ascii(input: &[u8], len: usize) -> IResult<&[u8], &str> { if input.len() < len { return Err(nom::Err::Incomplete(Needed::Size(len)));
for i in 0..len { match input[i] { 0 => { // This is the end let s = unsafe { str::from_utf8_unchecked(&input[..i]) }; return Ok((&input[len..], s)); } 32... 126 => { // OK } _ => { ...
}
random_line_split
util.rs
use std::str; use nom::{self, InputLength, IResult, Needed}; pub fn fixed_length_ascii(input: &[u8], len: usize) -> IResult<&[u8], &str> { if input.len() < len { return Err(nom::Err::Incomplete(Needed::Size(len))); } for i in 0..len { match input[i] { 0 => { /...
_ => { // Totally bogus character return Err(nom::Err::Error(nom::Context::Code(&input[i..], nom::ErrorKind::Custom(0)))); } } } Ok((&input[len..], unsafe { str::from_utf8_unchecked(&input[..len]) })) } /// Like nom's eof!(), except it actually...
{ // OK }
conditional_block
util.rs
use std::str; use nom::{self, InputLength, IResult, Needed}; pub fn fixed_length_ascii(input: &[u8], len: usize) -> IResult<&[u8], &str>
} Ok((&input[len..], unsafe { str::from_utf8_unchecked(&input[..len]) })) } /// Like nom's eof!(), except it actually works on buffers -- which means it won't work on streams pub fn naive_eof(input: &[u8]) -> IResult<&[u8], ()> { if input.input_len() == 0 { Ok((input, ())) } else { E...
{ if input.len() < len { return Err(nom::Err::Incomplete(Needed::Size(len))); } for i in 0..len { match input[i] { 0 => { // This is the end let s = unsafe { str::from_utf8_unchecked(&input[..i]) }; return Ok((&input[len..], s)); ...
identifier_body
util.rs
use std::str; use nom::{self, InputLength, IResult, Needed}; pub fn fixed_length_ascii(input: &[u8], len: usize) -> IResult<&[u8], &str> { if input.len() < len { return Err(nom::Err::Incomplete(Needed::Size(len))); } for i in 0..len { match input[i] { 0 => { /...
(input: &[u8]) -> IResult<&[u8], ()> { if input.input_len() == 0 { Ok((input, ())) } else { Err(nom::Err::Error(error_position!(input, nom::ErrorKind::Eof::<u32>))) } }
naive_eof
identifier_name
mod.rs
// Copyright 2020 The Exonum Team // // 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...
entry::Entry, group::Group, iter::{Entries, IndexIterator, Keys, Values}, key_set::KeySetIndex, list::ListIndex, map::MapIndex, proof_entry::ProofEntry, sparse_list::SparseListIndex, value_set::ValueSetIndex, }; mod entry; mod group; mod iter; mod key_set; mod list; mod map; mod pro...
pub use self::{
random_line_split
client_stress_test.rs
// Copyright 2016 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
else { println!("\n\tAccount Creation"); println!("\t================"); println!("\nTrying to create an account..."); unwrap!(Client::registered( &secret_0, &secret_1, &invitation, el_h, core_tx.clone(), net_tx, ...
{ unwrap!(Client::login( &secret_0, &secret_1, el_h, core_tx.clone(), net_tx, )) }
conditional_block
client_stress_test.rs
// Copyright 2016 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
}))); event_loop::run(el, &client, &(), core_rx); }
.into_box() .into()
random_line_split
client_stress_test.rs
// Copyright 2016 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
() { unwrap!(maidsafe_utilities::log::init(true)); let args: Args = Docopt::new(USAGE) .and_then(|docopt| docopt.decode()) .unwrap_or_else(|error| error.exit()); let immutable_data_count = unwrap!(args.flag_immutable); let mutable_data_count = unwrap!(args.flag_mutable); let mut rng ...
main
identifier_name
page.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::cell::DOMRefCell; use dom::bindings::js::{JS, Root}; use dom::document::Document; use dom::wind...
/// Indicates if reflow is required when reloading. needs_reflow: Cell<bool>, // Child Pages. pub children: DOMRefCell<Vec<Rc<Page>>>, } pub struct PageIterator { stack: Vec<Rc<Page>>, } pub trait IterablePage { fn iter(&self) -> PageIterator; fn find(&self, id: PipelineId) -> Option<Rc<...
id: PipelineId, /// The outermost frame containing the document and window. frame: DOMRefCell<Option<Frame>>,
random_line_split
page.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::cell::DOMRefCell; use dom::bindings::js::{JS, Root}; use dom::document::Document; use dom::wind...
(&self, id: PipelineId) -> Option<Rc<Page>> { let remove_idx = { self.children .borrow_mut() .iter_mut() .position(|page_tree| page_tree.id == id) }; match remove_idx { Some(idx) => Some(self.children.borrow_mut().remove(idx)),...
remove
identifier_name
clipboard_provider.rs
use msg::constellation_msg::ConstellationChan; use msg::constellation_msg::Msg as ConstellationMsg; use collections::borrow::ToOwned; use std::sync::mpsc::channel; pub trait ClipboardProvider { // blocking method to get the clipboard contents fn get_clipboard_contents(&mut self) -> String; // blocking met...
/* 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/. */
random_line_split
clipboard_provider.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 msg::constellation_msg::ConstellationChan; use msg::constellation_msg::Msg as ConstellationMsg; use collectio...
(&mut self, _: &str) { panic!("not yet implemented"); } } pub struct DummyClipboardContext { content: String } impl DummyClipboardContext { pub fn new(s: &str) -> DummyClipboardContext { DummyClipboardContext { content: s.to_owned() } } } impl ClipboardProvider for...
set_clipboard_contents
identifier_name
clipboard_provider.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 msg::constellation_msg::ConstellationChan; use msg::constellation_msg::Msg as ConstellationMsg; use collectio...
} pub struct DummyClipboardContext { content: String } impl DummyClipboardContext { pub fn new(s: &str) -> DummyClipboardContext { DummyClipboardContext { content: s.to_owned() } } } impl ClipboardProvider for DummyClipboardContext { fn get_clipboard_contents(&mut self) -...
{ panic!("not yet implemented"); }
identifier_body
codec.rs
// Copyright 2016 Google Inc. // // 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 in...
{ Uint8, Uint16, Float32, Float64, } impl PositionEncoding { pub fn new(bounding_cube: &Cube, resolution: f64) -> PositionEncoding { let min_bits = (bounding_cube.edge_length() / resolution).log2() as u32 + 1; match min_bits { 0..=8 => PositionEncoding::Uint8, ...
PositionEncoding
identifier_name
codec.rs
// Copyright 2016 Google Inc. // // 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 in...
// Capping at 24 keeps the worst resolution at ~1 mm for an edge length of ~8389 km. 17..=24 => PositionEncoding::Float32, _ => PositionEncoding::Float64, } } // TODO(sirver): Returning a Result here makes this function more expensive than needed - since // we re...
random_line_split
lib.rs
#![cfg_attr(feature = "nightly", feature(test))] #![feature(nll, try_trait)] #[macro_use] extern crate log; #[macro_use] extern crate lazy_static; #[macro_use] extern crate bitflags; extern crate syntax; #[macro_use] extern crate derive_more; extern crate rls_span; #[macro_use] mod testutils; #[macro_use] mod util; ...
complete_from_file, complete_fully_qualified_name, find_definition, is_use_stmt, to_coords, to_point, }; pub use core::{ BytePos, ByteRange, Coordinate, FileCache, FileLoader, Location, Match, MatchType, Session, }; pub use primitive::PrimKind; pub use project_model::ProjectModelProvider; pub use snippets::...
pub use ast_types::PathSearch; pub use core::{
random_line_split
class-impl-very-parameterized-trait.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...
fn find(&self, k: &int) -> Option<&T> { if *k <= self.meows { Some(&self.name) } else { None } } fn insert(&mut self, k: int, _: T) -> bool { self.meows += k; true } fn find_mut(&mut self, _k: &int) -> Option<&mut T> { panic!() } ...
{ *k <= self.meows }
identifier_body
class-impl-very-parameterized-trait.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...
<T> { // Yes, you can have negative meows meows : int, how_hungry : int, name : T, } impl<T> cat<T> { pub fn speak(&mut self) { self.meow(); } pub fn eat(&mut self) -> bool { if self.how_hungry > 0 { println!("OM NOM NOM"); self.how_hungry -= 2; ret...
cat
identifier_name
class-impl-very-parameterized-trait.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...
pub fn new(in_x: int, in_y: int, in_name: T) -> cat<T> { cat{meows: in_x, how_hungry: in_y, name: in_name } } } impl<T> cat<T> { fn meow(&mut self) { self.meows += 1; println!("Meow {}", self.meows); if self.meows % 5 == 0 { self.how_hungry += 1; } } ...
}
random_line_split
async_cmd_desc_map.rs
// Copyright 2020 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::collections::BTreeMap; use crate::virtio::queue::DescriptorChain; use crate::virtio::video::command::QueueType; use crate::virtio::video::dev...
_ => { // Keep commands for other streams. } } } responses } }
{ // TODO(b/1518105): Use more appropriate error code if a new protocol supports // one. responses.push(AsyncCmdResponse::from_error( *tag, VideoError::InvalidOperation, )); }
conditional_block
async_cmd_desc_map.rs
// Copyright 2020 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::collections::BTreeMap; use crate::virtio::queue::DescriptorChain; use crate::virtio::video::command::QueueType; use crate::virtio::video::dev...
impl AsyncCmdDescMap { pub fn insert(&mut self, tag: AsyncCmdTag, descriptor_chain: DescriptorChain) { self.0.insert(tag, descriptor_chain); } pub fn remove(&mut self, tag: &AsyncCmdTag) -> Option<DescriptorChain> { self.0.remove(tag) } /// Returns a list of `AsyncCmdResponse`s to ...
random_line_split
async_cmd_desc_map.rs
// Copyright 2020 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::collections::BTreeMap; use crate::virtio::queue::DescriptorChain; use crate::virtio::video::command::QueueType; use crate::virtio::video::dev...
AsyncCmdTag::Drain { stream_id } if stream_id == target_stream_id => { // TODO(b/1518105): Use more appropriate error code if a new protocol supports // one. responses.push(AsyncCmdResponse::from_error( *tag, ...
{ let mut responses = vec![]; for tag in self.0.keys().filter(|&&k| Some(k) != processing_tag) { match tag { AsyncCmdTag::Queue { stream_id, queue_type, .. } if stream_id == target_stream_id ...
identifier_body
async_cmd_desc_map.rs
// Copyright 2020 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::collections::BTreeMap; use crate::virtio::queue::DescriptorChain; use crate::virtio::video::command::QueueType; use crate::virtio::video::dev...
(BTreeMap<AsyncCmdTag, DescriptorChain>); impl AsyncCmdDescMap { pub fn insert(&mut self, tag: AsyncCmdTag, descriptor_chain: DescriptorChain) { self.0.insert(tag, descriptor_chain); } pub fn remove(&mut self, tag: &AsyncCmdTag) -> Option<DescriptorChain> { self.0.remove(tag) } //...
AsyncCmdDescMap
identifier_name
diagnostic.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn highlight_lines(cm: &codemap::CodeMap, sp: Span, lvl: Level, lines: &codemap::FileLines) { let fm = lines.file; let mut err = io::stderr(); let err = &mut err as &mut io::Writer; // arbitrarily only print up to six lines of the error l...
{ match cmsp { Some((cm, sp)) => { let sp = cm.adjust_span(sp); let ss = cm.span_to_str(sp); let lines = cm.span_to_lines(sp); print_diagnostic(ss, lvl, msg); highlight_lines(cm, sp, lvl, lines); print_ma...
identifier_body
diagnostic.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self) -> ~str { match *self { Fatal | Error => ~"error", Warning => ~"warning", Note => ~"note" } } } impl Level { fn color(self) -> term::color::Color { match self { Fatal | Error => term::color::BRIGHT_RED, Warning => term:...
to_str
identifier_name
diagnostic.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// arbitrarily only print up to six lines of the error let max_lines = 6u; let mut elided = false; let mut display_lines = lines.lines.as_slice(); if display_lines.len() > max_lines { display_lines = display_lines.slice(0u, max_lines); elided = true; } // Print the offending...
lines: &codemap::FileLines) { let fm = lines.file; let mut err = io::stderr(); let err = &mut err as &mut io::Writer;
random_line_split
plshadow.rs
use winapi::*; use create_device; use dxsafe::*; use dxsafe::structwrappers::*; use dxsems::VertexFormat; use std::marker::PhantomData; // Point Light Shadow // The name isn't quite correct. This module just fills depth cubemap. pub struct PLShadow<T: VertexFormat> { pub pso: D3D12PipelineState, pub root_sig: ...
Ok(_) => {}, }; trace!("Done"); trace!("Root signature creation"); let root_sig = try!(dev.create_root_signature(0, &rsig_bc[..])); try!(root_sig.set_name("plshadow RSD")); let input_elts_desc = T::generate(0); // pso_desc contains pointers to local...
], D3DCOMPILE_OPTIMIZATION_LEVEL3) { Err(err) => { error!("Error compiling 'plshadow.hlsl': {}", err); return Err(E_FAIL); },
random_line_split
plshadow.rs
use winapi::*; use create_device; use dxsafe::*; use dxsafe::structwrappers::*; use dxsems::VertexFormat; use std::marker::PhantomData; // Point Light Shadow // The name isn't quite correct. This module just fills depth cubemap. pub struct PLShadow<T: VertexFormat> { pub pso: D3D12PipelineState, pub root_sig: ...
(dev: &D3D12Device) -> HResult<PLShadow<T>> { let mut vshader_bc = vec![]; let mut gshader_bc = vec![]; let mut pshader_bc = vec![]; let mut rsig_bc = vec![]; trace!("Compiling 'plshadow.hlsl'..."); match create_device::compile_shaders("plshadow.hlsl",&mut[ ...
new
identifier_name
plshadow.rs
use winapi::*; use create_device; use dxsafe::*; use dxsafe::structwrappers::*; use dxsems::VertexFormat; use std::marker::PhantomData; // Point Light Shadow // The name isn't quite correct. This module just fills depth cubemap. pub struct PLShadow<T: VertexFormat> { pub pso: D3D12PipelineState, pub root_sig: ...
trace!("Root signature creation"); let root_sig = try!(dev.create_root_signature(0, &rsig_bc[..])); try!(root_sig.set_name("plshadow RSD")); let input_elts_desc = T::generate(0); // pso_desc contains pointers to local data, so I mustn't pass it around, but I can. Unsafe. ...
{ let mut vshader_bc = vec![]; let mut gshader_bc = vec![]; let mut pshader_bc = vec![]; let mut rsig_bc = vec![]; trace!("Compiling 'plshadow.hlsl'..."); match create_device::compile_shaders("plshadow.hlsl",&mut[ ("VSMain", "vs_5_0", &mut vshader_bc),...
identifier_body
lib.rs
pub mod nodes; pub mod parser; pub mod tokenizer; mod tests; use tokenizer::*; use parser::*; use nodes::*; pub struct Document { root: Element, } impl Document { pub fn new() -> Document { Document { root: Element::new("root"), } } pub fn from_element(e: Element) -> Doc...
(&self) -> &Element { match self.root.get_first_child() { Some(c) => c, None => panic!("Document has no root element!"), } } pub fn print(&self) { self.root.print(0); } }
get_root
identifier_name
lib.rs
pub mod nodes; pub mod parser; pub mod tokenizer;
mod tests; use tokenizer::*; use parser::*; use nodes::*; pub struct Document { root: Element, } impl Document { pub fn new() -> Document { Document { root: Element::new("root"), } } pub fn from_element(e: Element) -> Document { Document { root: e, ...
random_line_split
lib.rs
pub mod nodes; pub mod parser; pub mod tokenizer; mod tests; use tokenizer::*; use parser::*; use nodes::*; pub struct Document { root: Element, } impl Document { pub fn new() -> Document { Document { root: Element::new("root"), } } pub fn from_element(e: Element) -> Doc...
pub fn from_string(s: &str) -> Result<Document, String> { let tokens = match tokenize(&s) { Ok(tokens) => tokens, Err(e) => return Err(e), }; let element = match parse(tokens) { Ok(element) => element, Err(e) => return Err(e), }; ...
{ Document { root: e, } }
identifier_body
file.rs
//! Provides File Management functions use std::ffi; use std::os::windows::ffi::{ OsStrExt, OsStringExt }; use std::default; use std::ptr; use std::mem; use std::convert; use std::io; use crate::inner_raw as raw; use self::raw::winapi::*; use crate::utils; const NO_MORE_FILES: i32 = ERROR_NO_MORE_FILES as i3...
///Returns whether Entry is read-only pub fn is_read_only(&self) -> bool { (self.0.dwFileAttributes & FILE_ATTRIBUTE_READONLY)!= 0 } ///Returns name of Entry. pub fn name(&self) -> ffi::OsString { ffi::OsString::from_wide(match self.0.cFileName.iter().position(|c| *c == 0) { ...
{ ((self.0.nFileSizeHigh as u64) << 32) | (self.0.nFileSizeLow as u64) }
identifier_body
file.rs
//! Provides File Management functions use std::ffi; use std::os::windows::ffi::{ OsStrExt, OsStringExt }; use std::default; use std::ptr; use std::mem; use std::convert; use std::io; use crate::inner_raw as raw; use self::raw::winapi::*; use crate::utils; const NO_MORE_FILES: i32 = ERROR_NO_MORE_FILES as i3...
(&self) -> u64 { ((self.0.nFileSizeHigh as u64) << 32) | (self.0.nFileSizeLow as u64) } ///Returns whether Entry is read-only pub fn is_read_only(&self) -> bool { (self.0.dwFileAttributes & FILE_ATTRIBUTE_READONLY)!= 0 } ///Returns name of Entry. pub fn name(&self) -> ffi::OsSt...
size
identifier_name
file.rs
//! Provides File Management functions use std::ffi; use std::os::windows::ffi::{ OsStrExt, OsStringExt }; use std::default; use std::ptr; use std::mem; use std::convert; use std::io; use crate::inner_raw as raw; use self::raw::winapi::*; use crate::utils; const NO_MORE_FILES: i32 = ERROR_NO_MORE_FILES as i3...
!self.is_dir() } ///Returns size of entry pub fn size(&self) -> u64 { ((self.0.nFileSizeHigh as u64) << 32) | (self.0.nFileSizeLow as u64) } ///Returns whether Entry is read-only pub fn is_read_only(&self) -> bool { (self.0.dwFileAttributes & FILE_ATTRIBUTE_READONLY)!= 0...
random_line_split
mut_dns_packet.rs
use buf::*; #[derive(Debug)] pub struct MutDnsPacket<'a> { buf: &'a mut [u8], pos: usize, } impl<'a> MutDnsPacket<'a> { pub fn new(buf: &mut [u8]) -> MutDnsPacket { MutDnsPacket::new_at(buf, 0) } pub fn new_at(buf: &mut [u8], pos: usize) -> MutDnsPacket { debug!("New MutDn...
#[test] fn write_u16_bounds() { let mut vec = vec![0, 0, 0, 0]; let mut buf = vec.as_mut_slice(); let mut packet = MutDnsPacket::new(buf); assert_eq!(true, packet.write_u16(1)); assert_eq!(true, packet.write_u16(1)); assert_eq!(false, packet.write_u16(1)); //no ...
{ let mut vec = test_buf(); let mut buf = vec.as_mut_slice(); let mut packet = MutDnsPacket::new(buf); packet.write_u16(2161); packet.write_u16(1); packet.seek(0); println!("{:?}", packet); assert_eq!(2161, packet.next_u16().unwrap()); assert_eq!(1...
identifier_body
mut_dns_packet.rs
use buf::*; #[derive(Debug)] pub struct MutDnsPacket<'a> { buf: &'a mut [u8], pos: usize, } impl<'a> MutDnsPacket<'a> { pub fn new(buf: &mut [u8]) -> MutDnsPacket { MutDnsPacket::new_at(buf, 0) } pub fn new_at(buf: &mut [u8], pos: usize) -> MutDnsPacket { debug!("New MutDn...
#[test] fn write_u16() { let mut vec = test_buf(); let mut buf = vec.as_mut_slice(); let mut packet = MutDnsPacket::new(buf); packet.write_u16(2161); packet.write_u16(1); packet.seek(0); println!("{:?}", packet); assert_eq!(2161, packet.next_u16()...
assert_eq!(8, packet.next_u8().unwrap()); assert_eq!(9, packet.next_u8().unwrap()); }
random_line_split
mut_dns_packet.rs
use buf::*; #[derive(Debug)] pub struct MutDnsPacket<'a> { buf: &'a mut [u8], pos: usize, } impl<'a> MutDnsPacket<'a> { pub fn new(buf: &mut [u8]) -> MutDnsPacket { MutDnsPacket::new_at(buf, 0) } pub fn new_at(buf: &mut [u8], pos: usize) -> MutDnsPacket { debug!("New MutDn...
(&mut self) -> &mut [u8] { self.buf } } impl<'a> BufRead for MutDnsPacket<'a> { fn buf(&self) -> &[u8] { self.buf } } impl<'a> DirectAccessBuf for MutDnsPacket<'a> { fn pos(&self) -> usize { self.pos } fn set_pos(&mut self, pos: usize) { self.pos = pos; } ...
buf
identifier_name
crc32.rs
//! Helper module to compute a CRC32 checksum use std::io; use std::io::prelude::*; static CRC32_TABLE : [u32; 256] = [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1...
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2...
random_line_split
crc32.rs
//! Helper module to compute a CRC32 checksum use std::io; use std::io::prelude::*; static CRC32_TABLE : [u32; 256] = [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1...
/// Reader that validates the CRC32 when it reaches the EOF. pub struct Crc32Reader<R> { inner: R, crc: u32, check: u32, } impl<R> Crc32Reader<R> { /// Get a new Crc32Reader which check the inner reader against checksum. pub fn new(inner: R, checksum: u32) -> Crc32Reader<R> { Crc32Rea...
{ let mut crc = !prev; for &byte in buf.iter() { crc = CRC32_TABLE[((crc as u8) ^ byte) as usize] ^ (crc >> 8); } !crc }
identifier_body
crc32.rs
//! Helper module to compute a CRC32 checksum use std::io; use std::io::prelude::*; static CRC32_TABLE : [u32; 256] = [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1...
(prev: u32, buf: &[u8]) -> u32 { let mut crc =!prev; for &byte in buf.iter() { crc = CRC32_TABLE[((crc as u8) ^ byte) as usize] ^ (crc >> 8); } !crc } /// Reader that validates the CRC32 when it reaches the EOF. pub struct Crc32Reader<R> { inner: R, crc: u32, check: u32, } imp...
update
identifier_name
crc32.rs
//! Helper module to compute a CRC32 checksum use std::io; use std::io::prelude::*; static CRC32_TABLE : [u32; 256] = [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1...
, Ok(n) => n, Err(e) => return Err(e), }; self.crc = update(self.crc, &buf[0..count]); Ok(count) } } #[cfg(test)] mod test { #[test] fn samples() { assert_eq!(super::update(0, b""), 0); // test vectors from the iPXE project (input and output ...
{ return Err(io::Error::new(io::ErrorKind::Other, "Invalid checksum")) }
conditional_block
types.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
}, /// request to retreive data with specified type and location from network Get { location: ::routing::authority::Authority, data_request: ::routing::data::DataRequest, }, // /// request to post // Post { destination: ::routing::NameType, content: Data }, // /// Request del...
location: ::routing::authority::Authority, content: ::routing::data::Data,
random_line_split
types.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
/// Merge multiple refreshable objects into one fn merge(from_group: ::routing::NameType, responses: Vec<Self>) -> Option<Self>; }
{ ::routing::utils::encode(&self).unwrap_or(vec![]) }
identifier_body
types.rs
// Copyright 2015 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
(&self) -> Vec<u8> { ::routing::utils::encode(&self).unwrap_or(vec![]) } /// Merge multiple refreshable objects into one fn merge(from_group: ::routing::NameType, responses: Vec<Self>) -> Option<Self>; }
serialised_contents
identifier_name
uds.rs
use std::io::{Read, Write}; use std::mem; use std::net::Shutdown; use std::os::unix::prelude::*; use std::path::Path; use libc; use {io, Ready, Poll, PollOpt, Token}; use event::Evented; use sys::unix::{cvt, Io}; use sys::unix::io::{set_nonblock, set_cloexec}; trait MyInto<T> { fn my_into(self) -> T; } impl MyI...
Some(_) => len += 1, } Ok((addr, len as libc::socklen_t)) } fn sun_path_offset() -> usize { unsafe { // Work with an actual instance of the type since using a null pointer is UB let addr: libc::sockaddr_un = mem::uninitialized(); let base = &addr as *const _ as usize; ...
{}
conditional_block
uds.rs
use std::io::{Read, Write}; use std::mem; use std::net::Shutdown; use std::os::unix::prelude::*; use std::path::Path; use libc; use {io, Ready, Poll, PollOpt, Token}; use event::Evented; use sys::unix::{cvt, Io}; use sys::unix::io::{set_nonblock, set_cloexec}; trait MyInto<T> { fn my_into(self) -> T; } impl MyI...
(&self, backlog: usize) -> io::Result<()> { unsafe { cvt(libc::listen(self.as_raw_fd(), backlog as i32))?; Ok(()) } } pub fn accept(&self) -> io::Result<UnixSocket> { unsafe { let fd = cvt(libc::accept(self.as_raw_fd(), ...
listen
identifier_name
uds.rs
use std::io::{Read, Write}; use std::mem; use std::net::Shutdown; use std::os::unix::prelude::*; use std::path::Path; use libc; use {io, Ready, Poll, PollOpt, Token}; use event::Evented; use sys::unix::{cvt, Io}; use sys::unix::io::{set_nonblock, set_cloexec}; trait MyInto<T> { fn my_into(self) -> T; } impl MyI...
} } pub fn accept(&self) -> io::Result<UnixSocket> { unsafe { let fd = cvt(libc::accept(self.as_raw_fd(), 0 as *mut _, 0 as *mut _))?; let fd = Io::from_raw_fd(fd); set_cloe...
random_line_split
p_2_1_2_02.rs
// P_2_1_2_02 // // Generative Gestaltung – Creative Coding im Web // ISBN: 978-3-87439-902-9, First Edition, Hermann Schmidt, Mainz, 2018 // Benedikt Groß, Hartmut Bohnacker, Julia Laub, Claudius Lazzeroni // with contributions by Joey Lee and Niels Poldervaart // Copyright 2018 // // http://www.generative-gestaltung....
p: &App, model: &Model, frame: Frame) { let draw = app.draw(); let win = app.window_rect(); draw.background().color(WHITE); let mut rng = StdRng::seed_from_u64(model.act_random_seed); let mx = clamp(win.right() + app.mouse.x, 0.0, win.w()); let my = clamp(win.top() - app.mouse.y, 0.0, win.h()...
w(ap
identifier_name
p_2_1_2_02.rs
// P_2_1_2_02 // // Generative Gestaltung – Creative Coding im Web // ISBN: 978-3-87439-902-9, First Edition, Hermann Schmidt, Mainz, 2018 // Benedikt Groß, Hartmut Bohnacker, Julia Laub, Claudius Lazzeroni // with contributions by Joey Lee and Niels Poldervaart // Copyright 2018 // // http://www.generative-gestaltung....
} Key::Key3 => { if model.module_alpha_background == 1.0 { model.module_alpha_background = 0.5; model.module_alpha_foreground = 0.5; } else { model.module_alpha_background = 1.0; model.module_alpha_foreground = 1.0; ...
model.module_color_foreground = hsva(1.0, 1.0, 1.0, model.module_alpha_foreground); }
conditional_block
p_2_1_2_02.rs
// P_2_1_2_02 // // Generative Gestaltung – Creative Coding im Web // ISBN: 978-3-87439-902-9, First Edition, Hermann Schmidt, Mainz, 2018 // Benedikt Groß, Hartmut Bohnacker, Julia Laub, Claudius Lazzeroni // with contributions by Joey Lee and Niels Poldervaart // Copyright 2018 // // http://www.generative-gestaltung....
} Key::Key0 => { model.module_radius_background = 15.0; model.module_radius_foreground = 7.5; model.module_alpha_background = 1.0; model.module_alpha_foreground = 1.0; model.module_color_background = hsva(0.0, 0.0, 0.0, model.module_alpha_backg...
model.module_color_foreground.alpha = model.module_alpha_foreground;
random_line_split
p_2_1_2_02.rs
// P_2_1_2_02 // // Generative Gestaltung – Creative Coding im Web // ISBN: 978-3-87439-902-9, First Edition, Hermann Schmidt, Mainz, 2018 // Benedikt Groß, Hartmut Bohnacker, Julia Laub, Claudius Lazzeroni // with contributions by Joey Lee and Niels Poldervaart // Copyright 2018 // // http://www.generative-gestaltung....
module_radius_background: 15.0, module_radius_foreground: 7.5, } } f n view(app: &App, model: &Model, frame: Frame) { let draw = app.draw(); let win = app.window_rect(); draw.background().color(WHITE); let mut rng = StdRng::seed_from_u64(model.act_random_seed); let mx = clamp...
let _window = app .new_window() .size(600, 600) .view(view) .mouse_pressed(mouse_pressed) .key_pressed(key_pressed) .key_released(key_released) .build() .unwrap(); let module_alpha_background = 1.0; let module_alpha_foreground = 1.0; Model...
identifier_body
stat.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...
}
random_line_split
stat.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...
() { let dir = TempDir::new_in(&Path::new("."), "").unwrap(); let path = dir.path().join("file"); { match File::create(&path) { Err(..) => unreachable!(), Ok(f) => { let mut f = f; for _ in range(0u, 1000) { f.write([0]); ...
main
identifier_name
stat.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...
{ let dir = TempDir::new_in(&Path::new("."), "").unwrap(); let path = dir.path().join("file"); { match File::create(&path) { Err(..) => unreachable!(), Ok(f) => { let mut f = f; for _ in range(0u, 1000) { f.write([0]); ...
identifier_body
keymap.rs
) -> i32 { (c as i32) & 0x1f } // Hash table used to cache a reverse-map to speed up calls to where-is. declare_GC_protected_static!(where_is_cache, Qnil); /// Allows the C code to get the value of `where_is_cache` #[no_mangle] pub extern "C" fn get_where_is_cache() -> LispObject { unsafe { where_is_cache } }...
/// Return the parent keymap of KEYMAP. /// If KEYMAP has no parent, return nil. #[lisp_fn(name = "keymap-parent", c_name = "keymap_parent")] pub fn keymap_parent_lisp(keymap: LispObject) -> LispObject { keymap_parent(keymap, true) } /// Check whether MAP is one of MAPS parents. #[no_mangle] pub extern "C" fn ke...
{ let map = get_keymap(keymap, true, autoload); let mut current = Qnil; for elt in map.iter_tails(LispConsEndChecks::off, LispConsCircularChecks::off) { current = elt.cdr(); if keymapp(current) { return current; } } get_keymap(current, false, autoload) }
identifier_body
keymap.rs
) -> i32 { (c as i32) & 0x1f } // Hash table used to cache a reverse-map to speed up calls to where-is. declare_GC_protected_static!(where_is_cache, Qnil); /// Allows the C code to get the value of `where_is_cache` #[no_mangle] pub extern "C" fn get_where_is_cache() -> LispObject { unsafe { where_is_cache } }...
else if binding.is_vector() { if let Some(binding_vec) = binding.as_vectorlike() { for c in 0..binding_vec.pseudovector_size() { map_keymap_item(fun, args, c.into(), aref(binding, c), data); } } } else if bindin...
{ map_keymap_item(fun, args, car, cdr, data); }
conditional_block
keymap.rs
char) -> i32 { (c as i32) & 0x1f } // Hash table used to cache a reverse-map to speed up calls to where-is. declare_GC_protected_static!(where_is_cache, Qnil); /// Allows the C code to get the value of `where_is_cache` #[no_mangle] pub extern "C" fn get_where_is_cache() -> LispObject { unsafe { where_is_cach...
/// Construct and return a new keymap, of the form (keymap CHARTABLE. ALIST). /// CHARTABLE is a char-table that holds the bindings for all characters /// without modifiers. All entries in it are initially nil, meaning /// "command undefined". ALIST is an assoc-list which holds bindings for /// function keys, mouse ...
}
random_line_split
keymap.rs
we don't want to pursue autoloads. /// Functions like `Faccessible_keymaps` which scan entire keymap trees /// shouldn't load every autoloaded keymap. I'm not sure about this, /// but it seems to me that only `read_key_sequence`, `Flookup_key`, and /// `Fdefine_key` should cause keymaps to be autoloaded. /// /// This...
key_binding
identifier_name
mod.rs
use std::cmp::Ordering;
/// /// # Worst-case complexity /// Constant time and additional memory. /// /// # Examples /// ``` /// use malachite_base::orderings::ordering_from_str; /// use std::cmp::Ordering; /// /// assert_eq!(ordering_from_str("Equal"), Some(Ordering::Equal)); /// assert_eq!(ordering_from_str("Less"), Some(Ordering::Less)); //...
pub(crate) const ORDERINGS: [Ordering; 3] = [Ordering::Equal, Ordering::Less, Ordering::Greater]; /// Converts a `&str` to a `Ordering`. /// /// If the `&str` does not represent a valid `Ordering`, `None` is returned.
random_line_split
mod.rs
use std::cmp::Ordering; pub(crate) const ORDERINGS: [Ordering; 3] = [Ordering::Equal, Ordering::Less, Ordering::Greater]; /// Converts a `&str` to a `Ordering`. /// /// If the `&str` does not represent a valid `Ordering`, `None` is returned. /// /// # Worst-case complexity /// Constant time and additional memory. ///...
(src: &str) -> Option<Ordering> { match src { "Equal" => Some(Ordering::Equal), "Less" => Some(Ordering::Less), "Greater" => Some(Ordering::Greater), _ => None, } } /// This module contains iterators that generate `Ordering`s without repetition. pub mod exhaustive; /// This modu...
ordering_from_str
identifier_name
mod.rs
use std::cmp::Ordering; pub(crate) const ORDERINGS: [Ordering; 3] = [Ordering::Equal, Ordering::Less, Ordering::Greater]; /// Converts a `&str` to a `Ordering`. /// /// If the `&str` does not represent a valid `Ordering`, `None` is returned. /// /// # Worst-case complexity /// Constant time and additional memory. ///...
/// This module contains iterators that generate `Ordering`s without repetition. pub mod exhaustive; /// This module contains iterators that generate `Ordering`s randomly. pub mod random;
{ match src { "Equal" => Some(Ordering::Equal), "Less" => Some(Ordering::Less), "Greater" => Some(Ordering::Greater), _ => None, } }
identifier_body
error.rs
extern crate hyper; extern crate serde_json as json; extern crate serde_qs as qs; use params::to_snakecase; use std::error; use std::fmt; use std::io; use std::num::ParseIntError; /// An error encountered when communicating with the Stripe API. #[derive(Debug)] pub enum Error { /// An error reported by Stripe. ...
} impl error::Error for RequestError { fn description(&self) -> &str { self.message.as_ref().map(|s| s.as_str()).unwrap_or( "request error", ) } } #[doc(hidden)] #[derive(Deserialize)] pub struct ErrorObject { pub error: RequestError, } /// An error encountered when communica...
{ write!(f, "{}({})", self.error_type, self.http_status)?; if let Some(ref message) = self.message { write!(f, ": {}", message)?; } Ok(()) }
identifier_body
error.rs
extern crate hyper; extern crate serde_json as json; extern crate serde_qs as qs; use params::to_snakecase; use std::error; use std::fmt; use std::io; use std::num::ParseIntError; /// An error encountered when communicating with the Stripe API. #[derive(Debug)] pub enum Error { /// An error reported by Stripe. ...
/// The type of error returned. #[serde(rename = "type")] pub error_type: ErrorType, /// A human-readable message providing more details about the error. /// For card errors, these messages can be shown to end users. #[serde(default)] pub message: Option<String>, /// For card errors, ...
#[serde(skip_deserializing)] pub http_status: u16,
random_line_split
error.rs
extern crate hyper; extern crate serde_json as json; extern crate serde_qs as qs; use params::to_snakecase; use std::error; use std::fmt; use std::io; use std::num::ParseIntError; /// An error encountered when communicating with the Stripe API. #[derive(Debug)] pub enum Error { /// An error reported by Stripe. ...
(&self) -> Option<&error::Error> { match *self { WebhookError::BadHeader(ref err) => Some(err), WebhookError::BadSignature => None, WebhookError::BadTimestamp(_) => None, WebhookError::BadParse(ref err) => Some(err), } } }
cause
identifier_name
file.rs
use bytes; use std; use std::io::Read; use std::os::unix::fs::PermissionsExt; use std::path::Path; pub fn list_dir(path: &Path) -> Vec<String>
pub fn contents(path: &Path) -> bytes::Bytes { let mut contents = Vec::new(); std::fs::File::open(path) .and_then(|mut f| f.read_to_end(&mut contents)) .expect("Error reading file"); bytes::Bytes::from(contents) } pub fn is_executable(path: &Path) -> bool { std::fs::metadata(path) .expect("Getting f...
{ let mut v: Vec<_> = std::fs::read_dir(path) .unwrap_or_else(|err| panic!("Listing dir {:?}: {:?}", path, err)) .map(|entry| { entry .expect("Error reading entry") .file_name() .to_string_lossy() .to_string() }) .collect(); v.sort(); v }
identifier_body
file.rs
use bytes; use std; use std::io::Read; use std::os::unix::fs::PermissionsExt; use std::path::Path; pub fn list_dir(path: &Path) -> Vec<String> { let mut v: Vec<_> = std::fs::read_dir(path) .unwrap_or_else(|err| panic!("Listing dir {:?}: {:?}", path, err)) .map(|entry| { entry .expect("Error readin...
(path: &Path) -> bytes::Bytes { let mut contents = Vec::new(); std::fs::File::open(path) .and_then(|mut f| f.read_to_end(&mut contents)) .expect("Error reading file"); bytes::Bytes::from(contents) } pub fn is_executable(path: &Path) -> bool { std::fs::metadata(path) .expect("Getting file metadata") ...
contents
identifier_name
file.rs
use bytes; use std; use std::io::Read; use std::os::unix::fs::PermissionsExt; use std::path::Path;
.map(|entry| { entry .expect("Error reading entry") .file_name() .to_string_lossy() .to_string() }) .collect(); v.sort(); v } pub fn contents(path: &Path) -> bytes::Bytes { let mut contents = Vec::new(); std::fs::File::open(path) .and_then(|mut f| f.read_to_end(&m...
pub fn list_dir(path: &Path) -> Vec<String> { let mut v: Vec<_> = std::fs::read_dir(path) .unwrap_or_else(|err| panic!("Listing dir {:?}: {:?}", path, err))
random_line_split
project.rs
/* * project.rs: Commands to save/load projects. * Copyright (C) 2019 Oddcoder * This program 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...
0xfff31000 0x31000 0x337\n" ); assert_eq!(core.stderr.utf8_string().unwrap(), ""); fs::remove_file("rair_project").unwrap(); } }
{ let mut core = Core::new_no_colors(); core.stderr = Writer::new_buf(); core.stdout = Writer::new_buf(); let mut load = Load::new(); let mut save = Save::new(); core.io.open("malloc://0x500", IoMode::READ | IoMode::WRITE).unwrap(); core.io.open_at("malloc://0x133...
identifier_body
project.rs
/* * project.rs: Commands to save/load projects. * Copyright (C) 2019 Oddcoder * This program 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...
(&mut self, core: &mut Core, args: &[String]) { if args.len()!= 1 { expect(core, args.len() as u64, 1); return; } let mut file = match File::open(&args[0]) { Ok(file) => file, Err(e) => return error_msg(core, "Failed to open file", &e.to_string()),...
run
identifier_name
project.rs
/* * project.rs: Commands to save/load projects. * Copyright (C) 2019 Oddcoder * This program 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...
core.stdout = Writer::new_buf(); let mut load = Load::new(); let mut save = Save::new(); core.io.open("malloc://0x500", IoMode::READ | IoMode::WRITE).unwrap(); core.io.open_at("malloc://0x1337", IoMode::READ | IoMode::WRITE, 0x31000).unwrap(); core.io.map(0x31000, 0xfff31...
random_line_split
persistable.rs
use std::marker::PhantomData; use expression::Expression; use query_builder::{QueryBuilder, BuildQueryResult}; use query_source::{Table, Column}; use types::NativeSqlType; /// Represents that a structure can be used to to insert a new row into the database. /// Implementations can be automatically generated by /// [`...
() -> Self::Columns { <&'a U>::columns() } fn values(self) -> Self::Values { InsertValues { values: &*self, _marker: PhantomData, } } } pub struct InsertValues<'a, T, U: 'a> { values: &'a [U], _marker: PhantomData<T>, } impl<'a, T, U> Expression fo...
columns
identifier_name