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
tetris.rs
extern crate input; extern crate graphics; // External Imports use std::default::Default; use opengl_graphics::{Gl, Texture}; use event::{Window, UpdateArgs, RenderArgs,}; use self::graphics::*; use self::input::{keyboard, Button, Keyboard,}; // Project Imports use active::ActiveTetromino; use tetromino::Color; use s...
, } } _ => {} } } }
{}
conditional_block
tetris.rs
extern crate input; extern crate graphics; // External Imports use std::default::Default; use opengl_graphics::{Gl, Texture}; use event::{Window, UpdateArgs, RenderArgs,}; use self::graphics::*; use self::input::{keyboard, Button, Keyboard,}; // Project Imports use active::ActiveTetromino; use tetromino::Color; use s...
self.board[y][x] = Some(self.active_tetromino.get_color()); } else { self.state = Defeated; } } if self.state == Playing || self.state == Dropping { self.state = Playing; let mut board: [[Option<Color>,..BOARD_WIDTH],..BOARD_HEIGHT] = [[Non...
if y < self.board.len() && x < self.board[y].len() {
random_line_split
tetris.rs
extern crate input; extern crate graphics; // External Imports use std::default::Default; use opengl_graphics::{Gl, Texture}; use event::{Window, UpdateArgs, RenderArgs,}; use self::graphics::*; use self::input::{keyboard, Button, Keyboard,}; // Project Imports use active::ActiveTetromino; use tetromino::Color; use s...
<W: Window>(&mut self, _: &mut W, args: &UpdateArgs) { if self.paused { return } match self.state { Playing => self.gravity(args.dt), Dropping => self.gravity(0.12 + args.dt), _ => {} } } pub fn press(&mut self, args: Button) { match args { Keyboard(key) => { ...
update
identifier_name
task.rs
// The MIT License (MIT) // // Copyright (c) 2015 Kashyap // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, m...
struct TaskTable { lock: Spinlock, procs: &'static [Task; TASK_NUM] } static mut procs : TaskTable = TaskTable{ lock: DUMMY_LOCK, procs: &[ Task { sz: 0us, pid: 0us, killed: 0is, state: ProcState::UNUSED, name: "undef" }; TASK_...
impl Copy for ProcState {} impl Copy for Task {}
random_line_split
task.rs
// The MIT License (MIT) // // Copyright (c) 2015 Kashyap // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, m...
() { unsafe { init_lock(&mut procs.lock, "task_table"); } }
init_proc
identifier_name
search_test.rs
extern crate textsearch; extern crate futures; use std::sync::Arc; use std::sync::RwLock; use std::sync::RwLockReadGuard; use std::sync::RwLockWriteGuard; use futures::Future; use textsearch::global::Global; use textsearch::index::Index; use textsearch::search::Search; static NAME: &'static str = "some index"; const ...
() { let mut search = Search::new(); { search.create_index(NAME); let indices = search.indices.clone(); let indices = indices.read().unwrap(); assert_eq!(indices.len(), 1); } { search.remove_index(NAME); let indices = search.indices.clone(); let indices = indices.read().unwrap(); assert_eq!(indice...
remove_index_search
identifier_name
search_test.rs
extern crate textsearch; extern crate futures; use std::sync::Arc; use std::sync::RwLock; use std::sync::RwLockReadGuard; use std::sync::RwLockWriteGuard; use futures::Future; use textsearch::global::Global; use textsearch::index::Index; use textsearch::search::Search; static NAME: &'static str = "some index"; const ...
#[test] fn search_search() { let mut search = Search::new(); search.create_index(NAME); let DOC_iter = DOCS.into_iter(); let indices: Vec<Arc<Index>> = DOC_iter.map(|DOC| search.insert(NAME.to_string(), DOC.to_string()).wait().unwrap() ).collect(); let scores: Vec<(Arc<Index>, f32)> = search.search(NAME.to_str...
{ let mut search = Search::new(); search.create_index(NAME); let DOC_iter = DOCS.into_iter(); let text_indices: Vec<Arc<Index>> = DOC_iter.map(|DOC| search.insert(NAME.to_string(), DOC.to_string()).wait().unwrap() ).collect(); let indices = search.indices.clone(); let indices = indices.read().unwrap(); let g...
identifier_body
search_test.rs
extern crate textsearch; extern crate futures; use std::sync::Arc; use std::sync::RwLock; use std::sync::RwLockReadGuard; use std::sync::RwLockWriteGuard; use futures::Future; use textsearch::global::Global; use textsearch::index::Index; use textsearch::search::Search; static NAME: &'static str = "some index"; const ...
let DOC_iter = DOCS.into_iter(); let text_indices: Vec<Arc<Index>> = DOC_iter.map(|DOC| search.insert(NAME.to_string(), DOC.to_string()).wait().unwrap() ).collect(); let indices = search.indices.clone(); let indices = indices.read().unwrap(); let global: Arc<RwLock<Global>> = indices.get(NAME).unwrap().clone();...
fn insert_document_search() { let mut search = Search::new(); search.create_index(NAME);
random_line_split
mod.rs
pub mod client; pub mod lsm; pub mod sm; mod trees; #[cfg(test)] mod tests { use super::lsm::btree::storage; use super::lsm::btree::Ordering; use super::*; use crate::client::*; use crate::index::ranged::lsm::btree; use crate::index::ranged::lsm::tree::LAST_LEVEL_MULT_FACTOR; use crate::ind...
memory_size: 32 * 1024 * 1024 * 1024, // 1G backup_storage: None, wal_storage: None, services: vec![Service::Cell, Service::RangedIndexer], }, &server_addr, server_group, ) .await; let client = Arc...
let server_group = "ranged_index_test"; let server_addr = String::from("127.0.0.1:5711"); let server = NebServer::new_from_opts( &ServerOptions { chunk_count: 1,
random_line_split
mod.rs
pub mod client; pub mod lsm; pub mod sm; mod trees; #[cfg(test)] mod tests { use super::lsm::btree::storage; use super::lsm::btree::Ordering; use super::*; use crate::client::*; use crate::index::ranged::lsm::btree; use crate::index::ranged::lsm::tree::LAST_LEVEL_MULT_FACTOR; use crate::ind...
}
{ Schema { id: 11, name: String::from("test"), key_field: None, str_key_field: None, fields: Field::new( "*", 0, false, false, Some(vec![Field::new("data", 10, false, false...
identifier_body
mod.rs
pub mod client; pub mod lsm; pub mod sm; mod trees; #[cfg(test)] mod tests { use super::lsm::btree::storage; use super::lsm::btree::Ordering; use super::*; use crate::client::*; use crate::index::ranged::lsm::btree; use crate::index::ranged::lsm::tree::LAST_LEVEL_MULT_FACTOR; use crate::ind...
() -> Schema { Schema { id: 11, name: String::from("test"), key_field: None, str_key_field: None, fields: Field::new( "*", 0, false, false, Some(vec![Field::new("data", 10,...
schema
identifier_name
repeat_with.rs
use crate::iter::{FusedIterator, TrustedLen}; /// Creates a new iterator that repeats elements of type `A` endlessly by /// applying the provided closure, the repeater, `F: FnMut() -> A`. /// /// The `repeat_with()` function calls the repeater over and over again. /// /// Infinite iterators like `repeat_with()` are of...
(&mut self) -> Option<A> { Some((self.repeater)()) } #[inline] fn size_hint(&self) -> (usize, Option<usize>) { (usize::MAX, None) } } #[stable(feature = "iterator_repeat_with", since = "1.28.0")] impl<A, F: FnMut() -> A> FusedIterator for RepeatWith<F> {} #[unstable(feature = "trusted...
next
identifier_name
repeat_with.rs
use crate::iter::{FusedIterator, TrustedLen}; /// Creates a new iterator that repeats elements of type `A` endlessly by /// applying the provided closure, the repeater, `F: FnMut() -> A`. /// /// The `repeat_with()` function calls the repeater over and over again. /// /// Infinite iterators like `repeat_with()` are of...
/// applying the provided closure `F: FnMut() -> A`. /// /// This `struct` is created by the [`repeat_with()`] function. /// See its documentation for more. #[derive(Copy, Clone, Debug)] #[stable(feature = "iterator_repeat_with", since = "1.28.0")] pub struct RepeatWith<F> { repeater: F, } #[stable(feature = "iter...
} /// An iterator that repeats elements of type `A` endlessly by
random_line_split
render.rs
use std::any::Any; use viewport::Viewport; use { GenericEvent, RENDER }; /// Render arguments #[derive(Copy, Clone, PartialEq, Debug)] pub struct RenderArgs { /// Extrapolated time in seconds, used to do smooth animation. pub ext_dt: f64, /// The width of rendered area in points. pub width: u32, /...
(&self) -> Option<RenderArgs> { self.render(|args| args.clone()) } } impl<T: GenericEvent> RenderEvent for T { fn from_render_args(args: &RenderArgs, old_event: &Self) -> Option<Self> { GenericEvent::from_args(RENDER, args as &Any, old_event) } fn render<U, F>(&self, mut f: F) -> Optio...
render_args
identifier_name
render.rs
use std::any::Any; use viewport::Viewport; use { GenericEvent, RENDER }; /// Render arguments #[derive(Copy, Clone, PartialEq, Debug)] pub struct RenderArgs { /// Extrapolated time in seconds, used to do smooth animation. pub ext_dt: f64, /// The width of rendered area in points. pub width: u32, /...
impl<T: GenericEvent> RenderEvent for T { fn from_render_args(args: &RenderArgs, old_event: &Self) -> Option<Self> { GenericEvent::from_args(RENDER, args as &Any, old_event) } fn render<U, F>(&self, mut f: F) -> Option<U> where F: FnMut(&RenderArgs) -> U { if self.event_id()!= R...
fn render_args(&self) -> Option<RenderArgs> { self.render(|args| args.clone()) } }
random_line_split
render.rs
use std::any::Any; use viewport::Viewport; use { GenericEvent, RENDER }; /// Render arguments #[derive(Copy, Clone, PartialEq, Debug)] pub struct RenderArgs { /// Extrapolated time in seconds, used to do smooth animation. pub ext_dt: f64, /// The width of rendered area in points. pub width: u32, /...
} #[cfg(test)] mod tests { use super::*; #[test] fn test_event_render() { use Event; use RenderArgs; let e = Event::Render(RenderArgs { ext_dt: 0.0, width: 0, height: 0, draw_width: 0, draw_height: 0 }); let x: Option<Event> = RenderEvent::from_render_args( ...
{ if self.event_id() != RENDER { return None; } self.with_args(|any| { if let Some(args) = any.downcast_ref::<RenderArgs>() { Some(f(args)) } else { panic!("Expected RenderArgs") } }) }
identifier_body
render.rs
use std::any::Any; use viewport::Viewport; use { GenericEvent, RENDER }; /// Render arguments #[derive(Copy, Clone, PartialEq, Debug)] pub struct RenderArgs { /// Extrapolated time in seconds, used to do smooth animation. pub ext_dt: f64, /// The width of rendered area in points. pub width: u32, /...
else { panic!("Expected RenderArgs") } }) } } #[cfg(test)] mod tests { use super::*; #[test] fn test_event_render() { use Event; use RenderArgs; let e = Event::Render(RenderArgs { ext_dt: 0.0, width: 0, height: 0, draw_width: 0,...
{ Some(f(args)) }
conditional_block
text.rs
use std::borrow::ToOwned; use std::any::Any; use { GenericEvent, TEXT }; /// When receiving text from user, such as typing a character pub trait TextEvent { /// Creates a text event. fn from_text(text: &str, old_event: &Self) -> Option<Self>; /// Calls closure if this is a text event. fn text<U, F>(&s...
(bencher: &mut Bencher) { use Event; use input::Input; let e = Event::Input(Input::Text("".to_string())); bencher.iter(|| { let _: Option<Event> = TextEvent::from_text("hello", &e); }); } }
bench_event_text
identifier_name
text.rs
use std::borrow::ToOwned; use std::any::Any; use { GenericEvent, TEXT }; /// When receiving text from user, such as typing a character pub trait TextEvent { /// Creates a text event. fn from_text(text: &str, old_event: &Self) -> Option<Self>; /// Calls closure if this is a text event. fn text<U, F>(&s...
}) } } #[cfg(test)] mod tests { use super::*; use test::Bencher; #[test] fn test_input_text() { use input::Input; let e = Input::Text("".to_string()); let x: Option<Input> = TextEvent::from_text("hello", &e); let y: Option<Input> = x.clone().unwrap().text(...
{ panic!("Expected &str") }
conditional_block
text.rs
use std::borrow::ToOwned; use std::any::Any; use { GenericEvent, TEXT }; /// When receiving text from user, such as typing a character pub trait TextEvent { /// Creates a text event. fn from_text(text: &str, old_event: &Self) -> Option<Self>; /// Calls closure if this is a text event. fn text<U, F>(&s...
Some(f(&text)) } else { panic!("Expected &str") } }) } } #[cfg(test)] mod tests { use super::*; use test::Bencher; #[test] fn test_input_text() { use input::Input; let e = Input::Text("".to_string()); let x: O...
if self.event_id() != TEXT { return None; } self.with_args(|any| { if let Some(text) = any.downcast_ref::<String>() {
random_line_split
text.rs
use std::borrow::ToOwned; use std::any::Any; use { GenericEvent, TEXT }; /// When receiving text from user, such as typing a character pub trait TextEvent { /// Creates a text event. fn from_text(text: &str, old_event: &Self) -> Option<Self>; /// Calls closure if this is a text event. fn text<U, F>(&s...
}
{ use Event; use input::Input; let e = Event::Input(Input::Text("".to_string())); bencher.iter(|| { let _: Option<Event> = TextEvent::from_text("hello", &e); }); }
identifier_body
mod.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except accordin...
random_line_split
mod.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&mut self) -> Option<io::Result<SocketAddr>> { self.0.next() } } /// Resolve the host specified by `host` as a number of `SocketAddr` instances. /// /// This method may perform a DNS query to resolve `host` and may also inspect /// system configuration to resolve the specified hostname. /// /// # Examples /// /// ```...
next
identifier_name
context.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/. */ //! Data needed by the layout task. #![allow(unsafe_code)] use css::matching::{ApplicableDeclarationsCache, Styl...
let result = self.shared.image_cache_task.get_image_if_available(url.clone()); match result { Ok(image) => Some(image), Err(state) => { // If we are emitting an output file, then we need to block on // image load or we risk emitting an output file...
random_line_split
context.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/. */ //! Data needed by the layout task. #![allow(unsafe_code)] use css::matching::{ApplicableDeclarationsCache, Styl...
<'b>(&'b self) -> &'b mut StyleSharingCandidateCache { unsafe { let cached_context = &mut *self.cached_local_layout_context; &mut cached_context.style_sharing_candidate_cache } } pub fn get_or_request_image(&self, url: Url) -> Option<Arc<Image>> { // See if the i...
style_sharing_candidate_cache
identifier_name
context.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/. */ //! Data needed by the layout task. #![allow(unsafe_code)] use css::matching::{ApplicableDeclarationsCache, Styl...
#[inline(always)] pub fn font_context<'b>(&'b self) -> &'b mut FontContext { unsafe { let cached_context = &mut *self.cached_local_layout_context; &mut cached_context.font_context } } #[inline(always)] pub fn applicable_declarations_cache<'b>(&'b self) -> &...
{ let local_context = create_or_get_local_context(shared_layout_context); LayoutContext { shared: shared_layout_context, cached_local_layout_context: local_context, } }
identifier_body
context.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/. */ //! Data needed by the layout task. #![allow(unsafe_code)] use css::matching::{ApplicableDeclarationsCache, Styl...
None); None } // Image has been requested, is still pending. Return no image // for this paint loop. When the image loads it will trigger // a reflow...
{ // If we are emitting an output file, then we need to block on // image load or we risk emitting an output file missing the image. let is_sync = opts::get().output_file.is_some(); match (state, is_sync) { // Image failed to load, so ...
conditional_block
issue-2804.rs
// xfail-fast // 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 // <...
(store: int, managed_ip: ~str, device: HashMap<~str, extra::json::Json>) -> ~[(~str, object)] { match device.get(&~"interfaces") { &extra::json::List(ref interfaces) => { do interfaces.map |interface| { add_interface(store, copy managed_ip, copy *interface) } ...
add_interfaces
identifier_name
issue-2804.rs
// xfail-fast // 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 // <...
_ => { error!("Expected list for %s interfaces but found %?", managed_ip, device.get(&~"interfaces")); ~[] } } } pub fn main() {}
{ do interfaces.map |interface| { add_interface(store, copy managed_ip, copy *interface) } }
conditional_block
issue-2804.rs
// xfail-fast // 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 // <...
fn add_interface(store: int, managed_ip: ~str, data: extra::json::Json) -> (~str, object) { match &data { &extra::json::Object(ref interface) => { let name = lookup(copy *interface, ~"ifDescr", ~""); let label = fmt!("%s-%s", managed_ip, name); (label, bool_v...
}
random_line_split
issue-2804.rs
// xfail-fast // 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 // <...
fn add_interface(store: int, managed_ip: ~str, data: extra::json::Json) -> (~str, object) { match &data { &extra::json::Object(ref interface) => { let name = lookup(copy *interface, ~"ifDescr", ~""); let label = fmt!("%s-%s", managed_ip, name); (label, bool...
{ match table.find(&key) { option::Some(&extra::json::String(ref s)) => { copy *s } option::Some(value) => { error!("%s was expected to be a string but is a %?", key, value); default } option::None => { ...
identifier_body
day5.rs
extern crate crypto; use crypto::md5::Md5; use crypto::digest::Digest; fn main() { let mut sh = Md5::new(); let seed = "reyedfim"; let mut key = 0; let mut code_length = 0; while code_length < seed.len() { sh.input(seed.as_bytes()); sh.input(key.to_string().as_bytes()); l...
(key: &i32, md5: &[u8]) { print!("key: {}, MD5: ", key); for i in 0..16 { print!("{:02X}", md5[i]); } println!(""); }
print_md5_hash
identifier_name
day5.rs
extern crate crypto; use crypto::md5::Md5; use crypto::digest::Digest; fn main() { let mut sh = Md5::new(); let seed = "reyedfim"; let mut key = 0; let mut code_length = 0; while code_length < seed.len() { sh.input(seed.as_bytes()); sh.input(key.to_string().as_bytes()); l...
sh.reset(); key += 1; } } fn is_5_0(md5: &[u8]) -> bool { md5[0] == 0 && md5[1] == 0 && (md5[2] >> 4) == 0 } fn print_md5_hash(key: &i32, md5: &[u8]) { print!("key: {}, MD5: ", key); for i in 0..16 { print!("{:02X}", md5[i]); } println!(""); }
{ print_md5_hash(&key, &output); code_length += 1; }
conditional_block
day5.rs
extern crate crypto; use crypto::md5::Md5; use crypto::digest::Digest; fn main() { let mut sh = Md5::new(); let seed = "reyedfim"; let mut key = 0; let mut code_length = 0; while code_length < seed.len() { sh.input(seed.as_bytes()); sh.input(key.to_string().as_bytes()); l...
} } fn is_5_0(md5: &[u8]) -> bool { md5[0] == 0 && md5[1] == 0 && (md5[2] >> 4) == 0 } fn print_md5_hash(key: &i32, md5: &[u8]) { print!("key: {}, MD5: ", key); for i in 0..16 { print!("{:02X}", md5[i]); } println!(""); }
code_length += 1; } sh.reset(); key += 1;
random_line_split
day5.rs
extern crate crypto; use crypto::md5::Md5; use crypto::digest::Digest; fn main()
} } fn is_5_0(md5: &[u8]) -> bool { md5[0] == 0 && md5[1] == 0 && (md5[2] >> 4) == 0 } fn print_md5_hash(key: &i32, md5: &[u8]) { print!("key: {}, MD5: ", key); for i in 0..16 { print!("{:02X}", md5[i]); } println!(""); }
{ let mut sh = Md5::new(); let seed = "reyedfim"; let mut key = 0; let mut code_length = 0; while code_length < seed.len() { sh.input(seed.as_bytes()); sh.input(key.to_string().as_bytes()); let mut output = [0; 16]; sh.result(&mut output); if is_5_0(&output...
identifier_body
bytecode.rs
use parser; use parser::{Token, TokenType}; use std::iter; use std::io::Cursor; use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt}; // Bytecode management for Assembunny-plus // Bytecode binary files are in '.asmbb' // Assembunny-plus Bytecode Specification // (known in this passage as "ASMBP Bytecode") // An A...
(bytecode: &Vec<u8>) -> Result<(usize, Vec<Vec<Token>>), String> { let mut seg1reader = Cursor::new(&bytecode[0..4]); let reg_count = try_failsafe!(seg1reader.read_u32::<BigEndian>(), "Failed to read register count in metadata".to_owned()) as usize; let segment2 = bytecode[32..].chunks(5); let mut toks...
from_bytecode
identifier_name
bytecode.rs
use parser; use parser::{Token, TokenType}; use std::iter; use std::io::Cursor; use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt}; // Bytecode management for Assembunny-plus // Bytecode binary files are in '.asmbb' // Assembunny-plus Bytecode Specification // (known in this passage as "ASMBP Bytecode") // An A...
} // Converts a given bytecode sequence (Vec<u8>) to (usize /* register count */, Vec<Vec<Token>>). pub fn from_bytecode(bytecode: &Vec<u8>) -> Result<(usize, Vec<Vec<Token>>), String> { let mut seg1reader = Cursor::new(&bytecode[0..4]); let reg_count = try_failsafe!(seg1reader.read_u32::<BigEndian>(), "Faile...
{ let mut segment1: Vec<u8> = Vec::new(); let mut segment2: Vec<u8> = Vec::new(); let mut regs: Vec<String> = Vec::new(); for line in asmbp { if let Some(tokens) = try!(parser::to_tokens(line, &mut regs)) { for token in tokens { segment2.append(&mut token.to_byte...
identifier_body
bytecode.rs
use parser; use parser::{Token, TokenType}; use std::iter; use std::io::Cursor; use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt}; // Bytecode management for Assembunny-plus // Bytecode binary files are in '.asmbb' // Assembunny-plus Bytecode Specification // (known in this passage as "ASMBP Bytecode") // An A...
// [Type in u8] [Data in i32] // // Since every line of ASMB+ starts with a KEYWORD token, the tokens provided in the ASMBP Bytecode file are split whenever a new KEYWORD token is reached while iterating. // Converts a given ASMBP program to bytecode. // The program (parameter of this fn) should be a Slice of ...
random_line_split
bytecode.rs
use parser; use parser::{Token, TokenType}; use std::iter; use std::io::Cursor; use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt}; // Bytecode management for Assembunny-plus // Bytecode binary files are in '.asmbb' // Assembunny-plus Bytecode Specification // (known in this passage as "ASMBP Bytecode") // An A...
} // Querying length from regs after filling segment2 because regs also gets filled in the process. segment1.write_u32::<BigEndian>(regs.len() as u32).unwrap(); segment1.extend(iter::repeat(0u8).take(28 /* 32 - 4 */)); assert_eq!(segment1.len(), 32); segment1.append(&mut segment2); Ok(seg...
{ for token in tokens { segment2.append(&mut token.to_bytearray()); } }
conditional_block
csssupportsrule.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::{Parser, ParserInput}; use dom::bindings::codegen::Bindings::CSSSupportsRuleBinding; use dom::bindi...
/// https://drafts.csswg.org/css-conditional-3/#the-csssupportsrule-interface pub fn set_condition_text(&self, text: DOMString) { let mut input = ParserInput::new(&text); let mut input = Parser::new(&mut input); let cond = SupportsCondition::parse(&mut input); if let Ok(cond) = ...
rule.condition.to_css_string().into() }
random_line_split
csssupportsrule.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::{Parser, ParserInput}; use dom::bindings::codegen::Bindings::CSSSupportsRuleBinding; use dom::bindi...
} } impl SpecificCSSRule for CSSSupportsRule { fn ty(&self) -> u16 { use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleConstants; CSSRuleConstants::SUPPORTS_RULE } fn get_css(&self) -> DOMString { let guard = self.cssconditionrule.shared_lock().read(); self....
{ let global = self.global(); let win = global.as_window(); let url = win.Document().url(); let quirks_mode = win.Document().quirks_mode(); let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Supports), ...
conditional_block
csssupportsrule.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::{Parser, ParserInput}; use dom::bindings::codegen::Bindings::CSSSupportsRuleBinding; use dom::bindi...
/// https://drafts.csswg.org/css-conditional-3/#the-csssupportsrule-interface pub fn set_condition_text(&self, text: DOMString) { let mut input = ParserInput::new(&text); let mut input = Parser::new(&mut input); let cond = SupportsCondition::parse(&mut input); if let Ok(cond) =...
{ let guard = self.cssconditionrule.shared_lock().read(); let rule = self.supportsrule.read_with(&guard); rule.condition.to_css_string().into() }
identifier_body
csssupportsrule.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::{Parser, ParserInput}; use dom::bindings::codegen::Bindings::CSSSupportsRuleBinding; use dom::bindi...
{ cssconditionrule: CSSConditionRule, #[ignore_heap_size_of = "Arc"] supportsrule: Arc<Locked<SupportsRule>>, } impl CSSSupportsRule { fn new_inherited(parent_stylesheet: &CSSStyleSheet, supportsrule: Arc<Locked<SupportsRule>>) -> CSSSupportsRule { let guard = parent_style...
CSSSupportsRule
identifier_name
derive-partialeq-core.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] extern crate core; #[repr(C)] #[derive(Copy, Clone)] pub struct C { pub large_array: [::std::os::raw::c_int; 420usize], } #[test] fn bindgen_test_layout_C()
stringify!(large_array) ) ); } impl Default for C { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } impl ::core::cmp::PartialEq for C { fn eq(&self, other: &C) -> bool { &self.large_array[..] == &other.large_array[..] } }
{ assert_eq!( ::core::mem::size_of::<C>(), 1680usize, concat!("Size of: ", stringify!(C)) ); assert_eq!( ::core::mem::align_of::<C>(), 4usize, concat!("Alignment of ", stringify!(C)) ); assert_eq!( unsafe { &(*(::core::ptr::null::<C...
identifier_body
derive-partialeq-core.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] extern crate core; #[repr(C)] #[derive(Copy, Clone)] pub struct C { pub large_array: [::std::os::raw::c_int; 420usize], } #[test] fn bindgen_test_layout_C() { ass...
unsafe { &(*(::core::ptr::null::<C>())).large_array as *const _ as usize }, 0usize, concat!( "Offset of field: ", stringify!(C), "::", stringify!(large_array) ) ); } impl Default for C { fn default() -> Self { ...
::core::mem::align_of::<C>(), 4usize, concat!("Alignment of ", stringify!(C)) ); assert_eq!(
random_line_split
derive-partialeq-core.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] extern crate core; #[repr(C)] #[derive(Copy, Clone)] pub struct C { pub large_array: [::std::os::raw::c_int; 420usize], } #[test] fn bindgen_test_layout_C() { ass...
() -> Self { unsafe { ::core::mem::zeroed() } } } impl ::core::cmp::PartialEq for C { fn eq(&self, other: &C) -> bool { &self.large_array[..] == &other.large_array[..] } }
default
identifier_name
formal_usage.rs
extern crate rustorm; extern crate uuid; extern crate chrono; extern crate rustc_serialize; use uuid::Uuid; use rustorm::query::Query; use rustorm::query::Equality; use rustorm::pool::ManagedPool; use rustorm::database::Database; use rustorm::dao::{IsDao, Dao}; use rustorm::table::{IsTable, Table}; #[derive(Debug,...
Err(e) => { println!("Unable to connect to database {}", e); } } } Err(_) => { panic!("Unable to connect to database") } } } /// a dispatched controller with an accesss to a database reference fn show_product(db: &...
{ show_product(db.as_ref());//borrow a database }
conditional_block
formal_usage.rs
extern crate rustorm; extern crate uuid; extern crate chrono; extern crate rustc_serialize; use uuid::Uuid; use rustorm::query::Query; use rustorm::query::Equality; use rustorm::pool::ManagedPool; use rustorm::database::Database; use rustorm::dao::{IsDao, Dao}; use rustorm::table::{IsTable, Table}; #[derive(Debug,...
} /// a dispatched controller with an accesss to a database reference fn show_product(db: &Database) { let prod: Product = Query::select_all() .from_table("bazaar.product") .filter("name", Equality::EQ, &"GTX660 Ti videocard") .colle...
{ let url = "postgres://postgres:p0stgr3s@localhost/bazaar_v6"; let pool = ManagedPool::init(url, 1); match pool { Ok(pool) => { let db = pool.connect(); match db { Ok(db) => { show_product(db.as_ref());//borrow a database ...
identifier_body
formal_usage.rs
extern crate rustorm; extern crate uuid; extern crate chrono; extern crate rustc_serialize; use uuid::Uuid; use rustorm::query::Query; use rustorm::query::Equality; use rustorm::pool::ManagedPool; use rustorm::database::Database; use rustorm::dao::{IsDao, Dao}; use rustorm::table::{IsTable, Table}; #[derive(Debug,...
{ pub product_id: Uuid, pub name: Option<String>, pub description: Option<String>, } impl IsDao for Product{ fn from_dao(dao: &Dao) -> Self { Product { product_id: dao.get("product_id"), name: dao.get_opt("name"), description: dao.get_opt("description"), ...
Product
identifier_name
formal_usage.rs
extern crate rustorm; extern crate uuid; extern crate chrono; extern crate rustc_serialize; use uuid::Uuid; use rustorm::query::Query; use rustorm::query::Equality; use rustorm::pool::ManagedPool; use rustorm::database::Database; use rustorm::dao::{IsDao, Dao}; use rustorm::table::{IsTable, Table}; #[derive(Debug,...
impl IsDao for Product{ fn from_dao(dao: &Dao) -> Self { Product { product_id: dao.get("product_id"), name: dao.get_opt("name"), description: dao.get_opt("description"), } } fn to_dao(&self) -> Dao { let mut dao = Dao::new(); dao.set("pro...
random_line_split
builder.rs
use crate::builder::{FacetBuilder, MeshBuilder, SurfaceBuilder}; use crate::geometry::{FromGeometry, IntoGeometry}; use crate::graph::data::GraphData; use crate::graph::face::FaceKey; use crate::graph::mutation::face::{self, FaceInsertCache}; use crate::graph::mutation::vertex; use crate::graph::mutation::{Immediate, M...
<G> where G: GraphData, { mutation: Mutation<Immediate<MeshGraph<G>>>, } impl<G> Default for GraphBuilder<G> where G: GraphData, { fn default() -> Self { GraphBuilder { mutation: Mutation::from(MeshGraph::default()), } } } impl<G> ClosedInput for GraphBuilder<G> where ...
GraphBuilder
identifier_name
builder.rs
use crate::builder::{FacetBuilder, MeshBuilder, SurfaceBuilder}; use crate::geometry::{FromGeometry, IntoGeometry}; use crate::graph::data::GraphData; use crate::graph::face::FaceKey; use crate::graph::mutation::face::{self, FaceInsertCache}; use crate::graph::mutation::vertex; use crate::graph::mutation::{Immediate, M...
} impl<G> FacetBuilder<VertexKey> for GraphBuilder<G> where G: GraphData, { type Facet = G::Face; type Key = FaceKey; fn insert_facet<T, U>(&mut self, keys: T, data: U) -> Result<Self::Key, Self::Error> where Self::Facet: FromGeometry<U>, T: AsRef<[VertexKey]>, { let c...
{ Ok(vertex::insert(&mut self.mutation, data.into_geometry())) }
identifier_body
builder.rs
use crate::builder::{FacetBuilder, MeshBuilder, SurfaceBuilder}; use crate::geometry::{FromGeometry, IntoGeometry}; use crate::graph::data::GraphData; use crate::graph::face::FaceKey; use crate::graph::mutation::face::{self, FaceInsertCache}; use crate::graph::mutation::vertex; use crate::graph::mutation::{Immediate, M...
impl<G> FacetBuilder<VertexKey> for GraphBuilder<G> where G: GraphData, { type Facet = G::Face; type Key = FaceKey; fn insert_facet<T, U>(&mut self, keys: T, data: U) -> Result<Self::Key, Self::Error> where Self::Facet: FromGeometry<U>, T: AsRef<[VertexKey]>, { let cach...
Ok(vertex::insert(&mut self.mutation, data.into_geometry())) } }
random_line_split
mod.rs
// Copyright (c) Carl-Erwin Griffith // // Permission is hereby granted, free of charge, to any // person obtaining a copy of this software and associated // documentation files (the "Software"), to deal in the // Software without restriction, including without // limitation the rights to use, copy, modify, merge, // p...
{ unsafe { char::from_u32_unchecked(codep) } }
identifier_body
mod.rs
// Copyright (c) Carl-Erwin Griffith // // Permission is hereby granted, free of charge, to any // person obtaining a copy of this software and associated // documentation files (the "Software"), to deal in the // Software without restriction, including without // limitation the rights to use, copy, modify, merge, // p...
// shall be included in all copies or substantial portions // of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT // SHALL THE...
// // The above copyright notice and this permission notice
random_line_split
mod.rs
// Copyright (c) Carl-Erwin Griffith // // Permission is hereby granted, free of charge, to any // person obtaining a copy of this software and associated // documentation files (the "Software"), to deal in the // Software without restriction, including without // limitation the rights to use, copy, modify, merge, // p...
(codep: u32) -> char { unsafe { char::from_u32_unchecked(codep) } }
u32_to_char
identifier_name
page_templates.rs
use std::str; use std::rc::Rc; use error::*; use traits::*; use input::*; use output::*; use isymtope_data::*; #[derive(Debug, Default)] pub struct InternalTemplateRendererFactory; #[derive(Debug)] pub struct InternalTemplateRenderer { data: InternalTemplateData, } impl InternalTemplateRendererFactory { pu...
( &self, document_provider: Rc<DocumentProvider>, state_provider: Option<Rc<ReducerStateProvider>>, base_url: &str, ) -> DocumentProcessingResult<InternalTemplateRenderer> { let renderer = InternalTemplateRenderer::build(document_provider, state_provider, base_url...
build
identifier_name
page_templates.rs
use std::str; use std::rc::Rc;
use traits::*; use input::*; use output::*; use isymtope_data::*; #[derive(Debug, Default)] pub struct InternalTemplateRendererFactory; #[derive(Debug)] pub struct InternalTemplateRenderer { data: InternalTemplateData, } impl InternalTemplateRendererFactory { pub fn build( &self, document_pr...
use error::*;
random_line_split
task-stderr.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 ...
{ let (tx, rx) = channel(); let mut reader = ChanReader::new(rx); let stderr = ChanWriter::new(tx); let res = thread::Builder::new().stderr(box stderr as Box<Writer + Send>) .spawn(move|| -> () { panic!("Hello, world!") }).unwrap().join(); assert!(res...
identifier_body
task-stderr.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 ...
}
let output = reader.read_to_string().unwrap(); assert!(output.contains("Hello, world!"));
random_line_split
task-stderr.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 ...
() { let (tx, rx) = channel(); let mut reader = ChanReader::new(rx); let stderr = ChanWriter::new(tx); let res = thread::Builder::new().stderr(box stderr as Box<Writer + Send>) .spawn(move|| -> () { panic!("Hello, world!") }).unwrap().join(); assert!(r...
main
identifier_name
diff.rs
use super::*; use crate::config::Config; use crate::rustfmt_diff::{make_diff, print_diff}; pub(crate) struct DiffEmitter { config: Config, } impl DiffEmitter { pub(crate) fn new(config: Config) -> Self { Self { config } } } impl Emitter for DiffEmitter { fn emit_formatted_file( &mut s...
Ok(EmitterResult { has_diff }) } } #[cfg(test)] mod tests { use super::*; use crate::config::Config; use crate::FileName; use std::path::PathBuf; #[test] fn does_not_print_when_no_files_reformatted() { let mut writer = Vec::new(); let config = Config::default(); ...
let file_path = ensure_real_path(filename); writeln!(output, "Incorrect newline style in {}", file_path.display())?; return Ok(EmitterResult { has_diff: true }); }
random_line_split
diff.rs
use super::*; use crate::config::Config; use crate::rustfmt_diff::{make_diff, print_diff}; pub(crate) struct DiffEmitter { config: Config, } impl DiffEmitter { pub(crate) fn new(config: Config) -> Self { Self { config } } } impl Emitter for DiffEmitter { fn emit_formatted_file( &mut s...
else if original_text!= formatted_text { // This occurs when the only difference between the original and formatted values // is the newline style. This happens because The make_diff function compares the // original and formatted values line by line, independent of line endings. ...
{ if self.config.print_misformatted_file_names() { writeln!(output, "{}", ensure_real_path(filename).display())?; } else { print_diff( mismatch, |line_num| format!("Diff in {} at line {}:", filename, line_num), ...
conditional_block
diff.rs
use super::*; use crate::config::Config; use crate::rustfmt_diff::{make_diff, print_diff}; pub(crate) struct DiffEmitter { config: Config, } impl DiffEmitter { pub(crate) fn new(config: Config) -> Self { Self { config } } } impl Emitter for DiffEmitter { fn
( &mut self, output: &mut dyn Write, FormattedFile { filename, original_text, formatted_text, }: FormattedFile<'_>, ) -> Result<EmitterResult, io::Error> { const CONTEXT_SIZE: usize = 3; let mismatch = make_diff(&original_text, form...
emit_formatted_file
identifier_name
stylesheet.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 context::QuirksMode; use cssparser::{Parser, ParserInput, RuleListParser}; use error_reporting::{ContextualPar...
} #[cfg(feature = "servo")] impl Clone for Stylesheet { fn clone(&self) -> Self { // Create a new lock for our clone. let lock = self.shared_lock.clone(); let guard = self.shared_lock.read(); // Make a deep clone of the media, using the new lock. let media = self.media.rea...
{ self.disabled.swap(disabled, Ordering::SeqCst) != disabled }
identifier_body
stylesheet.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 context::QuirksMode; use cssparser::{Parser, ParserInput, RuleListParser}; use error_reporting::{ContextualPar...
/// Creates an empty stylesheet and parses it with a given base url, origin /// and media. /// /// Effectively creates a new stylesheet and forwards the hard work to /// `Stylesheet::update_from_str`. pub fn from_str( css: &str, url_data: UrlExtraData, origin: Origin, ...
random_line_split
stylesheet.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 context::QuirksMode; use cssparser::{Parser, ParserInput, RuleListParser}; use error_reporting::{ContextualPar...
}, Err((error, slice)) => { let location = error.location; let error = ContextualParseError::InvalidRule(slice, error); iter.parser.context.log_css_error(location, error); }, ...
{ break; }
conditional_block
stylesheet.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 context::QuirksMode; use cssparser::{Parser, ParserInput, RuleListParser}; use error_reporting::{ContextualPar...
( css: &str, url_data: UrlExtraData, origin: Origin, media: Arc<Locked<MediaList>>, shared_lock: SharedRwLock, stylesheet_loader: Option<&StylesheetLoader>, error_reporter: Option<&ParseErrorReporter>, quirks_mode: QuirksMode, line_number_offset: u...
from_str
identifier_name
pluggable.rs
use std::sync::{Arc, RwLock}; use app::M; use plugin1::{Plugin1Options, Plugin1}; use plugin2::Plugin2; use pluginbuilder::{Plugin, PluginWithOptions}; use std::thread; pub type AppRef = Arc<RwLock<M>>; pub enum Plugins { Plugin1(Plugin1Options), Plugin2, }
pub struct Pluggable { app: AppRef, plugins: Arc<RwLock<Vec<Box<Plugin>>>>, is_running: Arc<RwLock<bool>>, } impl Pluggable { pub fn new(app: M) -> Self { Pluggable { app: Arc::new(RwLock::new(app)), plugins: Arc::new(RwLock::new(vec![])), is_running: Arc::ne...
#[derive(Clone)]
random_line_split
pluggable.rs
use std::sync::{Arc, RwLock}; use app::M; use plugin1::{Plugin1Options, Plugin1}; use plugin2::Plugin2; use pluginbuilder::{Plugin, PluginWithOptions}; use std::thread; pub type AppRef = Arc<RwLock<M>>; pub enum Plugins { Plugin1(Plugin1Options), Plugin2, } #[derive(Clone)] pub struct Pluggable { app: Ap...
pub fn stop(&mut self) { *self.is_running.write().unwrap() = false; for pl in self.plugins.write().unwrap().iter_mut() { pl.stop(); } } }
{ let self_clone = self.clone(); thread::spawn(move || { while *self_clone.is_running.read().unwrap() { for pl in self_clone.plugins.write().unwrap().iter_mut() { pl.run(); } thread::yield_now(); } }); ...
identifier_body
pluggable.rs
use std::sync::{Arc, RwLock}; use app::M; use plugin1::{Plugin1Options, Plugin1}; use plugin2::Plugin2; use pluginbuilder::{Plugin, PluginWithOptions}; use std::thread; pub type AppRef = Arc<RwLock<M>>; pub enum Plugins { Plugin1(Plugin1Options), Plugin2, } #[derive(Clone)] pub struct Pluggable { app: Ap...
(&mut self) { *self.is_running.write().unwrap() = false; for pl in self.plugins.write().unwrap().iter_mut() { pl.stop(); } } }
stop
identifier_name
elf.rs
pub const ELF_CLASS: u8 = 2; pub type ElfAddr = u64; pub type ElfOff = u64; pub type ElfHalf = u16; pub type ElfWord = u32; pub type ElfXword = u64; /// An ELF header #[repr(packed)] #[derive(Debug)] pub struct ElfHeader { /// The "magic number" (4 bytes) pub magic: [u8; 4], /// 64 or 32 bit? pub class...
{ pub name: ElfWord, pub info: u8, pub other: u8, pub sh_index: ElfHalf, pub value: ElfAddr, pub size: ElfXword, }
ElfSymbol
identifier_name
elf.rs
pub const ELF_CLASS: u8 = 2; pub type ElfAddr = u64; pub type ElfOff = u64; pub type ElfHalf = u16; pub type ElfWord = u32; pub type ElfXword = u64; /// An ELF header #[repr(packed)] #[derive(Debug)] pub struct ElfHeader { /// The "magic number" (4 bytes) pub magic: [u8; 4], /// 64 or 32 bit? pub class...
} /// An ELF symbol #[repr(packed)] #[derive(Debug)] pub struct ElfSymbol { pub name: ElfWord, pub info: u8, pub other: u8, pub sh_index: ElfHalf, pub value: ElfAddr, pub size: ElfXword, }
pub addr_align: ElfXword, pub ent_len: ElfXword,
random_line_split
mod.rs
// Copyright 2017 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 ...
/// Response FFI module pub mod resp;
pub mod req;
random_line_split
str.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! The `ByteString` struct. use cssparser::CowRcStr; use html5ever::{LocalName, Namespace}; use servo_atoms::Ato...
(value: Vec<u8>) -> ByteString { ByteString(value) } /// Returns `self` as a string, if it encodes valid UTF-8, and `None` /// otherwise. pub fn as_str(&self) -> Option<&str> { str::from_utf8(&self.0).ok() } /// Returns the length. pub fn len(&self) -> usize { self....
new
identifier_name
str.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! The `ByteString` struct. use cssparser::CowRcStr; use html5ever::{LocalName, Namespace}; use servo_atoms::Ato...
ter().all(|&x| { // http://tools.ietf.org/html/rfc2616#section-2.2 match x { 0...31 | 127 => false, // CTLs 40 | 41 | 60 | 62 | 64 | 44 | 59 | 58 | 92 | 34 | 47...
return false; // A token must be at least a single character } s.i
conditional_block
str.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! The `ByteString` struct. use cssparser::CowRcStr; use html5ever::{LocalName, Namespace}; use servo_atoms::Ato...
<'a> Into<Cow<'a, str>> for DOMString { fn into(self) -> Cow<'a, str> { self.0.into() } } impl<'a> Into<CowRcStr<'a>> for DOMString { fn into(self) -> CowRcStr<'a> { self.0.into() } } impl Extend<char> for DOMString { fn extend<I>(&mut self, iterable: I) where I: IntoIterator<Item=...
self.0.into() } } impl
identifier_body
str.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! The `ByteString` struct. use cssparser::CowRcStr; use html5ever::{LocalName, Namespace}; use servo_atoms::Ato...
impl Deref for DOMString { type Target = str; #[inline] fn deref(&self) -> &str { &self.0 } } impl DerefMut for DOMString { #[inline] fn deref_mut(&mut self) -> &mut str { &mut self.0 } } impl AsRef<str> for DOMString { fn as_ref(&self) -> &str { &self.0 } ...
random_line_split
traversal.rs
whether /// a full traversal is needed. fn pre_traverse( root: E, shared_context: &SharedStyleContext, traversal_flags: TraversalFlags, ) -> PreTraverseToken { // If this is an unstyled-only traversal, the caller has already verified // that there's something to trav...
// Inform any paint worklets of changed style, to speculatively // evaluate the worklet code. In the case that the size hasn't changed, // this will result in increased concurrency between script and layout. notify_paint_worklet(context, data); } else { debug_assert!(data.h...
{ child_cascade_requirement = compute_style(traversal_data, context, element, data); if element.is_native_anonymous() { // We must always cascade native anonymous subtrees, since they inherit // styles from their first non-NAC ancestor. child_cascade_requ...
conditional_block
traversal.rs
} node = parent.as_node(); } } else { // Otherwise record the number of children to process when the time // comes. node.as_element().unwrap() .store_children_to_process(children_to_process); } } //...
{ // If the postorder step is a no-op, don't bother. if !Self::needs_postorder_traversal() { return; } if children_to_process == 0 { // We are a leaf. Walk up the chain. loop { self.process_postorder(context, node); if ...
identifier_body
traversal.rs
computing initial styles and the parent has a Gecko XBL // binding, that binding may inject anonymous children and remap the // explicit children to an insertion point (or hide them entirely). It // may also specify a scoped stylesheet, which changes the rules that // apply within the s...
ChildCascadeRequirement::CanSkipCascade => {} ChildCascadeRequirement::MustCascadeDescendants => { child_hint |= RECASCADE_SELF | RECASCADE_DESCENDANTS; }
random_line_split
traversal.rs
(&self) -> bool { self.0 } } #[cfg(feature = "servo")] #[inline] fn is_servo_nonincremental_layout() -> bool { use servo_config::opts; opts::get().nonincremental_layout } #[cfg(not(feature = "servo"))] #[inline] fn is_servo_nonincremental_layout() -> bool { false } /// A DOM Traversal trait, that is use...
should_traverse
identifier_name
codec_test.rs
extern crate erl_ext; use erl_ext::{Encoder,Decoder}; use std::io; use std::io::{Write,Read}; use std::fs; use std::process; use std::path::Path; #[test] fn main() { // generate tests/data/*.bin match process::Command::new("escript").arg("tests/term_gen.erl").spawn() { Ok(_) => (), Err(ioerr) ...
let data_dir = Path::new("tests/data"); for path in (fs::read_dir(&data_dir) .unwrap() .map(|de| de.unwrap().path()) .filter(|ref p| p.extension().unwrap().to_str() == Some("bin"))) { let mut in_f = fs::File::open(&path).unwrap(); let mut src = Ve...
return } }; // run decode-encode cycle and compare source and resulting binaries
random_line_split
codec_test.rs
extern crate erl_ext; use erl_ext::{Encoder,Decoder}; use std::io; use std::io::{Write,Read}; use std::fs; use std::process; use std::path::Path; #[test] fn
() { // generate tests/data/*.bin match process::Command::new("escript").arg("tests/term_gen.erl").spawn() { Ok(_) => (), Err(ioerr) => { (writeln!( &mut io::stderr(), "{}:{} [warn] Failed to launch escript - '{}'. Is Erlang installed?", ...
main
identifier_name
codec_test.rs
extern crate erl_ext; use erl_ext::{Encoder,Decoder}; use std::io; use std::io::{Write,Read}; use std::fs; use std::process; use std::path::Path; #[test] fn main()
let mut src = Vec::new(); in_f.read_to_end(&mut src).unwrap(); let mut rdr = io::Cursor::new(src); let dst = Vec::new(); let mut wrtr = io::BufWriter::new(dst); { let mut decoder = Decoder::new(&mut rdr); assert!(true == decoder.read_prelude().un...
{ // generate tests/data/*.bin match process::Command::new("escript").arg("tests/term_gen.erl").spawn() { Ok(_) => (), Err(ioerr) => { (writeln!( &mut io::stderr(), "{}:{} [warn] Failed to launch escript - '{}'. Is Erlang installed?", f...
identifier_body
member_access.rs
///! fff-lang ///! ///! syntax/member_access ///! member_access = expr '.' identifier use std::fmt; use crate::source::Span; use crate::lexical::Token; use crate::lexical::Seperator; use super::Expr; use super::SimpleName; use super::super::Formatter; use super::super::ParseResult; use super::super::Pars...
fn from(member_access_expr: MemberAccessExpr) -> Expr { Expr::MemberAccess(member_access_expr) } } impl MemberAccessExpr { pub fn new<T: Into<Expr>>(base: T, dot_span: Span, name: SimpleName) -> MemberAccessExpr { let base = base.into(); MemberAccessExpr{ all_span: base.get_all...
} impl From<MemberAccessExpr> for Expr {
random_line_split
member_access.rs
///! fff-lang ///! ///! syntax/member_access ///! member_access = expr '.' identifier use std::fmt; use crate::source::Span; use crate::lexical::Token; use crate::lexical::Seperator; use super::Expr; use super::SimpleName; use super::super::Formatter; use super::super::ParseResult; use super::super::Pars...
(sess: &mut ParseSession) -> ParseResult<MemberAccessExpr> { let dot_span = sess.expect_sep(Seperator::Dot)?; let name = SimpleName::parse(sess)?; Ok(MemberAccessExpr::new_by_parse_result(dot_span, name)) } }
parse
identifier_name
token.rs
/// Associates readiness notifications with [`Evented`] handles. /// /// `Token` is a wrapper around `usize` and is used as an argument to /// [`Poll::register`] and [`Poll::reregister`]. /// /// See [`Poll`] for more documentation on polling. /// /// # Example /// /// Using `Token` to track which socket generated the ...
}
{ val.0 }
identifier_body
token.rs
/// Associates readiness notifications with [`Evented`] handles. /// /// `Token` is a wrapper around `usize` and is used as an argument to /// [`Poll::register`] and [`Poll::reregister`]. /// /// See [`Poll`] for more documentation on polling. /// /// # Example /// /// Using `Token` to track which socket generated the ...
(val: usize) -> Token { Token(val) } } impl From<Token> for usize { fn from(val: Token) -> usize { val.0 } }
from
identifier_name
token.rs
/// Associates readiness notifications with [`Evented`] handles. /// /// `Token` is a wrapper around `usize` and is used as an argument to /// [`Poll::register`] and [`Poll::reregister`]. /// /// See [`Poll`] for more documentation on polling. /// /// # Example /// /// Using `Token` to track which socket generated the ...
/// // Perform operations in a loop until `WouldBlock` is /// // encountered. /// loop { /// match listener.accept() { /// Ok((socket, _)) => { /// // Shutdown the server /// ...
random_line_split
execute.rs
extern crate nix; extern crate exec; use self::nix::unistd::{fork, ForkResult, setpgid, getpid, tcsetpgrp, execvp}; use self::nix::sys::wait::*; use self::nix::Error; use self::nix::Errno; use std::process; use job_manager::*; use command::command::CommandLine; use functions::*; pub fn parse(command: String) -> i8 { ...
let args_c = args_c.as_slice(); setpgid(getpid(), getpid()).expect("setpgid failed"); let _ = execvp(&args_c[0], &args_c[0..]); println!("rush: unknown command {}", &args[0]); process::exit(1); }, Ok(ForkResult::Parent{child}) => { ...
let args_c: Vec<CString> = args.iter().map(|x| CString::new(x.as_bytes()).unwrap()).collect(); let args = args.as_slice();
random_line_split
execute.rs
extern crate nix; extern crate exec; use self::nix::unistd::{fork, ForkResult, setpgid, getpid, tcsetpgrp, execvp}; use self::nix::sys::wait::*; use self::nix::Error; use self::nix::Errno; use std::process; use job_manager::*; use command::command::CommandLine; use functions::*; pub fn
(command: String) -> i8 { let command_line = CommandLine::new(command); let mut command = command_line.get_command(); if command.is_empty() { return 0; } else if command.starts_with("cd") { return cd::change_dir(command.split_off(2).trim().to_string()); } else if command.starts_wi...
parse
identifier_name
execute.rs
extern crate nix; extern crate exec; use self::nix::unistd::{fork, ForkResult, setpgid, getpid, tcsetpgrp, execvp}; use self::nix::sys::wait::*; use self::nix::Error; use self::nix::Errno; use std::process; use job_manager::*; use command::command::CommandLine; use functions::*; pub fn parse(command: String) -> i8 { ...
//io::stdin().read_to_string(&mut buffer).unwrap(); tcsetpgrp(1, pid).expect("tcsetpgrp failed"); //println!("lol"); signal::kill(pid, signal::SIGCONT).expect("sigcont failed"); }, Ok(WaitStatus::Stopped(_, self::nix::sys::signal::S...
{ use self::nix::sys::signal; let mut err_code = 0; let mut wait_pid_flags = WUNTRACED; wait_pid_flags.insert(WCONTINUED); loop { match waitpid(pid, Some(wait_pid_flags)) { Ok(WaitStatus::StillAlive) => (), Ok(WaitStatus::Continued(_)) => (), Ok(WaitStatu...
identifier_body
wrappers.rs
use env::{Env, EnvRepr, EnvConvert, Discounted}; use rand::{Rng}; use std::cell::{Cell}; #[derive(Clone, Copy)] pub struct DiscountedWrapConfig<E> where E: Env<Response=f32> { pub discount: f32, pub env_init: E::Init, } #[derive(Clone, Default)] pub struct DiscountedWrapEnv<E> where E: Env<Response=f32> { pub ...
(&self, obs: &mut [T]) { self.env.extract_observable(obs); } } impl<E, Target> EnvConvert<DiscountedWrapEnv<Target>> for DiscountedWrapEnv<E> where E: Env<Response=f32> + EnvConvert<Target>, Target: Env<Response=f32> { fn clone_from_env(&mut self, other: &DiscountedWrapEnv<Target>) { self.discount.set(othe...
extract_observable
identifier_name
wrappers.rs
use env::{Env, EnvRepr, EnvConvert, Discounted}; use rand::{Rng}; use std::cell::{Cell}; #[derive(Clone, Copy)] pub struct DiscountedWrapConfig<E> where E: Env<Response=f32> { pub discount: f32, pub env_init: E::Init, } #[derive(Clone, Default)] pub struct DiscountedWrapEnv<E> where E: Env<Response=f32> { pub ...
type Response = Discounted<f32>; fn reset<R>(&self, init: &Self::Init, rng: &mut R) where R: Rng + Sized { self.discount.set(init.discount); self.env.reset(&init.env_init, rng); } fn is_terminal(&self) -> bool { self.env.is_terminal() } fn is_legal_action(&self, action: &Self::Action) -> bool...
//type Init = E::Init; type Init = DiscountedWrapConfig<E>; type Action = E::Action;
random_line_split
wrappers.rs
use env::{Env, EnvRepr, EnvConvert, Discounted}; use rand::{Rng}; use std::cell::{Cell}; #[derive(Clone, Copy)] pub struct DiscountedWrapConfig<E> where E: Env<Response=f32> { pub discount: f32, pub env_init: E::Init, } #[derive(Clone, Default)] pub struct DiscountedWrapEnv<E> where E: Env<Response=f32> { pub ...
fn extract_observable(&self, obs: &mut [T]) { self.env.extract_observable(obs); } } impl<E, Target> EnvConvert<DiscountedWrapEnv<Target>> for DiscountedWrapEnv<E> where E: Env<Response=f32> + EnvConvert<Target>, Target: Env<Response=f32> { fn clone_from_env(&mut self, other: &DiscountedWrapEnv<Target>) { ...
{ self.env.observable_sz() }
identifier_body
windowing.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! Abstract windowing methods. The concrete implementations of these can be found in `platform/`. use embedder_...
{ /// Sent when no message has arrived, but the event loop was kicked for some reason (perhaps /// by another Servo subsystem). /// /// FIXME(pcwalton): This is kind of ugly and may not work well with multiprocess Servo. /// It's possible that this should be something like /// `CompositorMessag...
WindowEvent
identifier_name
windowing.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! Abstract windowing methods. The concrete implementations of these can be found in `platform/`. use embedder_...
pub viewport: DeviceIntRect, }
random_line_split
atomic_cxchg_rel.rs
#![feature(core, core_intrinsics)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::atomic_cxchg_rel; use core::cell::UnsafeCell; use std::sync::Arc;
struct A<T> { v: UnsafeCell<T> } unsafe impl Sync for A<T> {} impl<T> A<T> { fn new(v: T) -> A<T> { A { v: UnsafeCell::<T>::new(v) } } } type T = usize; macro_rules! atomic_cxchg_rel_test { ($init:expr, $old:expr, $new:expr, $result:expr) => ({ let value: T = $init; le...
use std::thread; // pub fn atomic_cxchg_rel<T>(dst: *mut T, old: T, src: T) -> T;
random_line_split
atomic_cxchg_rel.rs
#![feature(core, core_intrinsics)] extern crate core; #[cfg(test)] mod tests { use core::intrinsics::atomic_cxchg_rel; use core::cell::UnsafeCell; use std::sync::Arc; use std::thread; // pub fn atomic_cxchg_rel<T>(dst: *mut T, old: T, src: T) -> T; struct A<T> { v: UnsafeCell<T> } ...
} type T = usize; macro_rules! atomic_cxchg_rel_test { ($init:expr, $old:expr, $new:expr, $result:expr) => ({ let value: T = $init; let a: A<T> = A::<T>::new(value); let data: Arc<A<T>> = Arc::<A<T>>::new(a); let clone: Arc<A<T>> = data.clone(); thread::spawn(move || { let d...
{ A { v: UnsafeCell::<T>::new(v) } }
identifier_body