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
net.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(Some(Duration::new(secs as u64, nsec as u32))) } } fn set_no_inherit(&self) -> io::Result<()> { sys::cvt(unsafe { c::SetHandleInformation(self.0 as libc::HANDLE, c::HANDLE_FLAG_INHERIT, 0) }).map(|_| ()) } } impl Drop f...
random_line_split
net.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 ...
} fn set_no_inherit(&self) -> io::Result<()> { sys::cvt(unsafe { c::SetHandleInformation(self.0 as libc::HANDLE, c::HANDLE_FLAG_INHERIT, 0) }).map(|_| ()) } } impl Drop for Socket { fn drop(&mut self) { let _ = unsafe { libc::clo...
{ let secs = raw / 1000; let nsec = (raw % 1000) * 1000000; Ok(Some(Duration::new(secs as u64, nsec as u32))) }
conditional_block
net.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 ...
(err: c_int) -> io::Result<()> { if err == 0 { return Ok(()) } cvt(err).map(|_| ()) } /// Provides the functionality of `cvt` for a closure. #[allow(deprecated)] pub fn cvt_r<T, F>(mut f: F) -> io::Result<T> where F: FnMut() -> T, T: One + Neg<Output=T> + PartialEq { cvt(f()) } impl Socket { pub f...
cvt_gai
identifier_name
net.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 ...
pub fn set_timeout(&self, dur: Option<Duration>, kind: libc::c_int) -> io::Result<()> { let timeout = match dur { Some(dur) => { let timeout = sys::dur2timeout(dur); if timeout == 0 { return Err(io::Error::new(io::ErrorKind::InvalidInput, ...
{ // On unix when a socket is shut down all further reads return 0, so we // do the same on windows to map a shut down socket to returning EOF. unsafe { match libc::recv(self.0, buf.as_mut_ptr() as *mut c_void, buf.len() as i32, 0) { -1 if...
identifier_body
stop_sign_editor.rs
// Copyright 2018 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
use map_model::{Map, Turn}; use piston::input::Key; use plugins::selection::SelectionState; pub struct StopSignEditor { i: IntersectionID, } impl StopSignEditor { pub fn new(i: IntersectionID) -> StopSignEditor { StopSignEditor { i } } pub fn event( &mut self, input: &mut User...
use ezgui::input::UserInput; use geom::GeomMap; use graphics::types::Color; use map_model::IntersectionID;
random_line_split
stop_sign_editor.rs
// Copyright 2018 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
if input.key_pressed(Key::D3, "Press 3 to make this turn always stop") { sign.set_priority(id, TurnPriority::Stop, geom_map); } } TurnPriority::Stop => { if sign.could_be_priority...
{ sign.set_priority(id, TurnPriority::Priority, geom_map); }
conditional_block
stop_sign_editor.rs
// Copyright 2018 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
( &mut self, input: &mut UserInput, map: &Map, geom_map: &GeomMap, control_map: &mut ControlMap, current_selection: &SelectionState, ) -> bool { if input.key_pressed(Key::Return, "Press enter to quit the editor") { return true; } i...
event
identifier_name
stop_sign_editor.rs
// Copyright 2018 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
{ sign.set_priority(id, TurnPriority::Priority, geom_map); } if input.key_pressed(Key::D3, "Press 3 to make this turn always stop") { sign.set_priority(id, TurnPriority::Stop, geom_map); ...
{ if input.key_pressed(Key::Return, "Press enter to quit the editor") { return true; } if let SelectionState::SelectedTurn(id) = *current_selection { if map.get_t(id).parent == self.i { let sign = &mut control_map.stop_signs.get_mut(&self.i).unwrap(); ...
identifier_body
ty.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 ...
global: bool) -> Path<'r> { Path { path: path, lifetime: lifetime, params: params, global: global } } pub fn to_ty(&self, cx: @ExtCtxt, span: Span, self_ty:...
pub fn new_<'r>(path: ~[&'r str], lifetime: Option<&'r str>, params: ~[~Ty<'r>],
random_line_split
ty.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 ...
() -> Ty<'static> { Tuple(~[]) } fn mk_lifetime(cx: @ExtCtxt, span: Span, lt: &Option<&str>) -> Option<ast::Lifetime> { match *lt { Some(ref s) => Some(cx.lifetime(span, cx.ident_of(*s))), None => None } } impl<'self> Ty<'self> { pub fn to_ty(&self, cx: @ExtCtxt, ...
nil_ty
identifier_name
ty.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 ...
Ptr(*) => { cx.span_bug(span, "Pointer in a path in generic `deriving`") } Tuple(*) => { cx.span_bug(span, "Tuple in a path in generic `deriving`") } } } } fn mk_ty_param(cx: @ExtCtxt, span: Span, name: &str, bounds: &[Path], self_ident: Ident, self_generics: &Gener...
{ p.to_path(cx, span, self_ty, self_generics) }
conditional_block
ty.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} }
{ let self_path = cx.expr_self(span); match *self_ptr { None => { (self_path, respan(span, ast::sty_value)) } Some(ref ptr) => { let self_ty = respan( span, match *ptr { Send => ast::sty_uniq, ...
identifier_body
lazy.rs
use std::mem; use std::sync; pub struct Lazy<T> { pub lock: sync::Once, pub ptr: *const T, } impl<T> Lazy<T> { pub fn get<F>(&'static mut self, init: F) -> &'static T where F : FnOnce() -> T
} pub const ONCE_INIT: sync::Once = sync::ONCE_INIT; #[cfg(test)] mod test { use super::{Lazy, ONCE_INIT}; use std::thread; use std::sync::{Arc, Barrier}; use std::sync::atomic::{AtomicIsize, Ordering, ATOMIC_ISIZE_INIT}; #[test] fn many_threads_calling_get() { const N_THREADS: usiz...
{ // ~ decouple the lifetimes of 'self' and 'self.lock' such we // can initialize self.ptr in the call_once closure (note: we // do have to initialize self.ptr in the closure to guarantee // the ptr is valid for all calling threads at any point in // time) let lock: &sync...
identifier_body
lazy.rs
use std::mem; use std::sync; pub struct Lazy<T> { pub lock: sync::Once, pub ptr: *const T, } impl<T> Lazy<T> { pub fn get<F>(&'static mut self, init: F) -> &'static T where F : FnOnce() -> T { // ~ decouple the lifetimes of'self' and'self.lock' such we // can initialize self.pt...
#[test] fn many_threads_calling_get() { const N_THREADS: usize = 32; const N_ITERS_IN_THREAD: usize = 32; const N_ITERS: usize = 16; static mut LAZY: Lazy<String> = Lazy { lock: ONCE_INIT, ptr: 0 as *const String, }; static CALL_COUNT: At...
mod test { use super::{Lazy, ONCE_INIT}; use std::thread; use std::sync::{Arc, Barrier}; use std::sync::atomic::{AtomicIsize, Ordering, ATOMIC_ISIZE_INIT};
random_line_split
lazy.rs
use std::mem; use std::sync; pub struct Lazy<T> { pub lock: sync::Once, pub ptr: *const T, } impl<T> Lazy<T> { pub fn get<F>(&'static mut self, init: F) -> &'static T where F : FnOnce() -> T { // ~ decouple the lifetimes of'self' and'self.lock' such we // can initialize self.pt...
() { const N_THREADS: usize = 32; const N_ITERS_IN_THREAD: usize = 32; const N_ITERS: usize = 16; static mut LAZY: Lazy<String> = Lazy { lock: ONCE_INIT, ptr: 0 as *const String, }; static CALL_COUNT: AtomicIsize = ATOMIC_ISIZE_INIT; let ...
many_threads_calling_get
identifier_name
websocket.rs
pcReceiver, IpcSender}; use js::jsapi::{JSAutoCompartment, JSObject}; use js::jsval::UndefinedValue; use js::rust::CustomAutoRooterGuard; use js::typedarray::{ArrayBuffer, ArrayBufferView, CreateWith}; use net_traits::request::{RequestInit, RequestMode}; use net_traits::MessageData; use net_traits::{CoreResourceMsg, Fe...
(&self, array: CustomAutoRooterGuard<ArrayBuffer>) -> ErrorResult { let bytes = array.to_vec(); let data_byte_len = bytes.len(); let send_data = self.send_impl(data_byte_len as u64)?; if send_data { let _ = self .sender .send(WebSocketDomAction:...
Send__
identifier_name
websocket.rs
IpcReceiver, IpcSender}; use js::jsapi::{JSAutoCompartment, JSObject}; use js::jsval::UndefinedValue; use js::rust::CustomAutoRooterGuard; use js::typedarray::{ArrayBuffer, ArrayBufferView, CreateWith}; use net_traits::request::{RequestInit, RequestMode}; use net_traits::MessageData; use net_traits::{CoreResourceMsg, ...
protocol: DomRefCell<String>, //Subprotocol selected by server } impl WebSocket { fn new_inherited(url: ServoUrl, sender: IpcSender<WebSocketDomAction>) -> WebSocket { WebSocket { eventtarget: EventTarget::new_inherited(), url: url, ready_state: Cell::new(WebSocketRe...
#[ignore_malloc_size_of = "Defined in std"] sender: IpcSender<WebSocketDomAction>, binary_type: Cell<BinaryType>,
random_line_split
websocket.rs
pcReceiver, IpcSender}; use js::jsapi::{JSAutoCompartment, JSObject}; use js::jsval::UndefinedValue; use js::rust::CustomAutoRooterGuard; use js::typedarray::{ArrayBuffer, ArrayBufferView, CreateWith}; use net_traits::request::{RequestInit, RequestMode}; use net_traits::MessageData; use net_traits::{CoreResourceMsg, Fe...
, WebSocketRequestState::Open => false, WebSocketRequestState::Closing | WebSocketRequestState::Closed => true, }; let address = Trusted::new(self); match data_byte_len.checked_add(self.buffered_amount.get()) { None => panic!(), Some(new_amount) ...
{ return Err(Error::InvalidState); }
conditional_block
file_loader.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 mime_classifier::MIMEClassifier; use net_traits::ProgressMsg::{Done, Payload}; use net_traits::{LoadConsumer, ...
}
});
random_line_split
file_loader.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 mime_classifier::MIMEClassifier; use net_traits::ProgressMsg::{Done, Payload}; use net_traits::{LoadConsumer, ...
{ Partial(Vec<u8>), EOF, } fn read_block(reader: &mut File) -> Result<ReadStatus, String> { let mut buf = vec![0; READ_SIZE]; match reader.read(&mut buf) { Ok(0) => return Ok(ReadStatus::EOF), Ok(n) => { buf.truncate(n); Ok(ReadStatus::Partial(buf)) } ...
ReadStatus
identifier_name
file_loader.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 mime_classifier::MIMEClassifier; use net_traits::ProgressMsg::{Done, Payload}; use net_traits::{LoadConsumer, ...
}; progress_chan.send(Done(res)).unwrap(); } Err(e) => { let progress_chan = start_sending(senders, metadata); progress_chan.send(Done(Err(e.description().to_owned()))).unwrap(); ...
{ let url = load_data.url; assert!(&*url.scheme == "file"); spawn_named("file_loader".to_owned(), move || { let metadata = Metadata::default(url.clone()); let file_path: Result<PathBuf, ()> = url.to_file_path(); match file_path { Ok(file_path) => { match F...
identifier_body
popup_menu.rs
#![allow(missing_docs)] // glade_helpers //! The popup menu subsystem when the user right-clicks on the tray icon. //! //! Shows the menu with the following entries: //! //! * Mute //! * Volume Control //! * Preferences //! * Reload Sound //! * About //! * Quit use app_state::*; use audio::frontend::*; use gtk::prelu...
} }
mute_check.set_active(true); mute_check.set_sensitive(false); mute_check.set_tooltip_text("Soundcard has no mute switch"); }
conditional_block
popup_menu.rs
#![allow(missing_docs)] // glade_helpers //! The popup menu subsystem when the user right-clicks on the tray icon. //! //! Shows the menu with the following entries: //! //! * Mute //! * Volume Control //! * Preferences //! * Reload Sound //! * About //! * Quit use app_state::*; use audio::frontend::*; use gtk::prelu...
where T: AudioFrontend, { let popup_menu = &appstate.gui.popup_menu.menu_window; let about_dialog = create_about_dialog(); about_dialog.set_skip_taskbar_hint(true); about_dialog.set_transient_for(popup_menu); about_dialog.run(); about_dialog.destroy(); } /// Create the About dialog from sc...
} /// When the about menu item is activated. fn on_about_item_activate<T>(appstate: &AppS<T>)
random_line_split
popup_menu.rs
#![allow(missing_docs)] // glade_helpers //! The popup menu subsystem when the user right-clicks on the tray icon. //! //! Shows the menu with the following entries: //! //! * Mute //! * Volume Control //! * Preferences //! * Reload Sound //! * About //! * Quit use app_state::*; use audio::frontend::*; use gtk::prelu...
<T>(appstate: &AppS<T>) where T: AudioFrontend, { let popup_menu = &appstate.gui.popup_menu.menu_window; let about_dialog = create_about_dialog(); about_dialog.set_skip_taskbar_hint(true); about_dialog.set_transient_for(popup_menu); about_dialog.run(); about_dialog.destroy(); } /// Create ...
on_about_item_activate
identifier_name
popup_menu.rs
#![allow(missing_docs)] // glade_helpers //! The popup menu subsystem when the user right-clicks on the tray icon. //! //! Shows the menu with the following entries: //! //! * Mute //! * Volume Control //! * Preferences //! * Reload Sound //! * About //! * Quit use app_state::*; use audio::frontend::*; use gtk::prelu...
move |_| set_mute_check(&apps), ); } /* mixer_item.connect_activate_link */ { let apps = appstate.clone(); let mixer_item = &appstate.gui.popup_menu.mixer_item; mixer_item.connect_activate(move |_| { let _ = result_warn!( execute_vol_...
{ /* audio.connect_handler */ { let apps = appstate.clone(); appstate.audio.connect_handler(Box::new(move |s, u| { /* skip if window is hidden */ if !apps.gui.popup_menu.menu.get_visible() { return; } match (s, u) { ...
identifier_body
file.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::js::{JS, JSRef, Temporary}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_obje...
(window: &JSRef<Window>, file_bits: &JSRef<Blob>, name: DOMString) -> Temporary<File> { reflect_dom_object(box File::new_inherited(window, file_bits, name), window, FileBinding::Wrap) } } pub trait FileMethods { fn Name(&self) -> DOMString; } impl ...
new
identifier_name
file.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::js::{JS, JSRef, Temporary}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_obje...
pub fn new(window: &JSRef<Window>, file_bits: &JSRef<Blob>, name: DOMString) -> Temporary<File> { reflect_dom_object(box File::new_inherited(window, file_bits, name), window, FileBinding::Wrap) } } pub trait FileMethods { fn Name(&self) -> DOM...
{ File { blob: Blob::new_inherited(window), name: name, window: JS::from_rooted(window), type_: FileTypeId } // XXXManishearth Once Blob is able to store data // the relevant subfields of file_bits should be copied over }
identifier_body
file.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::js::{JS, JSRef, Temporary}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_obje...
} impl File { pub fn new_inherited(window: &JSRef<Window>, _file_bits: &JSRef<Blob>, name: DOMString) -> File { File { blob: Blob::new_inherited(window), name: name, window: JS::from_rooted(window), type_: FileTypeId } // XXXManishearth Once B...
pub name: DOMString, pub window: JS<Window>, pub type_: BlobType
random_line_split
chains_with_comment.rs
// Chains with comment. fn main() { let x = y // comment .z; foo // foo // comment after parent .x .y // comment 1 .bar() // comment after bar() // comment 2 .foobar // comment after // comment 3 .baz(x, y, z); self.rev_dep_graph ...
() { let x = foo .bar?? ? // comment .baz; let x = foo .bar? ?? // comment .baz; let x = foo .bar??? // comment // comment .baz; let x = foo .bar??? // comment // comment ??? // comment ? ?? // comment ??? //...
foo
identifier_name
chains_with_comment.rs
// Chains with comment. fn main() { let x = y // comment .z; foo // foo // comment after parent .x .y // comment 1 .bar() // comment after bar() // comment 2 .foobar // comment after // comment 3 .baz(x, y, z); self.rev_dep_graph ...
// comment ??? .baz; }
{ let x = foo .bar?? ? // comment .baz; let x = foo .bar? ?? // comment .baz; let x = foo .bar? ? ? // comment // comment .baz; let x = foo .bar? ?? // comment // comment ? ?? // comment ? ?? // comment ...
identifier_body
chains_with_comment.rs
// Chains with comment. fn main() { let x = y // comment .z; foo // foo // comment after parent .x .y // comment 1 .bar() // comment after bar()
// comment 2 .foobar // comment after // comment 3 .baz(x, y, z); self.rev_dep_graph .iter() // Remove nodes that are not dirty .filter(|&(unit, _)| dirties.contains(&unit)) // Retain only dirty dependencies of the ones that are dirty .map(|(k, deps)| { ...
random_line_split
lib.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/. */ //! Servo's compiler plugin/macro crate //! //! Attributes this crate provides: //! //! - `#[privatize]` : Forces...
#[cfg(not(feature = "clippy"))] fn register_clippy(reg: &mut Registry) { reg.register_lint_pass(box lints::str_to_string::StrToStringPass as LintPassObject); }
{ ::clippy::plugin_registrar(reg); }
identifier_body
lib.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/. */ //! Servo's compiler plugin/macro crate //! //! Attributes this crate provides: //! //! - `#[privatize]` : Forces...
(reg: &mut Registry) { reg.register_syntax_extension(intern("dom_struct"), MultiModifier(box jstraceable::expand_dom_struct)); reg.register_syntax_extension(intern("derive_JSTraceable"), MultiDecorator(box jstraceable::expand_jstraceable)); reg.register_syntax_extension(intern("_generate_reflector"), MultiD...
plugin_registrar
identifier_name
lib.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/. */ //! Servo's compiler plugin/macro crate //! //! Attributes this crate provides: //! //! - `#[privatize]` : Forces...
fn register_clippy(reg: &mut Registry) { reg.register_lint_pass(box lints::str_to_string::StrToStringPass as LintPassObject); }
random_line_split
main.rs
#[macro_use] extern crate clap; extern crate dbus; use std::io::prelude::*; use std::error::Error; use std::{io, process, fs, env}; use clap::{App, ArgMatches}; use dbus::{Connection, Message}; use dbus::MessageItem::UInt32; const IBUS_BUSADDR_FILE: &'static str = ".config/ibus/bus"; const IBUS_SEND_BUS_NAME: &'s...
fn make_message(args: &ArgMatches) -> Result<Message, Box<Error>> { let triplet; if args.is_present("on") { triplet = KEY_TO_ON } else if let Some(k) = args.subcommand_matches("key") { triplet = [ k.value_of("keysym").unwrap().parse::<u32>()?, DUMMY_ZERO, k....
{ let buff = &mut String::new(); let file = fs::read_dir( format!("{}/{}", env::var("HOME")?, IBUS_BUSADDR_FILE))? .nth(0).ok_or(NONE_001)??; let _ = fs::File::open(file.path())?.read_to_string(buff); let line = buff.lines().nth(1).ok_or(NONE_002)?; let offs = 1 + line...
identifier_body
main.rs
#[macro_use] extern crate clap; extern crate dbus; use std::io::prelude::*; use std::error::Error; use std::{io, process, fs, env}; use clap::{App, ArgMatches}; use dbus::{Connection, Message}; use dbus::MessageItem::UInt32; const IBUS_BUSADDR_FILE: &'static str = ".config/ibus/bus"; const IBUS_SEND_BUS_NAME: &'s...
() -> Result<String, Box<Error>> { let buff = &mut String::new(); let file = fs::read_dir( format!("{}/{}", env::var("HOME")?, IBUS_BUSADDR_FILE))? .nth(0).ok_or(NONE_001)??; let _ = fs::File::open(file.path())?.read_to_string(buff); let line = buff.lines().nth(1).ok_or(NON...
get_address
identifier_name
main.rs
#[macro_use] extern crate clap; extern crate dbus; use std::io::prelude::*; use std::error::Error; use std::{io, process, fs, env}; use clap::{App, ArgMatches}; use dbus::{Connection, Message}; use dbus::MessageItem::UInt32; const IBUS_BUSADDR_FILE: &'static str = ".config/ibus/bus"; const IBUS_SEND_BUS_NAME: &'st...
} fn get_address() -> Result<String, Box<Error>> { let buff = &mut String::new(); let file = fs::read_dir( format!("{}/{}", env::var("HOME")?, IBUS_BUSADDR_FILE))? .nth(0).ok_or(NONE_001)??; let _ = fs::File::open(file.path())?.read_to_string(buff); let line = buff.lines()...
Ok(())
random_line_split
no_revealing_outside_defining_module.rs
// Copyright 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-MIT or ...
() -> boo::Boo { "" //~ ERROR mismatched types } fn bomp_loop() -> boo::Boo { loop {} }
bomp
identifier_name
no_revealing_outside_defining_module.rs
// Copyright 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-MIT or ...
fn bomp_loop() -> boo::Boo { loop {} }
{ "" //~ ERROR mismatched types }
identifier_body
no_revealing_outside_defining_module.rs
// Copyright 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-MIT or ...
pub existential type Boo: ::std::fmt::Debug; fn bomp() -> Boo { "" } } // don't actually know the type here fn bomp2() { let _: &str = bomp(); //~ ERROR mismatched types } fn bomp() -> boo::Boo { "" //~ ERROR mismatched types } fn bomp_loop() -> boo::Boo { loop {} }
mod boo {
random_line_split
system_tray_d.rs
/*! An application that runs in the system tray. Requires the following features: `cargo run --example system_tray_d --features "tray-notification message-window menu cursor"` */ extern crate native_windows_gui as nwg; extern crate native_windows_derive as nwd; use nwd::NwgUi; use nwg::NativeUi; #[derive(De...
(&self) { let flags = nwg::TrayNotificationFlags::USER_ICON | nwg::TrayNotificationFlags::LARGE_ICON; self.tray.show("Hello World", Some("Welcome to my application"), Some(flags), Some(&self.icon)); } fn exit(&self) { nwg::stop_thread_dispatch(); } } fn main() { nwg::init(...
hello2
identifier_name
system_tray_d.rs
/*! An application that runs in the system tray. Requires the following features: `cargo run --example system_tray_d --features "tray-notification message-window menu cursor"` */ extern crate native_windows_gui as nwg; extern crate native_windows_derive as nwd; use nwd::NwgUi; use nwg::NativeUi; #[derive(De...
fn exit(&self) { nwg::stop_thread_dispatch(); } } fn main() { nwg::init().expect("Failed to init Native Windows GUI"); let _ui = SystemTray::build_ui(Default::default()).expect("Failed to build UI"); nwg::dispatch_thread_events(); }
{ let flags = nwg::TrayNotificationFlags::USER_ICON | nwg::TrayNotificationFlags::LARGE_ICON; self.tray.show("Hello World", Some("Welcome to my application"), Some(flags), Some(&self.icon)); }
identifier_body
system_tray_d.rs
/*! An application that runs in the system tray. Requires the following features: `cargo run --example system_tray_d --features "tray-notification message-window menu cursor"` */ extern crate native_windows_gui as nwg; extern crate native_windows_derive as nwd; use nwd::NwgUi; use nwg::NativeUi; #[derive(De...
#[nwg_control(icon: Some(&data.icon), tip: Some("Hello"))] #[nwg_events(MousePressLeftUp: [SystemTray::show_menu], OnContextMenu: [SystemTray::show_menu])] tray: nwg::TrayNotification, #[nwg_control(parent: window, popup: true)] tray_menu: nwg::Menu, #[nwg_control(parent: tray_menu, text: "He...
#[nwg_control] window: nwg::MessageWindow, #[nwg_resource(source_file: Some("./test_rc/cog.ico"))] icon: nwg::Icon,
random_line_split
str.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use geometry::Au; use cssparser::{mod, RGBA, Color}; use std::ascii::AsciiExt; use std::iter::Filter; use std::nu...
if input.len() == 4 { match (input.as_bytes()[0], hex(input.as_bytes()[1] as char), hex(input.as_bytes()[2] as char), hex(input.as_bytes()[3] as char)) { (b'#', Ok(r), Ok(g), Ok(b)) => { return Ok(RGBA { red: (r as ...
// Steps 1 and 2. if input.len() == 0 { return Err(()) } // Step 3. input = input.trim_left_chars(Whitespace).trim_right_chars(Whitespace); // Step 4. if input.eq_ignore_ascii_case("transparent") { return Err(()) } // Step 5. match cssparser::parse_color_keyword...
identifier_body
str.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use geometry::Au; use cssparser::{mod, RGBA, Color}; use std::ascii::AsciiExt; use std::iter::Filter; use std::nu...
None => "".into_string() } } pub fn null_str_as_empty_ref<'a>(s: &'a Option<DOMString>) -> &'a str { match *s { Some(ref s) => s.as_slice(), None => "" } } /// Whitespace as defined by HTML5 § 2.4.1. struct Whitespace; impl CharEq for Whitespace { #[inline] fn matches(&mut...
match *s { Some(ref s) => s.clone(),
random_line_split
str.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use geometry::Au; use cssparser::{mod, RGBA, Color}; use std::ascii::AsciiExt; use std::iter::Filter; use std::nu...
c: &char) -> bool { match *c { '0'...'9' => true, _ => false, } } let mut input = input.skip_while(|c| { HTML_SPACE_CHARACTERS.iter().any(|s| s == c) }).peekable(); let sign = match input.peek() { None => return None, Some(&'-') => { ...
s_ascii_digit(
identifier_name
model.rs
use nom::types::CompleteByteSlice; use parser::{le_u32, le_u8}; /// A renderable voxel Model #[derive(Debug, PartialEq)] pub struct Model { /// The size of the model in voxels pub size: Size, /// The voxels to be displayed. pub voxels: Vec<Voxel>, } impl Model { /// Number of bytes when encoded in...
} /// The size of a model in voxels /// /// Indicates the size of the model in Voxels. #[derive(Copy, Clone, Debug, PartialEq)] pub struct Size { /// The width of the model in voxels. pub x: u32, /// The height of the model in voxels. pub y: u32, /// The depth of the model in voxels. pub z: u3...
{ 12 + 4 * self.voxels.len() as u32 }
identifier_body
model.rs
use nom::types::CompleteByteSlice; use parser::{le_u32, le_u8}; /// A renderable voxel Model #[derive(Debug, PartialEq)] pub struct Model { /// The size of the model in voxels pub size: Size, /// The voxels to be displayed. pub voxels: Vec<Voxel>, } impl Model { /// Number of bytes when encoded in...
(&self) -> u32 { 12 + 4 * self.voxels.len() as u32 } } /// The size of a model in voxels /// /// Indicates the size of the model in Voxels. #[derive(Copy, Clone, Debug, PartialEq)] pub struct Size { /// The width of the model in voxels. pub x: u32, /// The height of the model in voxels. pub...
num_vox_bytes
identifier_name
model.rs
use nom::types::CompleteByteSlice; use parser::{le_u32, le_u8}; /// A renderable voxel Model #[derive(Debug, PartialEq)] pub struct Model { /// The size of the model in voxels pub size: Size, /// The voxels to be displayed. pub voxels: Vec<Voxel>, } impl Model { /// Number of bytes when encoded in...
} named!(pub parse_size <CompleteByteSlice, Size>, do_parse!( x: le_u32 >> y: le_u32 >> z: le_u32 >> (Size { x, y, z }) )); named!(parse_voxel <CompleteByteSlice, Voxel>, do_parse!( x: le_u8 >> y: le_u8 >> z: le_u8 >> i: le_u8 >> (Voxel { x, y, z, i: i.saturating_sub(1) }) )); named!(pub parse_voxe...
/// Index in the Color Palette. Note that this will be 1 less than the value stored in the /// source file, as the palette indices run from 1-255, whereas in memory the indices run from /// 0-254. Therefore, to make life easier, we store the in-memory index here. Should you require /// the source file's...
random_line_split
mesh.rs
// Copyright 2014 The Gfx-rs Developers. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
fn next(&mut self) -> Option<AttributeIndex> { let id = (self.value as AttributeIndex) & MESH_ATTRIBUTE_MASK; self.value >>= BITS_PER_ATTRIBUTE; Some(id) } } /// Holds a remapping table from shader inputs to mesh attributes. #[derive(Clone, Copy)] pub struct Link { table: u64, } i...
impl Iterator for AttributeIter { type Item = AttributeIndex;
random_line_split
mesh.rs
// Copyright 2014 The Gfx-rs Developers. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
{ table: u64, } impl Link { /// Match mesh attributes against shader inputs, produce a mesh link. /// Exposed to public to allow external `Batch` implementations to use it. pub fn new<R: Resources>(mesh: &Mesh<R>, pinfo: &shade::ProgramInfo) -> Result<Link, Error> { ...
Link
identifier_name
document.rs
use rustc_serialize::{Encodable, Encoder}; #[derive(Debug, PartialEq)] pub enum SolrValue { I64(i64), U64(u64), F64(f64), String(String), Boolean(bool), Null } impl Encodable for SolrValue { fn
<E: Encoder>(&self, e: &mut E) -> Result<(), E::Error> { match *self { SolrValue::I64(v) => v.encode(e), SolrValue::U64(v) => v.encode(e), SolrValue::F64(v) => v.encode(e), SolrValue::String(ref v) => v.encode(e), SolrValue::Boolean(v) => v.encode(e), ...
encode
identifier_name
document.rs
use rustc_serialize::{Encodable, Encoder}; #[derive(Debug, PartialEq)] pub enum SolrValue { I64(i64), U64(u64), F64(f64), String(String), Boolean(bool), Null } impl Encodable for SolrValue { fn encode<E: Encoder>(&self, e: &mut E) -> Result<(), E::Error> {
SolrValue::U64(v) => v.encode(e), SolrValue::F64(v) => v.encode(e), SolrValue::String(ref v) => v.encode(e), SolrValue::Boolean(v) => v.encode(e), SolrValue::Null => "null".encode(e) } } } /// SolrDocument field #[derive(Debug)] pub struct SolrFiel...
match *self { SolrValue::I64(v) => v.encode(e),
random_line_split
document.rs
use rustc_serialize::{Encodable, Encoder}; #[derive(Debug, PartialEq)] pub enum SolrValue { I64(i64), U64(u64), F64(f64), String(String), Boolean(bool), Null } impl Encodable for SolrValue { fn encode<E: Encoder>(&self, e: &mut E) -> Result<(), E::Error> { match *self { ...
} impl Encodable for SolrDocument { fn encode<E: Encoder>(&self, s: &mut E) -> Result<(), E::Error> { let mut i = 0usize; s.emit_struct("SolrDocument", self.fields.len(), |e| { for field in self.fields.iter() { try!(e.emit_struct_field(&field.name, i, |e| field.value.en...
{ self.fields.push(SolrField{name: name.to_string(), value: SolrValue::String(value.to_string())}); }
identifier_body
context.rs
config: &'cfg Config, host: Layout, target_layout: Option<Layout>, root_pkg: &Package, build_config: BuildConfig, profiles: &'a Profiles) -> CargoResult<Context<'a, 'cfg>> { let target = build_config.requested_target.clone(); ...
lib_profile
identifier_name
context.rs
Vec<&'a PackageId>>, host: Layout, target: Option<Layout>, target_triple: String, host_dylib: Option<(String, String)>, host_exe: String, package_set: &'a PackageSet, target_dylib: Option<(String, String)>, target_exe: String, requirements: HashMap<(&'a PackageId, &'a...
{ self.target_config(kind).ar.as_ref().map(|s| &s[..]) }
identifier_body
context.rs
compiled: HashSet<(&'a PackageId, &'a Target, &'a Profile)>, pub build_config: BuildConfig, pub build_scripts: HashMap<(&'a PackageId, Kind, &'a Profile), Vec<&'a PackageId>>, host: Layout, target: Option<Layout>, target_triple: String, host_dylib: Option<(String...
package_set: deps, config: config, target_dylib: target_dylib, target_exe: target_exe, host_dylib: host_dylib, host_exe: host_exe, requirements: HashMap::new(), compilation: Compilation::new(root_pkg, config), bu...
resolve: resolve, sources: sources,
random_line_split
timeapi.rs
// Copyright © 2017 winapi-rs developers // 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, modi...
extern "system" { pub fn timeGetTime() -> DWORD; pub fn timeGetDevCaps( ptc: LPTIMECAPS, cbtc: UINT, ) -> MMRESULT; pub fn timeBeginPeriod( uPeriod: UINT, ) -> MMRESULT; pub fn timeEndPeriod( uPeriod: UINT, ) -> MMRESULT; }
random_line_split
build.rs
// build.rs use std::env; use std::fs::File; use std::io::Write; use std::path::Path; use glsl::syntax::{SingleDeclaration, StorageQualifier, TypeQualifierSpec }; use glsl::visitor::{Visit, Visitor}; struct Counter { var_nb: usize } impl Visitor for Counter { // fn visit_identifier(&mut self, id: &mut...
fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("hello.rs"); let mut f = File::create(&dest_path).unwrap(); f.write_all(b" pub fn message() -> &'static str { \"Hello, World!\" } ").unwrap(); let vs = "attribute ve...
Visit::Parent } }
random_line_split
build.rs
// build.rs use std::env; use std::fs::File; use std::io::Write; use std::path::Path; use glsl::syntax::{SingleDeclaration, StorageQualifier, TypeQualifierSpec }; use glsl::visitor::{Visit, Visitor}; struct Counter { var_nb: usize } impl Visitor for Counter { // fn visit_identifier(&mut self, id: &mut...
match &decl.name { Some(str) => { print!("declaration: {:?} {}\n", qs[1], str); print!("let shader = gl.create_shader(t).jsok()?;\n",); print!("gl.shader_source(&shader, code);\n"); print!("gl.compile_shader(&shader);\n"); ...
{ return Visit::Parent; }
conditional_block
build.rs
// build.rs use std::env; use std::fs::File; use std::io::Write; use std::path::Path; use glsl::syntax::{SingleDeclaration, StorageQualifier, TypeQualifierSpec }; use glsl::visitor::{Visit, Visitor}; struct Counter { var_nb: usize } impl Visitor for Counter { // fn visit_identifier(&mut self, id: &mut...
print!("fn shader_pbr() {{\n"); print!("let vscode = \"{}\";\n", vs); print!("let vsshader = gl.create_shader(t).jsok()?;\n",); print!("gl.shader_source(&vsshader, vscode);\n"); print!("gl.compile_shader(&vsshader);\n"); print!("let fscode = \"{}\";\n", fs); print!(...
{ let out_dir = env::var("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("hello.rs"); let mut f = File::create(&dest_path).unwrap(); f.write_all(b" pub fn message() -> &'static str { \"Hello, World!\" } ").unwrap(); let vs = "attribute vec3 coordinate...
identifier_body
build.rs
// build.rs use std::env; use std::fs::File; use std::io::Write; use std::path::Path; use glsl::syntax::{SingleDeclaration, StorageQualifier, TypeQualifierSpec }; use glsl::visitor::{Visit, Visitor}; struct Counter { var_nb: usize } impl Visitor for Counter { // fn visit_identifier(&mut self, id: &mut...
() { let out_dir = env::var("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("hello.rs"); let mut f = File::create(&dest_path).unwrap(); f.write_all(b" pub fn message() -> &'static str { \"Hello, World!\" } ").unwrap(); let vs = "attribute vec3 coordin...
main
identifier_name
const.rs
// min-llvm-version: 10.0.1 // only-x86_64 // run-pass // revisions: mirunsafeck thirunsafeck // [thirunsafeck]compile-flags: -Z thir-unsafeck #![feature(asm, global_asm)] fn const_generic<const X: usize>() -> usize { unsafe { let a: usize; asm!("mov {}, {}", out(reg) a, const X); a } ...
fn main() { unsafe { let a: usize; asm!("mov {}, {}", out(reg) a, const 5); assert_eq!(a, 5); let b: usize; asm!("mov {}, {}", out(reg) b, const constfn(5)); assert_eq!(b, 5); let c: usize; asm!("mov {}, {}", out(reg) c, const constfn(5) + constfn(...
{ x }
identifier_body
const.rs
// min-llvm-version: 10.0.1 // only-x86_64 // run-pass // revisions: mirunsafeck thirunsafeck // [thirunsafeck]compile-flags: -Z thir-unsafeck #![feature(asm, global_asm)] fn const_generic<const X: usize>() -> usize { unsafe { let a: usize; asm!("mov {}, {}", out(reg) a, const X); a } ...
() { unsafe { let a: usize; asm!("mov {}, {}", out(reg) a, const 5); assert_eq!(a, 5); let b: usize; asm!("mov {}, {}", out(reg) b, const constfn(5)); assert_eq!(b, 5); let c: usize; asm!("mov {}, {}", out(reg) c, const constfn(5) + constfn(5)); ...
main
identifier_name
const.rs
// min-llvm-version: 10.0.1 // only-x86_64 // run-pass // revisions: mirunsafeck thirunsafeck // [thirunsafeck]compile-flags: -Z thir-unsafeck #![feature(asm, global_asm)] fn const_generic<const X: usize>() -> usize { unsafe { let a: usize; asm!("mov {}, {}", out(reg) a, const X);
const fn constfn(x: usize) -> usize { x } fn main() { unsafe { let a: usize; asm!("mov {}, {}", out(reg) a, const 5); assert_eq!(a, 5); let b: usize; asm!("mov {}, {}", out(reg) b, const constfn(5)); assert_eq!(b, 5); let c: usize; asm!("mov {}...
a } }
random_line_split
engine.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
{ /// Null engine. Null, /// Ethash engine. Ethash(Ethash), } #[cfg(test)] mod tests { use serde_json; use spec::Engine; #[test] fn engine_deserialization() { let s = r#"{ "Null": null }"#; let deserialized: Engine = serde_json::from_str(s).unwrap(); assert_eq!(Engine::Null, deserialized); let...
Engine
identifier_name
engine.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
}"#; let _deserialized: Engine = serde_json::from_str(s).unwrap(); } }
{ let s = r#"{ "Null": null }"#; let deserialized: Engine = serde_json::from_str(s).unwrap(); assert_eq!(Engine::Null, deserialized); let s = r#"{ "Ethash": { "params": { "tieBreakingGas": false, "gasLimitBoundDivisor": "0x0400", "minimumDifficulty": "0x020000", "difficultyBoun...
identifier_body
engine.rs
// Copyright 2015, 2016 Ethcore (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version....
"blockReward": "0x4563918244F40000", "registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b" } } }"#; let _deserialized: Engine = serde_json::from_str(s).unwrap(); } }
"gasLimitBoundDivisor": "0x0400", "minimumDifficulty": "0x020000", "difficultyBoundDivisor": "0x0800", "durationLimit": "0x0d",
random_line_split
svh.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ hash: ~str, } impl Svh { pub fn new(hash: &str) -> Svh { assert!(hash.len() == 16); Svh { hash: hash.to_owned() } } pub fn as_str<'a>(&'a self) -> &'a str { self.hash.as_slice() } pub fn calculate(krate: &ast::Crate) -> Svh { // FIXME: see above for why this...
Svh
identifier_name
svh.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
krate.module.hash(&mut state); krate.attrs.hash(&mut state); let hash = state.result(); return Svh { hash: range_step(0, 64, 4).map(|i| hex(hash >> i)).collect() }; fn hex(b: u64) -> char { let b = (b & 0xf) as u8; let b = match b { ...
random_line_split
svh.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
krate.attrs.hash(&mut state); let hash = state.result(); return Svh { hash: range_step(0, 64, 4).map(|i| hex(hash >> i)).collect() }; fn hex(b: u64) -> char { let b = (b & 0xf) as u8; let b = match b { 0.. 9 => '0' as u8 + b, ...
{ // FIXME: see above for why this is wrong, it shouldn't just hash the // crate. Fixing this would require more in-depth analysis in // this function about what portions of the crate are reachable // in tandem with bug fixes throughout the rest of the compiler. ...
identifier_body
cmp.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::cmp::Ordering::{self, Less, Equal, Greater}; // impl<'a, A:?Sized> Ord for &'a mut A where A: Ord { // #[inline] // fn cmp(&self, other: &&'a mut A) -> Ordering { Ord::cmp(*self, *other) } // } mac...
let v2: &mut $t = &mut (100 as $t); { let result: Ordering = v1.cmp(&v2); assert_eq!(result, Less); } { let result: Ordering = v2.cmp(&v1); assert_eq!(result, Greater); } })*) } #[test] fn cmp_test1() { cmp_test! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 }; } ...
assert_eq!(result, Equal); }
random_line_split
cmp.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::cmp::Ordering::{self, Less, Equal, Greater}; // impl<'a, A:?Sized> Ord for &'a mut A where A: Ord { // #[inline] // fn cmp(&self, other: &&'a mut A) -> Ordering { Ord::cmp(*self, *other) } // } mac...
() { cmp_test! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 }; } }
cmp_test1
identifier_name
cmp.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::cmp::Ordering::{self, Less, Equal, Greater}; // impl<'a, A:?Sized> Ord for &'a mut A where A: Ord { // #[inline] // fn cmp(&self, other: &&'a mut A) -> Ordering { Ord::cmp(*self, *other) } // } mac...
}
{ cmp_test! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 }; }
identifier_body
p046.rs
//! [Problem 46](https://projecteuler.net/problem=46) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use integer::Integer; use prime::PrimeSet; fn is_goldbach(ps: &PrimeSet, n: u64) -> bool {
} if ps.contains(n - sq) { return true; } } false } fn solve() -> String { let ps = PrimeSet::new(); (3..) .step_by(2) .filter(|&n|!ps.contains(n)) .find(|&n|!is_goldbach(&ps, n)) .unwrap() .to_string() } common::problem!("5777", s...
for s in 1..((n / 2).sqrt() + 1) { let sq = s * s * 2; if sq > n { return false;
random_line_split
p046.rs
//! [Problem 46](https://projecteuler.net/problem=46) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use integer::Integer; use prime::PrimeSet; fn is_goldbach(ps: &PrimeSet, n: u64) -> bool { for s in 1..((n / 2).sq...
if ps.contains(n - sq) { return true; } } false } fn solve() -> String { let ps = PrimeSet::new(); (3..) .step_by(2) .filter(|&n|!ps.contains(n)) .find(|&n|!is_goldbach(&ps, n)) .unwrap() .to_string() } common::problem!("5777", solve);
{ return false; }
conditional_block
p046.rs
//! [Problem 46](https://projecteuler.net/problem=46) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use integer::Integer; use prime::PrimeSet; fn is_goldbach(ps: &PrimeSet, n: u64) -> bool { for s in 1..((n / 2).sq...
() -> String { let ps = PrimeSet::new(); (3..) .step_by(2) .filter(|&n|!ps.contains(n)) .find(|&n|!is_goldbach(&ps, n)) .unwrap() .to_string() } common::problem!("5777", solve);
solve
identifier_name
p046.rs
//! [Problem 46](https://projecteuler.net/problem=46) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use integer::Integer; use prime::PrimeSet; fn is_goldbach(ps: &PrimeSet, n: u64) -> bool
fn solve() -> String { let ps = PrimeSet::new(); (3..) .step_by(2) .filter(|&n|!ps.contains(n)) .find(|&n|!is_goldbach(&ps, n)) .unwrap() .to_string() } common::problem!("5777", solve);
{ for s in 1..((n / 2).sqrt() + 1) { let sq = s * s * 2; if sq > n { return false; } if ps.contains(n - sq) { return true; } } false }
identifier_body
registration.rs
#![cfg_attr(not(feature = "net"), allow(dead_code))] use crate::io::driver::{Direction, Handle, Interest, ReadyEvent, ScheduledIo}; use crate::util::slab; use mio::event::Source; use std::io; use std::task::{Context, Poll}; cfg_io_driver! { /// Associates an I/O resource with the reactor instance that drives it....
io: &mut impl Source, interest: Interest, handle: Handle, ) -> io::Result<Registration> { let shared = if let Some(inner) = handle.inner() { inner.add_source(io, interest)? } else { return Err(io::Error::new( io::ErrorKind::Other, ...
/// # Return /// /// - `Ok` if the registration happened successfully /// - `Err` if an error was encountered during registration pub(crate) fn new_with_interest_and_handle(
random_line_split
registration.rs
#![cfg_attr(not(feature = "net"), allow(dead_code))] use crate::io::driver::{Direction, Handle, Interest, ReadyEvent, ScheduledIo}; use crate::util::slab; use mio::event::Source; use std::io; use std::task::{Context, Poll}; cfg_io_driver! { /// Associates an I/O resource with the reactor instance that drives it....
} impl Drop for Registration { fn drop(&mut self) { // It is possible for a cycle to be created between wakers stored in // `ScheduledIo` instances and `Arc<driver::Inner>`. To break this // cycle, wakers are cleared. This is an imperfect solution as it is // possible to store a `R...
{ let ev = self.shared.ready_event(interest); // Don't attempt the operation if the resource is not ready. if ev.ready.is_empty() { return Err(io::ErrorKind::WouldBlock.into()); } match f() { Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { ...
identifier_body
registration.rs
#![cfg_attr(not(feature = "net"), allow(dead_code))] use crate::io::driver::{Direction, Handle, Interest, ReadyEvent, ScheduledIo}; use crate::util::slab; use mio::event::Source; use std::io; use std::task::{Context, Poll}; cfg_io_driver! { /// Associates an I/O resource with the reactor instance that drives it....
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { self.clear_readiness(ev); } Err(e) => return Poll::Ready(Err(e)), } } } pub(crate) fn try_io<R>( &self, interest: Interest, f: impl FnOnce() ...
{ return Poll::Ready(Ok(ret)); }
conditional_block
registration.rs
#![cfg_attr(not(feature = "net"), allow(dead_code))] use crate::io::driver::{Direction, Handle, Interest, ReadyEvent, ScheduledIo}; use crate::util::slab; use mio::event::Source; use std::io; use std::task::{Context, Poll}; cfg_io_driver! { /// Associates an I/O resource with the reactor instance that drives it....
<R>( &self, interest: Interest, f: impl FnOnce() -> io::Result<R>, ) -> io::Result<R> { let ev = self.shared.ready_event(interest); // Don't attempt the operation if the resource is not ready. if ev.ready.is_empty() { return Err(io::ErrorKind::WouldBlock....
try_io
identifier_name
enum-variants.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 mut a: Animal = Dog("Cocoa".to_string(), 37.2); a = Cat{ name: "Spotty".to_string(), weight: 2.7 }; // permuting the fields should work too let _c = Cat { weight: 3.1, name: "Spreckles".to_string() }; }
identifier_body
enum-variants.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 ...
{ Dog (String, f64), Cat { name: String, weight: f64 } } pub fn main() { let mut a: Animal = Dog("Cocoa".to_string(), 37.2); a = Cat{ name: "Spotty".to_string(), weight: 2.7 }; // permuting the fields should work too let _c = Cat { weight: 3.1, name: "Spreckles".to_string() }; }
Animal
identifier_name
enum-variants.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 ...
// permuting the fields should work too let _c = Cat { weight: 3.1, name: "Spreckles".to_string() }; }
let mut a: Animal = Dog("Cocoa".to_string(), 37.2); a = Cat{ name: "Spotty".to_string(), weight: 2.7 };
random_line_split
size-and-align.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> { a(T, int), b, } fn uhoh<T>(v: ~[clam<T>]) { match v[1] { a::<T>(ref t, ref u) => { debug!("incorrect"); debug!(u); fail!(); } b::<T> => { debug!("correct"); } } } pub fn main() { let v: ~[clam<int>] = ~[b::<int>, b::<int>, a::<int>(42, 17)]; uhoh::<int>(v); }
clam
identifier_name
size-and-align.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::<T> => { debug!("correct"); } } } pub fn main() { let v: ~[clam<int>] = ~[b::<int>, b::<int>, a::<int>(42, 17)]; uhoh::<int>(v); }
{ debug!("incorrect"); debug!(u); fail!(); }
conditional_block
size-and-align.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 ...
// -*- rust -*- enum clam<T> { a(T, int), b, } fn uhoh<T>(v: ~[clam<T>]) { match v[1] { a::<T>(ref t, ref u) => { debug!("incorrect"); debug!(u); fail!(); } b::<T> => { debug!("correct"); } } } pub fn main() { let v: ~[clam<int>] = ~[b::<int>, b::<int>, a::<int>(42, 17)]; uhoh::<int>(v)...
// except according to those terms.
random_line_split
regions-early-bound-used-in-bound-method.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 ...
<'a> { t: &'a isize } impl<'a> GetRef<'a> for Box<'a> { fn get(&self) -> &'a isize { self.t } } impl<'a> Box<'a> { fn add<'b,G:GetRef<'b>>(&self, g2: G) -> isize { *self.t + *g2.get() } } pub fn main() { let b1 = Box { t: &3 }; assert_eq!(b1.add(b1), 6); }
Box
identifier_name
regions-early-bound-used-in-bound-method.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn get(&self) -> &'a isize { self.t } } impl<'a> Box<'a> { fn add<'b,G:GetRef<'b>>(&self, g2: G) -> isize { *self.t + *g2.get() } } pub fn main() { let b1 = Box { t: &3 }; assert_eq!(b1.add(b1), 6); }
t: &'a isize } impl<'a> GetRef<'a> for Box<'a> {
random_line_split
aleph.rs
extern crate aleph; fn main() {} // use aleph::reader; // extern crate itertools; // use itertools::*; // extern crate ansi_term; // use ansi_term::Colour; // #[macro_use] // extern crate clap; // use clap::{App, AppSettings, SubCommand}; // use std::io::prelude::*; // fn main() { // let version = option_...
// .and_then(|f| aleph::tmp_eval(&mut env, f)) // .map(|f| Colour::Green.paint(f.to_string())) // .unwrap_or_else(|e| Colour::Red.paint(e))); // } // } // }
// println!("{}", // reader::read_string(input)
random_line_split
aleph.rs
extern crate aleph; fn
() {} // use aleph::reader; // extern crate itertools; // use itertools::*; // extern crate ansi_term; // use ansi_term::Colour; // #[macro_use] // extern crate clap; // use clap::{App, AppSettings, SubCommand}; // use std::io::prelude::*; // fn main() { // let version = option_env!("CARGO_PKG_VERSION").ex...
main
identifier_name
aleph.rs
extern crate aleph; fn main()
// use aleph::reader; // extern crate itertools; // use itertools::*; // extern crate ansi_term; // use ansi_term::Colour; // #[macro_use] // extern crate clap; // use clap::{App, AppSettings, SubCommand}; // use std::io::prelude::*; // fn main() { // let version = option_env!("CARGO_PKG_VERSION").expect(...
{}
identifier_body
eq_slice.rs
extern crate env_logger; extern crate must; use must::COLOR_ENV; use std::env; #[test] #[should_panic(expected ="Diff: | Index | Got | Expected | |-------|------|----------| | 0 | 1111 | 11 | | 2 | 3333 | 3 |")] fn array_failure()
/// See: https://github.com/rust-lang/rust/issues/38259 #[test] #[should_panic(expected = r#"Diff: | Index | Got | Expected | |-------|-------|----------| | 1 | "\na" | "b\n" |"#)] fn vec_failure() { let _ = env_logger::init(); env::set_var(COLOR_ENV, "none"); let err = must::eq(vec!["ABCDEFGHIZ...
{ let _ = env_logger::init(); env::set_var(COLOR_ENV, "none"); let err = must::eq([1111, 2222, 3333, 4444], [11, 2222, 3, 4444]).unwrap_err(); panic!("{}", err) }
identifier_body
eq_slice.rs
extern crate env_logger; extern crate must; use must::COLOR_ENV; use std::env; #[test] #[should_panic(expected ="Diff: | Index | Got | Expected | |-------|------|----------| | 0 | 1111 | 11 | | 2 | 3333 | 3 |")] fn
() { let _ = env_logger::init(); env::set_var(COLOR_ENV, "none"); let err = must::eq([1111, 2222, 3333, 4444], [11, 2222, 3, 4444]).unwrap_err(); panic!("{}", err) } /// See: https://github.com/rust-lang/rust/issues/38259 #[test] #[should_panic(expected = r#"Diff: | Index | Got | Expected | |-----...
array_failure
identifier_name
eq_slice.rs
extern crate env_logger; extern crate must; use must::COLOR_ENV; use std::env; #[test] #[should_panic(expected ="Diff: | Index | Got | Expected | |-------|------|----------| | 0 | 1111 | 11 | | 2 | 3333 | 3 |")] fn array_failure() { let _ = env_logger::init(); env::set_var(CO...
} /// See: https://github.com/rust-lang/rust/issues/38259 #[test] #[should_panic(expected = r#"Diff: | Index | Got | Expected | |-------|-------|----------| | 1 | "\na" | "b\n" |"#)] fn vec_failure() { let _ = env_logger::init(); env::set_var(COLOR_ENV, "none"); let err = must::eq(vec!["ABCDEFGHI...
let err = must::eq([1111, 2222, 3333, 4444], [11, 2222, 3, 4444]).unwrap_err(); panic!("{}", err)
random_line_split
error.rs
// Copyright (c) 2016, Mikkel Kroman <mk@uplink.io> // All rights reserved. // // 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, mo...
{ ApiError(String), JsonError(serde_json::Error), HttpError(hyper::Error), InvalidFilter(String), Io(io::Error), TrackNotDownloadable, TrackNotStreamable, } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Error::Jso...
Error
identifier_name
error.rs
// Copyright (c) 2016, Mikkel Kroman <mk@uplink.io> // All rights reserved. // // 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, mo...
Error::HttpError(ref error) => error.description(), Error::JsonError(ref error) => error.description(), Error::TrackNotStreamable => "track is not streamable", Error::TrackNotDownloadable => "track is not downloadable", Error::Io(ref error) => error.descriptio...
random_line_split
logger.rs
extern crate env_logger; extern crate log_panics; extern crate log; #[cfg(target_os = "android")] extern crate android_logger; use self::env_logger::Builder as EnvLoggerBuilder; use self::log::{LevelFilter, Level}; use std::env; use std::io::Write; #[cfg(target_os = "android")] use self::android_logger::Filter; use lo...
fn log(&self, record: &Record) { let log_cb = self.log; let level = record.level() as u32; let target = CString::new(record.target()).unwrap(); let message = CString::new(record.args().to_string()).unwrap(); let module_path = record.module_path().map(|a| CString::new(a).u...
{ if let Some(enabled_cb) = self.enabled { let level = metadata.level() as u32; let target = CString::new(metadata.target()).unwrap(); enabled_cb(self.context, level, target.as_ptr(), ) } else { true } }
identifier_body
logger.rs
extern crate env_logger; extern crate log_panics; extern crate log; #[cfg(target_os = "android")] extern crate android_logger; use self::env_logger::Builder as EnvLoggerBuilder; use self::log::{LevelFilter, Level}; use std::env; use std::io::Write; #[cfg(target_os = "android")] use self::android_logger::Filter; use lo...
(_context: *const c_void) { log::logger().flush() } } fn get_level(level: u32) -> Level { match level { 1 => Level::Error, 2 => Level::Warn, 3 => Level::Info, 4 => Level::Debug, 5 => Level::Trace, _ => unreachable!(), } } #[macro_export] macro_rules!...
flush
identifier_name