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
command.rs
use crate::direction::*; use crate::position::*; type Slot = u8; /// Anything the user can ask the back end to do. #[derive(Debug, Clone)] pub enum Command { /// Do not do anything. This exists solely to eliminate the need of using Option<Command>. Nothing, Movement(Movement), LevelManagement(LevelMa...
/// Push a crate straight towards `position` until the worker is there or the crate hits an /// obstacle. PushTowards { position: Position }, /// Walk to the given position, no matter where the path takes the worker, i.e. general path /// finding without moving any crates. WalkToPosition { posi...
/// Walk straight towards `position` until the worker is there or hits an obstacle. WalkTowards { position: Position },
random_line_split
utils.rs
use std::fs::File; use std::path::Path; use std::io::{Error, Read}; use regex::Regex; pub fn read_file<P: AsRef<Path>>(path: P) -> Result<String, Error> { let mut file = try!(File::open(&path)); let mut content = String::new(); try!(file.read_to_string(&mut content)); Ok(content) } pub fn prepare(con...
lazy_static! { pub static ref SUBS: Regex = Regex::new(r"(?x) (\d+) \r\n (\d{2}):(\d{2}):(\d{2}),(\d{3}) \s-->\s (\d{2}):(\d{2}):(\d{2}),(\d{3}) \r\n ([\S\s]*?) (?:\r\n){2}?").unwrap(); static ref EOF_EMPTY_LINES: Regex = Regex::new(r"\s*?\z").u...
{ SUBS.is_match(&content) }
identifier_body
utils.rs
use std::fs::File; use std::path::Path; use std::io::{Error, Read}; use regex::Regex; pub fn read_file<P: AsRef<Path>>(path: P) -> Result<String, Error> { let mut file = try!(File::open(&path)); let mut content = String::new(); try!(file.read_to_string(&mut content)); Ok(content) } pub fn prepare(con...
() { println!(""); let mut test_srt = r"1 00:01:38,958 --> 00:01:49,609 Firs line 2 00:04:19,604 --> 00:04:20,970 <i>Your Grace.</i> 3 00:04:21,072 --> 00:04:24,707 The trial will be getting under way soon. 4 00:04:57,141 --> 00:04:58,541 You got my money? 5 00:04:58,643 --> 00:05:00,943 Later. Go a...
_check
identifier_name
utils.rs
use std::fs::File; use std::path::Path; use std::io::{Error, Read}; use regex::Regex; pub fn read_file<P: AsRef<Path>>(path: P) -> Result<String, Error> { let mut file = try!(File::open(&path)); let mut content = String::new(); try!(file.read_to_string(&mut content)); Ok(content) } pub fn prepare(con...
\r\n (\d{2}):(\d{2}):(\d{2}),(\d{3}) \s-->\s (\d{2}):(\d{2}):(\d{2}),(\d{3}) \r\n ([\S\s]*?) (?:\r\n){2}?").unwrap(); static ref EOF_EMPTY_LINES: Regex = Regex::new(r"\s*?\z").unwrap(); static ref UNIFY_NEWLINE_STYLE: Regex = Regex::new(r"(?:\r\n|\n)").un...
random_line_split
checkstyle.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 ...
Ok(()) } // Convert special characters into XML entities. // This is needed for checkstyle output. fn xml_escape_str(string: &str) -> String { let mut out = String::new(); for c in string.chars() { match c { '<' => out.push_str("&lt;"), '>' => out.push_str("&gt;"), ...
{ try!(write!(writer, "<file name=\"{}\">", filename)); for mismatch in diff { for line in mismatch.lines { match line { DiffLine::Expected(ref str) => { let message = xml_escape_str(&str); try!(write!(writer, ...
identifier_body
checkstyle.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 ...
<T>(mut writer: T, filename: &str, diff: Vec<Mismatch>) -> Result<(), io::Error> where T: Write { try!(write!(writer, "<file name=\"{}\">", filename)); for mismatch in diff { for line in mismatch.lines...
output_checkstyle_file
identifier_name
checkstyle.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 ...
{ if mode == WriteMode::Checkstyle { let mut xml_tail = String::new(); xml_tail.push_str("</checkstyle>"); try!(write!(out, "{}", xml_tail)); } Ok(()) } pub fn output_checkstyle_file<T>(mut writer: T, filename: &str, ...
random_line_split
libbuild-protocols.rs
mod protocols { extern crate pkg_config; use std::env; use std::fs; use std::path::PathBuf; use std::process::Command; pub fn generate_if_feature_enabled() { if env::var("CARGO_FEATURE_PROTOCOLS").is_ok() { generate_protocols(); } } fn generate_protocols() ...
Ok(prefix) => prefix, Err(msg) => panic!("Unable to locate protobuf, err={:?}", msg), } } }; let out_dir = r"src/message"; let cmd = Command::new(format!("{}/bin/protoc", prefix)) .arg("--rust_out") .arg(o...
match pkg_config::get_variable("protobuf", "prefix") {
random_line_split
libbuild-protocols.rs
mod protocols { extern crate pkg_config; use std::env; use std::fs; use std::path::PathBuf; use std::process::Command; pub fn generate_if_feature_enabled() { if env::var("CARGO_FEATURE_PROTOCOLS").is_ok() { generate_protocols(); } } fn generate_protocols()
panic!("{:?}", out) } } Err(e) => panic!("{}", e), } } fn protocol_files() -> Vec<PathBuf> { let mut files = vec![]; for entry in fs::read_dir("protocols").unwrap() { let file = entry.unwrap(); // skip ...
{ let prefix = match env::var("PROTOBUF_PREFIX").ok() { Some(prefix) => prefix, None => { match pkg_config::get_variable("protobuf", "prefix") { Ok(prefix) => prefix, Err(msg) => panic!("Unable to locate protobuf, err={:?}", msg), ...
identifier_body
libbuild-protocols.rs
mod protocols { extern crate pkg_config; use std::env; use std::fs; use std::path::PathBuf; use std::process::Command; pub fn
() { if env::var("CARGO_FEATURE_PROTOCOLS").is_ok() { generate_protocols(); } } fn generate_protocols() { let prefix = match env::var("PROTOBUF_PREFIX").ok() { Some(prefix) => prefix, None => { match pkg_config::get_variable("protobuf"...
generate_if_feature_enabled
identifier_name
size_of.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 layout::Fragment; use layout::SpecificFragmentInfo; use std::mem::size_of; fn check_size_for(name: &'static s...
if actual > expected { panic!("Your changes have increased the stack size of {} \ from {} to {}. Please consider choosing a design which avoids this increase. \ If you feel that the increase is necessary, update the size in \ tests/unit/layout/size_of.rs.",...
{ panic!("Your changes have decreased the stack size of {} \ from {} to {}. Good work! Please update the size in tests/unit/layout/size_of.rs", name, expected, actual); }
conditional_block
size_of.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 layout::Fragment; use layout::SpecificFragmentInfo; use std::mem::size_of; fn check_size_for(name: &'static s...
{ let expected = 24; let actual = size_of::<SpecificFragmentInfo>(); check_size_for("layout::fragment::SpecificFragmentInfo", expected, actual); }
identifier_body
size_of.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 layout::Fragment; use layout::SpecificFragmentInfo; use std::mem::size_of; fn check_size_for(name: &'static s...
() { let expected = 160; let actual = size_of::<Fragment>(); check_size_for("layout::fragment::Fragment", expected, actual); } #[test] fn test_size_of_specific_fragment_info() { let expected = 24; let actual = size_of::<SpecificFragmentInfo>(); check_size_for("layout::fragment::SpecificFragment...
test_size_of_fragment
identifier_name
size_of.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 layout::Fragment; use layout::SpecificFragmentInfo; use std::mem::size_of; fn check_size_for(name: &'static s...
let actual = size_of::<SpecificFragmentInfo>(); check_size_for("layout::fragment::SpecificFragmentInfo", expected, actual); }
let expected = 24;
random_line_split
bluetooth.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 bluetooth_blacklist::{Blacklist, uuid_is_blacklisted}; use core::clone::Clone; use dom::bindings::codegen::Bin...
(error: BluetoothError) -> Self { match error { BluetoothError::Type(message) => Error::Type(message), BluetoothError::Network => Error::Network, BluetoothError::NotFound => Error::NotFound, BluetoothError::NotSupported => Error::NotSupported, Bluetoot...
from
identifier_name
bluetooth.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 bluetooth_blacklist::{Blacklist, uuid_is_blacklisted}; use core::clone::Clone; use dom::bindings::codegen::Bin...
} impl BluetoothMethods for Bluetooth { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice fn RequestDevice(&self, option: &RequestDeviceOptions) -> Fallible<Root<BluetoothDevice>> { let (sender, receiver) = ipc::channel().unwrap(); let option = try!(convert_request...
{ match error { BluetoothError::Type(message) => Error::Type(message), BluetoothError::Network => Error::Network, BluetoothError::NotFound => Error::NotFound, BluetoothError::NotSupported => Error::NotSupported, BluetoothError::Security => Error::Secur...
identifier_body
bluetooth.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 bluetooth_blacklist::{Blacklist, uuid_is_blacklisted}; use core::clone::Clone; use dom::bindings::codegen::Bin...
, } } }
{ Err(Error::from(error)) }
conditional_block
bluetooth.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 bluetooth_blacklist::{Blacklist, uuid_is_blacklisted}; use core::clone::Clone; use dom::bindings::codegen::Bin...
device.tx_power, device.rssi); Ok(BluetoothDevice::new(self.global().r(), DOMString::from(device.id), de...
random_line_split
common.rs
#![warn(bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results)] #![feature(into_cow, path_ext)] extern crate curl; extern crate getopts; extern crate num; extern crate rustc_serialize; extern crate term; extern crate time; use std::borrow::{Cow, IntoCow}...
Ok(()) } } enum SolverFn<'a> { FnOnly(fn() -> String), FnWithFile(&'a str, fn(File) -> io::Result<String>) } pub struct Solver<'a> { answer: &'a str, solver: SolverFn<'a> } impl<'a> Solver<'a> { pub fn new(answer: &'a str, solver: fn() -> String) -> Solver<'a> { Solver { ans...
{ (Some(COLOR_NG), s.into_cow()) }
identifier_body
common.rs
#![warn(bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results)] #![feature(into_cow, path_ext)] extern crate curl; extern crate getopts; extern crate num; extern crate rustc_serialize; extern crate term; extern crate time; use std::borrow::{Cow, IntoCow}...
None => { let mut out = io::stdout(); for &(_, ref s) in items { let _ = write!(&mut out, "{}", s); } let _ = out.flush(); } Some(mut t) => { for &(c, ref s) in items { match c { Some(...
} fn print_items(items: &[OutputPair]) { match term::stdout() {
random_line_split
common.rs
#![warn(bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results)] #![feature(into_cow, path_ext)] extern crate curl; extern crate getopts; extern crate num; extern crate rustc_serialize; extern crate term; extern crate time; use std::borrow::{Cow, IntoCow}...
<'a> { answer: &'a str, solver: SolverFn<'a> } impl<'a> Solver<'a> { pub fn new(answer: &'a str, solver: fn() -> String) -> Solver<'a> { Solver { answer: answer, solver: SolverFn::FnOnly(solver) } } pub fn new_with_file( answer: &'a str, file_name: &'a str, solver: fn(File) -> io::...
Solver
identifier_name
window_system.rs
extern crate libc; use std::fmt::{ Error, Formatter, Debug }; use window_manager::WindowManager; pub type Window = u64; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Rectangle(pub i32, pub i32, pub u32, pub u32); impl Rectangle { pub fn is_inside(&self, x: i32, y: i32) -> bool { let &Rectangle...
{ ConfigurationNotification(Window), ConfigurationRequest(Window, WindowChanges, u64), /// A window has been created and needs to be managed. WindowCreated(Window), /// A window has been destroyed and needs to be unmanaged. WindowDestroyed(Window), WindowUnmapped(Window, bool), /// The ...
WindowSystemEvent
identifier_name
window_system.rs
extern crate libc; use std::fmt::{ Error, Formatter, Debug }; use window_manager::WindowManager; pub type Window = u64; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Rectangle(pub i32, pub i32, pub u32, pub u32); impl Rectangle { pub fn is_inside(&self, x: i32, y: i32) -> bool { let &Rectangle...
impl MouseCommand { pub fn new(button: MouseButton, mask: KeyModifiers) -> MouseCommand { MouseCommand { button: button, mask: mask } } } bitflags! { flags KeyModifiers : u32 { const NONEMASK = (0 << 0), const SHIFTMASK = (1 << 0), const LOCKMASK = (1 << 1), ...
random_line_split
window_system.rs
extern crate libc; use std::fmt::{ Error, Formatter, Debug }; use window_manager::WindowManager; pub type Window = u64; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Rectangle(pub i32, pub i32, pub u32, pub u32); impl Rectangle { pub fn is_inside(&self, x: i32, y: i32) -> bool { let &Rectangle...
} #[derive(Clone, Copy, Debug)] pub struct WindowChanges { pub x: u32, pub y: u32, pub width: u32, pub height: u32, pub border_width: u32, pub sibling: Window, pub stack_mode: u32, } /// Represents a keyboard input /// with an abstracted modifier mask /// and the key represented as a stri...
{ let &Rectangle(ax, ay, aw, ah) = self; !(bx >= ax + aw as i32 || bx + bw as i32 <= ax || by >= ay + ah as i32 || by + bh as i32 <= ay) }
identifier_body
wikipages.rs
use structs::common::{Taiga}; pub struct WikiPagesProxy<'a> { pub taiga_client: &'a Taiga, pub project_id: Option<i64>, } pub struct WikiPageProxy<'a> { pub taiga_client: &'a Taiga, pub wikipage_id: i64, } #[derive(Serialize, Deserialize, Debug)] pub struct WikiPageListItem { pub id: i64, pub...
pub struct WikiPageDetail { pub id: i64, pub slug: String, pub html: String, pub content: String, pub is_watcher: bool, pub total_watchers: i64, pub editions: i64, pub version: i64, pub project: i64, pub owner: Option<i64>, pub last_modifier: Option<i64>, pub created_date...
} #[derive(Serialize, Deserialize, Debug)]
random_line_split
wikipages.rs
use structs::common::{Taiga}; pub struct WikiPagesProxy<'a> { pub taiga_client: &'a Taiga, pub project_id: Option<i64>, } pub struct WikiPageProxy<'a> { pub taiga_client: &'a Taiga, pub wikipage_id: i64, } #[derive(Serialize, Deserialize, Debug)] pub struct WikiPageListItem { pub id: i64, pub...
{ pub id: i64, pub slug: String, pub html: String, pub content: String, pub is_watcher: bool, pub total_watchers: i64, pub editions: i64, pub version: i64, pub project: i64, pub owner: Option<i64>, pub last_modifier: Option<i64>, pub created_date: String, pub modifie...
WikiPageDetail
identifier_name
wait_condition.rs
use alloc::arc::Arc; use collections::Vec; use spin::{Mutex, RwLock}; use context::{self, Context}; #[derive(Debug)] pub struct WaitCondition { contexts: Mutex<Vec<Arc<RwLock<Context>>>> } impl WaitCondition { pub fn new() -> WaitCondition { WaitCondition { contexts: Mutex::new(Vec::with_...
} impl Drop for WaitCondition { fn drop(&mut self){ self.notify(); } }
self.contexts.lock().push(context_lock); } unsafe { context::switch(); } }
random_line_split
wait_condition.rs
use alloc::arc::Arc; use collections::Vec; use spin::{Mutex, RwLock}; use context::{self, Context}; #[derive(Debug)] pub struct WaitCondition { contexts: Mutex<Vec<Arc<RwLock<Context>>>> } impl WaitCondition { pub fn new() -> WaitCondition { WaitCondition { contexts: Mutex::new(Vec::with_...
(&self) -> usize { let mut contexts = self.contexts.lock(); let len = contexts.len(); while let Some(context_lock) = contexts.pop() { context_lock.write().unblock(); } len } pub fn wait(&self) { { let context_lock = { let c...
notify
identifier_name
wait_condition.rs
use alloc::arc::Arc; use collections::Vec; use spin::{Mutex, RwLock}; use context::{self, Context}; #[derive(Debug)] pub struct WaitCondition { contexts: Mutex<Vec<Arc<RwLock<Context>>>> } impl WaitCondition { pub fn new() -> WaitCondition { WaitCondition { contexts: Mutex::new(Vec::with_...
pub fn wait(&self) { { let context_lock = { let contexts = context::contexts(); let context_lock = contexts.current().expect("WaitCondition::wait: no context"); context_lock.clone() }; context_lock.write().block(); ...
{ let mut contexts = self.contexts.lock(); let len = contexts.len(); while let Some(context_lock) = contexts.pop() { context_lock.write().unblock(); } len }
identifier_body
numeric_input.rs
use rustyline::{ Cmd, ConditionalEventHandler, Editor, Event, EventContext, EventHandler, KeyCode, KeyEvent, Modifiers, RepeatCount, Result, }; struct FilteringEventHandler; impl ConditionalEventHandler for FilteringEventHandler { fn handle(&self, evt: &Event, _: RepeatCount, _: bool, _: &EventContext) -> ...
{ let mut rl = Editor::<()>::new(); rl.bind_sequence( Event::Any, EventHandler::Conditional(Box::new(FilteringEventHandler)), ); loop { let line = rl.readline("> ")?; println!("Num: {}", line); } }
identifier_body
numeric_input.rs
use rustyline::{ Cmd, ConditionalEventHandler, Editor, Event, EventContext, EventHandler, KeyCode, KeyEvent, Modifiers, RepeatCount, Result, }; struct FilteringEventHandler; impl ConditionalEventHandler for FilteringEventHandler { fn handle(&self, evt: &Event, _: RepeatCount, _: bool, _: &EventContext) -> ...
} } fn main() -> Result<()> { let mut rl = Editor::<()>::new(); rl.bind_sequence( Event::Any, EventHandler::Conditional(Box::new(FilteringEventHandler)), ); loop { let line = rl.readline("> ")?; println!("Num: {}", line); } }
{ None }
conditional_block
numeric_input.rs
use rustyline::{ Cmd, ConditionalEventHandler, Editor, Event, EventContext, EventHandler, KeyCode, KeyEvent, Modifiers, RepeatCount, Result, };
if let Some(KeyEvent(KeyCode::Char(c), m)) = evt.get(0) { if m.contains(Modifiers::CTRL) || m.contains(Modifiers::ALT) || c.is_ascii_digit() { None } else { Some(Cmd::Noop) // filter out invalid input } } else { None ...
struct FilteringEventHandler; impl ConditionalEventHandler for FilteringEventHandler { fn handle(&self, evt: &Event, _: RepeatCount, _: bool, _: &EventContext) -> Option<Cmd> {
random_line_split
numeric_input.rs
use rustyline::{ Cmd, ConditionalEventHandler, Editor, Event, EventContext, EventHandler, KeyCode, KeyEvent, Modifiers, RepeatCount, Result, }; struct FilteringEventHandler; impl ConditionalEventHandler for FilteringEventHandler { fn handle(&self, evt: &Event, _: RepeatCount, _: bool, _: &EventContext) -> ...
() -> Result<()> { let mut rl = Editor::<()>::new(); rl.bind_sequence( Event::Any, EventHandler::Conditional(Box::new(FilteringEventHandler)), ); loop { let line = rl.readline("> ")?; println!("Num: {}", line); } }
main
identifier_name
window.rs
use std::collections::vec_deque::IntoIter as VecDequeIter; use std::default::Default; use Api; use BuilderAttribs; use CreationError; use Event; use GlRequest; use MouseCursor; use gl_common; use libc; use winimpl; /// Object that allows you to build windows. pub struct WindowBuilder<'a> { attribs: BuilderAttri...
// default dimensions if self.attribs.dimensions.is_none() { self.attribs.dimensions = Some((1024, 768)); } // building winimpl::Window::new(self.attribs).map(|w| Window { window: w }) } /// Builds the window. /// /// The context is build in a *str...
{ self.attribs.dimensions = Some(self.attribs.monitor.as_ref().unwrap().get_dimensions()) }
conditional_block
window.rs
use std::collections::vec_deque::IntoIter as VecDequeIter; use std::default::Default; use Api; use BuilderAttribs; use CreationError; use Event; use GlRequest; use MouseCursor; use gl_common; use libc; use winimpl; /// Object that allows you to build windows. pub struct WindowBuilder<'a> { attribs: BuilderAttri...
(&self) { self.window.hide() } /// Returns the position of the top-left hand corner of the window relative to the /// top-left hand corner of the desktop. /// /// Note that the top-left hand corner of the desktop is not necessarly the same as /// the screen. If the user uses a desktop...
hide
identifier_name
window.rs
use std::collections::vec_deque::IntoIter as VecDequeIter; use std::default::Default; use Api; use BuilderAttribs; use CreationError; use Event; use GlRequest; use MouseCursor; use gl_common; use libc; use winimpl; /// Object that allows you to build windows. pub struct WindowBuilder<'a> { attribs: BuilderAttri...
/// other libraries that need this information. #[inline] pub unsafe fn platform_display(&self) -> *mut libc::c_void { self.window.platform_display() } /// Gets the native platform specific window handle. This is /// typically only required when integrating with other libraries /// ...
} /// Gets the native platform specific display for this window. /// This is typically only required when integrating with
random_line_split
window.rs
use std::collections::vec_deque::IntoIter as VecDequeIter; use std::default::Default; use Api; use BuilderAttribs; use CreationError; use Event; use GlRequest; use MouseCursor; use gl_common; use libc; use winimpl; /// Object that allows you to build windows. pub struct WindowBuilder<'a> { attribs: BuilderAttri...
/// Builds the window. /// /// The context is build in a *strict* way. That means that if the backend couldn't give /// you what you requested, an `Err` will be returned. pub fn build_strict(mut self) -> Result<Window, CreationError> { self.attribs.strict = true; self.build() }...
{ // resizing the window to the dimensions of the monitor when fullscreen if self.attribs.dimensions.is_none() && self.attribs.monitor.is_some() { self.attribs.dimensions = Some(self.attribs.monitor.as_ref().unwrap().get_dimensions()) } // default dimensions if self....
identifier_body
bogus-tag.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 ...
{ rgb(isize, isize, isize), rgba(isize, isize, isize, isize), } fn main() { let red: color = rgb(255, 0, 0); match red { rgb(r, g, b) => { println!("rgb"); } hsl(h, s, l) => { println!("hsl"); } } }
color
identifier_name
bogus-tag.rs
// 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...
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
random_line_split
wrapper.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 ...
// except according to those terms. #[allow(ctypes)]; #[allow(heap_memory)]; #[allow(implicit_copies)]; #[allow(managed_heap_memory)]; #[allow(non_camel_case_types)]; #[allow(owned_heap_memory)]; #[allow(path_statement)]; #[allow(unrecognized_lint)]; #[allow(unused_imports)]; #[allow(while_true)]; #[allow(unused_varia...
random_line_split
wrapper.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 ...
<T>(result: T) { io::println(fmt!("%?", result)); }
print
identifier_name
wrapper.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 ...
{ io::println(fmt!("%?", result)); }
identifier_body
mod.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 ...
{ exiting_scopes: Vec<ast::NodeId> } pub type CFGIndex = graph::NodeIndex; pub type CFGGraph = graph::Graph<CFGNodeData, CFGEdgeData>; pub type CFGNode = graph::Node<CFGNodeData>; pub type CFGEdge = graph::Edge<CFGEdgeData>; pub struct CFGIndices { entry: CFGIndex, exit: CFGIndex, } impl CFG { pu...
CFGEdgeData
identifier_name
mod.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 ...
mod construct; pub struct CFG { exit_map: NodeMap<CFGIndex>, graph: CFGGraph, entry: CFGIndex, exit: CFGIndex, } pub struct CFGNodeData { id: ast::NodeId } pub struct CFGEdgeData { exiting_scopes: Vec<ast::NodeId> } pub type CFGIndex = graph::NodeIndex; pub type CFGGraph = graph::Graph<CFG...
use middle::typeck; use syntax::ast; use util::nodemap::NodeMap;
random_line_split
domparser.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::DOMParserBinding; use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{...
_ => { Err(FailureUnknown) } } } } impl Reflectable for DOMParser { fn reflector<'a>(&'a self) -> &'a Reflector { &self.reflector_ } fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector { &mut self.reflector_ } }
{ Document::Constructor(self.owner) }
conditional_block
domparser.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::DOMParserBinding; use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{...
(owner: @mut Window) -> @mut DOMParser { reflect_dom_object(@mut DOMParser::new_inherited(owner), owner, DOMParserBinding::Wrap) } pub fn Constructor(owner: @mut Window) -> Fallible<@mut DOMParser> { Ok(DOMParser::new(owner)) } pub fn ParseFromString(&self, ...
new
identifier_name
domparser.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::DOMParserBinding; use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{...
} impl Reflectable for DOMParser { fn reflector<'a>(&'a self) -> &'a Reflector { &self.reflector_ } fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector { &mut self.reflector_ } }
{ match ty { Text_html => { Ok(HTMLDocument::new(self.owner, None)) } Text_xml => { Document::Constructor(self.owner) } _ => { Err(FailureUnknown) } } }
identifier_body
domparser.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::DOMParserBinding; use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{...
} }
random_line_split
mod.rs
use super::lexer::{tokens, Lexer}; const DEBUG: bool = false; #[derive(Debug)] pub enum Result { Ok, Error(String), } #[derive(Debug)] pub struct Parser { /// Lexer lexer: Lexer, /// Active token lookahead_token: Option<tokens::Token>, } impl Parser { pub fn new(input: String) -> Parser
pub fn peek(&mut self) -> Option<&tokens::Token> { let result = if let Some(ref token) = self.lookahead_token { Some(token) } else if let Some(token) = self.lexer.next() { self.lookahead_token = Some(token); self.lookahead_token.as_ref() } else { ...
{ Parser { lexer: Lexer::new(input), lookahead_token: None, } }
identifier_body
mod.rs
use super::lexer::{tokens, Lexer}; const DEBUG: bool = false; #[derive(Debug)] pub enum Result { Ok, Error(String), } #[derive(Debug)] pub struct Parser { /// Lexer lexer: Lexer, /// Active token lookahead_token: Option<tokens::Token>, } impl Parser { pub fn new(input: String) -> Parser ...
(&mut self) -> Option<&tokens::Token> { let result = if let Some(ref token) = self.lookahead_token { Some(token) } else if let Some(token) = self.lexer.next() { self.lookahead_token = Some(token); self.lookahead_token.as_ref() } else { None ...
peek
identifier_name
mod.rs
use super::lexer::{tokens, Lexer}; const DEBUG: bool = false;
pub enum Result { Ok, Error(String), } #[derive(Debug)] pub struct Parser { /// Lexer lexer: Lexer, /// Active token lookahead_token: Option<tokens::Token>, } impl Parser { pub fn new(input: String) -> Parser { Parser { lexer: Lexer::new(input), lookahead_to...
#[derive(Debug)]
random_line_split
vtable.rs
/* * Copyright 2018 Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applica...
pub fn num_fields(&self) -> usize { (self.num_bytes() / SIZE_VOFFSET) - 2 } pub fn num_bytes(&self) -> usize { unsafe { read_scalar_at::<VOffsetT>(self.buf, self.loc) as usize } } pub fn object_inline_num_bytes(&self) -> usize { let n = unsafe { read_scalar_at::<VOffsetT>(se...
{ VTable { buf, loc } }
identifier_body
vtable.rs
/* * Copyright 2018 Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applica...
unsafe { read_scalar_at::<VOffsetT>( self.buf, self.loc + SIZE_VOFFSET + SIZE_VOFFSET + SIZE_VOFFSET * idx, ) } } pub fn get(&self, byte_loc: VOffsetT) -> VOffsetT { // TODO(rw): distinguish between None and 0? if byte_loc ...
{ return 0; }
conditional_block
vtable.rs
/* * Copyright 2018 Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applica...
pub struct VTable<'a> { buf: &'a [u8], loc: usize, } impl<'a> PartialEq for VTable<'a> { fn eq(&self, other: &VTable) -> bool { self.as_bytes().eq(other.as_bytes()) } } impl<'a> VTable<'a> { pub fn init(buf: &'a [u8], loc: usize) -> Self { VTable { buf, loc } } pub fn num_f...
/// VTable encapsulates read-only usage of a vtable. It is only to be used /// by generated code. #[derive(Debug)]
random_line_split
vtable.rs
/* * Copyright 2018 Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applica...
(&self) -> usize { unsafe { read_scalar_at::<VOffsetT>(self.buf, self.loc) as usize } } pub fn object_inline_num_bytes(&self) -> usize { let n = unsafe { read_scalar_at::<VOffsetT>(self.buf, self.loc + SIZE_VOFFSET) }; n as usize } pub fn get_field(&self, idx: usize) -> VOffsetT ...
num_bytes
identifier_name
socket.rs
use std::{ env, ffi::OsStr, fs::File, ops::Range, os::unix::{ io::{AsRawFd, FromRawFd, RawFd}, net::{UnixListener, UnixStream}, }, path::PathBuf, }; use nix::{ fcntl::{flock, open, FlockArg, OFlag}, sys::stat::{lstat, Mode}, unistd::unlink, }; #[derive(Debug)] p...
pub fn bind_auto(basename: &str, range: Range<usize>) -> Result<Self, BindError> { for i in range { // early return on any error except AlreadyInUse match ListeningSocket::bind(&format!("{}-{}", basename, i)) { Ok(socket) => return Ok(socket), Err(Bin...
Ok(ListeningSocket { listener, _lock, socket_path, lock_path }) }
random_line_split
socket.rs
use std::{ env, ffi::OsStr, fs::File, ops::Range, os::unix::{ io::{AsRawFd, FromRawFd, RawFd}, net::{UnixListener, UnixStream}, }, path::PathBuf, }; use nix::{ fcntl::{flock, open, FlockArg, OFlag}, sys::stat::{lstat, Mode}, unistd::unlink, }; #[derive(Debug)] p...
(&self) -> std::io::Result<Option<UnixStream>> { match self.listener.accept() { Ok((stream, _)) => Ok(Some(stream)), Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => Ok(None), Err(e) => Err(e), } } } impl AsRawFd for ListeningSocket { fn as_raw_fd(&sel...
accept
identifier_name
arm64_const.rs
// ARM64 registers #[repr(C)] #[derive(PartialEq, Debug, Clone, Copy)] pub enum RegisterARM64 { INVALID = 0, FP = 1, LR = 2, NZCV = 3, SP = 4, WSP = 5, WZR = 6, XZR = 7, B0 = 8, B1 = 9, B2 = 10, B3 = 11, B4 = 12, B5 = 13, B6 = 14, B7 = 15, B8 = 16, ...
X25 = 224, X26 = 225, X27 = 226, X28 = 227, V0 = 228, V1 = 229, V2 = 230, V3 = 231, V4 = 232, V5 = 233, V6 = 234, V7 = 235, V8 = 236, V9 = 237, V10 = 238, V11 = 239, V12 = 240, V13 = 241, V14 = 242, V15 = 243, V16 = 244, V17 = 245, ...
random_line_split
arm64_const.rs
// ARM64 registers #[repr(C)] #[derive(PartialEq, Debug, Clone, Copy)] pub enum
{ INVALID = 0, FP = 1, LR = 2, NZCV = 3, SP = 4, WSP = 5, WZR = 6, XZR = 7, B0 = 8, B1 = 9, B2 = 10, B3 = 11, B4 = 12, B5 = 13, B6 = 14, B7 = 15, B8 = 16, B9 = 17, B10 = 18, B11 = 19, B12 = 20, B13 = 21, B14 = 22, B15 = 23,...
RegisterARM64
identifier_name
day_10.rs
#[derive(PartialEq, Debug, Clone)] pub enum Token { Word(String), //characters LeftParenthesis, RightParenthesis, SemiColon, SingleQuote, Colon } pub struct Lexer { src: Vec<char>, } impl Lexer { pub fn new(line: &str) -> Lexer { Lexer { src: line.chars()....
(&mut self) -> Token { self.remove_front_spaces(); if self.has_lexem_in_begining() { let s = self.src.remove(0); println!("38 s - {:?}", s); match s { '(' => return Token::LeftParenthesis, ',' => return Token::Colon, ')'...
parse_lexem
identifier_name
day_10.rs
#[derive(PartialEq, Debug, Clone)] pub enum Token { Word(String), //characters LeftParenthesis, RightParenthesis, SemiColon, SingleQuote, Colon } pub struct Lexer { src: Vec<char>, } impl Lexer { pub fn new(line: &str) -> Lexer { Lexer { src: line.chars()....
fn parse_lexem(&mut self) -> Token { self.remove_front_spaces(); if self.has_lexem_in_begining() { let s = self.src.remove(0); println!("38 s - {:?}", s); match s { '(' => return Token::LeftParenthesis, ',' => return Token::Colon,...
{ if self.src.is_empty() { None } else { Some(self.parse_lexem()) } }
identifier_body
day_10.rs
#[derive(PartialEq, Debug, Clone)] pub enum Token { Word(String), //characters LeftParenthesis, RightParenthesis, SemiColon, SingleQuote, Colon } pub struct Lexer { src: Vec<char>, } impl Lexer { pub fn new(line: &str) -> Lexer { Lexer { src: line.chars()....
else if self.src[i] == '\'' && self.src[i+1] == '\'' { self.src.remove(i); i += 1; } else { break; } }, '' |...
{ self.src = self.src.split_off(1); return Token::SingleQuote; }
conditional_block
day_10.rs
#[derive(PartialEq, Debug, Clone)] pub enum Token { Word(String), //characters LeftParenthesis, RightParenthesis, SemiColon, SingleQuote, Colon } pub struct Lexer { src: Vec<char>, } impl Lexer { pub fn new(line: &str) -> Lexer { Lexer { src: line.chars()....
'(' => return Token::LeftParenthesis, ',' => return Token::Colon, ')' => return Token::RightParenthesis, ';' => return Token::SemiColon, _ => {} } } let mut i = 0; while i < self.src.len() { l...
self.remove_front_spaces(); if self.has_lexem_in_begining() { let s = self.src.remove(0); println!("38 s - {:?}", s); match s {
random_line_split
client.rs
use hello_world::greeter_client::GreeterClient; use hello_world::HelloRequest; use opentelemetry::sdk::propagation::TraceContextPropagator; use opentelemetry::{global, propagation::Injector}; use tracing::*; use tracing_futures::Instrument; use tracing_opentelemetry::OpenTelemetrySpanExt; use tracing_subscriber::prelud...
{ global::set_text_map_propagator(TraceContextPropagator::new()); let tracer = opentelemetry_jaeger::new_pipeline() .with_service_name("grpc-client") .install_simple()?; tracing_subscriber::registry() .with(tracing_subscriber::EnvFilter::new("INFO")) .with(tracing_opentelemet...
identifier_body
client.rs
use hello_world::greeter_client::GreeterClient; use hello_world::HelloRequest; use opentelemetry::sdk::propagation::TraceContextPropagator; use opentelemetry::{global, propagation::Injector}; use tracing::*; use tracing_futures::Instrument; use tracing_opentelemetry::OpenTelemetrySpanExt; use tracing_subscriber::prelud...
} #[instrument] async fn greet() -> Result<(), Box<dyn std::error::Error + Send + Sync +'static>> { let mut client = GreeterClient::connect("http://[::1]:50051") .instrument(info_span!("client connect")) .await?; let mut request = tonic::Request::new(HelloRequest { name: "Tonic".into(), ...
pub mod hello_world { tonic::include_proto!("helloworld");
random_line_split
client.rs
use hello_world::greeter_client::GreeterClient; use hello_world::HelloRequest; use opentelemetry::sdk::propagation::TraceContextPropagator; use opentelemetry::{global, propagation::Injector}; use tracing::*; use tracing_futures::Instrument; use tracing_opentelemetry::OpenTelemetrySpanExt; use tracing_subscriber::prelud...
} } pub mod hello_world { tonic::include_proto!("helloworld"); } #[instrument] async fn greet() -> Result<(), Box<dyn std::error::Error + Send + Sync +'static>> { let mut client = GreeterClient::connect("http://[::1]:50051") .instrument(info_span!("client connect")) .await?; let mut re...
{ if let Ok(val) = tonic::metadata::MetadataValue::from_str(&value) { self.0.insert(key, val); } }
conditional_block
client.rs
use hello_world::greeter_client::GreeterClient; use hello_world::HelloRequest; use opentelemetry::sdk::propagation::TraceContextPropagator; use opentelemetry::{global, propagation::Injector}; use tracing::*; use tracing_futures::Instrument; use tracing_opentelemetry::OpenTelemetrySpanExt; use tracing_subscriber::prelud...
() -> Result<(), Box<dyn std::error::Error + Send + Sync +'static>> { global::set_text_map_propagator(TraceContextPropagator::new()); let tracer = opentelemetry_jaeger::new_pipeline() .with_service_name("grpc-client") .install_simple()?; tracing_subscriber::registry() .with(tracing_subs...
main
identifier_name
mod.rs
use flowgger::config::Config; use openssl::bn::BigNum; use openssl::dh::DH; use openssl::ssl::*; use openssl::x509::X509FileType; use std::path::{Path, PathBuf}; use std::sync::Arc; pub mod tls_input; #[cfg(feature = "coroutines")] pub mod tlsco_input; pub use super::Input; const DEFAULT_CERT: &'static str = "flowgg...
#[cfg(not(feature = "coroutines"))] fn get_default_threads(_config: &Config) -> usize { 1 } pub fn config_parse(config: &Config) -> (TlsConfig, String, u64) { let listen = config.lookup("input.listen") .map_or(DEFAULT_LISTEN, |x| x.as_str().expect("input.listen must be an ip:port strin...
{ config.lookup("input.tls_threads").map_or(DEFAULT_THREADS, |x| { x.as_integer().expect("input.tls_threads must be an unsigned integer") as usize }) }
identifier_body
mod.rs
use flowgger::config::Config; use openssl::bn::BigNum; use openssl::dh::DH; use openssl::ssl::*; use openssl::x509::X509FileType; use std::path::{Path, PathBuf}; use std::sync::Arc; pub mod tls_input; #[cfg(feature = "coroutines")] pub mod tlsco_input; pub use super::Input; const DEFAULT_CERT: &'static str = "flowgg...
const DEFAULT_FRAMING: &'static str = "line"; const DEFAULT_KEY: &'static str = "flowgger.pem"; const DEFAULT_LISTEN: &'static str = "0.0.0.0:6514"; #[cfg(feature = "coroutines")] const DEFAULT_THREADS: usize = 1; const DEFAULT_TIMEOUT: u64 = 3600; const DEFAULT_TLS_METHOD: &'static str = "any"; const DEFAULT_VERIFY_PE...
AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:\ ECDHE-RSA-DES-CBC3-SHA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:\ !EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA"; const DEFAULT_COMPRESSION: bool = false;
random_line_split
mod.rs
use flowgger::config::Config; use openssl::bn::BigNum; use openssl::dh::DH; use openssl::ssl::*; use openssl::x509::X509FileType; use std::path::{Path, PathBuf}; use std::sync::Arc; pub mod tls_input; #[cfg(feature = "coroutines")] pub mod tlsco_input; pub use super::Input; const DEFAULT_CERT: &'static str = "flowgg...
(config: &Config) -> usize { config.lookup("input.tls_threads").map_or(DEFAULT_THREADS, |x| { x.as_integer().expect("input.tls_threads must be an unsigned integer") as usize }) } #[cfg(not(feature = "coroutines"))] fn get_default_threads(_config: &Config) -> usize { 1 } pub fn config_parse(config:...
get_default_threads
identifier_name
markdown.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 ...
/// Render `input` (e.g. "foo.md") into an HTML file in `output` /// (e.g. output = "bar" => "bar/foo.html"). pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches, external_html: &ExternalHtml, include_toc: bool) -> int { let input_p = Path::new(input); output.push(input_p....
{ let mut metadata = Vec::new(); for line in s.lines() { if line.starts_with("%") { // remove %<whitespace> metadata.push(line[1..].trim_left()) } else { let line_start_byte = s.subslice_offset(line); return (metadata, &s[line_start_byte..]); ...
identifier_body
markdown.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 ...
(input: &str, mut output: PathBuf, matches: &getopts::Matches, external_html: &ExternalHtml, include_toc: bool) -> int { let input_p = Path::new(input); output.push(input_p.file_stem().unwrap()); output.set_extension("html"); let mut css = String::new(); for name in &matches.opt_strs(...
render
identifier_name
markdown.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 ...
use externalfiles::ExternalHtml; use html::escape::Escape; use html::markdown; use html::markdown::{Markdown, MarkdownWithToc, find_testable_code, reset_headers}; use test::Collector; /// Separate any lines at the start of the file that begin with `%`. fn extract_leading_metadata<'a>(s: &'a str) -> (Vec<&'a str>, &'a...
use core; use getopts; use testing; use rustc::session::search_paths::SearchPaths;
random_line_split
scrollable.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
fn get_vscroll_policy(&self) -> gtk::ScrollablePolicy { unsafe { ffi::gtk_scrollable_get_vscroll_policy(GTK_SCROLLABLE(self.get_widget())) } } fn set_vscroll_policy(&mut self, policy: gtk::ScrollablePolicy) { unsafe { ffi::gtk_scrollable_set_vscroll_policy(GT...
random_line_split
scrollable.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
self) -> gtk::Adjustment { unsafe { gtk::Adjustment::wrap_pointer(ffi::gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(self.get_widget()))) } } fn set_vadjustment(&mut self, vadjustment: gtk::Adjustment) { unsafe { ffi::gtk_scrollable_set_vadjustment(GTK_SCROLLABLE...
t_vadjustment(&
identifier_name
scrollable.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
fn get_vscroll_policy(&self) -> gtk::ScrollablePolicy { unsafe { ffi::gtk_scrollable_get_vscroll_policy(GTK_SCROLLABLE(self.get_widget())) } } fn set_vscroll_policy(&mut self, policy: gtk::ScrollablePolicy) { unsafe { ffi::gtk_scrollable_set_vscroll_policy(GT...
unsafe { ffi::gtk_scrollable_set_hscroll_policy(GTK_SCROLLABLE(self.get_widget()), policy) } }
identifier_body
sepcomp-extern.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 ...
() -> usize { unsafe { ::foo() } } } mod b { pub fn call3() -> usize { unsafe { ::foo() } } } fn main() { assert_eq!(call1(), 1234); assert_eq!(a::call2(), 1234); assert_eq!(b::call3(), 1234); }
call2
identifier_name
sepcomp-extern.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 ...
mod a { pub fn call2() -> usize { unsafe { ::foo() } } } mod b { pub fn call3() -> usize { unsafe { ::foo() } } } fn main() { assert_eq!(call1(), 1234); assert_eq!(a::call2(), 1234); assert_eq!(b::call3(), 1234); }
{ unsafe { foo() } }
identifier_body
sepcomp-extern.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 ...
assert_eq!(b::call3(), 1234); }
assert_eq!(a::call2(), 1234);
random_line_split
dsputils.rs
#![feature(core)] /* Copyright Ian Daniher, 2013, 2014. Distributed under the terms of the GPLv3. */ extern crate core; // basic tools for type coercion and FIR filter creation, useful for DSP // mad props to Bob Maling for his work @ http://musicdsp.org/showArchiveComment.php?ArchiveID=194 use core::num::*; use st...
<T: Float+Ord>(xs: &[T]) -> T { xs.iter().fold(xs[0], |a, &b| cmp::max(a, b)) } #[inline(always)] pub fn min<T: Float+Ord>(xs: &[T]) -> T { xs.iter().fold(xs[0], |a, &b| cmp::min(a, b)) } #[inline(always)] pub fn convolve<T: Float>(u: &[T], v: &[T]) -> Vec<T> { u.windows(v.len()).map(|x| {x.iter().zip(v.iter()).ma...
max
identifier_name
dsputils.rs
#![feature(core)] /* Copyright Ian Daniher, 2013, 2014. Distributed under the terms of the GPLv3. */ extern crate core; // basic tools for type coercion and FIR filter creation, useful for DSP // mad props to Bob Maling for his work @ http://musicdsp.org/showArchiveComment.php?ArchiveID=194 use core::num::*; use st...
#[inline(always)] pub fn min<T: Float+Ord>(xs: &[T]) -> T { xs.iter().fold(xs[0], |a, &b| cmp::min(a, b)) } #[inline(always)] pub fn convolve<T: Float>(u: &[T], v: &[T]) -> Vec<T> { u.windows(v.len()).map(|x| {x.iter().zip(v.iter()).map(|(&x, &y)| x*y).fold(Float::zero(), |a:T, b| a + b)}).collect() } // filter c...
{ xs.iter().fold(xs[0], |a, &b| cmp::max(a, b)) }
identifier_body
dsputils.rs
#![feature(core)] /* Copyright Ian Daniher, 2013, 2014. Distributed under the terms of the GPLv3. */ extern crate core; // basic tools for type coercion and FIR filter creation, useful for DSP // mad props to Bob Maling for his work @ http://musicdsp.org/showArchiveComment.php?ArchiveID=194 use core::num::*; use st...
a[0] - a[1]*(2f32*pi*n/(nn-1f32)).cos()+a[2]*(4f32*pi*n/(nn-1f32)).cos()-a[3]*(6f32*pi*n/(nn-1f32).cos()) }).collect() } pub fn sinc(m: usize, fc: f32) -> Vec<f32> { // fc should always specify corner below nyquist assert!(fc < 0.5); let pi = f32::consts::PI; (0..m).map(|x| -> f32 { let n = x as f32 - m as f3...
(0..m + 1).map(|x| { let nn = x as f32;
random_line_split
dsputils.rs
#![feature(core)] /* Copyright Ian Daniher, 2013, 2014. Distributed under the terms of the GPLv3. */ extern crate core; // basic tools for type coercion and FIR filter creation, useful for DSP // mad props to Bob Maling for his work @ http://musicdsp.org/showArchiveComment.php?ArchiveID=194 use core::num::*; use st...
r }).collect() } // low-pass filter pub fn lpf(m: usize, fc: f32) -> Vec<f32> { // assert_eq!(m % 2, 1); let w = window(m); let s = sinc(m, fc); w.iter().zip(s.iter()).map(|(&x, &y)| x * y).collect() } // high-pass filter pub fn hpf(m: usize, fc: f32) -> Vec<f32> { let l = lpf(m, fc); let mut h: Vec<f32> = l...
{ r = (2f32*pi*fc*n).sin()/(pi*n); }
conditional_block
lib.rs
pub struct WordProblem { text: String, } impl WordProblem { pub fn new(command: &str) -> Self { WordProblem { text: command.to_string(), } } pub fn answer(&self) -> Result<i32,()> { if!self.text.starts_with("What") { return Err(()); } le...
Ok(sum) } }
random_line_split
lib.rs
pub struct
{ text: String, } impl WordProblem { pub fn new(command: &str) -> Self { WordProblem { text: command.to_string(), } } pub fn answer(&self) -> Result<i32,()> { if!self.text.starts_with("What") { return Err(()); } let mut temp = self.text...
WordProblem
identifier_name
main.rs
extern crate clap; extern crate num_bigint; extern crate num_traits; // Time Start: Tue, 24 Dec 2019 05:49:55 -0500 // Time Finish 1: Tue, 24 Dec 2019 07:29:32 -0500 (1 hour, 39 minutes, 37 seconds) // Time Finish 2: // Time Total: use std::convert::TryFrom; use std::fs; use clap::{Arg, App}; use num_bigint::BigInt...
(&self, x: i64) -> i64 { let rv = BigInt::from(self.m) * x + self.b; return self.bi_to_64(&rv, "rv too big!?"); } pub fn invert(&self, y: i64) -> i64 { fn inverse(a: i64, b: i64) -> i64 { // inverse of a, mod b let (mut r, mut r_, mut t, mut t_) = (b, a, 0, 1); w...
eval
identifier_name
main.rs
extern crate clap; extern crate num_bigint; extern crate num_traits; // Time Start: Tue, 24 Dec 2019 05:49:55 -0500 // Time Finish 1: Tue, 24 Dec 2019 07:29:32 -0500 (1 hour, 39 minutes, 37 seconds) // Time Finish 2: // Time Total: use std::convert::TryFrom; use std::fs; use clap::{Arg, App}; use num_bigint::BigInt;...
pub fn as_tx(&self, mo: i64) -> LinModXForm { match self { DealNew => LinModXForm::new(mo-1, mo-1, mo), Cut(n) => LinModXForm::new(1, mo-(*n), mo), DealInc(n) => LinModXForm::new(*n, 0, mo), } } } fn deck(n: u16) -> Deck { (0..n).collect() } fn num_...
_ => unreachable!("Stupid rust"), } }
random_line_split
main.rs
extern crate clap; extern crate num_bigint; extern crate num_traits; // Time Start: Tue, 24 Dec 2019 05:49:55 -0500 // Time Finish 1: Tue, 24 Dec 2019 07:29:32 -0500 (1 hour, 39 minutes, 37 seconds) // Time Finish 2: // Time Total: use std::convert::TryFrom; use std::fs; use clap::{Arg, App}; use num_bigint::BigInt...
} fn deck(n: u16) -> Deck { (0..n).collect() } fn num_at(s: &str, n: usize) -> i64 { let mut ok = false; let mut sign = 1_i64; let mut rv = 0_i64; for ch in s.chars().skip(n) { match ch { '+' => (), '-' => sign *= -1, '0'..='9' => { ok = true; rv *= 10; rv...
{ match self { DealNew => LinModXForm::new(mo-1, mo-1, mo), Cut(n) => LinModXForm::new(1, mo-(*n), mo), DealInc(n) => LinModXForm::new(*n, 0, mo), } }
identifier_body
parser.rs
use std::fs::File; use std::io::{BufReader, Read}; use std::path::Path; use super::MalTestingLine; pub enum Test { Ok, None, } fn load_local_mal_spec_file(filepath: &Path) -> Result<BufReader<File>, String> { Ok(BufReader::new(File::open(filepath).map_err(|err| { format!( "load_local_...
} declaring_input.push(line); } Ok(parsed_lines) } pub fn load_and_parse_mal_spec(filename: &str) -> Result<Vec<MalTestingLine>, String> { let filename = format!("./tests/{}", filename); let filepath = Path::new(&filename); parse_mal_spec(load_local_mal_spec_file(&filepath)?) }
} parsed_lines.push(MalTestingLine::InputShouldThrow(declaring_input.clone())); declaring_input = vec![]; continue;
random_line_split
parser.rs
use std::fs::File; use std::io::{BufReader, Read}; use std::path::Path; use super::MalTestingLine; pub enum Test { Ok, None, } fn load_local_mal_spec_file(filepath: &Path) -> Result<BufReader<File>, String> { Ok(BufReader::new(File::open(filepath).map_err(|err| { format!( "load_local_...
parsed_lines.push(MalTestingLine::InputShouldThrow(declaring_input.clone())); declaring_input = vec![]; continue; } declaring_input.push(line); } Ok(parsed_lines) } pub fn load_and_parse_mal_spec(filename: &str) -> Result<Vec<MalTestingLine>, String> { ...
{ return Err(format!("no matching input for error output \"{}\"", output)); }
conditional_block
parser.rs
use std::fs::File; use std::io::{BufReader, Read}; use std::path::Path; use super::MalTestingLine; pub enum Test { Ok, None, } fn load_local_mal_spec_file(filepath: &Path) -> Result<BufReader<File>, String> { Ok(BufReader::new(File::open(filepath).map_err(|err| { format!( "load_local_...
{ let filename = format!("./tests/{}", filename); let filepath = Path::new(&filename); parse_mal_spec(load_local_mal_spec_file(&filepath)?) }
identifier_body
parser.rs
use std::fs::File; use std::io::{BufReader, Read}; use std::path::Path; use super::MalTestingLine; pub enum Test { Ok, None, } fn load_local_mal_spec_file(filepath: &Path) -> Result<BufReader<File>, String> { Ok(BufReader::new(File::open(filepath).map_err(|err| { format!( "load_local_...
(mut reader: BufReader<File>) -> Result<Vec<MalTestingLine>, String> { // read all lines let mut content = String::new(); reader .read_to_string(&mut content) .map_err(|err| format!("parse_mal_spec reading error: {}", err))?; let lines: Vec<String> = content.split('\n').map(|l| l.trim().in...
parse_mal_spec
identifier_name
struct-partial-move-2.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 ...
{ val: int } impl S { fn new(v: int) -> S { S { val: v } } } impl Drop for S { fn drop(&mut self) { } } pub type Two<T> = (Partial<T>, Partial<T>); pub fn f<T, F>((b1, b2): (T, T), (b3, b4): (T, T), mut f: F) -> Two<T> where F: FnMut(T) -> T { let p = Partial { x: b1, y: b2 }; let q = Partial { x: b3, y: b4 ...
S
identifier_name
struct-partial-move-2.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 two = f((S::new(1), S::new(3)), (S::new(5), S::new(7)), |S { val: z }| S::new(z+1)); assert_eq!(two, (Partial { x: S::new(8), y: S::new(3) }, Partial { x: S::new(5), y: S::new(2) })); }
// Move of `q` is legal even though we have already moved `q.y`; // the `..q` moves all fields *except* `q.y` in this context. // Likewise, the move of `p.x` is legal for similar reasons. (Partial { x: f(q.y), ..p }, Partial { y: f(p.x), ..q }) }
random_line_split
struct-partial-move-2.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 two = f((S::new(1), S::new(3)), (S::new(5), S::new(7)), |S { val: z }| S::new(z+1)); assert_eq!(two, (Partial { x: S::new(8), y: S::new(3) }, Partial { x: S::new(5), y: S::new(2) })); }
{ let p = Partial { x: b1, y: b2 }; let q = Partial { x: b3, y: b4 }; // Move of `q` is legal even though we have already moved `q.y`; // the `..q` moves all fields *except* `q.y` in this context. // Likewise, the move of `p.x` is legal for similar reasons. (Partial { x: f(q.y), ..p }, Parti...
identifier_body
mod.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...
//! * You're interested in what the smallest or largest key-value pair is. //! * You want to find the largest or smallest key that is smaller or larger //! than something. //! * You want to be able to get all of the entries in order on-demand. //! * You want a sorted map. //! //! ### Use a `VecMap` when: //! * You wa...
//! * You want to associate arbitrary keys with an arbitrary value. //! * You want a cache. //! * You want a map, with no extra functionality. //! //! ### Use a `BTreeMap` when:
random_line_split
10b.rs
#[macro_use] extern crate lazy_static; extern crate regex; use regex::Regex; use std::cmp::max; use std::cmp::min; use std::i32::MAX; fn solve(input: String) -> i32 { lazy_static! { static ref RE: Regex = Regex::new(r"^position=<?(-?\d+), *(-?\d+)> velocity=<?(-?\d+), *(-?\d+)>$").unwrap(); ...
() { println!("{}", solve(include_str!("input.txt").into())); } #[test] fn test_10b() { let input = vec![ "position=< 9, 1> velocity=< 0, 2>", "position=< 7, 0> velocity=<-1, 0>", "position=< 3, -2> velocity=<-1, 1>", "position=< 6, 10> velocity=<-2, -1>", "position...
main
identifier_name
10b.rs
#[macro_use] extern crate lazy_static; extern crate regex; use regex::Regex; use std::cmp::max; use std::cmp::min; use std::i32::MAX; fn solve(input: String) -> i32 { lazy_static! { static ref RE: Regex = Regex::new(r"^position=<?(-?\d+), *(-?\d+)> velocity=<?(-?\d+), *(-?\d+)>$").unwrap(); ...
#[test] fn test_10b() { let input = vec![ "position=< 9, 1> velocity=< 0, 2>", "position=< 7, 0> velocity=<-1, 0>", "position=< 3, -2> velocity=<-1, 1>", "position=< 6, 10> velocity=<-2, -1>", "position=< 2, -4> velocity=< 2, 2>", "position=<-6, 10> velocity=<...
{ println!("{}", solve(include_str!("input.txt").into())); }
identifier_body
10b.rs
#[macro_use] extern crate lazy_static; extern crate regex; use regex::Regex; use std::cmp::max; use std::cmp::min; use std::i32::MAX; fn solve(input: String) -> i32 {
.split("\n") .map(|l| { let c = RE.captures(l).unwrap(); ( ( c.get(1).unwrap().as_str().parse::<i32>().unwrap(), c.get(2).unwrap().as_str().parse::<i32>().unwrap(), ), ( c.ge...
lazy_static! { static ref RE: Regex = Regex::new(r"^position=< ?(-?\d+), *(-?\d+)> velocity=< ?(-?\d+), *(-?\d+)>$").unwrap(); } let points: Vec<((i32, i32), (i32, i32))> = input
random_line_split
main.rs
extern crate winapi; extern crate user32; extern crate gdi32; extern crate comctl32; extern crate kernel32; use std::ptr::null_mut; use std::mem::size_of; use std::mem::zeroed; use std::os::raw::c_int; use winapi::winnt::MAKELANGID; use winapi::winnt::LANG_NEUTRAL; use winapi::winnt::SUBLANG_DEFAULT; use winapi::winu...
type Res<T> = Result<T, String>; #[link(name = "gdi32")] extern { // why doesn't this show up in gdi32?? it's documented... //gdi32::SetBkMode(hdc, winapi::wingdi::TRANSPARENT); fn SetBkMode(hdc: HDC, mode: c_int) -> c_int; } #[link(name = "shell32")] extern { fn Shell_NotifyIconW(mode: DWORD, iconData: *con...
use winapi::HGDIOBJ;
random_line_split