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
plugin.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 ...
F: FnOnce(&mut BTreeMap<Name, Option<Name>>) -> T, { REGISTERED_DIAGNOSTICS.with(move |slot| { f(&mut *slot.borrow_mut()) }) } fn with_used_diagnostics<T, F>(f: F) -> T where F: FnOnce(&mut BTreeMap<Name, Span>) -> T, { USED_DIAGNOSTICS.with(move |slot| { f(&mut *slot.borrow_mut()) ...
fn with_registered_diagnostics<T, F>(f: F) -> T where
random_line_split
plugin.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 ...
"__register_diagnostic_".to_string() + &token::get_ident(*code) )[])); MacItems::new(vec![quote_item!(ecx, mod $sym {}).unwrap()].into_iter()) } pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt, span: Span, ...
{ let (code, description) = match token_tree { [ast::TtToken(_, token::Ident(ref code, _))] => { (code, None) }, [ast::TtToken(_, token::Ident(ref code, _)), ast::TtToken(_, token::Comma), ast::TtToken(_, token::Literal(token::StrRaw(description, _), None))] => ...
identifier_body
samba.rs
use std::fs::{create_dir, File}; use std::path::Path; use std::io::Write; use std::fmt::Write as FmtWrite; use users::get_user_by_name; use nix::unistd::chown; use common::config::SambaConfig; pub fn is_installed() -> bool { Path::new("/usr/sbin/smbd").is_file() } pub fn setup(tmp: &Path, samba: &SambaConfig, u...
smb passwd file={0}/smbpasswd security = user map to guest = Bad User load printers = no printing = bsd disable spoolss = yes usershare max shares = 0 create mask = 0644 [qemu] path={1} read only=no guest ok=yes force user={2} "#, samba_folder.display(), samba.path, samba.user) ....
{ assert!(is_installed(), "Optional samba dependency not installed!"); let user = get_user_by_name(&samba.user).unwrap(); let samba_cfg = tmp.join("smbd.conf"); let mut smbd_conf = File::create(&samba_cfg).expect("Failed to create smbd conf"); let samba_folder = tmp.join("samba"); write!(smbd_...
identifier_body
samba.rs
use std::fs::{create_dir, File}; use std::path::Path; use std::io::Write; use std::fmt::Write as FmtWrite; use users::get_user_by_name; use nix::unistd::chown; use common::config::SambaConfig; pub fn is_installed() -> bool { Path::new("/usr/sbin/smbd").is_file() } pub fn
(tmp: &Path, samba: &SambaConfig, usernet: &mut String) { assert!(is_installed(), "Optional samba dependency not installed!"); let user = get_user_by_name(&samba.user).unwrap(); let samba_cfg = tmp.join("smbd.conf"); let mut smbd_conf = File::create(&samba_cfg).expect("Failed to create smbd conf"); ...
setup
identifier_name
samba.rs
use std::fs::{create_dir, File}; use std::path::Path; use std::io::Write; use std::fmt::Write as FmtWrite; use users::get_user_by_name; use nix::unistd::chown; use common::config::SambaConfig; pub fn is_installed() -> bool { Path::new("/usr/sbin/smbd").is_file() } pub fn setup(tmp: &Path, samba: &SambaConfig, u...
map to guest = Bad User load printers = no printing = bsd disable spoolss = yes usershare max shares = 0 create mask = 0644 [qemu] path={1} read only=no guest ok=yes force user={2} "#, samba_folder.display(), samba.path, samba.user) .expect("Failed to write smbd conf"); crea...
cache directory={0} ncalrpc dir={0}/ncalrpc log file={0}/log.smbd smb passwd file={0}/smbpasswd security = user
random_line_split
grad.rs
#pragma version(1) #pragma rs java_package_name(com.xjt.crazypic.edit.filters) #define MAX_POINTS 16 uint32_t inputWidth; uint32_t inputHeight; static const float Rf = 0.2999f; static const float Gf = 0.587f; static const float Bf = 0.114f; //static const float size_scale = 0.01f; typedef struct { rs_matrix3x3 c...
// generated data static UPointData grads[MAX_POINTS]; void setupGradParams() { int k = 0; for (int i = 0; i < MAX_POINTS; i++) { if (!mask[i]) { continue; } float x1 = xPos1[i]; float y1 = yPos1[i]; float x2 = xPos2[i]; float y2 = yPos2[i]; float denom = (y...
int contrast[MAX_POINTS]; int saturation[MAX_POINTS];
random_line_split
grad.rs
#pragma version(1) #pragma rs java_package_name(com.xjt.crazypic.edit.filters) #define MAX_POINTS 16 uint32_t inputWidth; uint32_t inputHeight; static const float Rf = 0.2999f; static const float Gf = 0.587f; static const float Bf = 0.114f; //static const float size_scale = 0.01f; typedef struct { rs_matrix3x3 c...
grads[k].dy = (y1 - y2) / denom; grads[k].dx = (x1 - x2) / denom; grads[k].off = (y2 * y2 + x2 * x2 - x1 * x2 - y1 * y2) / denom; float S = 1+saturation[i]/100.f; float MS = 1-S; float Rt = Rf * MS; float Gt = Gf * MS; float Bt = Bf * MS; float b = 1+brightness[i...
{ continue; }
conditional_block
crypto.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::cell::DOMRefCell; use dom::bindings::codegen::Bindings::CryptoBinding; use dom::bindings::codeg...
(input: *mut JSObject) -> bool { match unsafe { JS_GetArrayBufferViewType(input) } { Type::Uint8 | Type::Uint8Clamped | Type::Int8 | Type::Uint16 | Type::Int16 | Type::Uint32 | Type::Int32 => true, _ => false } }
is_integer_buffer
identifier_name
crypto.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::cell::DOMRefCell; use dom::bindings::codegen::Bindings::CryptoBinding; use dom::bindings::codegen::Bindings::CryptoBinding::CryptoMethods; use dom::bindings::error::{Error, Fallible}; use dom::bindings::global::GlobalRef; use dom::bindin...
random_line_split
crypto.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::cell::DOMRefCell; use dom::bindings::codegen::Bindings::CryptoBinding; use dom::bindings::codeg...
if!is_integer_buffer(input) { return Err(Error::TypeMismatch); } if length > 65536 { return Err(Error::QuotaExceeded); } let mut buffer = unsafe { slice::from_raw_parts_mut(data, length as usize) }; self.rng.borrow_mut().fill...
{ return Err(Error::Type("Argument to Crypto.getRandomValues is not an ArrayBufferView".to_owned())); }
conditional_block
timer.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 ...
(active: &mut Vec<Box<Inner>>, dead: &mut Vec<(uint, Box<Inner>)>) { if active.is_empty() { return } let mut timer = active.remove(0); let mut cb = timer.cb.take().unwrap(); cb.call(); if timer.repeat { timer.cb = Some(cb); timer.target += t...
signal
identifier_name
timer.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 ...
} } pub fn oneshot(&mut self, msecs: u64, cb: Box<Callback + Send>) { let now = now(); let mut inner = self.inner(); inner.repeat = false; inner.cb = Some(cb); inner.interval = msecs; inner.target = now + msecs; HELPER.send(NewTimer(inner)); ...
{ panic!("failed to sleep, but not because of EINTR?"); }
conditional_block
timer.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 mut to_sleep = libc::timespec { tv_sec: (ms / 1000) as libc::time_t, tv_nsec: ((ms % 1000) * 1000000) as libc::c_long, }; while unsafe { libc::nanosleep(&to_sleep, &mut to_sleep) }!= 0 { if os::errno() as int!= libc::EINTR as int { panic!("...
pub fn sleep(&mut self, ms: u64) { let mut inner = self.inner(); inner.cb = None; // cancel any previous request self.inner = Some(inner);
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/. */ //! An actor-based remote devtools server implementation. Only tested with //! nightly Firefox versions at time of...
Vacant(entry) => { let actor_name = actors.new_name("netevent"); let actor = NetworkEventActor::new(actor_name.clone()); entry.insert(actor_name.clone()); actors.register(box actor); actor_name } } } ...
{ //TODO: Delete from map like Firefox does? name.into_mut().clone() }
conditional_block
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/. */ //! An actor-based remote devtools server implementation. Only tested with //! nightly Firefox versions at time of...
// We need separate actor representations for each script global that exists; // clients can theoretically connect to multiple globals simultaneously. // TODO: move this into the root or tab modules? fn handle_new_global(actors: Arc<Mutex<ActorRegistry>>, ids: (PipelineId, Opt...
{ let actors = actors.lock().unwrap(); let framerate_actor = actors.find::<FramerateActor>(&actor_name); framerate_actor.add_tick(tick); }
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/. */ //! An actor-based remote devtools server implementation. Only tested with //! nightly Firefox versions at time of...
ConsoleMessage::LogMessage { message, filename, lineNumber, columnNumber, } => { let msg = ConsoleAPICall { from: console_actor.name.clone(), __type__: "consoleAPICall".to_stri...
let console_actor_name = find_console_actor(actors.clone(), id, actor_pipelines); let actors = actors.lock().unwrap(); let console_actor = actors.find::<ConsoleActor>(&console_actor_name); match console_message {
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/. */ //! An actor-based remote devtools server implementation. Only tested with //! nightly Firefox versions at time of...
(actors: Arc<Mutex<ActorRegistry>>, actor_name: String, tick: f64) { let actors = actors.lock().unwrap(); let framerate_actor = actors.find::<FramerateActor>(&actor_name); framerate_actor.add_tick(tick); } // We need separate actor representations for each script global that exists; ...
handle_framerate_tick
identifier_name
documentfragment.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::DocumentFragmentBinding; use dom::bindings::codegen::Bindings::DocumentFragm...
}
{ let root: JSRef<Node> = NodeCast::from_ref(self); root.query_selector_all(selectors) }
identifier_body
documentfragment.rs
/* This Source Code Form is subject to the terms of the Mozilla Public
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::InheritTypes::DocumentFragmentDerived; use dom::bindings::codegen::InheritTypes::{ElementCast, NodeCast}; use dom::bindings::codegen::UnionTypes::NodeOrString; use dom::bindings::js::{JSRef, Rootable, Temporary}; use dom::bi...
* 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::DocumentFragmentBinding; use dom::bindings::codegen::Bindings::DocumentFragmentBinding::DocumentFragmentMethods;
random_line_split
documentfragment.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::DocumentFragmentBinding; use dom::bindings::codegen::Bindings::DocumentFragm...
(self) -> Temporary<HTMLCollection> { let window = window_from_node(self).root(); HTMLCollection::children(window.r(), NodeCast::from_ref(self)) } // https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild fn GetFirstElementChild(self) -> Option<Temporary<Element>> { NodeCast:...
Children
identifier_name
buttons.rs
/* * Copyright (c) 2017-2020 Boucher, Antoni <bouanto@zoho.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, ...
{ Decrement, Increment, Quit, } // Create the structure that holds the widgets used in the view. #[derive(Clone)] struct Widgets { counter_label: Label, minus_button: Button, plus_button: Button, window: Window, } struct Win { model: Model, widgets: Widgets, } impl Update for Win...
Msg
identifier_name
buttons.rs
/* * Copyright (c) 2017-2020 Boucher, Antoni <bouanto@zoho.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, ...
use gtk::{ Button, Inhibit, Label, Window, WindowType, prelude::ButtonExt, prelude::ContainerExt, prelude::LabelExt, prelude::WidgetExt, }; use gtk::Orientation::Vertical; use relm_derive::Msg; use relm::{connect, Relm, Update, Widget, WidgetTest}; struct Model { counter: i32, }...
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
random_line_split
if_same_then_else.rs
#![warn(clippy::if_same_then_else)] #![allow( clippy::blacklisted_name, clippy::eq_op, clippy::never_loop, clippy::no_effect, clippy::unused_unit, clippy::zero_divided_by_zero, clippy::branches_sharing_code )] struct Foo { bar: u8, } fn foo() -> bool { unimplemented!() } fn if_sam...
() {}
main
identifier_name
if_same_then_else.rs
#![warn(clippy::if_same_then_else)] #![allow( clippy::blacklisted_name, clippy::eq_op, clippy::never_loop, clippy::no_effect, clippy::unused_unit, clippy::zero_divided_by_zero, clippy::branches_sharing_code )] struct Foo { bar: u8, } fn foo() -> bool { unimplemented!() } fn if_sam...
if true { Foo { bar: 42 }; } else { Foo { bar: 43 }; } if true { (); } else { () } if true { 0..10; } else { 0..=10; } if true { foo(); foo(); } else { foo(); } let _ = if true { 0.0 ...
{ if true { Foo { bar: 42 }; 0..10; ..; 0..; ..10; 0..=10; foo(); } else { //~ ERROR same body as `if` block Foo { bar: 42 }; 0..10; ..; 0..; ..10; 0..=10; foo(); }
identifier_body
if_same_then_else.rs
#![warn(clippy::if_same_then_else)] #![allow( clippy::blacklisted_name, clippy::eq_op, clippy::never_loop, clippy::no_effect, clippy::unused_unit, clippy::zero_divided_by_zero, clippy::branches_sharing_code )] struct Foo { bar: u8, } fn foo() -> bool { unimplemented!() } fn if_sam...
let _ = match 42 { 42 => 1, a if a > 0 => 2, 10..=15 => 3, _ => 4, }; } else if false { foo(); } else if foo() { let _ = match 42 { 42 => 1, a if a > 0 => 2, 10..=15 => 3, _ => 4, ...
} bar + 1; } if true {
random_line_split
if_same_then_else.rs
#![warn(clippy::if_same_then_else)] #![allow( clippy::blacklisted_name, clippy::eq_op, clippy::never_loop, clippy::no_effect, clippy::unused_unit, clippy::zero_divided_by_zero, clippy::branches_sharing_code )] struct Foo { bar: u8, } fn foo() -> bool { unimplemented!() } fn if_sam...
; if true { foo(); } let _ = if true { 42 } else { //~ ERROR same body as `if` block 42 }; if true { let bar = if true { 42 } else { 43 }; while foo() { break; } bar + 1; } else { //~ ERROR same body as `...
{ f32::NAN }
conditional_block
lib.rs
extern crate futures; extern crate rpassword; extern crate ethcore_util as util; extern crate bigint; extern crate parity_rpc as rpc; extern crate parity_rpc_client as client; use rpc::signer::{U256, ConfirmationRequest}; use client::signer_client::SignerRpc; use std::io::{Write, BufRead, BufReader, stdout, stdin}; ...
// cmds pub fn signer_list( signerport: u16, authfile: PathBuf ) -> Result<String, String> { let addr = &format!("ws://127.0.0.1:{}", signerport); let mut signer = SignerRpc::new(addr, &authfile).map_err(|err| { format!("{:?}", err) })?; list_transactions(&mut signer) } pub fn signer_reject( id: Option<usize>...
random_line_split
lib.rs
extern crate futures; extern crate rpassword; extern crate ethcore_util as util; extern crate bigint; extern crate parity_rpc as rpc; extern crate parity_rpc_client as client; use rpc::signer::{U256, ConfirmationRequest}; use client::signer_client::SignerRpc; use std::io::{Write, BufRead, BufReader, stdout, stdin}; ...
Ok(ref reqs) => { Ok(format!("Transaction queue:\n{}", reqs .iter() .map(|r| format!("{}", r)) .collect::<Vec<String>>() .join("\n"))) } Err(err) => { Err(format!("error: {:?}", err)) } } }).map_err(|err| { format!("{:?}", err) }).wait()? } fn sign_transaction...
{ Ok("No transactions in signing queue".to_owned()) }
conditional_block
lib.rs
extern crate futures; extern crate rpassword; extern crate ethcore_util as util; extern crate bigint; extern crate parity_rpc as rpc; extern crate parity_rpc_client as client; use rpc::signer::{U256, ConfirmationRequest}; use client::signer_client::SignerRpc; use std::io::{Write, BufRead, BufReader, stdout, stdin}; ...
fn reject_transaction( signer: &mut SignerRpc, id: U256) -> Result<String, String> { signer.reject_request(id).map(|res| { match res { Ok(true) => Ok(format!("Rejected transaction id {:#x}", id)), Ok(false) => Err(format!("No such request")), Err(e) => Err(format!("{:?}", e)), } }).map_err(|err| { f...
{ signer.confirm_request(id, None, None, None, password).map(|res| { match res { Ok(u) => Ok(format!("Signed transaction id: {:#x}", u)), Err(e) => Err(format!("{:?}", e)), } }).map_err(|err| { format!("{:?}", err) }).wait()? }
identifier_body
lib.rs
extern crate futures; extern crate rpassword; extern crate ethcore_util as util; extern crate bigint; extern crate parity_rpc as rpc; extern crate parity_rpc_client as client; use rpc::signer::{U256, ConfirmationRequest}; use client::signer_client::SignerRpc; use std::io::{Write, BufRead, BufReader, stdout, stdin}; ...
( id: Option<usize>, signerport: u16, authfile: PathBuf ) -> Result<String, String> { let id = id.ok_or(format!("id required for signer reject"))?; let addr = &format!("ws://127.0.0.1:{}", signerport); let mut signer = SignerRpc::new(addr, &authfile).map_err(|err| { format!("{:?}", err) })?; reject_transaction(...
signer_reject
identifier_name
view_wrapper.rs
use crate::direction::Direction; use crate::event::{AnyCb, Event, EventResult}; use crate::rect::Rect; use crate::view::{Selector, View}; use crate::Printer; use crate::Vec2; /// Generic wrapper around a view. /// /// This trait is a shortcut to implement `View` on a type by forwarding /// calls to a wrapped view. ///...
fn layout(&mut self, size: Vec2) { self.wrap_layout(size); } fn take_focus(&mut self, source: Direction) -> bool { self.wrap_take_focus(source) } fn call_on_any<'a>( &mut self, selector: &Selector<'_>, callback: AnyCb<'a>, ) { self.wrap_call_on...
{ self.wrap_on_event(ch) }
identifier_body
view_wrapper.rs
use crate::direction::Direction; use crate::event::{AnyCb, Event, EventResult}; use crate::rect::Rect; use crate::view::{Selector, View}; use crate::Printer; use crate::Vec2; /// Generic wrapper around a view. /// /// This trait is a shortcut to implement `View` on a type by forwarding /// calls to a wrapped view. ///...
/// Wraps the `on_event` method. fn wrap_on_event(&mut self, ch: Event) -> EventResult { self.with_view_mut(|v| v.on_event(ch)) .unwrap_or(EventResult::Ignored) } /// Wraps the `layout` method. fn wrap_layout(&mut self, size: Vec2) { self.with_view_mut(|v| v.layout(size)...
random_line_split
view_wrapper.rs
use crate::direction::Direction; use crate::event::{AnyCb, Event, EventResult}; use crate::rect::Rect; use crate::view::{Selector, View}; use crate::Printer; use crate::Vec2; /// Generic wrapper around a view. /// /// This trait is a shortcut to implement `View` on a type by forwarding /// calls to a wrapped view. ///...
(&mut self, req: Vec2) -> Vec2 { self.wrap_required_size(req) } fn on_event(&mut self, ch: Event) -> EventResult { self.wrap_on_event(ch) } fn layout(&mut self, size: Vec2) { self.wrap_layout(size); } fn take_focus(&mut self, source: Direction) -> bool { self.w...
required_size
identifier_name
error.rs
//! Postgres errors use std::collections::HashMap; use std::from_str::FromStr; use std::io::IoError; use std::fmt; use openssl::ssl::error::SslError; use phf::PhfMap; use types::PostgresType; macro_rules! make_errors( ($($code:expr => $error:ident),+) => ( /// SQLSTATE error codes #[deriving(Par...
= fields.move_iter().collect(); PostgresDbError { severity: map.pop(&('S' as u8)).unwrap(), code: PostgresSqlState::from_code(map.pop(&('C' as u8)).unwrap().as_slice()), message: map.pop(&('M' as u8)).unwrap(), detail: map.pop(&('D' as u8)), hint: map....
_>
identifier_name
error.rs
//! Postgres errors use std::collections::HashMap; use std::from_str::FromStr; use std::io::IoError; use std::fmt; use openssl::ssl::error::SslError; use phf::PhfMap; use types::PostgresType; macro_rules! make_errors( ($($code:expr => $error:ident),+) => ( /// SQLSTATE error codes #[deriving(Par...
"57P04" => DatabaseDropped, // Class 58 — System Error "58000" => SystemError, "58030" => IoError, "58P01" => UndefinedFile, "58P02" => DuplicateFile, // Class F0 — Configuration File Error "F0000" => ConfigFileError, "F0001" => LockFileExists, // Class HV — Foreign Data Wrapp...
"57014" => QueryCanceled, "57P01" => AdminShutdown, "57P02" => CrashShutdown, "57P03" => CannotConnectNow,
random_line_split
page.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
(&self) -> &ByteBufferPtr { match self { &Page::DataPage { ref buf,.. } => &buf, &Page::DataPageV2 { ref buf,.. } => &buf, &Page::DictionaryPage { ref buf,.. } => &buf, } } /// Returns number of values in this page. pub fn num_values(&self) -> u32 { ...
buffer
identifier_name
page.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
/// Returns page type. pub fn page_type(&self) -> PageType { self.compressed_page.page_type() } /// Returns underlying page with potentially compressed buffer. pub fn compressed_page(&self) -> &Page { &self.compressed_page } /// Returns uncompressed size in bytes. pub...
{ Self { compressed_page, uncompressed_size, } }
identifier_body
page.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
pub trait PageIterator: Iterator<Item = Result<Box<PageReader>>> { /// Get schema of parquet file. fn schema(&mut self) -> Result<SchemaDescPtr>; /// Get column schema of this page iterator. fn column_schema(&mut self) -> Result<ColumnDescPtr>; } #[cfg(test)] mod tests { use super::*; #[test]...
/// An iterator over pages of some specific column in a parquet file.
random_line_split
assignment.rs
// Test assignment fn main()
fn break_meee() { { (block_start, block_size, margin_block_start, margin_block_end) = match (block_start, block_end, block_size) { x => 1, _ => 2, }; } }
{ let some_var: Type; let mut mutable; let variable = AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA::BBBBBBBBBBBBBBBBBBBBBB::CCCCCCCCCCCCCCCCCCCCCC::EEEEEE; variable = LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG; let single_line_fit = DDDDDDD...
identifier_body
assignment.rs
// Test assignment fn main() { let some_var: Type; let mut mutable; let variable = AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA::BBBBBBBBBBBBBBBBBBBBBB::CCCCCCCCCCCCCCCCCCCCCC::EEEEEE; variable = LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG; ...
() { { (block_start, block_size, margin_block_start, margin_block_end) = match (block_start, block_end, block_size) { x => 1, _ => 2, }; } }
break_meee
identifier_name
assignment.rs
// Test assignment fn main() { let some_var: Type; let mut mutable; let variable = AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA::BBBBBBBBBBBBBBBBBBBBBB::CCCCCCCCCCCCCCCCCCCCCC::EEEEEE;
single_line_fit = 5; single_lit_fit >>= 10; } fn break_meee() { { (block_start, block_size, margin_block_start, margin_block_end) = match (block_start, block_end, block_size) { x => 1, _ => 2, }; } }
variable = LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG; let single_line_fit = DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD;
random_line_split
cmp.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::{cmp}; #[test] fn min() { test!(cmp::min(0, 1) == 0); test!(cmp::min(0, 0) == 0); }
#[test] fn min_mut() { test!(cmp::min_mut(&mut 0, &mut 1) == &mut 0); test!(cmp::min_mut(&mut 0, &mut 0) == &mut 0); } #[test] fn max() { test!(cmp::max(0, 1) == 1); test!(cmp::max(0, 0) == 0); } #[test] fn max_ref() { test!(cmp::max_ref(&0, &1) == &1); test!(cmp::max_ref(&0, &0) == &0); } #...
#[test] fn min_ref() { test!(cmp::min_ref(&0, &1) == &0); test!(cmp::min_ref(&0, &0) == &0); }
random_line_split
cmp.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::{cmp}; #[test] fn min() { test!(cmp::min(0, 1) == 0); test!(cmp::min(0, 0) == 0); } #[test] fn min...
#[test] fn max_ref() { test!(cmp::max_ref(&0, &1) == &1); test!(cmp::max_ref(&0, &0) == &0); } #[test] fn max_mut() { test!(cmp::max_mut(&mut 0, &mut 1) == &mut 1); test!(cmp::max_mut(&mut 0, &mut 0) == &mut 0); }
{ test!(cmp::max(0, 1) == 1); test!(cmp::max(0, 0) == 0); }
identifier_body
cmp.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::{cmp}; #[test] fn min() { test!(cmp::min(0, 1) == 0); test!(cmp::min(0, 0) == 0); } #[test] fn min...
() { test!(cmp::max_mut(&mut 0, &mut 1) == &mut 1); test!(cmp::max_mut(&mut 0, &mut 0) == &mut 0); }
max_mut
identifier_name
scheduler.rs
use std::collections::{HashSet, VecDeque}; use std::io; use std::path::Path; use core::{FNV, Field, Key, TypeConstraint}; use graph::{EntryId, Graph}; use nodes::{Complete, Node, Runnable, State}; use selectors::{Selector, SelectDependencies}; use tasks::Tasks; /** * Represents the state of an execution of (a subgr...
pub fn root_states(&self) -> Vec<(&Key, &TypeConstraint, Option<&Complete>)> { self.roots.iter() .map(|root| { let state = self.graph.entry(root).and_then(|e| e.state()); (root.subject(), root.product(), state) }) .collect() } pub fn add_root_select(&mut self, subject: Key, ...
{ self.roots.clear(); self.candidates.clear(); self.outstanding.clear(); }
identifier_body
scheduler.rs
use std::collections::{HashSet, VecDeque}; use std::io; use std::path::Path; use core::{FNV, Field, Key, TypeConstraint}; use graph::{EntryId, Graph}; use nodes::{Complete, Node, Runnable, State}; use selectors::{Selector, SelectDependencies}; use tasks::Tasks; /** * Represents the state of an execution of (a subgr...
* Attempt to run a step with the currently available dependencies of the given Node. If * a step runs, the new State of the Node will be returned. */ fn attempt_step(&self, id: EntryId) -> Option<State<Node>> { if!self.graph.is_ready_entry(id) { return None; } // Run a step. let entry ...
random_line_split
scheduler.rs
use std::collections::{HashSet, VecDeque}; use std::io; use std::path::Path; use core::{FNV, Field, Key, TypeConstraint}; use graph::{EntryId, Graph}; use nodes::{Complete, Node, Runnable, State}; use selectors::{Selector, SelectDependencies}; use tasks::Tasks; /** * Represents the state of an execution of (a subgr...
, None => // Not ready to step. continue, } } self.runnable.clear(); ready } }
{ // Add the new dependencies. self.graph.add_dependencies(entry_id, w); let ref graph = self.graph; let mut incomplete_deps = self.graph.entry_for_id(entry_id).dependencies().iter() .map(|&d| graph.entry_for_id(d)) .filter(|e| !e.is_comple...
conditional_block
scheduler.rs
use std::collections::{HashSet, VecDeque}; use std::io; use std::path::Path; use core::{FNV, Field, Key, TypeConstraint}; use graph::{EntryId, Graph}; use nodes::{Complete, Node, Runnable, State}; use selectors::{Selector, SelectDependencies}; use tasks::Tasks; /** * Represents the state of an execution of (a subgr...
(&self) -> Vec<(&Key, &TypeConstraint, Option<&Complete>)> { self.roots.iter() .map(|root| { let state = self.graph.entry(root).and_then(|e| e.state()); (root.subject(), root.product(), state) }) .collect() } pub fn add_root_select(&mut self, subject: Key, product: TypeConstrain...
root_states
identifier_name
comment4.rs
// rustfmt-normalise_comments: false //! Doc comment fn test() { // comment // comment2 code(); /* leave this comment alone! * ok? */ /* Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a * diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam ...
{ }
identifier_body
comment4.rs
// rustfmt-normalise_comments: false //! Doc comment fn
() { // comment // comment2 code(); /* leave this comment alone! * ok? */ /* Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a * diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam * viverra nec consectetur ante hendrerit. Donec et m...
test
identifier_name
comment4.rs
// rustfmt-normalise_comments: false //! Doc comment
code(); /* leave this comment alone! * ok? */ /* Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a * diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam * viverra nec consectetur ante hendrerit. Donec et mollis dolor. * Praesent et ...
fn test() { // comment // comment2
random_line_split
sort.rs
use par_exec::{Executor, WorkAmount, JobIterBuild, ExecutorJobError, JobExecuteError}; use super::{Set, SetManager, merge}; pub trait SortManager { type S: Set; type E; fn sort<SF>(&mut self, set: &mut Self::S, pred: SF) -> Result<(), Self::E> where SF: Fn(usize, usize) -> bool; } pub trait RetrieveSortM...
<SE, SME, SRE> { Set(SE), SetManager(SME), Sort(SRE) } #[derive(Debug)] pub enum Error<ExecE, SE, SME, SRE> { EmptySet, Executor(ExecutorJobError<ExecE, JobExecuteError<SortError<SE, SME, SRE>, merge::Error<SE, SME>>>), } pub fn sort<Exec, LC, S, SetM, SortM, WA, F>(amount: WA, pred: F, exec: &mut...
SortError
identifier_name
sort.rs
use par_exec::{Executor, WorkAmount, JobIterBuild, ExecutorJobError, JobExecuteError}; use super::{Set, SetManager, merge}; pub trait SortManager { type S: Set; type E; fn sort<SF>(&mut self, set: &mut Self::S, pred: SF) -> Result<(), Self::E> where SF: Fn(usize, usize) -> bool; } pub trait RetrieveSortM...
Err(e) => Err(Error::Executor(e)), } } #[cfg(test)] mod tests { extern crate rand; use std::sync::Arc; use self::rand::Rng; use super::{RetrieveSortManager, RetrieveSetManager, sort}; use super::super::vec; use par_exec::{Executor, WorkAmount}; use par_exec::par::{ParallelExecu...
Ok(None) => Err(Error::EmptySet), Ok(Some(sorted_set)) => Ok(sorted_set),
random_line_split
simd-generics.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...
(f32, f32, f32, f32); fn add<T: ops::Add<Output=T>>(lhs: T, rhs: T) -> T { lhs + rhs } impl ops::Add for f32x4 { type Output = f32x4; fn add(self, rhs: f32x4) -> f32x4 { self + rhs } } pub fn main() { let lr = f32x4(1.0f32, 2.0f32, 3.0f32, 4.0f32); // lame-o let f32x4(x, y, z, w...
f32x4
identifier_name
simd-generics.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. //
// except according to those terms. #![feature(simd)] use std::ops; #[simd] #[derive(Copy, Clone)] struct f32x4(f32, f32, f32, f32); fn add<T: ops::Add<Output=T>>(lhs: T, rhs: T) -> T { lhs + rhs } impl ops::Add for f32x4 { type Output = f32x4; fn add(self, rhs: f32x4) -> f32x4 { self + rhs ...
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed
random_line_split
simd-generics.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...
impl ops::Add for f32x4 { type Output = f32x4; fn add(self, rhs: f32x4) -> f32x4 { self + rhs } } pub fn main() { let lr = f32x4(1.0f32, 2.0f32, 3.0f32, 4.0f32); // lame-o let f32x4(x, y, z, w) = add(lr, lr); assert_eq!(x, 2.0f32); assert_eq!(y, 4.0f32); assert_eq!(z, 6....
{ lhs + rhs }
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 ...
impl<'a,A> Drop for Finallyalizer<'a,A> { #[inline] fn drop(&mut self) { (self.dtor)(self.mutate); } } #[test] fn test_success() { let mut i = 0; try_finally( &mut i, (), |i, ()| { *i = 10; }, |i| { assert!(!failing()); ass...
#[unsafe_destructor]
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 ...
() { let closure: || -> int = || 10; let i = closure.finally(|| { }); assert_eq!(i, 10); } #[test] fn test_compact() { fn do_some_fallible_work() {} fn but_always_run_this_function() { } do_some_fallible_work.finally( but_always_run_this_function); }
test_retval
identifier_name
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 ...
#[test] #[should_fail] fn test_fail() { let mut i = 0; try_finally( &mut i, (), |i, ()| { *i = 10; fail!(); }, |i| { assert!(failing()); assert_eq!(*i, 10); }) } #[test] fn test_retval() { let closure: || -> int = || ...
{ let mut i = 0; try_finally( &mut i, (), |i, ()| { *i = 10; }, |i| { assert!(!failing()); assert_eq!(*i, 10); *i = 20; }); assert_eq!(i, 20); }
identifier_body
main.rs
#![crate_type="staticlib"] #![feature(alloc)] #![feature(allocator)] #![feature(arc_counts)] #![feature(augmented_assignments)] #![feature(asm)] #![feature(box_syntax)] #![feature(collections)] #![feature(const_fn)] #![feature(core_intrinsics)] #![feature(core_str_ext)] #![feature(core_slice_ext)] #![feature(fnbox)] #!...
/// Common std-like functionality #[macro_use] pub mod common; #[macro_use] pub mod macros; /// Allocation pub mod alloc_system; /// ACPI pub mod acpi; /// Disk drivers pub mod disk; /// Various drivers pub mod drivers; /// Environment pub mod env; /// Filesystems pub mod fs; /// Various graphical methods pub mod graph...
pub use system::externs::*;
random_line_split
main.rs
#![crate_type="staticlib"] #![feature(alloc)] #![feature(allocator)] #![feature(arc_counts)] #![feature(augmented_assignments)] #![feature(asm)] #![feature(box_syntax)] #![feature(collections)] #![feature(const_fn)] #![feature(core_intrinsics)] #![feature(core_str_ext)] #![feature(core_slice_ext)] #![feature(fnbox)] #!...
: "intel", "volatile"); } else { asm!("sti" : : : : "intel", "volatile"); } context_switch(false); } } /// Event poll loop fn poll_loop() { loop { env().on_poll(); unsafe { ...
{ loop { asm!("cli" : : : : "intel", "volatile"); let mut halt = true; for i in env().contexts.lock().iter().skip(1) { if i.interrupted { halt = false; break; } } if halt { asm!("sti hlt...
identifier_body
main.rs
#![crate_type="staticlib"] #![feature(alloc)] #![feature(allocator)] #![feature(arc_counts)] #![feature(augmented_assignments)] #![feature(asm)] #![feature(box_syntax)] #![feature(collections)] #![feature(const_fn)] #![feature(core_intrinsics)] #![feature(core_str_ext)] #![feature(core_slice_ext)] #![feature(fnbox)] #!...
() { { let mut console = env().console.lock(); console.instant = false; } let mut cmd = String::new(); loop { loop { let mut console = env().console.lock(); match env().events.lock().pop_front() { Some(event) => { if co...
event_loop
identifier_name
get_backfill.rs
//! `GET /_matrix/federation/*/backfill/{roomId}` //! //! Endpoint to request more history from another homeserver. pub mod v1 { //! `/v1/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1backfillroomid use js_int::UInt; use ruma_common::{api::ruma_ap...
} impl Response { /// Creates a new `Response` with: /// * the `server_name` of the homeserver. /// * the timestamp in milliseconds of when this transaction started. /// * the list of persistent updates to rooms. pub fn new( origin: Box<ServerName>, ...
{ Self { room_id, v, limit } }
identifier_body
get_backfill.rs
//! `GET /_matrix/federation/*/backfill/{roomId}` //! //! Endpoint to request more history from another homeserver. pub mod v1 { //! `/v1/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1backfillroomid use js_int::UInt; use ruma_common::{api::ruma_ap...
/// POSIX timestamp in milliseconds on originating homeserver when this transaction started. pub origin_server_ts: MilliSecondsSinceUnixEpoch, /// List of persistent updates to rooms. pub pdus: Vec<Box<RawJsonValue>>, } } impl<'a> Request<'a> { /...
random_line_split
get_backfill.rs
//! `GET /_matrix/federation/*/backfill/{roomId}` //! //! Endpoint to request more history from another homeserver. pub mod v1 { //! `/v1/` ([spec]) //! //! [spec]: https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1backfillroomid use js_int::UInt; use ruma_common::{api::ruma_ap...
( origin: Box<ServerName>, origin_server_ts: MilliSecondsSinceUnixEpoch, pdus: Vec<Box<RawJsonValue>>, ) -> Self { Self { origin, origin_server_ts, pdus } } } }
new
identifier_name
raw.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 ...
{ pub data: *mut (), pub vtable: *mut (), } impl Copy for TraitObject {} /// This trait is meant to map equivalences between raw structs and their /// corresponding rust values. pub trait Repr<T> for Sized? { /// This function "unwraps" a rust value (without consuming it) into its raw /// struct repr...
TraitObject
identifier_name
raw.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 ...
pub env: *mut (), } impl Copy for Closure {} /// The representation of a Rust procedure (`proc()`) #[repr(C)] pub struct Procedure { pub code: *mut (), pub env: *mut (), } impl Copy for Procedure {} /// The representation of a Rust trait object. /// /// This struct does not have a `Repr` implementation ...
random_line_split
scale_button.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use libc::c_double; use cast::GTK_SCALEBUTTON; use ffi; pub trait ScaleButtonTrait: ::Widge...
(&self, value: f64) -> () { unsafe { ffi::gtk_scale_button_set_value(GTK_SCALEBUTTON(self.unwrap_widget()), value as c_double); } } fn get_value(&self) -> f64 { unsafe { ffi::gtk_scale_button_get_value(GTK_SCALEBUTTON(self.unwrap_widget())) as f64 } }...
set_value
identifier_name
scale_button.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use libc::c_double; use cast::GTK_SCALEBUTTON; use ffi; pub trait ScaleButtonTrait: ::Widge...
}
{ unsafe { ::Adjustment::wrap_pointer(ffi::gtk_scale_button_get_adjustment(GTK_SCALEBUTTON(self.unwrap_widget()))) } }
identifier_body
scale_button.rs
// Copyright 2013-2015, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use libc::c_double; use cast::GTK_SCALEBUTTON; use ffi; pub trait ScaleButtonTrait: ::Widge...
ffi::gtk_scale_button_get_value(GTK_SCALEBUTTON(self.unwrap_widget())) as f64 } } fn get_adjustment(&self) -> ::Adjustment { unsafe { ::Adjustment::wrap_pointer(ffi::gtk_scale_button_get_adjustment(GTK_SCALEBUTTON(self.unwrap_widget()))) } } }
} } fn get_value(&self) -> f64 { unsafe {
random_line_split
type-alias-impl-trait.rs
// run-pass
#![allow(unused_assignments)] #![allow(unused_variables)] #![feature(type_alias_impl_trait)] fn main() { assert_eq!(foo().to_string(), "foo"); assert_eq!(bar1().to_string(), "bar1"); assert_eq!(bar2().to_string(), "bar2"); let mut x = bar1(); x = bar2(); assert_eq!(my_iter(42u8).collect::<Vec<u...
#![allow(dead_code)]
random_line_split
type-alias-impl-trait.rs
// run-pass #![allow(dead_code)] #![allow(unused_assignments)] #![allow(unused_variables)] #![feature(type_alias_impl_trait)] fn main() { assert_eq!(foo().to_string(), "foo"); assert_eq!(bar1().to_string(), "bar1"); assert_eq!(bar2().to_string(), "bar2"); let mut x = bar1(); x = bar2(); assert...
// two definitions type Bar = impl std::fmt::Display; fn bar1() -> Bar { "bar1" } fn bar2() -> Bar { "bar2" } type MyIter<T> = impl Iterator<Item = T>; fn my_iter<T>(t: T) -> MyIter<T> { std::iter::once(t) } fn my_iter2<T>(t: T) -> MyIter<T> { std::iter::once(t) } // param names should not have ...
{ "foo" }
identifier_body
type-alias-impl-trait.rs
// run-pass #![allow(dead_code)] #![allow(unused_assignments)] #![allow(unused_variables)] #![feature(type_alias_impl_trait)] fn main() { assert_eq!(foo().to_string(), "foo"); assert_eq!(bar1().to_string(), "bar1"); assert_eq!(bar2().to_string(), "bar2"); let mut x = bar1(); x = bar2(); assert...
<U>(u: U) -> MyIter<U> { std::iter::once(u) } // param position should not have an effect! fn my_iter4<U, V>(_: U, v: V) -> MyIter<V> { std::iter::once(v) } // param names should not have an effect! type MyOtherIter<T> = impl Iterator<Item = T>; fn my_other_iter<U>(u: U) -> MyOtherIter<U> { std::iter::on...
my_iter3
identifier_name
run.rs
use agent::Crowd; use observer::{Observer, ProgressMeter, DiskWriter}; mod agent; mod geometry; mod observer; fn main() { let mut cells=Crowd::new(1); let tmax=10f64; let dt=0.0001; let mut t=0.0; for _ in range(0,(tmax/dt) as uint){ let new_cells=cells.evolve(dt); let obs_cell...
} } ); cells=new_cells; t+=dt; } }
obs2.see(st, &obs_cells);
random_line_split
run.rs
use agent::Crowd; use observer::{Observer, ProgressMeter, DiskWriter}; mod agent; mod geometry; mod observer; fn
() { let mut cells=Crowd::new(1); let tmax=10f64; let dt=0.0001; let mut t=0.0; for _ in range(0,(tmax/dt) as uint){ let new_cells=cells.evolve(dt); let obs_cells=cells; let st=t; spawn(proc() { let obs = ProgressMeter::new(tmax, 100); if obs.reque...
main
identifier_name
run.rs
use agent::Crowd; use observer::{Observer, ProgressMeter, DiskWriter}; mod agent; mod geometry; mod observer; fn main() { let mut cells=Crowd::new(1); let tmax=10f64; let dt=0.0001; let mut t=0.0; for _ in range(0,(tmax/dt) as uint){ let new_cells=cells.evolve(dt); let obs_cell...
} ); cells=new_cells; t+=dt; } }
{ obs2.see(st, &obs_cells); }
conditional_block
run.rs
use agent::Crowd; use observer::{Observer, ProgressMeter, DiskWriter}; mod agent; mod geometry; mod observer; fn main()
if obs2.request_at(st,dt) { obs2.see(st, &obs_cells); } } ); cells=new_cells; t+=dt; } }
{ let mut cells=Crowd::new(1); let tmax=10f64; let dt=0.0001; let mut t=0.0; for _ in range(0,(tmax/dt) as uint){ let new_cells=cells.evolve(dt); let obs_cells=cells; let st=t; spawn(proc() { let obs = ProgressMeter::new(tmax, 100); if obs.request_...
identifier_body
rtlsdr.rs
/* Copyright Ian Daniher, 2013, 2014. Distributed under the terms of the GPLv3. */ #![feature(libc)] #![feature(collections)] #![feature(core)] extern crate num; extern crate libc; use num::complex; use libc::{c_int, c_uint}; use std::sync::mpsc::{Receiver, Sender, channel}; use std::vec; use std::str; use std::ff...
(i: u8) -> f32 {i as f32/127.0 - 1.0} pub fn data_to_samples(data: Vec<u8>) -> Vec<complex::Complex<f32>> { data[0..].chunks(2).map(|i| complex::Complex{re:i2f(i[0]), im:i2f(i[1])}).collect() }
i2f
identifier_name
rtlsdr.rs
/* Copyright Ian Daniher, 2013, 2014. Distributed under the terms of the GPLv3. */ #![feature(libc)] #![feature(collections)] #![feature(core)] extern crate num; extern crate libc; use num::complex; use libc::{c_int, c_uint}; use std::sync::mpsc::{Receiver, Sender, channel}; use std::vec; use std::str; use std::ff...
i += 1; } return RtlSdrDev {bx: Arc::new(internal)}; } } pub fn clear_buffer(&self) { unsafe { let success = rtlsdr_reset_buffer(&(*self.bx)); assert_eq!(success, 0); } } pub fn set_frequency(&self, freq: u32) { unsafe { let success = rtlsdr_set_center_freq(&(*self.bx), freq); a...
{ panic!("no available devices"); }
conditional_block
rtlsdr.rs
/* Copyright Ian Daniher, 2013, 2014. Distributed under the terms of the GPLv3. */ #![feature(libc)] #![feature(collections)] #![feature(core)] extern crate num; extern crate libc; use num::complex; use libc::{c_int, c_uint}; use std::sync::mpsc::{Receiver, Sender, channel}; use std::vec; use std::str; use std::ff...
pub fn set_frequency(&self, freq: u32) { unsafe { let success = rtlsdr_set_center_freq(&(*self.bx), freq); assert_eq!(success, 0); } } pub fn set_gain(&self, v: u32) { unsafe { let success = rtlsdr_set_tuner_gain_mode(&(*self.bx), 1); assert_eq!(success, 0); let success = rtlsdr_set_tuner_gain(...
{ unsafe { let success = rtlsdr_reset_buffer(&(*self.bx)); assert_eq!(success, 0); } }
identifier_body
rtlsdr.rs
/* Copyright Ian Daniher, 2013, 2014. Distributed under the terms of the GPLv3. */ #![feature(libc)] #![feature(collections)] #![feature(core)] extern crate num; extern crate libc; use num::complex; use libc::{c_int, c_uint}; use std::sync::mpsc::{Receiver, Sender, channel}; use std::vec; use std::str; use std::ff...
unsafe { let mut i: u32 = 0; let internal: RtlSdrInternal = intrinsics::init(); 'tryDevices: loop { let success = rtlsdr_open(&internal, i); if success == 0 { break 'tryDevices } if i > get_device_count() { panic!("no available devices"); } i += 1; } retur...
pub fn open() -> RtlSdrDev {
random_line_split
server.rs
use chatterbox::*; use output::WavChatterboxOutput; use iron::prelude::*; use iron::status; use staticfile::Static; use mount::Mount; use router::Router; use url::percent_encoding::percent_decode; use iron::headers::{ContentLength, ContentType}; use iron::mime::{Mime, TopLevel, SubLevel}; use iron::modifiers::Header; u...
(backend: Arc<Box<Backend + Send + Sync>>) { let mut router = Router::new(); router .get("/synth/:query", move |req: &mut Request| synth(req, backend.clone())); let mut mount = Mount::new(); mount .mount("/api/", router) .mount("/", Static::new(Path::new("www"))); println...
run
identifier_name
server.rs
use chatterbox::*; use output::WavChatterboxOutput; use iron::prelude::*; use iron::status; use staticfile::Static; use mount::Mount; use router::Router; use url::percent_encoding::percent_decode; use iron::headers::{ContentLength, ContentType}; use iron::mime::{Mime, TopLevel, SubLevel}; use iron::modifiers::Header; u...
fn synth(req: &mut Request, backend: Arc<Box<Backend + Send + Sync>>) -> IronResult<Response> { let ref query = req.extensions.get::<Router>().unwrap().find("query").unwrap_or(""); let decoded_query = percent_decode(query.as_bytes()).decode_utf8().unwrap(); let mut buf = Cursor::new(Vec::new()); { let mut outp...
random_line_split
server.rs
use chatterbox::*; use output::WavChatterboxOutput; use iron::prelude::*; use iron::status; use staticfile::Static; use mount::Mount; use router::Router; use url::percent_encoding::percent_decode; use iron::headers::{ContentLength, ContentType}; use iron::mime::{Mime, TopLevel, SubLevel}; use iron::modifiers::Header; u...
pub fn run(backend: Arc<Box<Backend + Send + Sync>>) { let mut router = Router::new(); router .get("/synth/:query", move |req: &mut Request| synth(req, backend.clone())); let mut mount = Mount::new(); mount .mount("/api/", router) .mount("/", Static::new(Path::new("www"))); ...
{ let ref query = req.extensions.get::<Router>().unwrap().find("query").unwrap_or(""); let decoded_query = percent_decode(query.as_bytes()).decode_utf8().unwrap(); let mut buf = Cursor::new(Vec::new()); { let mut output = WavChatterboxOutput::new_for_mem(&mut buf); backend.synth(&decoded_query, &mut output);...
identifier_body
copies.rs
the same function call" } declare_clippy_lint! { /// ### What it does /// Checks for `if/else` with the same body as the *then* part /// and the *else* part. /// /// ### Why is this bad? /// This is probably a copy & paste error. /// /// ### Example /// ```ignore /// let foo = ...
Expr<'_>) -> u64 = &|expr| -> u64 { let mut h = SpanlessHash::new(cx); h.hash_expr(expr); h.finish() }; let eq: &dyn Fn(&&Expr<'_>, &&Expr<'_>) -> bool = &|&lhs, &rhs| -> bool { eq_expr_value(cx, lhs, rhs) }; for (i, j) in search_same(conds, hash, eq) { span_lint_and_note( ...
identifier_body
copies.rs
```ignore /// if foo() { /// … /// } else if foo() { // not linted /// … /// } /// ``` pub IFS_SAME_COND, correctness, "consecutive `if`s with the same condition" } declare_clippy_lint! { /// ### What it does /// Checks for consecutive `if`s with the same function c...
ateContext<'tcx>, /// The `HirId`s of defined values in the scanned statements defs: FxHashSet<HirId>, /// The Symbols of the defined symbols in the scanned statements def_symbols: FxHashSet<Symbol>, /// The `HirId`s of the used values uses: FxHashSet<HirId>, } impl<'a, 'tcx> UsedValueFinder...
'tcx> { cx: &'a L
identifier_name
copies.rs
```ignore /// if foo() { /// … /// } else if foo() { // not linted /// … /// } /// ``` pub IFS_SAME_COND, correctness, "consecutive `if`s with the same condition" } declare_clippy_lint! { /// ### What it does /// Checks for consecutive `if`s with the same function c...
); let moved_end = block .expr .map_or_else(|| block.stmts[block.stmts.len() - 1].span, |expr| expr.span) .source_callsite(); let moved_span = moved_start.to(moved_end); let moved_snipped = reindent_multiline(snippet(cx, moved_span, "_"), true, None); le...
block.stmts.len() - end_stmts].span } .source_callsite(
conditional_block
copies.rs
/// ```ignore /// if foo() { /// … /// } else if foo() { // not linted /// … /// } /// ``` pub IFS_SAME_COND, correctness, "consecutive `if`s with the same condition" } declare_clippy_lint! { /// ### What it does /// Checks for consecutive `if`s with the same functi...
(block_eq.start_eq, block_eq.end_eq, block_eq.expr_eq) } else { return; }; // BRANCHES_SHARING_CODE prerequisites if has_conditional_else || (start_eq == 0 && end_eq == 0 && (has_expr &&!expr_eq)) { return; } // Only the start is the same if start_eq!= 0 && end_eq =...
let (start_eq, mut end_eq, expr_eq) = if let Some(block_eq) = scan_block_for_eq(cx, blocks) {
random_line_split
doctree.rs
// Copyright 2012-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-MI...
{ pub name: Ident, pub id: ast::NodeId, pub attrs: Vec<ast::Attribute>, pub where: Span, } pub fn struct_type_from_def(sd: &ast::StructDef) -> StructType { if sd.ctor_id.is_some() { // We are in a tuple-struct match sd.fields.len() { 0 => Unit, 1 => Newtype,...
Macro
identifier_name
doctree.rs
// Copyright 2012-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-MI...
pub variants: Vec<Variant>, pub generics: ast::Generics, pub attrs: Vec<ast::Attribute>, pub id: NodeId, pub where: Span, pub name: Ident, } pub struct Variant { pub name: Ident, pub attrs: Vec<ast::Attribute>, pub kind: ast::VariantKind, pub id: ast::NodeId, pub vis: ast::V...
pub struct Enum { pub vis: ast::Visibility,
random_line_split
cargo_run.rs
use std::path::Path; use ops::{self, Packages}; use util::{self, CargoResult, CargoError, ProcessError}; use util::errors::CargoErrorKind; use core::Workspace; pub fn run(ws: &Workspace, options: &ops::CompileOptions, args: &[String]) -> CargoResult<Option<ProcessError>> { let config = ws.co...
bail!("a bin target must be available for `cargo run`") } else { // this will be verified in cargo_compile } } if bins.next().is_some() { if!options.filter.is_specific() { bail!("`cargo run` requires that a project only have one \ ex...
}); if bins.next().is_none() { if !options.filter.is_specific() {
random_line_split
cargo_run.rs
use std::path::Path; use ops::{self, Packages}; use util::{self, CargoResult, CargoError, ProcessError}; use util::errors::CargoErrorKind; use core::Workspace; pub fn
(ws: &Workspace, options: &ops::CompileOptions, args: &[String]) -> CargoResult<Option<ProcessError>> { let config = ws.config(); let pkg = match options.spec { Packages::All => unreachable!("cargo run supports single package only"), Packages::OptOut(_) => unreachable!("ca...
run
identifier_name
cargo_run.rs
use std::path::Path; use ops::{self, Packages}; use util::{self, CargoResult, CargoError, ProcessError}; use util::errors::CargoErrorKind; use core::Workspace; pub fn run(ws: &Workspace, options: &ops::CompileOptions, args: &[String]) -> CargoResult<Option<ProcessError>>
a.is_bin() } else { options.filter.matches(a) } }); if bins.next().is_none() { if!options.filter.is_specific() { bail!("a bin target must be available for `cargo run`") } else { // this will be verified in cargo_compile } ...
{ let config = ws.config(); let pkg = match options.spec { Packages::All => unreachable!("cargo run supports single package only"), Packages::OptOut(_) => unreachable!("cargo run supports single package only"), Packages::Packages(xs) => match xs.len() { 0 => ws.current()?, ...
identifier_body
type.rs
// rustfmt-normalize_comments: true fn types() { let x: [Vec<_>] = []; let y: *mut [SomeType; konst_funk()] = expr(); let z: (// #digits usize, // exp i16) = funk(); let z: (usize /* #digits */, i16 /* exp */) = funk(); } struct F { f: extern "C" fn(x: u8,... /* ...
fn impl_trait_fn_2<E>() -> impl Future<Item = &'a i64, Error = E> {} fn issue_1234() { do_parse!(name: take_while1!(is_token) >> (Header)) }
{}
identifier_body
type.rs
// rustfmt-normalize_comments: true fn types() { let x: [Vec<_>] = []; let y: *mut [SomeType; konst_funk()] = expr(); let z: (// #digits usize, // exp i16) = funk(); let z: (usize /* #digits */, i16 /* exp */) = funk(); } struct F { f: extern "C" fn(x: u8,... /* ...
fn issue_1006(def_id_to_string: for<'a, 'b> unsafe fn(TyCtxt<'b, 'tcx, 'tcx>, DefId) -> String) {} fn impl_trait_fn_1() -> impl Fn(i32) -> Option<u8> {} fn impl_trait_fn_2<E>() -> impl Future<Item = &'a i64, Error = E> {} fn issue_1234() { do_parse!(name: take_while1!(is_token) >> (Header)) }
// comment ... /* comment 2 */), }
random_line_split
type.rs
// rustfmt-normalize_comments: true fn types() { let x: [Vec<_>] = []; let y: *mut [SomeType; konst_funk()] = expr(); let z: (// #digits usize, // exp i16) = funk(); let z: (usize /* #digits */, i16 /* exp */) = funk(); } struct F { f: extern "C" fn(x: u8,... /* ...
<E>() -> impl Future<Item = &'a i64, Error = E> {} fn issue_1234() { do_parse!(name: take_while1!(is_token) >> (Header)) }
impl_trait_fn_2
identifier_name
elision.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 ...
} fn main() { }
{ unimplemented!() }
identifier_body
elision.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 ...
() { }
main
identifier_name
elision.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 ...
fn split_whitespace<'a>(&'a self) -> SplitWhitespace<'a>; } impl UnicodeStr for str { #[inline] fn split_whitespace(&self) -> SplitWhitespace { unimplemented!() } } fn main() { }
pub trait UnicodeStr {
random_line_split
export_common.rs
use std::ffi::OsString; use crate::common::ui::UI; use crate::error::Result; pub async fn start(ui: &mut UI, args: &[OsString], export_cmd: &str, export_pkg_ident: &str, export_pkg_ident_envvar: &str) -> Result<()> { i...
} #[cfg(target_os = "macos")] mod inner { use std::ffi::OsString; use crate::common::ui::{UIWriter, UI}; use crate::error::{Error, Result}; pub async fn start(ui: &mut UI, _args: &[OsString], export_cmd...
{ crypto::init()?; let ident = match henv::var(export_pkg_ident_envvar) { Ok(ref ident_str) => PackageIdent::from_str(ident_str)?, Err(_) => { let version: Vec<&str> = VERSION.split('/').collect(); PackageIdent::from_str(&format!("{}/{}", export_pk...
identifier_body