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
challenge19_20.rs
use crate::errors::*; use crate::set1::break_multibyte_xor_for_keysize; use aes::random_block; use std::path::PathBuf; use aes::{Aes128, MODE}; use serialize::from_base64_lines; pub enum Exercise { _19, _20, } struct
{ key: Vec<u8>, exercise: Exercise, } impl Encrypter { pub fn new(exercise: Exercise) -> Self { Encrypter { key: random_block(), exercise, } } pub fn get_ciphertexts(&self) -> Result<Vec<Vec<u8>>> { let mut input_file_path = PathBuf::from("data"); ...
Encrypter
identifier_name
challenge19_20.rs
use crate::errors::*; use crate::set1::break_multibyte_xor_for_keysize; use aes::random_block; use std::path::PathBuf; use aes::{Aes128, MODE}; use serialize::from_base64_lines;
pub enum Exercise { _19, _20, } struct Encrypter { key: Vec<u8>, exercise: Exercise, } impl Encrypter { pub fn new(exercise: Exercise) -> Self { Encrypter { key: random_block(), exercise, } } pub fn get_ciphertexts(&self) -> Result<Vec<Vec<u8>>> { ...
random_line_split
challenge19_20.rs
use crate::errors::*; use crate::set1::break_multibyte_xor_for_keysize; use aes::random_block; use std::path::PathBuf; use aes::{Aes128, MODE}; use serialize::from_base64_lines; pub enum Exercise { _19, _20, } struct Encrypter { key: Vec<u8>, exercise: Exercise, } impl Encrypter { pub fn new(exe...
{ let encrypter = Encrypter::new(exercise); let ciphertexts = encrypter.get_ciphertexts()?; let size = ciphertexts.iter().map(|c| c.len()).min().unwrap(); // unwrap is ok let ciphertext: Vec<u8> = ciphertexts .iter() .flat_map(|ciphertext| &ciphertext[..size]) .cloned() ....
identifier_body
helpers.rs
// Example of a module shared among test code. /*BEGIN*/pub fn helper() { // ^^^^^^^^^^^^^^^WARN(>=1.22.0) function is never used // ^^^^^^^^^^^^^^^NOTE(>=1.22.0) #[warn(dead_code)] }/*END*/ // ~WARN(<1.22.0) function is never used // ~NOTE(<1.22.0,>=1.17.0) #[warn(dead_code)] /*BEGIN*/pub fn unused() { /...
// ~NOTE(<1.22.0,>=1.17.0) #[warn(dead_code)]
// ^^^^^^^^^^^^^^^NOTE(>=1.22.0,<1.24.0-beta) #[warn(dead_code)] }/*END*/ // ~WARN(<1.22.0) function is never used
random_line_split
helpers.rs
// Example of a module shared among test code. /*BEGIN*/pub fn helper()
/*END*/ // ~WARN(<1.22.0) function is never used // ~NOTE(<1.22.0,>=1.17.0) #[warn(dead_code)] /*BEGIN*/pub fn unused() { // ^^^^^^^^^^^^^^^WARN(>=1.22.0) function is never used // ^^^^^^^^^^^^^^^NOTE(>=1.22.0,<1.24.0-beta) #[warn(dead_code)] }/*END*/ // ~WARN(<1.22.0) function is never used // ~NOTE(<1.22...
{ // ^^^^^^^^^^^^^^^WARN(>=1.22.0) function is never used // ^^^^^^^^^^^^^^^NOTE(>=1.22.0) #[warn(dead_code)] }
identifier_body
helpers.rs
// Example of a module shared among test code. /*BEGIN*/pub fn helper() { // ^^^^^^^^^^^^^^^WARN(>=1.22.0) function is never used // ^^^^^^^^^^^^^^^NOTE(>=1.22.0) #[warn(dead_code)] }/*END*/ // ~WARN(<1.22.0) function is never used // ~NOTE(<1.22.0,>=1.17.0) #[warn(dead_code)] /*BEGIN*/pub fn
() { // ^^^^^^^^^^^^^^^WARN(>=1.22.0) function is never used // ^^^^^^^^^^^^^^^NOTE(>=1.22.0,<1.24.0-beta) #[warn(dead_code)] }/*END*/ // ~WARN(<1.22.0) function is never used // ~NOTE(<1.22.0,>=1.17.0) #[warn(dead_code)]
unused
identifier_name
match-arm-statics.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 ...
_ => { "Unknown" } } } assert_eq!(action_to_str(glfw::RELEASE), "Released"); assert_eq!(action_to_str(glfw::PRESS), "Pressed"); assert_eq!(action_to_str(glfw::REPEAT), "Repeated"); } fn issue_13626() { const VAL: [u8,..1] = [0]; match [1] { VAL => unreachabl...
{ "Repeated" }
conditional_block
match-arm-statics.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
assert_eq!(match C::D { F => 1i, _ => 2, }, 1); } fn issue_13731() { enum A { AA(()) } const B: A = A::AA(()); match A::AA(()) { B => () } } fn issue_15393() { #![allow(dead_code)] struct Flags { bits: uint } const FOO: Flags = Flags { bits: 0x01 }; const BAR...
enum C { D = 3, E = 4 } const F : C = C::D;
random_line_split
match-arm-statics.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 ...
{ Variant1(bool), Variant2 { dir: Direction } } const TRUE_TRUE: (bool, bool) = (true, true); const NONE: Option<Direction> = None; const EAST: Direction = Direction::East; const NEW_FALSE: NewBool = NewBool(false); const STATIC_FOO: Foo = Foo { bar: Some(Direction::South), baz: NEW_FALSE }; const...
EnumWithStructVariants
identifier_name
animation.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! CSS transitions and animations. use clock_ticks; use flow::{self, Flow}; use gfx::display_list::OpaqueNode; u...
{ layout_task.tick_animations(rw_data); layout_task.script_chan .send(ConstellationControlMsg::TickAllAnimations(layout_task.id)) .unwrap(); }
identifier_body
animation.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! CSS transitions and animations. use clock_ticks; use flow::{self, Flow}; use gfx::display_list::OpaqueNode; u...
(layout_task: &LayoutTask, rw_data: &mut LayoutTaskData) { layout_task.tick_animations(rw_data); layout_task.script_chan .send(ConstellationControlMsg::TickAllAnimations(layout_task.id)) .unwrap(); }
tick_all_animations
identifier_name
animation.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! CSS transitions and animations.
use incremental::{self, RestyleDamage}; use layout_task::{LayoutTask, LayoutTaskData}; use msg::constellation_msg::{AnimationState, Msg, PipelineId}; use script::layout_interface::Animation; use script_traits::ConstellationControlMsg; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::sync::...
use clock_ticks; use flow::{self, Flow}; use gfx::display_list::OpaqueNode;
random_line_split
cache_padded.rs
use std::marker; use std::cell::UnsafeCell; use std::mem; use std::ptr; use std::ops::{Deref, DerefMut}; // For now, treat this as an arch-independent constant. const CACHE_LINE: usize = 32; #[repr(simd)] struct Padding(u64, u64, u64, u64); /// Pad `T` to the length of a cacheline. /// /// Sometimes concurrent progr...
(&self) -> &T { assert_valid::<T>(); unsafe { mem::transmute(&self.data) } } } impl<T> DerefMut for CachePadded<T> { fn deref_mut(&mut self) -> &mut T { assert_valid::<T>(); unsafe { mem::transmute(&mut self.data) } } } // FIXME: support Drop by pulling out a version usable...
deref
identifier_name
cache_padded.rs
use std::marker; use std::cell::UnsafeCell; use std::mem; use std::ptr; use std::ops::{Deref, DerefMut}; // For now, treat this as an arch-independent constant. const CACHE_LINE: usize = 32; #[repr(simd)] struct Padding(u64, u64, u64, u64); /// Pad `T` to the length of a cacheline. /// /// Sometimes concurrent progr...
/// architectures. /// /// **Warning**: the wrapped data is never dropped; move out using `ptr::read` /// if you need to run dtors. pub struct CachePadded<T> { data: UnsafeCell<[usize; CACHE_LINE]>, _marker: ([Padding; 0], marker::PhantomData<T>), } unsafe impl<T: Send> Send for CachePadded<T> {} unsafe impl<T...
/// /// At the moment, cache lines are assumed to be 32 * sizeof(usize) on all
random_line_split
highlighter.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later ve...
} } }
{ self.state.highlighted_line = matched_line.line; self.state.highlighted_match = matched_line.match_index; }
conditional_block
highlighter.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later ve...
{ VisibleOrLast, Next, Previous, Current, } pub struct LineHighlighter<'a> { line: &'a Line, window: WINDOW, container_width: i32, color_pair_id: i16, } impl<'a> LineHighlighter<'a> { pub fn new(window: WINDOW, line: &'a Line, container_width: i32, ...
Highlight
identifier_name
highlighter.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later ve...
use ui::rendered_line::RenderedLineCollection; #[derive(PartialEq)] pub enum Highlight { VisibleOrLast, Next, Previous, Current, } pub struct LineHighlighter<'a> { line: &'a Line, window: WINDOW, container_width: i32, color_pair_id: i16, } impl<'a> LineHighlighter<'a> { pub fn new...
use ncurses::*; use core::line::Line; use ui::printer::Viewport; use ui::content::State as ContentState;
random_line_split
process.rs
// This file is part of the uutils coreutils package. // // (c) Maciej Dziardziel <fiedzia@gmail.com> // (c) Jian Zeng <anonymousknight96 AT gmail.com> // // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. // spell-checker:ignore (vars) cvar e...
if start.elapsed() >= timeout { break; } // XXX: this is kinda gross, but it's cleaner than starting a thread just to wait // (which was the previous solution). We might want to use a different duration // here as well ...
{ return Ok(Some(ExitStatus::from_std_status(status))); }
conditional_block
process.rs
// This file is part of the uutils coreutils package. // // (c) Maciej Dziardziel <fiedzia@gmail.com> // (c) Jian Zeng <anonymousknight96 AT gmail.com> // // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. // spell-checker:ignore (vars) cvar e...
pub fn signal(&self) -> Option<i32> { match *self { ExitStatus::Signal(code) => Some(code), _ => None, } } } impl fmt::Display for ExitStatus { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { ExitStatus::Code(code) => write!...
{ match *self { ExitStatus::Code(code) => Some(code), _ => None, } }
identifier_body
process.rs
// This file is part of the uutils coreutils package. // // (c) Maciej Dziardziel <fiedzia@gmail.com> // (c) Jian Zeng <anonymousknight96 AT gmail.com> // // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. // spell-checker:ignore (vars) cvar e...
() -> gid_t { unsafe { libc::getegid() } } /// `getgid()` returns the real group ID of the calling process. pub fn getgid() -> gid_t { unsafe { libc::getgid() } } /// `getuid()` returns the real user ID of the calling process. pub fn getuid() -> uid_t { unsafe { libc::getuid() } } // This is basically sy...
getegid
identifier_name
process.rs
// This file is part of the uutils coreutils package. // // (c) Maciej Dziardziel <fiedzia@gmail.com> // (c) Jian Zeng <anonymousknight96 AT gmail.com> // // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. // spell-checker:ignore (vars) cvar e...
} // This is basically sys::unix::process::ExitStatus #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub enum ExitStatus { Code(i32), Signal(i32), } #[allow(clippy::trivially_copy_pass_by_ref)] impl ExitStatus { fn from_std_status(status: StdExitStatus) -> Self { #[cfg(unix)] { u...
unsafe { libc::getuid() }
random_line_split
webglshader.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use angle::hl::{BuiltInResources, Output, Sha...
, Err(error) => { self.compilation_status.set(ShaderCompilationStatus::Failed); debug!("Shader {} compilation failed: {}", self.id, error); }, } *self.info_log.borrow_mut() = Some(validator.info_log()); // TODO(...
{ debug!("Shader translated: {}", translated_source); // NOTE: At this point we should be pretty sure that the compilation in the paint thread // will succeed. // It could be interesting to retrieve the info log from the paint thread though...
conditional_block
webglshader.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use angle::hl::{BuiltInResources, Output, Sha...
compilation_status: Cell<ShaderCompilationStatus>, #[ignore_heap_size_of = "Defined in ipc-channel"] renderer: WebGLMsgSender, } #[cfg(not(target_os = "android"))] const SHADER_OUTPUT_FORMAT: Output = Output::Glsl; #[cfg(target_os = "android")] const SHADER_OUTPUT_FORMAT: Output = Output::Essl; static GL...
source: DOMRefCell<Option<DOMString>>, info_log: DOMRefCell<Option<String>>, is_deleted: Cell<bool>, attached_counter: Cell<u32>,
random_line_split
webglshader.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use angle::hl::{BuiltInResources, Output, Sha...
(&self) -> bool { self.compilation_status.get() == ShaderCompilationStatus::Succeeded } } impl Drop for WebGLShader { fn drop(&mut self) { assert!(self.attached_counter.get() == 0); self.delete(); } }
successfully_compiled
identifier_name
webglshader.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use angle::hl::{BuiltInResources, Output, Sha...
pub fn is_deleted(&self) -> bool { self.is_deleted.get() } pub fn is_attached(&self) -> bool { self.attached_counter.get() > 0 } pub fn increment_attached_counter(&self) { self.attached_counter.set(self.attached_counter.get() + 1); } pub fn decrement_attached_cou...
{ if !self.is_deleted.get() { self.is_deleted.set(true); let _ = self.renderer.send(WebGLCommand::DeleteShader(self.id)); } }
identifier_body
verify_project.rs
use crate::command_prelude::*; use std::collections::HashMap; use std::process; use cargo::print_json; pub fn cli() -> App { subcommand("verify-project") .about("Check correctness of crate manifest") .arg(opt("quiet", "No output printed to stdout").short("q")) .arg_manifest_path() } pub fn ...
if let Err(e) = args.workspace(config) { fail("invalid", &e.to_string()) } let mut h = HashMap::new(); h.insert("success".to_string(), "true".to_string()); print_json(&h); Ok(()) }
{ let mut h = HashMap::new(); h.insert(reason.to_string(), value.to_string()); print_json(&h); process::exit(1) }
identifier_body
verify_project.rs
use crate::command_prelude::*; use std::collections::HashMap; use std::process; use cargo::print_json; pub fn
() -> App { subcommand("verify-project") .about("Check correctness of crate manifest") .arg(opt("quiet", "No output printed to stdout").short("q")) .arg_manifest_path() } pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { fn fail(reason: &str, value: &str) ->! { ...
cli
identifier_name
verify_project.rs
use crate::command_prelude::*; use std::collections::HashMap; use std::process; use cargo::print_json; pub fn cli() -> App { subcommand("verify-project") .about("Check correctness of crate manifest") .arg(opt("quiet", "No output printed to stdout").short("q")) .arg_manifest_path() } pub fn ...
process::exit(1) } if let Err(e) = args.workspace(config) { fail("invalid", &e.to_string()) } let mut h = HashMap::new(); h.insert("success".to_string(), "true".to_string()); print_json(&h); Ok(()) }
let mut h = HashMap::new(); h.insert(reason.to_string(), value.to_string()); print_json(&h);
random_line_split
verify_project.rs
use crate::command_prelude::*; use std::collections::HashMap; use std::process; use cargo::print_json; pub fn cli() -> App { subcommand("verify-project") .about("Check correctness of crate manifest") .arg(opt("quiet", "No output printed to stdout").short("q")) .arg_manifest_path() } pub fn ...
let mut h = HashMap::new(); h.insert("success".to_string(), "true".to_string()); print_json(&h); Ok(()) }
{ fail("invalid", &e.to_string()) }
conditional_block
voxtree.rs
use voxel::vox::Vox; /// voxel tree for fast traversal of content #[derive(Clone)] pub struct Voxtree<T>{ pub bitset:u64, pub content:Option<T>, pub children:Vec<Voxtree<T>>, } impl <T> Voxtree<T>{ pub fn new()->Self{ Voxtree{bitset:0u64, content: None, children:Vec::new()} } ...
fn drain(&mut self){ drop(self); } }
{ self.bitset = self.bitset | location; }
identifier_body
voxtree.rs
use voxel::vox::Vox; /// voxel tree for fast traversal of content #[derive(Clone)] pub struct Voxtree<T>{ pub bitset:u64, pub content:Option<T>, pub children:Vec<Voxtree<T>>, } impl <T> Voxtree<T>{ pub fn new()->Self{ Voxtree{bitset:0u64, content: None, children:Vec::new()} } ...
(&mut self, location:u64){ self.bitset = self.bitset | location; } fn drain(&mut self){ drop(self); } }
or_bitset
identifier_name
voxtree.rs
use voxel::vox::Vox; /// voxel tree for fast traversal of content #[derive(Clone)] pub struct Voxtree<T>{ pub bitset:u64, pub content:Option<T>, pub children:Vec<Voxtree<T>>, } impl <T> Voxtree<T>{ pub fn new()->Self{ Voxtree{bitset:0u64, content: None, children:Vec::new()} }
///Traverse the tree and get the node at this location /// /// pub fn get_content(&self, location:&Vec<u64>)->&Option<T>{ let voxtree = self.get_tree(location); &voxtree.content } pub fn set_content(&mut self, location:&Vec<u64>, content:&mut Option<T>){ let mut...
///
random_line_split
logging-separate-lines.rs
// Copyright 2013-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...
// ignore-android // ignore-win32 // exec-env:RUST_LOG=debug #![feature(phase)] #[phase(plugin, link)] extern crate log; use std::io::Command; use std::os; use std::str; fn main() { let args = os::args(); let args = args.as_slice(); if args.len() > 1 && args[1].as_slice() == "child" { debug!("fo...
random_line_split
logging-separate-lines.rs
// Copyright 2013-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 p = Command::new(args[0].as_slice()) .arg("child") .spawn().unwrap().wait_with_output().unwrap(); assert!(p.status.success()); let mut lines = str::from_utf8(p.error.as_slice()).unwrap().lines(); assert!(lines.next().unwrap().contains("foo")); assert!(line...
{ debug!("foo"); debug!("bar"); return }
conditional_block
logging-separate-lines.rs
// Copyright 2013-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 args = os::args(); let args = args.as_slice(); if args.len() > 1 && args[1].as_slice() == "child" { debug!("foo"); debug!("bar"); return } let p = Command::new(args[0].as_slice()) .arg("child") .spawn().unwrap().wait_with_output...
main
identifier_name
logging-separate-lines.rs
// Copyright 2013-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 args = os::args(); let args = args.as_slice(); if args.len() > 1 && args[1].as_slice() == "child" { debug!("foo"); debug!("bar"); return } let p = Command::new(args[0].as_slice()) .arg("child") .spawn().unwrap().wait_with_output(...
identifier_body
day_4.rs
pub use tdd_kata::string_calc_kata::iter_2::day_4::evaluate; pub use expectest::prelude::be_ok; describe! string_calculator { it "should evaluate integer number" { expect!(evaluate("54357632471")).to(be_ok().value(54357632471.0)); } it "shoould evaluate float number" { expect!(evaluate("...
expect!(evaluate("3245+45.55+567.876-658561.54÷154+4325×25+3534")).to(be_ok().value(111241.05236363637)); } }
random_line_split
atbash-cipher.rs
extern crate atbash_cipher as cipher; #[test] fn test_encode_yes() { assert_eq!("bvh", cipher::encode("yes")); } #[test] #[ignore] fn test_encode_no() { assert_eq!("ml", cipher::encode("no")); } #[test] #[ignore] fn test_encode_omg() { assert_eq!("lnt", cipher::encode("OMG")); } #[test] #[ignore] fn tes...
#[test] #[ignore] fn test_encode_deep_thought() { assert_eq!("gifgs rhurx grlm", cipher::encode("Truth is fiction.")); } #[test] #[ignore] fn test_encode_all_the_letters() { assert_eq!("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt", cipher::encode("The quick brown fox jumps over the lazy dog.")); } #[t...
{ assert_eq!("gvhgr mt123 gvhgr mt", cipher::encode("Testing,1 2 3, testing.")); }
identifier_body
atbash-cipher.rs
extern crate atbash_cipher as cipher; #[test] fn test_encode_yes() { assert_eq!("bvh", cipher::encode("yes")); } #[test] #[ignore] fn test_encode_no() { assert_eq!("ml", cipher::encode("no")); } #[test] #[ignore] fn test_encode_omg() { assert_eq!("lnt", cipher::encode("OMG")); } #[test] #[ignore] fn tes...
assert_eq!("gifgs rhurx grlm", cipher::encode("Truth is fiction.")); } #[test] #[ignore] fn test_encode_all_the_letters() { assert_eq!("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt", cipher::encode("The quick brown fox jumps over the lazy dog.")); } #[test] #[ignore] fn test_encode_ignores_non_ascii() { ...
#[test] #[ignore] fn test_encode_deep_thought() {
random_line_split
atbash-cipher.rs
extern crate atbash_cipher as cipher; #[test] fn test_encode_yes() { assert_eq!("bvh", cipher::encode("yes")); } #[test] #[ignore] fn test_encode_no() { assert_eq!("ml", cipher::encode("no")); } #[test] #[ignore] fn test_encode_omg() { assert_eq!("lnt", cipher::encode("OMG")); } #[test] #[ignore] fn tes...
() { assert_eq!("nrmwy oldrm tob", cipher::encode("mindblowingly")); } #[test] #[ignore] fn test_encode_numbers() { assert_eq!("gvhgr mt123 gvhgr mt", cipher::encode("Testing,1 2 3, testing.")); } #[test] #[ignore] fn test_encode_deep_thought() { assert_eq!("gifgs rhurx grlm", cipher::encode("Truth is fic...
test_encode_mindblowingly
identifier_name
lib.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library 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 ...
#[macro_use] extern crate libimagstore; extern crate libimagerror; extern crate libimagentryedit; module_entry_path_mod!("notes"); pub mod error; pub mod note; pub mod notestore; pub mod notestoreid; pub mod iter;
#[macro_use] extern crate error_chain; extern crate libimagrt;
random_line_split
barrier.rs
use std::sync::{Mutex,Condvar,Arc}; use std::thread; struct Barrier { threshold: usize, state: Mutex<BarrierState>, open: Condvar, } impl Barrier { fn new(threshold: usize) -> Self { Barrier { threshold: threshold, open: Condvar::new(), state: Mutex::new(Bar...
} struct ThreadArray { data: [u32; ARRAY_SIZE], increment: u32, } impl ThreadArray { fn new(increment: u32) -> Self { let mut array = ThreadArray { data: [0; ARRAY_SIZE], increment: increment, }; for i in 0..array.data.len() { array.data[i] = (...
{ ThreadContext { array: Mutex::new(ThreadArray::new(increment)), barrier: barrier, } }
identifier_body
barrier.rs
use std::sync::{Mutex,Condvar,Arc}; use std::thread; struct Barrier { threshold: usize, state: Mutex<BarrierState>, open: Condvar, } impl Barrier { fn new(threshold: usize) -> Self { Barrier { threshold: threshold, open: Condvar::new(), state: Mutex::new(Bar...
else { while current_cycle == state.cycle { state = self.open.wait(state).unwrap(); } ret = false; } }, } ret } } struct BarrierState { counter: usize, cycle: bool, valid: b...
{ state.cycle = !state.cycle; state.counter = self.threshold; self.open.notify_all(); ret = true; }
conditional_block
barrier.rs
use std::sync::{Mutex,Condvar,Arc}; use std::thread; struct Barrier { threshold: usize, state: Mutex<BarrierState>, open: Condvar, } impl Barrier { fn new(threshold: usize) -> Self { Barrier { threshold: threshold, open: Condvar::new(), state: Mutex::new(Bar...
(counter: usize) -> Self { BarrierState { counter: counter, cycle: true, valid: true, } } } const ARRAY_SIZE: usize = 6; const THREADS: usize = 5; const OUTLOOPS: usize = 10; const INLOOPS: usize = 1000; struct ThreadContext { array: Mutex<ThreadArray>, ...
new
identifier_name
barrier.rs
use std::sync::{Mutex,Condvar,Arc}; use std::thread; struct Barrier { threshold: usize, state: Mutex<BarrierState>, open: Condvar, } impl Barrier { fn new(threshold: usize) -> Self { Barrier { threshold: threshold, open: Condvar::new(), state: Mutex::new(Bar...
impl ThreadArray { fn new(increment: u32) -> Self { let mut array = ThreadArray { data: [0; ARRAY_SIZE], increment: increment, }; for i in 0..array.data.len() { array.data[i] = (i + 1) as u32; } array } } fn main() { let mut han...
}
random_line_split
wait.rs
use libc::{self, c_int}; use {Errno, Result}; use unistd::Pid; use sys::signal::Signal; libc_bitflags!( pub struct WaitPidFlag: c_int { WNOHANG; WUNTRACED; #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "haiku", tar...
WaitStatus::Stopped(pid, stop_signal(status)) } } } decode_stopped(pid, status) } else { assert!(continued(status)); WaitStatus::Continued(pid) } } pub fn waitpid<P: Into<Option<Pid>>>(pid: P, options: Option<WaitPidFlag>) -> Resu...
{ if exited(status) { WaitStatus::Exited(pid, exit_status(status)) } else if signaled(status) { WaitStatus::Signaled(pid, term_signal(status), dumped_core(status)) } else if stopped(status) { cfg_if! { if #[cfg(any(target_os = "linux", target_os = "android"))] { ...
identifier_body
wait.rs
use libc::{self, c_int}; use {Errno, Result}; use unistd::Pid; use sys::signal::Signal; libc_bitflags!( pub struct WaitPidFlag: c_int { WNOHANG; WUNTRACED; #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "haiku", tar...
(status: i32) -> bool { unsafe { libc::WCOREDUMP(status) } } fn stopped(status: i32) -> bool { unsafe { libc::WIFSTOPPED(status) } } fn stop_signal(status: i32) -> Signal { Signal::from_c_int(unsafe { libc::WSTOPSIG(status) }).unwrap() } fn syscall_stop(status: i32) -> bool { // From ptrace(2), setti...
dumped_core
identifier_name
wait.rs
use libc::{self, c_int}; use {Errno, Result}; use unistd::Pid; use sys::signal::Signal; libc_bitflags!( pub struct WaitPidFlag: c_int { WNOHANG; WUNTRACED; #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "haiku", tar...
waitpid(None, None) }
random_line_split
newtype-struct-drop-run.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let y = &Cell::new(32); { let _x = Foo(y); } assert_eq!(y.get(), 23); }
identifier_body
newtype-struct-drop-run.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
#[unsafe_destructor] impl<'a> Drop for Foo<'a> { fn drop(&mut self) { let Foo(i) = *self; i.set(23); } } pub fn main() { let y = &Cell::new(32); { let _x = Foo(y); } assert_eq!(y.get(), 23); }
use std::cell::Cell; struct Foo<'a>(&'a Cell<isize>);
random_line_split
newtype-struct-drop-run.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let y = &Cell::new(32); { let _x = Foo(y); } assert_eq!(y.get(), 23); }
main
identifier_name
headless.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 compositor_task::{CompositorEventListener, CompositorReceiver, Msg}; use windowing::WindowEvent; use geom::sc...
} true } fn repaint_synchronously(&mut self) {} fn shutdown(&mut self) { // Drain compositor port, sometimes messages contain channels that are blocking // another task from finishing (i.e. SetIds) while self.port.try_recv_compositor_msg().is_some() {} sel...
{}
conditional_block
headless.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 compositor_task::{CompositorEventListener, CompositorReceiver, Msg}; use windowing::WindowEvent; use geom::sc...
} // Explicitly list ignored messages so that when we add a new one, // we'll notice and think about whether it needs a response, like // SetFrameTree. Msg::CreateOrUpdateBaseLayer(..) | Msg::CreateOrUpdateDescendantLayer(..) | Msg::S...
{ match self.port.recv_compositor_msg() { Msg::Exit(chan) => { debug!("shutting down the constellation"); let ConstellationChan(ref con_chan) = self.constellation_chan; con_chan.send(ConstellationMsg::Exit).unwrap(); chan.send(()).unwra...
identifier_body
headless.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 compositor_task::{CompositorEventListener, CompositorReceiver, Msg}; use windowing::WindowEvent; use geom::sc...
(&self) -> f32 { 1.0 } fn get_title_for_main_frame(&self) {} }
pinch_zoom_level
identifier_name
headless.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 compositor_task::{CompositorEventListener, CompositorReceiver, Msg}; use windowing::WindowEvent; use geom::sc...
Msg::CreateOrUpdateDescendantLayer(..) | Msg::SetLayerRect(..) | Msg::AssignPaintedBuffers(..) | Msg::ChangeReadyState(..) | Msg::ChangePaintState(..) | Msg::ChangeRunningAnimationsState(..) | Msg::ScrollFragmentPoint(..) | ...
Msg::CreateOrUpdateBaseLayer(..) |
random_line_split
registry.rs
use std::collections::HashSet; use std::collections::hash_map::HashMap; use core::{Source, SourceId, SourceMap, Summary, Dependency, PackageId, Package}; use util::{CargoResult, ChainError, Config, human, profile}; /// Source of informations about a group of packages. /// /// See also `core::Source`. pub trait Regist...
() -> RegistryBuilder { RegistryBuilder { summaries: vec!(), overrides: vec!() } } pub fn summary(mut self, summary: Summary) -> RegistryBuilder { self.summaries.push(summary); self } pub fn summaries(mut self, summaries: Vec<Summary>) -> RegistryBui...
new
identifier_name
registry.rs
use std::collections::HashSet; use std::collections::hash_map::HashMap; use core::{Source, SourceId, SourceMap, Summary, Dependency, PackageId, Package}; use util::{CargoResult, ChainError, Config, human, profile}; /// Source of informations about a group of packages. /// /// See also `core::Source`. pub trait Regist...
if id == dep.source_id() { ret.extend(try!(src.query(dep)).into_iter()); } } ret } else { overrides }; // post-process all returned summaries to ensure that we lock all // relevant summaries to the r...
// Ensure the requested source_id is loaded try!(self.ensure_loaded(dep.source_id())); let mut ret = Vec::new(); for (id, src) in self.sources.sources_mut() {
random_line_split
registry.rs
use std::collections::HashSet; use std::collections::hash_map::HashMap; use core::{Source, SourceId, SourceMap, Summary, Dependency, PackageId, Package}; use util::{CargoResult, ChainError, Config, human, profile}; /// Source of informations about a group of packages. /// /// See also `core::Source`. pub trait Regist...
} } }
{ Ok(overrides) }
conditional_block
registry.rs
use std::collections::HashSet; use std::collections::hash_map::HashMap; use core::{Source, SourceId, SourceMap, Summary, Dependency, PackageId, Package}; use util::{CargoResult, ChainError, Config, human, profile}; /// Source of informations about a group of packages. /// /// See also `core::Source`. pub trait Regist...
} } #[cfg(test)] pub mod test { use core::{Summary, Registry, Dependency}; use util::{CargoResult}; pub struct RegistryBuilder { summaries: Vec<Summary>, overrides: Vec<Summary> } impl RegistryBuilder { pub fn new() -> RegistryBuilder { RegistryBuilder { s...
{ let overrides = try!(self.query_overrides(dep)); let ret = if overrides.len() == 0 { // Ensure the requested source_id is loaded try!(self.ensure_loaded(dep.source_id())); let mut ret = Vec::new(); for (id, src) in self.sources.sources_mut() { ...
identifier_body
accept.rs
// error-pattern:Worked! extern crate nemo; use nemo::*; use nemo::session_types::*; use nemo::peano::*; fn main() { use nemo::channels::Blocking; struct MyProtocol; type SendString = Send<String, End>; type SendUsize = Send<usize, End>; type SendIsize = Send<isize, End>; type Orig = Choose<...
} impl<I: Transfers<String> + Transfers<usize> + Transfers<isize>, E: SessionType> Handler<I, E, DualSendString> for MyProtocol { fn with(_: Channel<Self, I, E, DualSendString>) -> Defer<Self, I> { panic!("fail") } } impl<I: Transfers<String> + Transfers<usize> + Transfers...
{ this.accept().ok().unwrap() }
identifier_body
accept.rs
// error-pattern:Worked! extern crate nemo; use nemo::*; use nemo::session_types::*; use nemo::peano::*; fn
() { use nemo::channels::Blocking; struct MyProtocol; type SendString = Send<String, End>; type SendUsize = Send<usize, End>; type SendIsize = Send<isize, End>; type Orig = Choose<SendString, Choose<SendUsize, Finally<SendIsize>>>; type DualSendString = Recv<String, End>; type DualSen...
main
identifier_name
accept.rs
// error-pattern:Worked! extern crate nemo; use nemo::*;
fn main() { use nemo::channels::Blocking; struct MyProtocol; type SendString = Send<String, End>; type SendUsize = Send<usize, End>; type SendIsize = Send<isize, End>; type Orig = Choose<SendString, Choose<SendUsize, Finally<SendIsize>>>; type DualSendString = Recv<String, End>; type ...
use nemo::session_types::*; use nemo::peano::*;
random_line_split
accept.rs
// error-pattern:Worked! extern crate nemo; use nemo::*; use nemo::session_types::*; use nemo::peano::*; fn main() { use nemo::channels::Blocking; struct MyProtocol; type SendString = Send<String, End>; type SendUsize = Send<usize, End>; type SendIsize = Send<isize, End>; type Orig = Choose<...
} } } let (client1, client2) = Blocking::new::<MyProtocol>(MyProtocol, MyProtocol); let mut client1 = client1.defer(); let mut client2 = client2.defer(); assert_eq!(false, client1.with()); // client1 chooses a protocol, sends 10, closes channel assert_eq!(true, client...
{ panic!("fail") }
conditional_block
fast_thread_local.rs
// Copyright 2016 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 ptr: *mut u8) { while!ptr.is_null() { let list: Box<List> = Box::from_raw(ptr as *mut List); for (ptr, dtor) in list.into_iter() { dtor(ptr); } ptr = DTORS.get(); DTORS.set(ptr::null_mut()); } } } pub unsafe extern fn ...
run_dtors
identifier_name
fast_thread_local.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} pub fn requires_move_before_drop() -> bool { false }
{ ptr::drop_in_place((*ptr).inner.get()); }
conditional_block
fast_thread_local.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { // The fallback implementation uses a vanilla OS-based TLS key to track // the list of destructors that need to be run for this thread. The key // then has its own destructor which runs all the other destructors. // // Th...
{ if !mem::needs_drop::<T>() || self.dtor_registered.get() { return } register_dtor(self as *const _ as *mut u8, destroy_value::<T>); self.dtor_registered.set(true); }
identifier_body
fast_thread_local.rs
// 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...
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
random_line_split
word_splitters.rs
//! Word splitting functionality. //! //! To wrap text into lines, long words sometimes need to be split //! across lines. The [`WordSplitter`] enum defines this //! functionality. use crate::core::{display_width, Word}; /// The `WordSplitter` enum describes where words can be split. /// /// If the textwrap crate has...
(&self, word: &str) -> Vec<usize> { match self { WordSplitter::NoHyphenation => Vec::new(), WordSplitter::HyphenSplitter => { let mut splits = Vec::new(); for (idx, _) in word.match_indices('-') { // We only use hyphens that are surrou...
split_points
identifier_name
word_splitters.rs
//! Word splitting functionality. //! //! To wrap text into lines, long words sometimes need to be split //! across lines. The [`WordSplitter`] enum defines this //! functionality. use crate::core::{display_width, Word}; /// The `WordSplitter` enum describes where words can be split. /// /// If the textwrap crate has...
#[test] fn split_words_no_hyphenation() { assert_iter_eq!( split_words(vec![Word::from("foo-bar")], &WordSplitter::NoHyphenation), vec![Word::from("foo-bar")] ); } #[test] fn split_words_adds_penalty() { let fixed_split_point = |_: &str| vec![3]; ...
{ assert_iter_eq!( split_words(vec![Word::from("foo-bar")], &WordSplitter::HyphenSplitter), vec![Word::from("foo-"), Word::from("bar")] ); }
identifier_body
word_splitters.rs
//! Word splitting functionality. //! //! To wrap text into lines, long words sometimes need to be split //! across lines. The [`WordSplitter`] enum defines this //! functionality. use crate::core::{display_width, Word}; /// The `WordSplitter` enum describes where words can be split. /// /// If the textwrap crate has...
#[test] fn split_words_no_words() { assert_iter_eq!(split_words(vec![], &WordSplitter::HyphenSplitter), vec![]); } #[test] fn split_words_empty_word() { assert_iter_eq!( split_words(vec![Word::from(" ")], &WordSplitter::HyphenSplitter), vec![Word::from(" ...
($left:expr, $right:expr) => { assert_eq!($left.collect::<Vec<_>>(), $right); }; }
random_line_split
resources.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::env; use std::fs::File; use std::io::Read; use std::path::PathBuf; use std::sync::{Once, ONCE_INIT, RwLoc...
pub fn register_resources_for_tests() { INIT.call_once(|| { struct ResourceReader; impl ResourceReaderMethods for ResourceReader { fn sandbox_access_files(&self) -> Vec<PathBuf> { vec![] } fn sandbox_access_files_dirs(&self) -> Vec<PathBuf> { vec![] } fn read(&se...
} static INIT: Once = ONCE_INIT;
random_line_split
resources.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::env; use std::fs::File; use std::io::Read; use std::path::PathBuf; use std::sync::{Once, ONCE_INIT, RwLoc...
break; } path.pop(); } path.push(file); let mut buffer = vec![]; File::open(path).expect(&format!("Can't find file: {}", file)) .read_to_end(&mut buffer).expect(...
{ let file = match file { Resource::Preferences => "prefs.json", Resource::BluetoothBlocklist => "gatt_blocklist.txt", Resource::DomainList => "public_domains.txt", Resource::HstsPreloadList => "hsts_preload.json", ...
identifier_body
resources.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::env; use std::fs::File; use std::io::Read; use std::path::PathBuf; use std::sync::{Once, ONCE_INIT, RwLoc...
(res: Resource) -> Vec<u8> { RES.read().unwrap().as_ref().expect("Resource reader not set.").read(res) } pub fn read_string(res: Resource) -> String { String::from_utf8(read_bytes(res)).unwrap() } pub fn sandbox_access_files() -> Vec<PathBuf> { RES.read().unwrap().as_ref().expect("Resource reader not set....
read_bytes
identifier_name
main.rs
// @adjivas - github.com/adjivas. See the LICENSE // file at the top-level directory of this distribution and at // https://github.com/adjivas/pasteur // // This file may not be copied, modified, or distributed // except according to those terms. #[macro_use] extern crate clap; extern crate pasteur; /// Default* cons...
{ let yaml = load_yaml!("cli.yml"); let options = clap::App::from_yaml(yaml).get_matches(); pasteur::new ( options.value_of("template").unwrap_or(DEFAULT_TEMPLATE), options.value_of("locale").unwrap_or(DEFAULT_LOCALE), options.value_of("style").unwrap_or(DEFAULT_STYLE), opti...
identifier_body
main.rs
// @adjivas - github.com/adjivas. See the LICENSE // file at the top-level directory of this distribution and at // https://github.com/adjivas/pasteur // // This file may not be copied, modified, or distributed // except according to those terms. #[macro_use] extern crate clap; extern crate pasteur; /// Default* cons...
() { let yaml = load_yaml!("cli.yml"); let options = clap::App::from_yaml(yaml).get_matches(); pasteur::new ( options.value_of("template").unwrap_or(DEFAULT_TEMPLATE), options.value_of("locale").unwrap_or(DEFAULT_LOCALE), options.value_of("style").unwrap_or(DEFAULT_STYLE), ...
main
identifier_name
main.rs
// @adjivas - github.com/adjivas. See the LICENSE // file at the top-level directory of this distribution and at // https://github.com/adjivas/pasteur // // This file may not be copied, modified, or distributed // except according to those terms.
extern crate pasteur; /// Default* const arguments defined by CLI. const DEFAULT_TEMPLATE: &'static str = "etc/templates"; const DEFAULT_LOCALE: &'static str = "etc/locales"; const DEFAULT_STYLE: &'static str = "etc/stylesheets"; const DEFAULT_CERT: &'static str = "etc/ca/cert.pem"; const DEFAULT_KEY: &'static str = ...
#[macro_use] extern crate clap;
random_line_split
mine_nrd_kernel.rs
// Copyright 2021 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
} assert_eq!(chain.head().unwrap().height, 8); let key_id1 = ExtKeychainPath::new(1, 1, 0, 0, 0).to_identifier(); let key_id2 = ExtKeychainPath::new(1, 2, 0, 0, 0).to_identifier(); let tx = build::transaction( KernelFeatures::NoRecentDuplicate { fee: 20000.into(), relative_height: NRDRelativeHeight::new(...
for n in 1..9 { let key_id = ExtKeychainPath::new(1, n, 0, 0, 0).to_identifier(); let block = build_block(&chain, &keychain, &key_id, vec![]); chain.process_block(block, Options::MINE).unwrap();
random_line_split
mine_nrd_kernel.rs
// Copyright 2021 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
edge_bits, ) .unwrap(); block } #[test] fn mine_block_with_nrd_kernel_and_nrd_feature_enabled() { global::set_local_chain_type(global::ChainTypes::AutomatedTesting); global::set_local_nrd_enabled(true); util::init_test_logger(); let chain_dir = ".grin.nrd_kernel"; clean_output_dir(chain_dir); let keych...
{ let prev = chain.head_header().unwrap(); let next_header_info = consensus::next_difficulty(1, chain.difficulty_iter().unwrap()); let fee = txs.iter().map(|x| x.fee()).sum(); let reward = reward::output(keychain, &ProofBuilder::new(keychain), key_id, fee, false).unwrap(); let mut block = Block::new(&prev, &txs...
identifier_body
mine_nrd_kernel.rs
// Copyright 2021 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
() { global::set_local_chain_type(global::ChainTypes::AutomatedTesting); global::set_local_nrd_enabled(true); util::init_test_logger(); let chain_dir = ".grin.invalid_nrd_kernel"; clean_output_dir(chain_dir); let keychain = ExtKeychain::from_random_seed(false).unwrap(); let pb = ProofBuilder::new(&keychain); ...
mine_invalid_block_with_nrd_kernel_and_nrd_feature_enabled_before_hf
identifier_name
player_loop.rs
// Tunnul // Copyright (c) 2015, Richard Lettich // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of...
{ // Packet(Packet), TcpErr, // Packet already formed KeepAlive, // Fixme, Thread to thread transmission } const PLAYER_STREAM: Token = Token(0); const RECIEVER: Token = Token(1); struct MyHandler(TcpStream); impl Handler for MyHandler { type Timeout = (); type Message = (); fn ready(&mu...
ReceiverData
identifier_name
player_loop.rs
// Tunnul // Copyright (c) 2015, Richard Lettich // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of...
struct MyHandler(TcpStream); impl Handler for MyHandler { type Timeout = (); type Message = (); fn ready(&mut self, event_loop: &mut EventLoop<MyHandler>, token: Token, _: EventSet) { match token { PLAYER_STREAM => { println!("hi"); } _ => panic...
const PLAYER_STREAM: Token = Token(0); const RECIEVER: Token = Token(1);
random_line_split
player_loop.rs
// Tunnul // Copyright (c) 2015, Richard Lettich // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of...
fn use_entity(player: &mut Player, packet: &mut Packet) -> Option<&'static str> { let target_id = packet.get_varint(); let interact_type = packet.getas::<u8>(); if interact_type == 2 { let interact_location = packet.get_location(); if player.location.distance(&interact_location) > 25.0 { ...
{ unimplemented!(); }
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 ...
#[derive(Copy, Clone, PartialEq, Debug)] #[stable(feature = "rust1", since = "1.0.0")] pub enum Shutdown { /// Indicates that the reading portion of this stream/socket should be shut /// down. All currently blocked and future reads will return `Ok(0)`. #[stable(feature = "rust1", since = "1.0.0")] Read,...
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
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 ...
{ net_imp::lookup_addr(addr) }
identifier_body
issue-2735-3.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 ...
(&mut self) { self.b.set(true); } } fn defer(b: &Cell<bool>) -> defer { defer { b: b } } pub fn main() { let dtor_ran = &Cell::new(false); defer(dtor_ran); assert!(dtor_ran.get()); }
drop
identifier_name
issue-2735-3.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let dtor_ran = &Cell::new(false); defer(dtor_ran); assert!(dtor_ran.get()); }
{ defer { b: b } }
identifier_body
issue-2735-3.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 ...
impl<'a> Drop for defer<'a> { fn drop(&mut self) { self.b.set(true); } } fn defer(b: &Cell<bool>) -> defer { defer { b: b } } pub fn main() { let dtor_ran = &Cell::new(false); defer(dtor_ran); assert!(dtor_ran.get()); }
struct defer<'a> { b: &'a Cell<bool>, }
random_line_split
textobject.rs
use std::default::Default; use editor::text_editor::buffer::Mark; #[derive(Copy, Clone, Debug)] pub enum Kind { Char, Line(Anchor), Word(Anchor), // Sentence(Anchor), // Paragraph(Anchor), // Expression(Anchor), // Statement(Anchor), // Block(Anchor), } impl Kind { pub fn with_a...
} #[derive(Copy, Clone, Debug)] pub enum Anchor { Before, // Index just prior to TextObject Start, // First index within TextObject // Middle, // Middle index of TextObject End, // Last index within TextObject After, // First index after TextObject Same, // Same as ...
{ Kind::Char }
identifier_body
textobject.rs
use std::default::Default; use editor::text_editor::buffer::Mark; #[derive(Copy, Clone, Debug)] pub enum Kind { Char, Line(Anchor), Word(Anchor), // Sentence(Anchor), // Paragraph(Anchor), // Expression(Anchor), // Statement(Anchor), // Block(Anchor), } impl Kind { pub fn with_a...
pub enum Anchor { Before, // Index just prior to TextObject Start, // First index within TextObject // Middle, // Middle index of TextObject End, // Last index within TextObject After, // First index after TextObject Same, // Same as index within current TextObject of...
random_line_split
textobject.rs
use std::default::Default; use editor::text_editor::buffer::Mark; #[derive(Copy, Clone, Debug)] pub enum Kind { Char, Line(Anchor), Word(Anchor), // Sentence(Anchor), // Paragraph(Anchor), // Expression(Anchor), // Statement(Anchor), // Block(Anchor), } impl Kind { pub fn with_a...
{ pub kind: Kind, pub offset: Offset } impl Default for TextObject { fn default() -> TextObject { TextObject { kind: Default::default(), offset: Default::default() } } }
TextObject
identifier_name
e05-atexit-type.rs
/// Exercise 7.5: Use the typedef facility of C to define a new data type Exitfunc for an exit /// handler. Redo the prototype for atexit using this data type. /// /// $ e05-atexit-type /// main is done /// first exit handler /// first exit handler /// second exit handler extern crate libc; #[macro_use(cstr)] extern c...
() { unsafe { printf(cstr!("second exit handler\n")) }; } fn main() { my_atexit(my_exit2).expect(&format!("can't register my_exit2: {}", errno::errno())); my_atexit(my_exit1).expect(&format!("can't register my_exit1: {}", errno::errno())); my_atexit(my_exit1).expect(&format!("can't register my_exit1: {...
my_exit2
identifier_name
e05-atexit-type.rs
/// Exercise 7.5: Use the typedef facility of C to define a new data type Exitfunc for an exit /// handler. Redo the prototype for atexit using this data type. /// /// $ e05-atexit-type /// main is done /// first exit handler /// first exit handler /// second exit handler extern crate libc; #[macro_use(cstr)] extern c...
extern "C" fn my_exit2() { unsafe { printf(cstr!("second exit handler\n")) }; } fn main() { my_atexit(my_exit2).expect(&format!("can't register my_exit2: {}", errno::errno())); my_atexit(my_exit1).expect(&format!("can't register my_exit1: {}", errno::errno())); my_atexit(my_exit1).expect(&format!("ca...
{ unsafe { printf(cstr!("first exit handler\n")) }; }
identifier_body
e05-atexit-type.rs
/// Exercise 7.5: Use the typedef facility of C to define a new data type Exitfunc for an exit /// handler. Redo the prototype for atexit using this data type. /// /// $ e05-atexit-type /// main is done /// first exit handler /// first exit handler /// second exit handler extern crate libc; #[macro_use(cstr)] extern c...
unsafe { atexit(f).check_not_negative() } } extern "C" fn my_exit1() { unsafe { printf(cstr!("first exit handler\n")) }; } extern "C" fn my_exit2() { unsafe { printf(cstr!("second exit handler\n")) }; } fn main() { my_atexit(my_exit2).expect(&format!("can't register my_exit2: {}", errno::errno())); ...
random_line_split
main.rs
extern crate iron; extern crate logger; extern crate router; extern crate hyper; extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_json; #[macro_use] extern crate log; extern crate env_logger; use std::str::FromStr; use std::io::Read; use iron::prelude::*; use router::Router; ...
let mut body = Vec::new(); req.body.read_to_end(&mut body); self.client.request(req.method.clone(), &url_base) .headers(req.headers.clone()) .body(Body::BufBody(body.as_slice(), body.len())) .send() .unwrap(); } fn new(protocol: &st...
{ url_base.push_str("?"); url_base.push_str(q); }
conditional_block
main.rs
extern crate iron; extern crate logger; extern crate router; extern crate hyper; extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_json; #[macro_use] extern crate log; extern crate env_logger; use std::str::FromStr; use std::io::Read; use iron::prelude::*; use router::Router; ...
} let mut body = Vec::new(); req.body.read_to_end(&mut body); self.client.request(req.method.clone(), &url_base) .headers(req.headers.clone()) .body(Body::BufBody(body.as_slice(), body.len())) .send() .unwrap(); } fn new(prot...
random_line_split
main.rs
extern crate iron; extern crate logger; extern crate router; extern crate hyper; extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_json; #[macro_use] extern crate log; extern crate env_logger; use std::str::FromStr; use std::io::Read; use iron::prelude::*; use router::Router; ...
fn rate_handler(req: &mut Request) -> IronResult<Response> { Ok(Response::with((iron::status::Ok, "Hello admin"))) } fn buffer_handler(req: &mut Request) -> IronResult<Response> { Ok(Response::with((iron::status::Ok, "Hello admin"))) } fn get_target(req: &mut Request) -> IronResult<Response> { Ok(Respons...
{ let stats = Stats { requests_forwarded: 345242, target_requests_per_second: 250., average_requests_per_second: 261., max_requests_per_second: 342., buffer_size_in_bytes: 5098231, }; Ok(Response::with((iron::status::Ok, serde_json::to_string(&stats).unwrap(...
identifier_body
main.rs
extern crate iron; extern crate logger; extern crate router; extern crate hyper; extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_json; #[macro_use] extern crate log; extern crate env_logger; use std::str::FromStr; use std::io::Read; use iron::prelude::*; use router::Router; ...
() { env_logger::init().unwrap(); let (logger_before, logger_after) = Logger::new(None); let mut forward_chain = Chain::new(forward); forward_chain.link_before(logger_before); forward_chain.link_after(logger_after); let forward_server = Iron::new(forward_chain).http("localhost:6666"); let ...
main
identifier_name
worker.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::WorkerBinding; use dom::bindings::codegen::Bindings::WorkerBinding::WorkerMe...
(address: TrustedWorkerAddress, message: DOMString, filename: DOMString, lineno: u32, colno: u32) { let worker = address.to_temporary().root(); let global = worker.r().global.root(); let error = UndefinedValue(); let target: JSRef<EventTarget> = EventTarge...
handle_error_message
identifier_name
worker.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::WorkerBinding; use dom::bindings::codegen::Bindings::WorkerBinding::WorkerMe...
} pub fn handle_error_message(address: TrustedWorkerAddress, message: DOMString, filename: DOMString, lineno: u32, colno: u32) { let worker = address.to_temporary().root(); let global = worker.r().global.root(); let error = UndefinedValue(); let t...
let message = data.read(global.r()); MessageEvent::dispatch_jsval(target, global.r(), message);
random_line_split