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
lib.rs
#![deny(missing_debug_implementations)] use janus_plugin_sys as ffi; use bitflags::bitflags; pub use debug::LogLevel; pub use debug::log; pub use jansson::{JanssonDecodingFlags, JanssonEncodingFlags, JanssonValue, RawJanssonValue}; pub use session::SessionWrapper; pub use ffi::events::janus_eventhandler as EventHandle...
$crate::Plugin { get_api_compatibility, get_version, get_version_string, get_description, get_name, get_author, get_package, $($cb,)* } }} } /// Macro to export a Janus plugin instance from this module. ...
extern "C" fn get_version_string() -> *const c_char { $md.version_str.as_ptr() } extern "C" fn get_description() -> *const c_char { $md.description.as_ptr() } extern "C" fn get_name() -> *const c_char { $md.name.as_ptr() } extern "C" fn get_author() -> *const c_char { $md.author.as_ptr()...
random_line_split
events.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
(window: &glfw::Window, (time, event): (f64, glfw::WindowEvent)) { match event { glfw::PosEvent(x, y) => window.set_title(format!("Time: {}, Window pos: ({}, {})", time, x, y).as_slice()), glfw::SizeEvent(w, h) => window.set_title(format!("Time: {}, Window size: ({}, {})...
handle_window_event
identifier_name
events.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
window.set_char_polling(true); window.set_mouse_button_polling(true); window.set_cursor_pos_polling(true); window.set_cursor_enter_polling(true); window.set_scroll_polling(true); // Alternatively, all event types may be set to poll at once. Note that // in this example, this call is redunda...
{ let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap(); glfw.window_hint(glfw::Resizable(true)); let (window, events) = glfw.create_window(800, 600, "Hello, I am a window.", glfw::Windowed) .expect("Failed to create GLFW window."); window.set_sticky_keys(true); // Polling of events can b...
identifier_body
events.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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...
glfw.window_hint(glfw::Resizable(true)); let (window, events) = glfw.create_window(800, 600, "Hello, I am a window.", glfw::Windowed) .expect("Failed to create GLFW window."); window.set_sticky_keys(true); // Polling of events can be turned on and off by the specific event type window.set_...
fn main() { let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
random_line_split
second.rs
// Module containing functions for calculating second order greeks use std::f64::consts::E; use common::*; /// Calculates the Gamma for an option /// /// Gamma measures the rate of change in the delta with respect to the change in the underlying price. /// /// # Arguments /// * `s0` - The underlying price of the opti...
() { let gamma = gamma(UNDERLYING, STRIKE, TIME_TO_EXPIRY, INTEREST_RATE, DIV_YIELD, VOL); let abs = (gamma - E_GAMMA).abs(); assert!(abs < 0.001); } }
test_gamma
identifier_name
second.rs
// Module containing functions for calculating second order greeks use std::f64::consts::E;
use common::*; /// Calculates the Gamma for an option /// /// Gamma measures the rate of change in the delta with respect to the change in the underlying price. /// /// # Arguments /// * `s0` - The underlying price of the option /// * `x` - The strike price of the option /// * `t` - time to expiration as a percentage...
random_line_split
second.rs
// Module containing functions for calculating second order greeks use std::f64::consts::E; use common::*; /// Calculates the Gamma for an option /// /// Gamma measures the rate of change in the delta with respect to the change in the underlying price. /// /// # Arguments /// * `s0` - The underlying price of the opti...
#[cfg(test)] mod tests { use greeks::*; const UNDERLYING: f64 = 64.68; const STRIKE: f64 = 65.00; const VOL: f64 = 0.5051; const INTEREST_RATE: f64 = 0.0150; const DIV_YIELD: f64 = 0.0210; const DAYS_PER_YEAR: f64 = 365.0; const TIME_TO_EXPIRY: f64 = 23.0 / DAYS_PER_YEAR; const ...
{ let arg1 = E.powf(-(q * t)) / (s0 * sigma * (t.sqrt())); let arg2 = one_over_sqrt_pi(); let arg3 = E.powf((-d1).powf(2.0)) / 2.0; return arg1 * arg2 * arg3; }
identifier_body
state.rs
use std::fmt::{Debug, Formatter, Result}; use std::clone::Clone; pub enum State { Unknown, Unsupported, Unauthorized, PoweredOff, PoweredOn, } impl State { fn id(&self) -> usize { match *self { State::Unknown => 1, State::Unsupported => 3, Stat...
} impl Debug for State { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, "State::{}", match *self { State::Unknown => "Unknown", State::Unsupported => "Unsupported", State::Unauthorized => "Unauthorized", State::PoweredOff => "PoweredOff", ...
{ self.id() == other.id() }
identifier_body
state.rs
use std::fmt::{Debug, Formatter, Result}; use std::clone::Clone; pub enum State { Unknown, Unsupported, Unauthorized, PoweredOff, PoweredOn, } impl State { fn id(&self) -> usize { match *self { State::Unknown => 1, State::Unsupported => 3, Stat...
(&self, f: &mut Formatter) -> Result { write!(f, "State::{}", match *self { State::Unknown => "Unknown", State::Unsupported => "Unsupported", State::Unauthorized => "Unauthorized", State::PoweredOff => "PoweredOff", State::PoweredOn => "Powe...
fmt
identifier_name
state.rs
use std::fmt::{Debug, Formatter, Result}; use std::clone::Clone; pub enum State { Unknown, Unsupported, Unauthorized, PoweredOff, PoweredOn, } impl State { fn id(&self) -> usize { match *self { State::Unknown => 1, State::Unsupported => 3, Stat...
} impl PartialEq for State { fn eq(&self, other: &State) -> bool { self.id() == other.id() } } impl Debug for State { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, "State::{}", match *self { State::Unknown => "Unknown", State::Unsupported => "Unsuppor...
}
random_line_split
build.rs
use std::{ env, fs::File, io::{BufRead, BufReader, Write}, path::Path, }; use quote::ToTokens; use syn::{parse_quote, visit::Visit, visit_mut::VisitMut}; struct FilterSwigAttrs; impl VisitMut for FilterSwigAttrs { fn visit_attribute_mut(&mut self, i: &mut syn::Attribute) { if i.path ...
let mut jni_global_vars = jni_cache_macro_cache.global_vars(); file.items.append(&mut jni_global_vars); let out_path = Path::new(&out_dir).join(include_path.file_name().expect("No file name")); let mut cache = file_cache::FileWriteCache::new(&out_path, &mut file_cache::NoNe...
{ panic!("jni cache macros visiting failed: {}", visitor.errors[0]); }
conditional_block
build.rs
use std::{ env, fs::File, io::{BufRead, BufReader, Write}, path::Path, }; use quote::ToTokens; use syn::{parse_quote, visit::Visit, visit_mut::VisitMut}; struct FilterSwigAttrs; impl VisitMut for FilterSwigAttrs { fn visit_attribute_mut(&mut self, i: &mut syn::Attribute) { if i.path ...
.unwrap(); } exp_code .update_file_if_necessary() .unwrap_or_else(|err| panic!("Can not write to {}: {}", exp_code_path.display(), err)); println!("cargo:rerun-if-changed={}", exp_tests_list_path.display()); }
random_line_split
build.rs
use std::{ env, fs::File, io::{BufRead, BufReader, Write}, path::Path, }; use quote::ToTokens; use syn::{parse_quote, visit::Visit, visit_mut::VisitMut}; struct FilterSwigAttrs; impl VisitMut for FilterSwigAttrs { fn visit_attribute_mut(&mut self, i: &mut syn::Attribute) { if i.path ...
() { let out_dir = env::var("OUT_DIR").unwrap(); for include_path in &[ Path::new("src/java_jni/jni-include.rs"), Path::new("src/cpp/cpp-include.rs"), ] { let src_cnt_tail = std::fs::read_to_string(include_path) .unwrap_or_else(|err| panic!("Error during read {}: {}", inc...
main
identifier_name
build.rs
use std::{ env, fs::File, io::{BufRead, BufReader, Write}, path::Path, }; use quote::ToTokens; use syn::{parse_quote, visit::Visit, visit_mut::VisitMut}; struct FilterSwigAttrs; impl VisitMut for FilterSwigAttrs { fn visit_attribute_mut(&mut self, i: &mut syn::Attribute)
} mod file_cache { include!("src/file_cache.rs"); } mod jni_find_cache { include!("src/java_jni/find_cache.rs"); } fn main() { let out_dir = env::var("OUT_DIR").unwrap(); for include_path in &[ Path::new("src/java_jni/jni-include.rs"), Path::new("src/cpp/cpp-include.rs"), ] { ...
{ if i.path .clone() .into_token_stream() .to_string() .starts_with("swig_") { *i = parse_quote! { #[doc = "swig_ replace"] }; } }
identifier_body
common.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 indenter() -> _indenter { debug!(">>"); _indenter(()) } pub fn field_expr(f: ast::field) -> @ast::expr { return f.node.expr; } pub fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] { fields.map(|f| f.node.expr) } // Takes a predicate p, returns true iff p is true for any subexpressions // o...
{ _indenter { _i: () } }
identifier_body
common.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>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T { if!do_it { return thunk(); } let start = std::time::precise_time_s(); let rv = thunk(); let end = std::time::precise_time_s(); io::println(fmt!("time: %3.3f s\t%s", end - start, what)); rv } pub fn indent<R>(op: &fn() -> R) -> R { // Us...
time
identifier_name
common.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 ...
debug!(">>"); let r = op(); debug!("<< (Result = %?)", r); r } pub struct _indenter { _i: (), } impl Drop for _indenter { fn finalize(&self) { debug!("<<"); } } pub fn _indenter(_i: ()) -> _indenter { _indenter { _i: () } } pub fn indenter() -> _indenter { debug!(">>"); ...
pub fn indent<R>(op: &fn() -> R) -> R { // Use in conjunction with the log post-processor like `src/etc/indenter` // to make debug output more readable.
random_line_split
vr_event.rs
use {VRDisplayData, VRGamepadData, VRGamepadState}; #[derive(Debug, Clone)] #[cfg_attr(feature = "serde-serialization", derive(Deserialize, Serialize))] pub enum VREvent { Display(VRDisplayEvent), Gamepad(VRGamepadEvent), } #[derive(Debug, Clone, Copy)] #[cfg_attr(feature = "serde-serialization", derive(Deser...
(self) -> VREvent { VREvent::Display(self) } } #[derive(Debug, Clone)] #[cfg_attr(feature = "serde-serialization", derive(Deserialize, Serialize))] pub enum VRGamepadEvent { /// Indicates that a VRGamepad has been connected. /// params: name, displa_id, state Connect(VRGamepadData, VRGamepadSt...
into
identifier_name
vr_event.rs
use {VRDisplayData, VRGamepadData, VRGamepadState}; #[derive(Debug, Clone)] #[cfg_attr(feature = "serde-serialization", derive(Deserialize, Serialize))] pub enum VREvent { Display(VRDisplayEvent), Gamepad(VRGamepadEvent), } #[derive(Debug, Clone, Copy)] #[cfg_attr(feature = "serde-serialization", derive(Deser...
Pause(u32), /// Indicates that VRDisplay presentation loop must be resumed (i.e Android app goes to foreground) Resume(u32), /// Indicates that user has exited VRDisplay presentation (i.e. User clicked back key on android) Exit(u32) } impl Into<VREvent> for VRDisplayEvent { fn into(self) -> V...
PresentChange(VRDisplayData, bool), /// Indicates that VRDisplay presentation loop must be paused (i.e Android app goes to background)
random_line_split
finally.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 ...
} #[cfg(test)] mod test { use super::{try_finally, Finally}; use realstd::task::failing; #[test] fn test_success() { let mut i = 0; try_finally( &mut i, (), |i, ()| { *i = 10; }, |i| { assert!(!failing());...
{ (self.dtor)(self.mutate); }
identifier_body
finally.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 ...
"finally" case. For advanced cases, the `try_finally` function can also be used. See that function for more details. # Example ``` use std::unstable::finally::Finally; (|| { //... }).finally(|| { // this code is always run }) ``` */ #![experimental] use ops::Drop; /// A trait for executing a destructor un...
The Finally trait provides a method, `finally` on stack closures that emulates Java-style try/finally blocks. Using the `finally` method is sometimes convenient, but the type rules prohibit any shared, mutable state between the "try" case and the
random_line_split
finally.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 ...
() {} fn but_always_run_this_function() { } let mut f = do_some_fallible_work; f.finally(but_always_run_this_function); } }
do_some_fallible_work
identifier_name
errors.rs
use attaca::marshal::ObjectHash;
types { Error, ErrorKind, ResultExt, Result; } links { Attaca(::attaca::Error, ::attaca::ErrorKind); } foreign_links { Clap(::clap::Error); Fmt(::std::fmt::Error); GlobSet(::globset::Error); Nul(::std::ffi::NulError); Io(::std::io::Error); } err...
error_chain! {
random_line_split
mod.rs
// Copyright 2015-2017 Intecture Developers. // // Licensed under the Mozilla Public License 2.0 <LICENSE or // https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied, // modified, or distributed except according to those terms. //! OS abstractions for `Telemetry`. mod centos; mod debian; mod fedora; mod f...
() -> Result<Box<TelemetryProvider>> { if Centos::available() { Ok(Box::new(Centos)) } else if Debian::available() { Ok(Box::new(Debian)) } else if Fedora::available() { Ok(Box::new(Fedora)) } else if Freebsd::available() { Ok(Box::new(Freebsd)) } else...
factory
identifier_name
mod.rs
// Copyright 2015-2017 Intecture Developers. // // Licensed under the Mozilla Public License 2.0 <LICENSE or // https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied, // modified, or distributed except according to those terms. //! OS abstractions for `Telemetry`. mod centos; mod debian; mod fedora; mod f...
if Centos::available() { Ok(Box::new(Centos)) } else if Debian::available() { Ok(Box::new(Debian)) } else if Fedora::available() { Ok(Box::new(Fedora)) } else if Freebsd::available() { Ok(Box::new(Freebsd)) } else if Macos::available() { Ok(Box...
} #[doc(hidden)] pub fn factory() -> Result<Box<TelemetryProvider>> {
random_line_split
mod.rs
// Copyright 2015-2017 Intecture Developers. // // Licensed under the Mozilla Public License 2.0 <LICENSE or // https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied, // modified, or distributed except according to those terms. //! OS abstractions for `Telemetry`. mod centos; mod debian; mod fedora; mod f...
Ok(Box::new(Ubuntu)) } else { Err(ErrorKind::ProviderUnavailable("Telemetry").into()) } }
{ if Centos::available() { Ok(Box::new(Centos)) } else if Debian::available() { Ok(Box::new(Debian)) } else if Fedora::available() { Ok(Box::new(Fedora)) } else if Freebsd::available() { Ok(Box::new(Freebsd)) } else if Macos::available() { Ok(B...
identifier_body
regions-mock-tcx.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 ...
(ty_arena: &'tcx Arena, ast_arena: &'ast Arena) -> TypeContext<'tcx, 'ast> { TypeContext { ty_arena: ty_arena, types: ~[], type_table: HashMap::new(), ast_arena: ast_arena, ast_counter: 0 } } fn add_type...
new
identifier_name
regions-mock-tcx.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 ty_arena = arena::Arena::new(); let ast_arena = arena::Arena::new(); let mut tcx = TypeContext::new(&ty_arena, &ast_arena); let ast = tcx.ast(ExprInt); let ty = compute_types(&mut tcx, ast); assert_eq!(*ty, TypeInt); }
}
random_line_split
regions-mock-tcx.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 ...
ExprLambda(ast) => { let arg_ty = tcx.add_type(TypeInt); let body_ty = compute_types(tcx, ast); let lambda_ty = tcx.add_type(TypeFunction(arg_ty, body_ty)); tcx.set_type(ast.id, lambda_ty) } } } pub fn main() { let ty_arena = arena::Arena::new();...
{ let ty = tcx.add_type(TypeInt); tcx.set_type(ast.id, ty) }
conditional_block
unix.rs
use super::RW; use super::evented::{Evented, EventedImpl, MioAdapter}; use std::io; use std::path::Path; use std::os::unix::io::RawFd; use mio_orig; /// Unix pipe reader pub type PipeReader = MioAdapter<mio_orig::unix::PipeReader>; /// Unix pipe writer pub type PipeWriter = MioAdapter<mio_orig::unix::PipeWriter>; //...
/// Try cloning the socket descriptor. pub fn try_clone(&self) -> io::Result<Self> { self.shared().io_ref().try_clone().map(MioAdapter::new) } } /// Unix socket pub type UnixSocket = MioAdapter<mio_orig::unix::UnixSocket>; impl UnixSocket { /// Returns a new, unbound, Unix domain socket ...
{ mio_orig::unix::UnixListener::bind(addr).map(MioAdapter::new) }
identifier_body
unix.rs
use super::RW; use super::evented::{Evented, EventedImpl, MioAdapter}; use std::io; use std::path::Path; use std::os::unix::io::RawFd; use mio_orig; /// Unix pipe reader pub type PipeReader = MioAdapter<mio_orig::unix::PipeReader>; /// Unix pipe writer pub type PipeWriter = MioAdapter<mio_orig::unix::PipeWriter>; //...
<P: AsRef<Path> +?Sized>(self, addr: &P) -> io::Result<(UnixStream, bool)> { self.shared() .io_ref() .try_clone() .and_then(|t| mio_orig::unix::UnixSocket::connect(t, addr)) .map(|(t, b)| (MioAdapter::new(t), b)) } /// Bind the socket to the specified address...
connect
identifier_name
unix.rs
use super::RW; use super::evented::{Evented, EventedImpl, MioAdapter}; use std::io; use std::path::Path; use std::os::unix::io::RawFd; use mio_orig; /// Unix pipe reader pub type PipeReader = MioAdapter<mio_orig::unix::PipeReader>; /// Unix pipe writer pub type PipeWriter = MioAdapter<mio_orig::unix::PipeWriter>; //...
pub fn connect<P: AsRef<Path> +?Sized>(path: &P) -> io::Result<UnixStream> { mio_orig::unix::UnixStream::connect(path).map(MioAdapter::new) } /// Clone pub fn try_clone(&self) -> io::Result<Self> { self.shared().io_ref().try_clone().map(MioAdapter::new) } /// Try reading data i...
impl UnixStream { /// Connect UnixStream to `path`
random_line_split
matching.rs
in CSS rules changes, we // need to try to update all CSS animations on the element if the // element has or will have CSS animation style regardless of whether // the animation is running or not. // // TODO: We should check which @keyframes were added/changed/deleted and ...
}
random_line_split
matching.rs
if replacements.contains(RestyleHint::RESTYLE_STYLE_ATTRIBUTE) { let style_attribute = self.style_attribute(); result |= replace_rule_node( CascadeLevel::StyleAttributeNormal, style_attribute, primary_rules, )...
// // Thus, we can't assume all the animations have been already // updated by layout, because other restyle due to script might be // triggered by layout before the animation tick. // // See #12171 and the associated PR for an example where this ...
{ use animation::{self, Animation}; use dom::TNode; // Finish any expired transitions. let this_opaque = self.as_node().opaque(); animation::complete_expired_transitions(this_opaque, style, context); // Merge any running animations into the current style, and cancel the...
identifier_body
matching.rs
if replacements.contains(RestyleHint::RESTYLE_STYLE_ATTRIBUTE) { let style_attribute = self.style_attribute(); result |= replace_rule_node( CascadeLevel::StyleAttributeNormal, style_attribute, primary_rules, )...
( &self, context: &mut StyleContext<Self>, old_values: &mut Option<Arc<ComputedValues>>, new_values: &mut Arc<ComputedValues>, restyle_hint: RestyleHint, important_rules_changed: bool, ) { use context::UpdateAnimationsTasks; if context.shared.traversa...
process_animations
identifier_name
mod.rs
// we try to parse these as windows keycodes mod keys; pub use self::keys::Keys as Key; mod linux; mod qcode; #[repr(u32)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum Modifier { Alt = 0x0001, Ctrl = 0x0002, Shift = 0x0004, Win = 0x0008, } const NOREPEAT: u32 = 0x4000; ...
else { if let Some(i) = self.modifiers.iter().position(|&x| x == m) { self.modifiers.swap_remove(i); } } } else if down { bindings.extend(self.bindings.iter().enumerate() .filter(|...
{ if !self.modifiers.contains(&m) { self.modifiers.push(m); } }
conditional_block
mod.rs
// we try to parse these as windows keycodes mod keys; pub use self::keys::Keys as Key; mod linux; mod qcode; #[repr(u32)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum Modifier { Alt = 0x0001, Ctrl = 0x0002, Shift = 0x0004, Win = 0x0008, } const NOREPEAT: u32 = 0x4000; ...
} } else if down { bindings.extend(self.bindings.iter().enumerate() .filter(|&(_, b)| b.matches(&self.modifiers, k)) .map(|(i, _)| i)); } KeyResolution { hotkeys: bindings, ...
random_line_split
mod.rs
// we try to parse these as windows keycodes mod keys; pub use self::keys::Keys as Key; mod linux; mod qcode; #[repr(u32)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum Modifier { Alt = 0x0001, Ctrl = 0x0002, Shift = 0x0004, Win = 0x0008, } const NOREPEAT: u32 = 0x4000; ...
(bindings: &'a [KeyBinding]) -> KeyboardState { KeyboardState { modifiers: Vec::new(), bindings, } } pub fn input_linux(&mut self, code: u32, down: bool) -> Option<KeyResolution> { linux::key_convert(code).map(|k| { let mut bindings = Vec::new(); ...
new
identifier_name
lib.rs
// Copyright 2016 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 applicable l...
(reg: &mut Registry) { let pass = box pass::KytheLintPass::new(box JsonEntryWriter); reg.register_late_lint_pass(pass as LateLintPassObject); }
plugin_registrar
identifier_name
lib.rs
// Copyright 2016 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 applicable l...
// Load rustc as a plugin to get macros. #[macro_use] extern crate rustc; extern crate rustc_plugin; #[macro_use] extern crate log; mod kythe; mod pass; mod visitor; use kythe::writer::JsonEntryWriter; use rustc_plugin::Registry; use rustc::lint::LateLintPassObject; // Informs the compiler of the existence and imp...
extern crate rustc_serialize;
random_line_split
lib.rs
// Copyright 2016 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 applicable l...
{ let pass = box pass::KytheLintPass::new(box JsonEntryWriter); reg.register_late_lint_pass(pass as LateLintPassObject); }
identifier_body
issue-24081.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 ...
() {}
main
identifier_name
issue-24081.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 ...
use std::ops::Mul; use std::ops::Div; use std::ops::Rem; type Add = bool; //~ ERROR the name `Add` is defined multiple times //~| `Add` redefined here struct Sub { x: f32 } //~ ERROR the name `Sub` is defined multiple times //~| `Sub` redefined here enum Mul { A, B } //~ ERROR the name `Mul` is defined multiple times ...
use std::ops::Add; use std::ops::Sub;
random_line_split
nullable-pointer-size.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 ...
check_option!($T); check_fancy!($T); }} } pub fn main() { check_type!(&'static int); check_type!(Box<int>); check_type!(Gc<int>); check_type!(extern fn()); }
($T:ty) => {{
random_line_split
nullable-pointer-size.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 ...
() { check_type!(&'static int); check_type!(Box<int>); check_type!(Gc<int>); check_type!(extern fn()); }
main
identifier_name
unboxed-closures-call-sugar-autoderef.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 z = call_with_2(&mut |x| x - 22); assert_eq!(z, -20); }
{ x(2) // look ma, no `*` }
identifier_body
unboxed-closures-call-sugar-autoderef.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let z = call_with_2(&mut |x| x - 22); assert_eq!(z, -20); }
main
identifier_name
unboxed-closures-call-sugar-autoderef.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 z = call_with_2(&mut |x| x - 22); assert_eq!(z, -20);
random_line_split
aarch64.rs
use dynasmrt::{dynasm, DynasmApi, DynasmLabelApi}; use std::{io, slice, mem}; use std::io::Write; fn main() { let mut ops = dynasmrt::aarch64::Assembler::new().unwrap(); let string = "Hello World!"; dynasm!(ops ;.arch aarch64 ; ->hello: ;.bytes string.as_bytes() ;.align 4 ...
{ io::stdout() .write_all(unsafe { slice::from_raw_parts(buffer, length as usize) }) .is_ok() }
identifier_body
aarch64.rs
use dynasmrt::{dynasm, DynasmApi, DynasmLabelApi}; use std::{io, slice, mem}; use std::io::Write; fn main() { let mut ops = dynasmrt::aarch64::Assembler::new().unwrap(); let string = "Hello World!"; dynasm!(ops ;.arch aarch64 ; ->hello: ;.bytes string.as_bytes() ;.align 4 ...
(buffer: *const u8, length: u64) -> bool { io::stdout() .write_all(unsafe { slice::from_raw_parts(buffer, length as usize) }) .is_ok() }
print
identifier_name
aarch64.rs
use dynasmrt::{dynasm, DynasmApi, DynasmLabelApi}; use std::{io, slice, mem}; use std::io::Write; fn main() { let mut ops = dynasmrt::aarch64::Assembler::new().unwrap(); let string = "Hello World!"; dynasm!(ops ;.arch aarch64 ; ->hello: ;.bytes string.as_bytes() ;.align 4 ...
} pub extern "C" fn print(buffer: *const u8, length: u64) -> bool { io::stdout() .write_all(unsafe { slice::from_raw_parts(buffer, length as usize) }) .is_ok() }
let buf = ops.finalize().unwrap(); let hello_fn: extern "C" fn() -> bool = unsafe { mem::transmute(buf.ptr(hello)) }; assert!(hello_fn());
random_line_split
store.rs
pub struct StoreStats { pub num_keys: u64, pub total_memory_in_bytes: u64, } impl StoreStats { pub fn new() -> StoreStats { StoreStats { num_keys: 0, total_memory_in_bytes: 0, } } } pub trait ValueStore<K, V> { fn get(&self, key: &K) -> Option<&V>; fn se...
pub fn set(&mut self, key: K, value: V) { self.evict_keys_if_necessary(); self.eviction_policy.update_metadata_on_set(key.clone(), value.clone()); self.value_store.set(key, value); } fn evict_keys_if_necessary(&mut self) { let should_evict = self.eviction_policy.should_evi...
{ self.evict_keys_if_necessary(); self.eviction_policy.update_metadata_on_get(key.clone()); self.value_store.get(key) }
identifier_body
store.rs
pub struct StoreStats { pub num_keys: u64, pub total_memory_in_bytes: u64, } impl StoreStats { pub fn new() -> StoreStats { StoreStats { num_keys: 0, total_memory_in_bytes: 0, } } } pub trait ValueStore<K, V> { fn get(&self, key: &K) -> Option<&V>; fn se...
} }
{ let keys_to_evict = self.eviction_policy.choose_keys_to_evict(); self.value_store.delete_many(&keys_to_evict); self.eviction_policy.delete_metadata(&keys_to_evict); }
conditional_block
store.rs
pub struct StoreStats { pub num_keys: u64, pub total_memory_in_bytes: u64, } impl StoreStats { pub fn new() -> StoreStats { StoreStats { num_keys: 0, total_memory_in_bytes: 0, } }
fn set(&mut self, key: K, value: V); fn delete(&mut self, key: &K) -> bool; fn delete_many(&mut self, keys: &Vec<K>); fn clear(&mut self); fn stats(&self) -> &StoreStats; } pub trait EvictionPolicy<K, V> { // Metadata management fn update_metadata_on_get(&mut self, key: K); fn update_me...
} pub trait ValueStore<K, V> { fn get(&self, key: &K) -> Option<&V>;
random_line_split
store.rs
pub struct StoreStats { pub num_keys: u64, pub total_memory_in_bytes: u64, } impl StoreStats { pub fn new() -> StoreStats { StoreStats { num_keys: 0, total_memory_in_bytes: 0, } } } pub trait ValueStore<K, V> { fn get(&self, key: &K) -> Option<&V>; fn se...
(&mut self, key: &K) -> Option<&V> { self.evict_keys_if_necessary(); self.eviction_policy.update_metadata_on_get(key.clone()); self.value_store.get(key) } pub fn set(&mut self, key: K, value: V) { self.evict_keys_if_necessary(); self.eviction_policy.update_metadata_on_se...
get
identifier_name
ddraw.rs
// 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. // All files in the project carrying such notice may not be copied, modified, or distributed // except according ...
0xda044e00, 0x69b2, 0x11d0, 0xa1, 0xd5, 0x00, 0xaa, 0x00, 0xb8, 0xdf, 0xbb} DEFINE_GUID!{IID_IDirectDrawSurface4, 0x0b2b8630, 0xad35, 0x11d0, 0x8e, 0xa6, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b} DEFINE_GUID!{IID_IDirectDrawSurface7, 0x06675a80, 0x3b9b, 0x11d2, 0xb9, 0x2f, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b} DEFI...
DEFINE_GUID!{IID_IDirectDrawSurface2, 0x57805885, 0x6eec, 0x11cf, 0x94, 0x41, 0xa8, 0x23, 0x03, 0xc1, 0x0e, 0x27} DEFINE_GUID!{IID_IDirectDrawSurface3,
random_line_split
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...
//! Many collections provide several constructors and methods that refer to "capacity". //! These collections are generally built on top of an array. Optimally, this array would be //! exactly the right size to fit only the elements stored in the collection, but for the //! collection to do this would be very inefficie...
//! specific collection in particular, consult its documentation for detailed discussion //! and code examples. //! //! ## Capacity Management //!
random_line_split
scheme.rs
use alloc::boxed::Box; use collections::vec::Vec; use collections::vec_deque::VecDeque; use core::ops::DerefMut; use fs::Resource; use system::error::Result; use sync::{Intex, WaitQueue}; pub trait NetworkScheme { fn add(&mut self, resource: *mut NetworkResource); fn remove(&mut self, resource: *mut Netwo...
fn write(&mut self, buf: &[u8]) -> Result<usize> { unsafe { (*self.ptr).outbound.lock().push_back(Vec::from(buf)); (*self.nic).sync(); } Ok(buf.len()) } fn sync(&mut self) -> Result<()> { unsafe { (*self.nic).sync(); } ...
{ let bytes = unsafe { (*self.nic).sync(); (*self.ptr).inbound.receive() }; let mut i = 0; while i < bytes.len() && i < buf.len() { buf[i] = bytes[i]; i += 1; } return Ok(bytes.len()); }
identifier_body
scheme.rs
use alloc::boxed::Box; use collections::vec::Vec; use collections::vec_deque::VecDeque; use core::ops::DerefMut; use fs::Resource; use system::error::Result; use sync::{Intex, WaitQueue}; pub trait NetworkScheme { fn add(&mut self, resource: *mut NetworkResource); fn remove(&mut self, resource: *mut Netwo...
(&mut self, buf: &[u8]) -> Result<usize> { unsafe { (*self.ptr).outbound.lock().push_back(Vec::from(buf)); (*self.nic).sync(); } Ok(buf.len()) } fn sync(&mut self) -> Result<()> { unsafe { (*self.nic).sync(); } Ok(()) } }...
write
identifier_name
scheme.rs
use alloc::boxed::Box; use collections::vec::Vec; use collections::vec_deque::VecDeque; use core::ops::DerefMut; use fs::Resource; use system::error::Result; use sync::{Intex, WaitQueue}; pub trait NetworkScheme { fn add(&mut self, resource: *mut NetworkResource); fn remove(&mut self, resource: *mut Netwo...
Ok(buf.len()) } fn sync(&mut self) -> Result<()> { unsafe { (*self.nic).sync(); } Ok(()) } } impl Drop for NetworkResource { fn drop(&mut self) { unsafe { (*self.nic).remove(self.ptr); } } }
(*self.ptr).outbound.lock().push_back(Vec::from(buf)); (*self.nic).sync(); }
random_line_split
unsized5.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 ...
{ }
identifier_body
unsized5.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
struct S4 { f: str, //~ ERROR `core::marker::Sized` is not implemented g: usize } enum E<X:?Sized> { V1(X, isize), //~ERROR `core::marker::Sized` is not implemented } enum F<X:?Sized> { V2{f1: X, f: isize}, //~ERROR `core::marker::Sized` is not implemented } pub fn main() { }
}
random_line_split
unsized5.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 ...
<X:?Sized> { f: isize, g: X, //~ ERROR `core::marker::Sized` is not implemented h: isize, } struct S3 { f: str, //~ ERROR `core::marker::Sized` is not implemented g: [usize] } struct S4 { f: str, //~ ERROR `core::marker::Sized` is not implemented g: usize } enum E<X:?Sized> { V1(X, isize...
S2
identifier_name
mmio.rs
// This file is part of zinc64. // Copyright (c) 2016-2019 Sebastian Jastrzebski. All rights reserved. // Licensed under the GPLv3. See LICENSE file in the project root for full license text. use zinc64_core::{AddressableFaded, Chip, Ram, Shared}; pub struct Mmio { cia_1: Shared<dyn Chip>, cia_2: Shared<dyn C...
} impl Mmio { pub fn new( cia_1: Shared<dyn Chip>, cia_2: Shared<dyn Chip>, color_ram: Shared<Ram>, expansion_port: Shared<dyn AddressableFaded>, sid: Shared<dyn Chip>, vic: Shared<dyn Chip>, ) -> Self { Self { cia_1, cia_2, ...
color_ram: Shared<Ram>, expansion_port: Shared<dyn AddressableFaded>, sid: Shared<dyn Chip>, vic: Shared<dyn Chip>,
random_line_split
mmio.rs
// This file is part of zinc64. // Copyright (c) 2016-2019 Sebastian Jastrzebski. All rights reserved. // Licensed under the GPLv3. See LICENSE file in the project root for full license text. use zinc64_core::{AddressableFaded, Chip, Ram, Shared}; pub struct Mmio { cia_1: Shared<dyn Chip>, cia_2: Shared<dyn C...
(&self, address: u16) -> u8 { match address { 0xd000..=0xd3ff => self.vic.borrow_mut().read((address & 0x003f) as u8), 0xd400..=0xd7ff => self.sid.borrow_mut().read((address & 0x001f) as u8), 0xd800..=0xdbff => self.color_ram.borrow().read(address - 0xd800), 0xdc0...
read
identifier_name
borrowck-lend-flow-match.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 ...
b = ~8; //~ ERROR cannot assign } fn main() {}
{ // Here the guard performs a borrow. This borrow "infects" all // subsequent arms (but not the prior ones). let mut a = ~3; let mut b = ~4; let mut w = &*a; match 22 { _ if cond() => { b = ~5; } _ if link(&*b, &mut w) => { b = ~6; //~ ERROR can...
identifier_body
borrowck-lend-flow-match.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 ...
() { // Here the guard performs a borrow. This borrow "infects" all // subsequent arms (but not the prior ones). let mut a = ~3; let mut b = ~4; let mut w = &*a; match 22 { _ if cond() => { b = ~5; } _ if link(&*b, &mut w) => { b = ~6; //~ ERROR ...
guard
identifier_name
borrowck-lend-flow-match.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 ...
_ => { b = ~7; //~ ERROR cannot assign } } b = ~8; //~ ERROR cannot assign } fn main() {}
b = ~6; //~ ERROR cannot assign }
random_line_split
mod.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/. */ #![allow(unsafe_code)] //! A drop-in replacement for string_cache, but backed by Gecko `nsAtom`s. use gecko_bind...
impl Atom { /// Execute a callback with the atom represented by `ptr`. pub unsafe fn with<F, R>(ptr: *mut nsAtom, callback: F) -> R where F: FnOnce(&Atom) -> R, { let atom = Atom(WeakAtom::new(ptr)); let ret = callback(&atom); mem::forget(atom); ret } ///...
random_line_split
mod.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/. */ #![allow(unsafe_code)] //! A drop-in replacement for string_cache, but backed by Gecko `nsAtom`s. use gecko_bind...
<'a>(atom: *const nsAtom) -> &'a mut Self { &mut *(atom as *mut WeakAtom) } /// Clone this atom, bumping the refcount if the atom is not static. #[inline] pub fn clone(&self) -> Atom { unsafe { Atom::from_raw(self.as_ptr()) } } /// Get the atom hash. #[inline] pub fn ge...
new
identifier_name
mod.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/. */ #![allow(unsafe_code)] //! A drop-in replacement for string_cache, but backed by Gecko `nsAtom`s. use gecko_bind...
, } } /// Return whether two atoms are ASCII-case-insensitive matches pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool { if self == other { return true; } let a = self.as_slice(); let b = other.as_slice(); a.len() == b.len() && a.iter().z...
{ let mut buffer: [u16; 64] = unsafe { mem::uninitialized() }; let mut vec; let mutable_slice = if let Some(buffer_prefix) = buffer.get_mut(..slice.len()) { buffer_prefix.copy_from_slice(slice); buffer_prefix } else ...
conditional_block
mod.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/. */ #![allow(unsafe_code)] //! A drop-in replacement for string_cache, but backed by Gecko `nsAtom`s. use gecko_bind...
} impl fmt::Display for Atom { fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { unsafe { (&*self.0).fmt(w) } } } impl<'a> From<&'a str> for Atom { #[inline] fn from(string: &str) -> Atom { debug_assert!(string.len() <= u32::max_value() as usize); unsafe { Ato...
{ write!(w, "Gecko Atom({:p}, {})", self.0, self) }
identifier_body
main.rs
use std::collections::HashMap; use std::io::{self, BufRead}; use lazy_regex::regex; use regex::Regex; use structopt::StructOpt; type H = HashMap<Header, Vec<(String, String, String)>>; #[derive(Debug, Clone, PartialEq, Eq, Hash)] enum Header { Versioned { package: String, version: String }, Missing { package...
println!("\nTESTS\n"); } for (header, packages) in tests { for (package, version, component) in packages { let s = printer(" ", &package, false, &version, &component, &header); println!("{}", s); auto_tests.push(s); } } if!benches.is_empty(...
} if !tests.is_empty() {
random_line_split
main.rs
use std::collections::HashMap; use std::io::{self, BufRead}; use lazy_regex::regex; use regex::Regex; use structopt::StructOpt; type H = HashMap<Header, Vec<(String, String, String)>>; #[derive(Debug, Clone, PartialEq, Eq, Hash)] enum Header { Versioned { package: String, version: String }, Missing { package...
fn add() { let mut lib_exes: H = Default::default(); let mut tests: H = Default::default(); let mut benches: H = Default::default(); let mut last_header: Option<Header> = None; let header_versioned = regex!( r#"^(?P<package>[a-zA-z]([a-zA-z0-9.-]*?))-(?P<version>(\d+(\.\d+)*)).+?is out of...
{ commenter::outdated(); }
identifier_body
main.rs
use std::collections::HashMap; use std::io::{self, BufRead}; use lazy_regex::regex; use regex::Regex; use structopt::StructOpt; type H = HashMap<Header, Vec<(String, String, String)>>; #[derive(Debug, Clone, PartialEq, Eq, Hash)] enum Header { Versioned { package: String, version: String }, Missing { package...
(s: &str, r: &Regex) -> bool { r.captures(s).is_some() }
is_reg_match
identifier_name
main.rs
use std::collections::HashMap; use std::io::{self, BufRead}; use lazy_regex::regex; use regex::Regex; use structopt::StructOpt; type H = HashMap<Header, Vec<(String, String, String)>>; #[derive(Debug, Clone, PartialEq, Eq, Hash)] enum Header { Versioned { package: String, version: String }, Missing { package...
; format!( "{indent}- {package}{lt0} # tried {package}-{version}, but its *{component}* {cause}", indent = indent, package = package, lt0 = lt0, version = version, component = component, cause = match header { Header::Versioned { package, version }...
{ "" }
conditional_block
trait-cast-generic.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let a = Bar { x: 1 }; let b = &a as &Foo; }
identifier_body
trait-cast-generic.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T> { x: T, } impl<T> Foo for Bar<T> { } pub fn main() { let a = Bar { x: 1 }; let b = &a as &Foo; }
Bar
identifier_name
trait-cast-generic.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let b = &a as &Foo; }
let a = Bar { x: 1 };
random_line_split
config.rs
use std::io::prelude::*; use std::fs::File; use std::str::FromStr; use docopt::Docopt; use toml; use gobjects; use version::Version; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum WorkMode { Normal, //generate widgets etc. Sys, //generate -sys with ffi } impl Default for WorkMode { fn d...
let external_libraries = toml.lookup("options.external_libraries") .map(|a| a.as_slice().unwrap().iter() .filter_map(|v| if let &toml::Value::String(ref s) = v { Some(s.clone()) } else { None } ) .collect()) .unwrap_or_else(|| Vec::new());...
let mut objects = toml.lookup("object").map(|t| gobjects::parse_toml(t)) .unwrap_or_else(|| Default::default()); gobjects::parse_status_shorthands(&mut objects, &toml);
random_line_split
config.rs
use std::io::prelude::*; use std::fs::File; use std::str::FromStr; use docopt::Docopt; use toml; use gobjects; use version::Version; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum WorkMode { Normal, //generate widgets etc. Sys, //generate -sys with ffi } impl Default for WorkMode { fn d...
(s: &str) -> Result<Self, Self::Err> { match s { "normal" => Ok(WorkMode::Normal), "sys" => Ok(WorkMode::Sys), _ => Err("Wrong work mode".into()) } } } static USAGE: &'static str = " Usage: gir [options] [<library> <version>] gir --help Options: -h, -...
from_str
identifier_name
config.rs
use std::io::prelude::*; use std::fs::File; use std::str::FromStr; use docopt::Docopt; use toml; use gobjects; use version::Version; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum WorkMode { Normal, //generate widgets etc. Sys, //generate -sys with ffi } impl Default for WorkMode { fn d...
} static USAGE: &'static str = " Usage: gir [options] [<library> <version>] gir --help Options: -h, --help Show this message. -c CONFIG Config file path (default: Gir.toml) -d GIRSPATH Directory for girs -m MODE Work mode: normal or sys -o PATH ...
{ match s { "normal" => Ok(WorkMode::Normal), "sys" => Ok(WorkMode::Sys), _ => Err("Wrong work mode".into()) } }
identifier_body
dompoint.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::DOMPointBinding::{DOMPointInit, DOMPointMethods, Wrap}; use dom::bindings::c...
} impl DOMPointMethods for DOMPoint { // https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x fn X(&self) -> f64 { self.point.X() } // https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-x fn SetX(&self, value: f64) { self.point.SetX(value); } ...
{ DOMPoint::new(global, p.x, p.y, p.z, p.w) }
identifier_body
dompoint.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::DOMPointBinding::{DOMPointInit, DOMPointMethods, Wrap}; use dom::bindings::c...
} // https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w fn SetW(&self, value: f64) { self.point.SetW(value); } }
self.point.W()
random_line_split
dompoint.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::DOMPointBinding::{DOMPointInit, DOMPointMethods, Wrap}; use dom::bindings::c...
(&self) -> f64 { self.point.Z() } // https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z fn SetZ(&self, value: f64) { self.point.SetZ(value); } // https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w fn W(&self) -> f64 { self.point.W()...
Z
identifier_name
assoc-types.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 ...
// @has assoc_types/fn.cmp_input.html // @has - '//*[@class="rust fn"]' 'where T::Input: PartialEq<U::Input>' pub fn cmp_input<T: Feed, U: Feed>(a: &T::Input, b: &U::Input) -> bool where T::Input: PartialEq<U::Input> { a == b }
{ }
identifier_body
assoc-types.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: Index<usize>>(obj: &T, index: usize) -> &T::Output { obj.index(index) } pub trait Feed { type Input; } // @has assoc_types/fn.use_input.html // @has - '//*[@class="rust fn"]' 'T::Input' pub fn use_input<T: Feed>(_feed: &T, _element: T::Input) { } // @has assoc_types/fn.cmp_input.html // @has - '//*[@clas...
use_output
identifier_name
assoc-types.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
// option. This file may not be copied, modified, or distributed // except according to those terms. #![crate_type="lib"] // @has assoc_types/trait.Index.html pub trait Index<I:?Sized> { // @has - '//*[@id="associatedtype.Output"]//code' 'type Output:?Sized' type Output:?Sized; // @has - '//*[@id="tymetho...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
underscore_const_names.rs
// Copyright 2012-2018 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...
{ check_impl!(Str, Trt); check_impl!(Str, Trt); }
identifier_body
underscore_const_names.rs
// Copyright 2012-2018 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...
() { check_impl!(Str, Trt); check_impl!(Str, Trt); }
main
identifier_name
underscore_const_names.rs
// Copyright 2012-2018 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...
trait Trt {} struct Str {} impl Trt for Str {} macro_rules! check_impl { ($struct:ident,$trait:ident) => { const _ : () = { use std::marker::PhantomData; struct ImplementsTrait<T: $trait>(PhantomData<T>); let _ = ImplementsTrait::<$struct>(PhantomData); () ...
// compile-pass #![feature(const_let)] #![feature(underscore_const_names)]
random_line_split
mod.rs
use libc::{self, c_int}; #[macro_use] pub mod dlsym; #[cfg(any(target_os = "linux", target_os = "android"))] mod epoll; #[cfg(any(target_os = "linux", target_os = "android"))] pub use self::epoll::{Events, Selector}; #[cfg(any(target_os = "bitrig", target_os = "dragonfly", target_os = "freebsd", target_os...
} impl IsMinusOne for i32 { fn is_minus_one(&self) -> bool { *self == -1 } } impl IsMinusOne for isize { fn is_minus_one(&self) -> bool { *self == -1 } } fn cvt<T: IsMinusOne>(t: T) -> ::io::Result<T> { use std::io; if t.is_minus_one() { Err(io::Error::last_os_error()) } else { Ok...
trait IsMinusOne { fn is_minus_one(&self) -> bool;
random_line_split
mod.rs
use libc::{self, c_int}; #[macro_use] pub mod dlsym; #[cfg(any(target_os = "linux", target_os = "android"))] mod epoll; #[cfg(any(target_os = "linux", target_os = "android"))] pub use self::epoll::{Events, Selector}; #[cfg(any(target_os = "bitrig", target_os = "dragonfly", target_os = "freebsd", target_os...
}
{ Ok(t) }
conditional_block
mod.rs
use libc::{self, c_int}; #[macro_use] pub mod dlsym; #[cfg(any(target_os = "linux", target_os = "android"))] mod epoll; #[cfg(any(target_os = "linux", target_os = "android"))] pub use self::epoll::{Events, Selector}; #[cfg(any(target_os = "bitrig", target_os = "dragonfly", target_os = "freebsd", target_os...
(&self) -> bool { *self == -1 } } fn cvt<T: IsMinusOne>(t: T) -> ::io::Result<T> { use std::io; if t.is_minus_one() { Err(io::Error::last_os_error()) } else { Ok(t) } }
is_minus_one
identifier_name
mod.rs
use libc::{self, c_int}; #[macro_use] pub mod dlsym; #[cfg(any(target_os = "linux", target_os = "android"))] mod epoll; #[cfg(any(target_os = "linux", target_os = "android"))] pub use self::epoll::{Events, Selector}; #[cfg(any(target_os = "bitrig", target_os = "dragonfly", target_os = "freebsd", target_os...
unsafe { Ok((Io::from_raw_fd(pipes[0]), Io::from_raw_fd(pipes[1]))) } } trait IsMinusOne { fn is_minus_one(&self) -> bool; } impl IsMinusOne for i32 { fn is_minus_one(&self) -> bool { *self == -1 } } impl IsMinusOne for isize { fn is_minus_one(&self) -> bool { *self == -1 } } fn cvt<T: I...
{ // Use pipe2 for atomically setting O_CLOEXEC if we can, but otherwise // just fall back to using `pipe`. dlsym!(fn pipe2(*mut c_int, c_int) -> c_int); let mut pipes = [0; 2]; let flags = libc::O_NONBLOCK | libc::O_CLOEXEC; unsafe { match pipe2.get() { Some(pipe2_fn) => { ...
identifier_body
mod.rs
mod handlers; use crate::server::Server; use log::{debug, error}; use protocol::frame::Framed; use protocol::Decode; use runtime::net::TcpStream; use std::sync::Arc; const SALT_LEN: usize = 32; const AES_KEY_LEN: usize = 32; const AES_IV_LEN: usize = 16; #[derive(PartialEq, Eq, Debug)] enum State { Init, Log...
let mut rng = rand::thread_rng(); std::iter::repeat(()) .map(|()| rng.sample(rand::distributions::Alphanumeric)) .take(SALT_LEN) .collect() }; self.stream.write(HelloConnectMessage { salt: &salt, key: unsafe { ...
{ use futures::StreamExt; use protocol::messages::connection::HelloConnectMessage; use protocol::messages::connection::IdentificationMessage; use protocol::messages::connection::ServerSelectionMessage; use protocol::messages::handshake::ProtocolRequired; use rand::Rng; ...
identifier_body
mod.rs
mod handlers; use crate::server::Server; use log::{debug, error}; use protocol::frame::Framed; use protocol::Decode; use runtime::net::TcpStream; use std::sync::Arc; const SALT_LEN: usize = 32; const AES_KEY_LEN: usize = 32; const AES_IV_LEN: usize = 16; #[derive(PartialEq, Eq, Debug)] enum
{ Init, Logged { aes_key: [u8; AES_KEY_LEN], ticket: String, }, } pub struct Session { stream: Framed<TcpStream>, state: State, server: Arc<Server>, } impl Session { pub fn new(stream: TcpStream, server: Arc<Server>) -> Self { Self { stream: Framed::new...
State
identifier_name
mod.rs
mod handlers; use crate::server::Server; use log::{debug, error}; use protocol::frame::Framed; use protocol::Decode; use runtime::net::TcpStream; use std::sync::Arc; const SALT_LEN: usize = 32; const AES_KEY_LEN: usize = 32; const AES_IV_LEN: usize = 16; #[derive(PartialEq, Eq, Debug)] enum State { Init, Log...
match IdentificationMessage::decode(&mut frame.payload()) { Ok(msg) => self.handle_identification(msg).await?, Err(err) => error!("decode error: {}", err), } } <ServerSelectionMessage<'_> as Decode<'...
debug!("received message with id {}", frame.id()); match frame.id() { <IdentificationMessage<'_> as Decode<'_>>::ID => {
random_line_split
main.rs
extern crate sdl2; extern crate rustc_serialize; use sdl2::keycode::KeyCode; use sdl2::event::Event; use sdl2::timer::get_ticks; mod sprite; mod assets; mod draw; mod player; mod tile; mod map; mod physics; use sprite::Sprite; use player::Player; use player::PlayerStatus; use draw::Draw; fn
() { //initialize sdl let sdl_context = sdl2::init().video().events().build() .ok().expect("Failed to initialize SDL."); //create a window let window = sdl_context.window("Rust-Man", 640, 480) .position_centered() .build() .ok().expect("Failed to create window."); //create a renderer let m...
main
identifier_name
main.rs
extern crate sdl2; extern crate rustc_serialize; use sdl2::keycode::KeyCode; use sdl2::event::Event; use sdl2::timer::get_ticks; mod sprite; mod assets; mod draw; mod player; mod tile; mod map; mod physics; use sprite::Sprite; use player::Player; use player::PlayerStatus; use draw::Draw; fn main()
let mut drawer = renderer.drawer(); drawer.clear(); drawer.present(); //event loop stuff let mut running = true; let mut event_pump = sdl_context.event_pump(); let mut prev_time = get_ticks(); let mut delta_t = get_ticks() - prev_time; while running { //timer stuff delta_t = get_ticks(...
{ //initialize sdl let sdl_context = sdl2::init().video().events().build() .ok().expect("Failed to initialize SDL."); //create a window let window = sdl_context.window("Rust-Man", 640, 480) .position_centered() .build() .ok().expect("Failed to create window."); //create a renderer let ...
identifier_body