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
gc.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 ...
rri += 1; } return true; } #[cfg(stage0)] unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) { _walk_safe_point(fp, sp, visitor); } #[cfg(not(stage0))] unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool { _walk_safe_point(fp, sp, visitor) } // Is ...
{ // FIXME(#2997): Need to find callee saved registers on the stack. }
conditional_block
gc.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let mut spi = 0; while spi < num_safe_points { let sp: **Word = bump(safe_points, spi*3); let sp_loc = *sp; if sp_loc == pc { return Some(SafePoint { sp_meta: *bump(sp, 1), fn_meta: *bump(sp, 2), }); } spi += 1; ...
// FIXME (#2997): Use binary rather than linear search.
random_line_split
type_.rs
use super::misc::MiscMethods; use super::Backend; use super::HasCodegen; use crate::common::TypeKind; use crate::mir::place::PlaceRef; use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::{self, Ty}; use rustc_span::DUMMY_SP; use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg}; use rustc_target::a...
let tail = self.tcx().struct_tail_erasing_lifetimes(ty, param_env); match tail.kind() { ty::Foreign(..) => false, ty::Str | ty::Slice(..) | ty::Dynamic(..) => true, _ => bug!("unexpected unsized tail: {:?}", tail), } } } impl<T> DerivedTypeMethods<'tcx>...
{ return false; }
conditional_block
type_.rs
use super::misc::MiscMethods; use super::Backend; use super::HasCodegen; use crate::common::TypeKind; use crate::mir::place::PlaceRef; use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::{self, Ty}; use rustc_span::DUMMY_SP; use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg}; use rustc_target::a...
fn type_f32(&self) -> Self::Type; fn type_f64(&self) -> Self::Type; fn type_func(&self, args: &[Self::Type], ret: Self::Type) -> Self::Type; fn type_struct(&self, els: &[Self::Type], packed: bool) -> Self::Type; fn type_kind(&self, ty: Self::Type) -> TypeKind; fn type_ptr_to(&self, ty: Self::Ty...
fn type_isize(&self) -> Self::Type;
random_line_split
type_.rs
use super::misc::MiscMethods; use super::Backend; use super::HasCodegen; use crate::common::TypeKind; use crate::mir::place::PlaceRef; use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::{self, Ty}; use rustc_span::DUMMY_SP; use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg}; use rustc_target::a...
(&self, ty: Ty<'tcx>) -> bool { ty.is_sized(self.tcx().at(DUMMY_SP), ty::ParamEnv::reveal_all()) } fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool { ty.is_freeze(self.tcx().at(DUMMY_SP), ty::ParamEnv::reveal_all()) } fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool { let param_...
type_is_sized
identifier_name
type_.rs
use super::misc::MiscMethods; use super::Backend; use super::HasCodegen; use crate::common::TypeKind; use crate::mir::place::PlaceRef; use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::{self, Ty}; use rustc_span::DUMMY_SP; use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg}; use rustc_target::a...
fn type_i8p_ext(&self, address_space: AddressSpace) -> Self::Type { self.type_ptr_to_ext(self.type_i8(), address_space) } fn type_int(&self) -> Self::Type { match &self.sess().target.c_int_width[..] { "16" => self.type_i16(), "32" => self.type_i32(), "6...
{ self.type_i8p_ext(AddressSpace::DATA) }
identifier_body
error.rs
// Copyright 2015-2017 Parity Technologies (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 lat...
}
random_line_split
error.rs
// Copyright 2015-2017 Parity Technologies (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 lat...
} impl From<UtilError> for Error { fn from(err: UtilError) -> Self { Error::Util(err) } } impl<E> From<Box<E>> for Error where Error: From<E> { fn from(err: Box<E>) -> Self { Error::from(*err) } } impl Display for Error { fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> { match *self { Error::...
{ Error::Trie(err) }
identifier_body
error.rs
// Copyright 2015-2017 Parity Technologies (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 lat...
(err: UtilError) -> Self { Error::Util(err) } } impl<E> From<Box<E>> for Error where Error: From<E> { fn from(err: Box<E>) -> Self { Error::from(*err) } } impl Display for Error { fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> { match *self { Error::Trie(ref err) => write!(f, "{}", err), Err...
from
identifier_name
context.rs
use std::collections::hash_map::Entry; use std::path::{Path, PathBuf}; use isymtope_generate::*; use super::*; pub trait ServerContext { fn handle_msg(&mut self, msg: Msg) -> IsymtopeServerResult<ResponseMsg>; } #[derive(Debug)] pub struct DefaultServerContext { app_dir: PathBuf, srs: DefaultSecureRandom...
{ RenderComplete(RenderResponse), } impl ServerContext for DefaultServerContext { fn handle_msg(&mut self, msg: Msg) -> IsymtopeServerResult<ResponseMsg> { match msg { Msg::RenderAppRoute(ref base_url, ref app_name, ref template_path, ref path) => { // let template_path = i...
ResponseMsg
identifier_name
context.rs
use std::collections::hash_map::Entry; use std::path::{Path, PathBuf}; use isymtope_generate::*; use super::*; pub trait ServerContext { fn handle_msg(&mut self, msg: Msg) -> IsymtopeServerResult<ResponseMsg>; } #[derive(Debug)] pub struct DefaultServerContext { app_dir: PathBuf, srs: DefaultSecureRandom...
} #[derive(Debug)] pub enum Msg { RenderAppRoute(String, String, String, String), } #[derive(Debug)] pub enum ResponseMsg { RenderComplete(RenderResponse), } impl ServerContext for DefaultServerContext { fn handle_msg(&mut self, msg: Msg) -> IsymtopeServerResult<ResponseMsg> { match msg { ...
{ DefaultServerContext { app_dir: app_dir.to_owned(), srs: Default::default(), cookies: Default::default(), } }
identifier_body
context.rs
use std::collections::hash_map::Entry; use std::path::{Path, PathBuf}; use isymtope_generate::*; use super::*; pub trait ServerContext { fn handle_msg(&mut self, msg: Msg) -> IsymtopeServerResult<ResponseMsg>; } #[derive(Debug)] pub struct DefaultServerContext { app_dir: PathBuf, srs: DefaultSecureRandom...
impl DefaultServerContext { #[cfg(not(feature = "cookies"))] pub fn new(app_dir: &Path) -> Self { DefaultServerContext { app_dir: app_dir.to_owned(), srs: Default::default(), } } #[cfg(feature = "cookies")] pub fn new(app_dir: &Path) -> Self { Default...
#[cfg(feature = "cookies")] cookies: Cookies, }
random_line_split
index.rs
use inverted_index::InvertedIndex; use field_ref::FieldRef; use vector::Vector; use builder::Builder; use serde::ser::{Serialize, Serializer, SerializeStruct}; use std::collections::HashSet; use std::convert::From; type FieldVector = (FieldRef, Vector); pub struct
{ version: String, inverted_index: InvertedIndex, field_vectors: Vec<FieldVector>, fields: HashSet<String>, pipeline: Vec<String>, } impl From<Builder> for Index { fn from(mut builder: Builder) -> Index { builder.build(); Index { version: String::from("2.1.3"), ...
Index
identifier_name
index.rs
use inverted_index::InvertedIndex; use field_ref::FieldRef; use vector::Vector; use builder::Builder; use serde::ser::{Serialize, Serializer, SerializeStruct}; use std::collections::HashSet; use std::convert::From; type FieldVector = (FieldRef, Vector); pub struct Index { version: String, inverted_index: In...
}
{ let mut index = serializer.serialize_struct("Index", 3)?; index.serialize_field("version", &self.version)?; index.serialize_field("pipeline", &self.pipeline)?; index.serialize_field("fields", &self.fields)?; index.serialize_field("fieldVectors", &self.field_vectors)?; ...
identifier_body
index.rs
use inverted_index::InvertedIndex; use field_ref::FieldRef; use vector::Vector; use builder::Builder; use serde::ser::{Serialize, Serializer, SerializeStruct}; use std::collections::HashSet; use std::convert::From; type FieldVector = (FieldRef, Vector); pub struct Index { version: String, inverted_index: In...
fields: builder.fields, } } } impl Serialize for Index { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer { let mut index = serializer.serialize_struct("Index", 3)?; index.serialize_field("version", &self.version)?; in...
.into_iter() .map(|(k, v)| (k, v)) .collect(),
random_line_split
document_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/. */ //! Tracking of pending loads in a document. //! //! <https://html.spec.whatwg.org/multipage/#the-end> use dom::b...
_ => false }) } pub fn inhibit_events(&mut self) { self.events_inhibited = true; } pub fn events_inhibited(&self) -> bool { self.events_inhibited } pub fn resource_threads(&self) -> &ResourceThreads { &self.resource_threads } }
} pub fn is_only_blocked_by_iframes(&self) -> bool { self.blocking_loads.iter().all(|load| match *load { LoadType::Subframe(_) => true,
random_line_split
document_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/. */ //! Tracking of pending loads in a document. //! //! <https://html.spec.whatwg.org/multipage/#the-end> use dom::b...
(&mut self) { self.events_inhibited = true; } pub fn events_inhibited(&self) -> bool { self.events_inhibited } pub fn resource_threads(&self) -> &ResourceThreads { &self.resource_threads } }
inhibit_events
identifier_name
document_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/. */ //! Tracking of pending loads in a document. //! //! <https://html.spec.whatwg.org/multipage/#the-end> use dom::b...
} } #[derive(JSTraceable, MallocSizeOf)] pub struct DocumentLoader { resource_threads: ResourceThreads, blocking_loads: Vec<LoadType>, events_inhibited: bool, } impl DocumentLoader { pub fn new(existing: &DocumentLoader) -> DocumentLoader { DocumentLoader::new_with_threads(existing.resour...
{ debug_assert!(self.load.is_none()); }
conditional_block
document_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/. */ //! Tracking of pending loads in a document. //! //! <https://html.spec.whatwg.org/multipage/#the-end> use dom::b...
/// Remove this load from the associated document's list of blocking loads. pub fn terminate(blocker: &mut Option<LoadBlocker>) { if let Some(this) = blocker.as_mut() { this.doc.finish_load(this.load.take().unwrap()); } *blocker = None; } /// Return the url associa...
{ doc.loader_mut().add_blocking_load(load.clone()); LoadBlocker { doc: Dom::from_ref(doc), load: Some(load), } }
identifier_body
mod.rs
#![allow(dead_code)] use anyhow::Result; use tokio::io::{self, AsyncWriteExt}; pub use pueue_lib::state::PUEUE_DEFAULT_GROUP; mod daemon; mod env; mod group; mod message; mod network; mod state; mod task; mod wait; pub use daemon::*; pub use env::*; pub use group::*; pub use message::*; pub use network::*; pub use s...
/// A small helper function, which instantly writes the given string to stdout with a newline. /// Useful for debugging async tests. pub async fn async_println(out: &str) -> Result<()> { let mut stdout = io::stdout(); stdout .write_all(out.as_bytes()) .await .expect("Failed to write to std...
pub fn sleep_ms(ms: u64) { std::thread::sleep(std::time::Duration::from_millis(ms)); }
random_line_split
mod.rs
#![allow(dead_code)] use anyhow::Result; use tokio::io::{self, AsyncWriteExt}; pub use pueue_lib::state::PUEUE_DEFAULT_GROUP; mod daemon; mod env; mod group; mod message; mod network; mod state; mod task; mod wait; pub use daemon::*; pub use env::*; pub use group::*; pub use message::*; pub use network::*; pub use s...
/// A small helper function, which instantly writes the given string to stdout with a newline. /// Useful for debugging async tests. pub async fn async_println(out: &str) -> Result<()> { let mut stdout = io::stdout(); stdout .write_all(out.as_bytes()) .await .expect("Failed to write to st...
{ std::thread::sleep(std::time::Duration::from_millis(ms)); }
identifier_body
mod.rs
#![allow(dead_code)] use anyhow::Result; use tokio::io::{self, AsyncWriteExt}; pub use pueue_lib::state::PUEUE_DEFAULT_GROUP; mod daemon; mod env; mod group; mod message; mod network; mod state; mod task; mod wait; pub use daemon::*; pub use env::*; pub use group::*; pub use message::*; pub use network::*; pub use s...
(out: &str) -> Result<()> { let mut stdout = io::stdout(); stdout .write_all(out.as_bytes()) .await .expect("Failed to write to stdout."); stdout .write_all("\n".as_bytes()) .await .expect("Failed to write to stdout."); stdout.flush().await?; Ok(()) }
async_println
identifier_name
manticore_protocol_spdm_GetCaps__req_to_wire.rs
// Copyright lowRISC contributors. // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 //!! DO NOT EDIT!! // To regenerate this file, run `fuzz/generate_proto_tests.py`. #![no_main] #![allow(non_snake_case)] use libfuzzer_sys::fuzz_target; use manticore...
});
let _ = Req::borrow(&data).to_wire(&mut &mut out[..]);
random_line_split
issue-3563-3.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} // This is similar to an interface in other languages: it defines a protocol which // developers can implement for arbitrary concrete types. trait Canvas { fn add_point(&mut self, shape: Point); fn add_rect(&mut self, shape: Rect); // Unlike interfaces traits support default implementations. // Got...
{ // Convert each line into a string. let lines = self.lines.iter() .map(|line| String::from_chars(line.as_slice())) .collect::<Vec<String>>(); // Concatenate the lines together using a new-line. write!(f, "{}", lines.connect("...
identifier_body
issue-3563-3.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ width: int, height: int, } impl Copy for Size {} struct Rect { top_left: Point, size: Size, } impl Copy for Rect {} // Contains the information needed to do shape rendering via ASCII art. struct AsciiArt { width: uint, height: uint, fill: char, lines: Vec<Vec<char> >, // This...
Size
identifier_name
issue-3563-3.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
test_shapes();
random_line_split
issue-3563-3.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
return true; } fn test_ascii_art_ctor() { let art = AsciiArt(3, 3, '*'); assert!(check_strs(art.to_string().as_slice(), "...\n...\n...")); } fn test_add_pt() { let mut art = AsciiArt(3, 3, '*'); art.add_pt(0, 0); art.add_pt(0, -10); art.add_pt(1, 2); assert!(check_strs(art.to_string...
{ println!("Found:\n{}\nbut expected\n{}", actual, expected); return false; }
conditional_block
doc.rs
use std::cell::{RefCell, UnsafeCell}; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::fmt::{Display, Error, Formatter}; use std::rc::Rc; use super::parser::{Builder, ParserError, ShowType}; pub struct ContainerData { direct_children_vec: Vec<(Key, Rc<DirectChild>)>, dire...
} struct DocBuilder; impl Builder for DocBuilder { type Table = Container; type Array = Container; type Key = Key; type Value = (); fn root_table(lead_ws: &str) -> Self::Table { Container::new(ContainerKind::Root, lead_ws.to_string()) } fn table(lead_ws: &str) -> Self::Table { Cont...
{ unimplemented!() }
identifier_body
doc.rs
use std::cell::{RefCell, UnsafeCell}; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::fmt::{Display, Error, Formatter}; use std::rc::Rc; use super::parser::{Builder, ParserError, ShowType}; pub struct ContainerData { direct_children_vec: Vec<(Key, Rc<DirectChild>)>, dire...
Float(f64), Boolean(bool), Datetime(String), Array(Vec<ArrayElement>), InlineTable(Container), } enum ArrayElement { String(String), Integer(i64), Float(f64), Boolean(bool), Datetime(String), Array(Vec<ArrayElement>), } #[derive(PartialEq, Eq, Hash)] pub st...
Integer(i64),
random_line_split
doc.rs
use std::cell::{RefCell, UnsafeCell}; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::fmt::{Display, Error, Formatter}; use std::rc::Rc; use super::parser::{Builder, ParserError, ShowType}; pub struct ContainerData { direct_children_vec: Vec<(Key, Rc<DirectChild>)>, dire...
{ String(String), Integer(i64), Float(f64), Boolean(bool), Datetime(String), Array(Vec<ArrayElement>), } #[derive(PartialEq, Eq, Hash)] pub struct Key { text: String, lead: String, trail: String } impl Display for Key { fn fmt(&self, f: &mut Formatter) -> Resu...
ArrayElement
identifier_name
lib.rs
extern crate openvr_sys; #[macro_use] extern crate lazy_static; use std::cell::Cell; use std::ffi::{CStr, CString}; use std::sync::atomic::{AtomicBool, Ordering}; use std::{error, fmt, mem, ptr}; use openvr_sys as sys; mod tracking; pub mod chaperone; pub mod compositor; pub mod property; pub mod render_models; pub...
{ Left = sys::EVREye_Eye_Left as isize, Right = sys::EVREye_Eye_Right as isize, } /// Helper to call OpenVR functions that return strings unsafe fn get_string<F: FnMut(*mut std::os::raw::c_char, u32) -> u32>(mut f: F) -> Option<CString> { let n = f(ptr::null_mut(), 0); if n == 0 { return None;...
Eye
identifier_name
lib.rs
extern crate openvr_sys; #[macro_use] extern crate lazy_static; use std::cell::Cell; use std::ffi::{CStr, CString}; use std::sync::atomic::{AtomicBool, Ordering}; use std::{error, fmt, mem, ptr}; use openvr_sys as sys; mod tracking; pub mod chaperone; pub mod compositor; pub mod property; pub mod render_models; pub...
pub const DPAD_DOWN: sys::EVRButtonId = sys::EVRButtonId_k_EButton_DPad_Down; pub const A: sys::EVRButtonId = sys::EVRButtonId_k_EButton_A; pub const PROXIMITY_SENSOR: sys::EVRButtonId = sys::EVRButtonId_k_EButton_ProximitySensor; pub const AXIS0: sys::EVRButtonId = sys::EVRButtonId_k_EButton_Axis0; ...
pub const GRIP: sys::EVRButtonId = sys::EVRButtonId_k_EButton_Grip; pub const DPAD_LEFT: sys::EVRButtonId = sys::EVRButtonId_k_EButton_DPad_Left; pub const DPAD_UP: sys::EVRButtonId = sys::EVRButtonId_k_EButton_DPad_Up; pub const DPAD_RIGHT: sys::EVRButtonId = sys::EVRButtonId_k_EButton_DPad_Right;
random_line_split
lib.rs
extern crate openvr_sys; #[macro_use] extern crate lazy_static; use std::cell::Cell; use std::ffi::{CStr, CString}; use std::sync::atomic::{AtomicBool, Ordering}; use std::{error, fmt, mem, ptr}; use openvr_sys as sys; mod tracking; pub mod chaperone; pub mod compositor; pub mod property; pub mod render_models; pub...
} } #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum ApplicationType { /// Some other kind of application that isn't covered by the other entries Other = sys::EVRApplicationType_VRApplication_Other as isize, /// Application will submit 3D frames Scene = sys::EVRApplicationType_VRApplication_S...
{ sys::VR_ShutdownInternal(); INITIALIZED.store(false, Ordering::Release); }
conditional_block
check_button.rs
// This file was generated by gir (b7f5189) from gir-files (71d73f0) // DO NOT EDIT use Actionable; use Bin; use Button; use Container; use ToggleButton; use Widget; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; glib_wrapper! { pub struct CheckButton(Object<ffi::GtkCheckButto...
pub trait CheckButtonExt {} impl<O: IsA<CheckButton>> CheckButtonExt for O {}
Widget::from_glib_none(ffi::gtk_check_button_new_with_mnemonic(label.to_glib_none().0)).downcast_unchecked() } } }
random_line_split
check_button.rs
// This file was generated by gir (b7f5189) from gir-files (71d73f0) // DO NOT EDIT use Actionable; use Bin; use Button; use Container; use ToggleButton; use Widget; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; glib_wrapper! { pub struct CheckButton(Object<ffi::GtkCheckButto...
() -> CheckButton { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(ffi::gtk_check_button_new()).downcast_unchecked() } } pub fn new_with_label(label: &str) -> CheckButton { assert_initialized_main_thread!(); unsafe { Widget::fr...
new
identifier_name
check_button.rs
// This file was generated by gir (b7f5189) from gir-files (71d73f0) // DO NOT EDIT use Actionable; use Bin; use Button; use Container; use ToggleButton; use Widget; use ffi; use glib::object::Downcast; use glib::object::IsA; use glib::translate::*; glib_wrapper! { pub struct CheckButton(Object<ffi::GtkCheckButto...
} pub trait CheckButtonExt {} impl<O: IsA<CheckButton>> CheckButtonExt for O {}
{ assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(ffi::gtk_check_button_new_with_mnemonic(label.to_glib_none().0)).downcast_unchecked() } }
identifier_body
lib.rs
// This file is part of Twig (ported to Rust). // // For the copyright and license information, please view the LICENSE // file that was distributed with this source code. //! # Twig Templating for Rust //! //! **Work in progress** - This library is still in development and not yet ready for use. //! Take a look at th...
//! ## Syntax and Semantics //! //! Twig uses a syntax similar to the Django and Jinja template languages which inspired the Twig runtime environment. //! //! ```html //! <!DOCTYPE html> //! <html> //! <head> //! <title>Display a thread of posts</title> //! </head> //! <body> //! <h1>{{ thread.t...
//!
random_line_split
v1kpdb.rs
use std::cell::{RefCell}; use std::rc::Rc; use chrono::{DateTime, Local}; use kpdb::crypter::Crypter; use kpdb::parser::Parser; use kpdb::v1error::V1KpdbError; use kpdb::v1group::V1Group; use kpdb::v1entry::V1Entry; use kpdb::v1header::V1Header; use super::super::sec_str::SecureString; #[doc = " V1Kpdb implements a ...
if id >= new_id { new_id = id + 1; } } let new_group = Rc::new(RefCell::new(V1Group::new())); new_group.borrow_mut().title = title; match expire { Some(s) => { new_group.borrow_mut().expire = s }, None => {}, // is 12-28-29...
random_line_split
v1kpdb.rs
use std::cell::{RefCell}; use std::rc::Rc; use chrono::{DateTime, Local}; use kpdb::crypter::Crypter; use kpdb::parser::Parser; use kpdb::v1error::V1KpdbError; use kpdb::v1group::V1Group; use kpdb::v1entry::V1Entry; use kpdb::v1header::V1Header; use super::super::sec_str::SecureString; #[doc = " V1Kpdb implements a ...
(&self, item: &T) -> Result<usize, V1KpdbError> { for index in 0..self.len() { if *(self[index].borrow()) == *item { return Ok(index); } } Err(V1KpdbError::ParentErr) } } impl V1Kpdb { /// Call this to create a new database inst...
get_index
identifier_name
integration_test.rs
// Copyright 2020 The Tink-Rust Authors // // 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...
{ tink_aead::init(); // Check for AES-GCM key manager. tink_core::registry::get_key_manager(tink_tests::AES_GCM_TYPE_URL).unwrap(); // Check for ChaCha20Poly1305 key manager. tink_core::registry::get_key_manager(tink_tests::CHA_CHA20_POLY1305_TYPE_URL).unwrap(); // Check for XChaCha20Poly1305...
identifier_body
integration_test.rs
// Copyright 2020 The Tink-Rust Authors // // 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...
// Check for AES-GCM key manager. tink_core::registry::get_key_manager(tink_tests::AES_GCM_TYPE_URL).unwrap(); // Check for ChaCha20Poly1305 key manager. tink_core::registry::get_key_manager(tink_tests::CHA_CHA20_POLY1305_TYPE_URL).unwrap(); // Check for XChaCha20Poly1305 key manager. tink_co...
fn test_aead_init() { tink_aead::init();
random_line_split
integration_test.rs
// Copyright 2020 The Tink-Rust Authors // // 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...
() { tink_aead::init(); let kh = tink_core::keyset::Handle::new(&tink_aead::aes256_gcm_key_template()).unwrap(); // NOTE: save the keyset to a safe location. DO NOT hardcode it in source code. // Consider encrypting it with a remote key in Cloud KMS, AWS KMS or HashiCorp Vault. // See https://githu...
example
identifier_name
statfs.rs
use {Errno, Result, NixPath}; use std::os::unix::io::AsRawFd; pub mod vfs { #[cfg(target_pointer_width = "32")] pub mod hwdep { use libc::{c_uint}; pub type FsType = c_uint; pub type BlockSize = c_uint; pub type NameLen = c_uint; pub type FragmentSize = c_uint; p...
pub fn fstatfs<T: AsRawFd>(fd: &T, stat: &mut vfs::Statfs) -> Result<()> { unsafe { Errno::clear(); Errno::result(ffi::fstatfs(fd.as_raw_fd(), stat)).map(drop) } }
{ unsafe { Errno::clear(); let res = try!( path.with_nix_path(|path| ffi::statfs(path.as_ptr(), stat)) ); Errno::result(res).map(drop) } }
identifier_body
statfs.rs
use {Errno, Result, NixPath}; use std::os::unix::io::AsRawFd; pub mod vfs { #[cfg(target_pointer_width = "32")] pub mod hwdep { use libc::{c_uint}; pub type FsType = c_uint; pub type BlockSize = c_uint; pub type NameLen = c_uint; pub type FragmentSize = c_uint; p...
<P:?Sized + NixPath>(path: &P, stat: &mut vfs::Statfs) -> Result<()> { unsafe { Errno::clear(); let res = try!( path.with_nix_path(|path| ffi::statfs(path.as_ptr(), stat)) ); Errno::result(res).map(drop) } } pub fn fstatfs<T: AsRawFd>(fd: &T, stat: &mut vfs::Statfs)...
statfs
identifier_name
statfs.rs
use {Errno, Result, NixPath}; use std::os::unix::io::AsRawFd; pub mod vfs { #[cfg(target_pointer_width = "32")] pub mod hwdep { use libc::{c_uint}; pub type FsType = c_uint; pub type BlockSize = c_uint; pub type NameLen = c_uint; pub type FragmentSize = c_uint; p...
pub const CRAMFS_MAGIC : FsType = 0x28cd3d45; pub const DEVFS_SUPER_MAGIC : FsType = 0x1373; pub const EFS_SUPER_MAGIC : FsType = 0x00414A53; pub const EXT_SUPER_MAGIC : FsType = 0x137D; pub const EXT2_OLD_SUPER_MAGIC : FsType = 0xEF51; pub const EXT2_SUPER_MAGIC : FsTy...
random_line_split
lib.rs
#![feature(libc, std_misc, core, unicode, old_io, collections)] extern crate libc; extern crate "mpfr-sys" as mpfr_sys; #[macro_use] #[no_link] extern crate bitflags; extern crate num; use std::mem; use std::ptr; use std::ffi::CStr; use std::fmt; use std::ops::{Add, Mul, Sub, Div, Rem, Neg}; use std::cmp::Ordering; u...
() -> BigFloat { BigFloat::new().from(1u32) } }
one
identifier_name
lib.rs
#![feature(libc, std_misc, core, unicode, old_io, collections)] extern crate libc; extern crate "mpfr-sys" as mpfr_sys; #[macro_use] #[no_link] extern crate bitflags; extern crate num; use std::mem; use std::ptr; use std::ffi::CStr; use std::fmt; use std::ops::{Add, Mul, Sub, Div, Rem, Neg}; use std::cmp::Ordering; u...
} } } // Zero and one impl Zero for BigFloat { #[inline] fn zero() -> BigFloat { let mut r = BigFloat::new().fresh(); r.set_to_zero(Sign::Positive); r } #[inline] fn is_zero(&self) -> bool { BigFloat::is_zero(self) } } impl One for BigFloat { #...
r if r > 0 => Some(Ordering::Greater), _ if Flags::Erange.is_set() => None, _ => Some(Ordering::Equal)
random_line_split
lib.rs
#![feature(libc, std_misc, core, unicode, old_io, collections)] extern crate libc; extern crate "mpfr-sys" as mpfr_sys; #[macro_use] #[no_link] extern crate bitflags; extern crate num; use std::mem; use std::ptr; use std::ffi::CStr; use std::fmt; use std::ops::{Add, Mul, Sub, Div, Rem, Neg}; use std::cmp::Ordering; u...
} // Equality check impl PartialEq for BigFloat { #[inline] fn eq(&self, other: &BigFloat) -> bool { unsafe { mpfr_equal_p(&self.value, &other.value) > 0 } } } impl PartialOrd for BigFloat { fn partial_cmp(&self, other: &BigFloat) -> Option<Ordering> { match unsafe { mpfr_cmp(&self....
{ -self.clone() }
identifier_body
md5.rs
use digest::Digest; use utils::buffer::{ FixedBuffer64, FixedBuffer, StandardPadding }; use byteorder::{ WriteBytesExt, ReadBytesExt, LittleEndian }; #[derive(Debug)] struct MD5State { s0: u32, s1: u32, s2: u32, s3: u32 } impl MD5State { fn new() -> Self { MD5State ...
(u: u32, v: u32, w: u32) -> u32 { (u & w) | (v &!w) } fn h(u: u32, v: u32, w: u32) -> u32 { u ^ v ^ w } fn i(u: u32, v: u32, w: u32) -> u32 { v ^ (u |!w) } fn op_f(w: u32, x: u32, y: u32, z: u32, m: u32, s: u32) -> u32 { ...
g
identifier_name
md5.rs
use digest::Digest; use utils::buffer::{ FixedBuffer64, FixedBuffer, StandardPadding }; use byteorder::{ WriteBytesExt, ReadBytesExt, LittleEndian }; #[derive(Debug)] struct MD5State { s0: u32, s1: u32, s2: u32, s3: u32 } impl MD5State { fn new() -> Self { MD5State ...
fn test_md5() { // Examples from wikipedia // Test that it works when accepting the message all at once for test in &TESTS { test.test(MD5::new()); } } }
Test { input: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", output: "d174ab98d277d9f5a5611c2c9f419d9f" }, Test { input: "12345678901234567890123456789012345678901234567890123456789012345678901234567890", output: "57edf4a22be3c955ac49da2e2107b67a" }, ]; #[test]
random_line_split
md5.rs
use digest::Digest; use utils::buffer::{ FixedBuffer64, FixedBuffer, StandardPadding }; use byteorder::{ WriteBytesExt, ReadBytesExt, LittleEndian }; #[derive(Debug)] struct MD5State { s0: u32, s1: u32, s2: u32, s3: u32 } impl MD5State { fn new() -> Self { MD5State ...
fn i(u: u32, v: u32, w: u32) -> u32 { v ^ (u |!w) } fn op_f(w: u32, x: u32, y: u32, z: u32, m: u32, s: u32) -> u32 { w.wrapping_add(f(x, y, z)).wrapping_add(m).rotate_left(s).wrapping_add(x) } fn op_g(w: u32, x: u32, y: u32, z: u32, m: u32, s: u32) -> ...
{ u ^ v ^ w }
identifier_body
once-cant-call-twice-on-heap.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 x = Arc::new(true); foo(proc() { assert!(*x); drop(x); }); }
identifier_body
once-cant-call-twice-on-heap.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 ...
blk(); blk(); //~ ERROR use of moved value } fn main() { let x = Arc::new(true); foo(proc() { assert!(*x); drop(x); }); }
#![feature(once_fns)] use std::sync::Arc; fn foo(blk: proc()) {
random_line_split
once-cant-call-twice-on-heap.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 x = Arc::new(true); foo(proc() { assert!(*x); drop(x); }); }
main
identifier_name
keyframes_rule.rs
::ParserContext; use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction; use properties::LonghandIdSet; use properties::{Importance, PropertyDeclaration}; use properties::{LonghandId, PropertyDeclarationBlock, PropertyId}; use properties::{PropertyDeclarationId, S...
<'i>( css: &'i str, parent_stylesheet_contents: &StylesheetContents, lock: &SharedRwLock, ) -> Result<Arc<Locked<Self>>, ParseError<'i>> { let url_data = parent_stylesheet_contents.url_data.read(); let namespaces = parent_stylesheet_contents.namespaces.read(); let mut...
parse
identifier_name
keyframes_rule.rs
parser::ParserContext; use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction; use properties::LonghandIdSet; use properties::{Importance, PropertyDeclaration}; use properties::{LonghandId, PropertyDeclarationBlock, PropertyId}; use properties::{PropertyDeclarati...
context: &'a ParserContext<'b>, declarations: &'a mut SourcePropertyDeclaration, } /// Default methods reject all at rules. impl<'a, 'b, 'i> AtRuleParser<'i> for KeyframeDeclarationParser<'a, 'b> { type PreludeNoBlock = (); type PreludeBlock = (); type AtRule = (); type Error = StyleParseErrorK...
random_line_split
keyframes_rule.rs
::ParserContext; use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction; use properties::LonghandIdSet; use properties::{Importance, PropertyDeclaration}; use properties::{LonghandId, PropertyDeclarationBlock, PropertyId}; use properties::{PropertyDeclarationId, S...
, Err((error, slice)) => { iter.parser.declarations.clear(); let location = error.location; let error = ContextualParseError::UnsupportedKeyframePropertyDeclaration(slice, error); context.log_css_erro...
{ block.extend(iter.parser.declarations.drain(), Importance::Normal); }
conditional_block
common.rs
//! Contains several types used throughout the library. use std::fmt; use std::error; /// Represents a thing which has a position inside some textual document. /// /// This trait is implemented by parsers, lexers and errors. It is used primarily to create /// error objects. pub trait HasPosition { /// R...
{ row: usize, col: usize, msg: String } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}:{}: {}", self.row + 1, self.col + 1, self.msg) } } impl HasPosition for Error { #[inline] fn row(&self) -> usize { self.row } ...
Error
identifier_name
common.rs
//! Contains several types used throughout the library. use std::fmt; use std::error; /// Represents a thing which has a position inside some textual document. /// /// This trait is implemented by parsers, lexers and errors. It is used primarily to create /// error objects. pub trait HasPosition { /// R...
} impl Error { /// Creates a new error using position information from the provided /// `HasPosition` object and a message. #[inline] pub fn new<O: HasPosition>(o: &O, msg: String) -> Error { Error { row: o.row(), col: o.col(), msg: msg } } /// Creates a new error using pro...
{ self.col }
identifier_body
common.rs
//! Contains several types used throughout the library. use std::fmt; use std::error; /// Represents a thing which has a position inside some textual document. /// /// This trait is implemented by parsers, lexers and errors. It is used primarily to create /// error objects. pub trait HasPosition { /// R...
fn description(&self) -> &str { &*self.msg } } /// XML version enumeration. #[derive(Copy, Clone, PartialEq, Eq)] pub enum XmlVersion { /// XML version 1.0. Version10, /// XML version 1.1. Version11 } impl fmt::Display for XmlVersion { fn fmt(&self, f: &mut fmt::Formatter) -> fm...
} impl error::Error for Error { #[inline]
random_line_split
mod.rs
pub type c_long = i32; pub type c_ulong = u32; pub type nlink_t = u32; s! { pub struct pthread_attr_t { __size: [u32; 9] } pub struct sigset_t { __val: [::c_ulong; 32], } pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, pub msg...
// Unknown target_arch } }
random_line_split
coding.rs
//! Coding system handler. use remacs_macros::lisp_fn; use crate::{ data::aref, eval::unbind_to, hashtable::{ gethash, HashLookupResult::{Found, Missing}, LispHashTableRef, }, lisp::LispObject, lists::{get, put}, minibuf::completing_read, multibyte::LispStringRe...
include!(concat!(env!("OUT_DIR"), "/coding_exports.rs"));
random_line_split
coding.rs
//! Coding system handler. use remacs_macros::lisp_fn; use crate::{ data::aref, eval::unbind_to, hashtable::{ gethash, HashLookupResult::{Found, Missing}, LispHashTableRef, }, lisp::LispObject, lists::{get, put}, minibuf::completing_read, multibyte::LispStringRe...
(fname: LispStringRef) -> LispStringRef { unsafe { c_encode_file_name(fname.into()) }.into() } /// Implements DECODE_SYSTEM macro /// Decode the string `input_string` using the specified coding system /// for system functions, if any. pub fn decode_system(input_string: LispStringRef) -> LispStringRef { let loc...
encode_file_name
identifier_name
coding.rs
//! Coding system handler. use remacs_macros::lisp_fn; use crate::{ data::aref, eval::unbind_to, hashtable::{ gethash, HashLookupResult::{Found, Missing}, LispHashTableRef, }, lisp::LispObject, lists::{get, put}, minibuf::completing_read, multibyte::LispStringRe...
/// Return t if OBJECT is nil or a coding-system. /// See the documentation of `define-coding-system' for information /// about coding-system objects. #[lisp_fn] pub fn coding_system_p(object: LispObject) -> bool { object.is_nil() || coding_system_id(object) >= 0 || object.is_symbol() && get(objec...
{ match coding_system_spec(x) { Qnil => { check_coding_system_lisp(x); match coding_system_spec(x) { Qnil => wrong_type!(Qcoding_system_p, x), spec => spec, } } spec => spec, } }
identifier_body
auracite_worker.rs
#![feature(plugin)] #![plugin(dotenv_macros)] extern crate auracite; extern crate dotenv; extern crate select; extern crate reqwest; use std::io::Read; use auracite::lodestone::NewsItem; use auracite::storage::{connect_redis, push_news}; use dotenv::dotenv; use select::document::Document; use select::predicate::{Cla...
(doc: &str) -> Vec<NewsItem> { let mut topics: Vec<NewsItem> = vec![]; let document = Document::from(doc); for (_, topic) in document.find(Class("news__list--topics")).enumerate() { let title = match topic.find(Class("news__list--title")).into_selection().children().first() { ...
parse_document
identifier_name
auracite_worker.rs
#![feature(plugin)] #![plugin(dotenv_macros)] extern crate auracite; extern crate dotenv; extern crate select; extern crate reqwest; use std::io::Read; use auracite::lodestone::NewsItem; use auracite::storage::{connect_redis, push_news}; use dotenv::dotenv; use select::document::Document; use select::predicate::{Cla...
fn parse_document(doc: &str) -> Vec<NewsItem> { let mut topics: Vec<NewsItem> = vec![]; let document = Document::from(doc); for (_, topic) in document.find(Class("news__list--topics")).enumerate() { let title = match topic.find(Class("news__list--title")).into_selection().children().f...
{ let mut res = reqwest::get(url).unwrap(); let mut body = String::new(); res.read_to_string(&mut body).unwrap(); body }
identifier_body
auracite_worker.rs
#![feature(plugin)] #![plugin(dotenv_macros)] extern crate auracite; extern crate dotenv; extern crate select; extern crate reqwest; use std::io::Read; use auracite::lodestone::NewsItem; use auracite::storage::{connect_redis, push_news}; use dotenv::dotenv; use select::document::Document; use select::predicate::{Cla...
for page in PAGES.into_iter() { let url = format!("http://{}.finalfantasyxiv.com/lodestone/topics", page); let download = download_page(url.as_str()); let topics = parse_document(download.as_str()); match push_news(page, &topics, &conn) { Ok(()) => println!("Pushed {} i...
fn main() { dotenv().ok(); let conn = connect_redis().unwrap();
random_line_split
mod.rs
#[cfg(feature = "backend_session")] use std::cell::RefCell; use std::os::unix::io::{AsRawFd, RawFd}; use std::path::PathBuf; use std::sync::{atomic::AtomicBool, Arc}; use std::time::{Instant, SystemTime}; use calloop::{EventSource, Interest, Poll, PostAction, Readiness, Token, TokenFactory}; use drm::control::{connect...
fn register(&mut self, poll: &mut Poll, factory: &mut TokenFactory) -> std::io::Result<()> { self.token = factory.token(); poll.register(self.as_raw_fd(), Interest::READ, calloop::Mode::Level, self.token) } fn reregister(&mut self, poll: &mut Poll, factory: &mut TokenFactory) -> std::io::Re...
Ok(PostAction::Continue) }
random_line_split
mod.rs
#[cfg(feature = "backend_session")] use std::cell::RefCell; use std::os::unix::io::{AsRawFd, RawFd}; use std::path::PathBuf; use std::sync::{atomic::AtomicBool, Arc}; use std::time::{Instant, SystemTime}; use calloop::{EventSource, Interest, Poll, PostAction, Readiness, Token, TokenFactory}; use drm::control::{connect...
(&self) -> bool { match *self.internal { DrmDeviceInternal::Atomic(_) => true, DrmDeviceInternal::Legacy(_) => false, } } /// Returns a list of crtcs for this device pub fn crtcs(&self) -> &[crtc::Handle] { self.resources.crtcs() } /// Returns a set ...
is_atomic
identifier_name
tool_bar.rs
// Copyright 2013-2015, The Rust-GNOME 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> //! Create bars of buttons and other widgets use libc::c_int; use ffi; use glib::{to_bo...
-> Option<Toolbar> { let tmp_pointer = unsafe { ffi::gtk_toolbar_new() }; check_pointer!(tmp_pointer, Toolbar) } pub fn insert<T: ::ToolItemTrait>(&self, item: &T, pos: i32) -> () { unsafe { ffi::gtk_toolba...
w()
identifier_name
tool_bar.rs
// Copyright 2013-2015, The Rust-GNOME 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> //! Create bars of buttons and other widgets use libc::c_int; use ffi; use glib::{to_bo...
} pub fn get_drop_index(&self, x: i32, y: i32) -> i32 { unsafe { ffi::gtk_toolbar_get_drop_index(GTK_TOOLBAR(self.pointer), x as c_int, y as c_int) as i32 } } pub fn set_drop_highlight_item<T: ::ToolItemTrait>(&self, item: &T, index: i32) -> () { unsafe { ...
None } else { Some(::FFIWidget::wrap_widget(tmp_pointer)) } }
random_line_split
tool_bar.rs
// Copyright 2013-2015, The Rust-GNOME 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> //! Create bars of buttons and other widgets use libc::c_int; use ffi; use glib::{to_bo...
lse { Some(::FFIWidget::wrap_widget(tmp_pointer)) } } } pub fn get_drop_index(&self, x: i32, y: i32) -> i32 { unsafe { ffi::gtk_toolbar_get_drop_index(GTK_TOOLBAR(self.pointer), x as c_int, y as c_int) as i32 } } pub fn set_drop_highlight...
None } e
conditional_block
tool_bar.rs
// Copyright 2013-2015, The Rust-GNOME 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> //! Create bars of buttons and other widgets use libc::c_int; use ffi; use glib::{to_bo...
pub fn set_icon_size(&self, icon_size: IconSize) -> () { unsafe { ffi::gtk_toolbar_set_icon_size(GTK_TOOLBAR(self.pointer), icon_size); } } pub fn unset_style(&self) -> () { unsafe { ffi::gtk_toolbar_unset_style(GTK_TOOLBAR(self.pointer)); } } } ...
unsafe { ffi::gtk_toolbar_set_style(GTK_TOOLBAR(self.pointer), style); } }
identifier_body
p3.rs
/// ### Largest prime factor /// ## Problem 3 /// The prime factors of 13195 are 5, 7, 13 and 29. /// /// What is the largest prime factor of the number 600851475143? use std::collections::TreeSet; fn factors(num: int) -> Option<(int, int)> { for divisor in range(2, num / 2) { if num % divisor == 0 { retu...
) { let num = 600851475143; println!("{}", prime_factors(num).iter().max().unwrap()); }
ain(
identifier_name
p3.rs
/// ### Largest prime factor /// ## Problem 3 /// The prime factors of 13195 are 5, 7, 13 and 29. /// /// What is the largest prime factor of the number 600851475143? use std::collections::TreeSet; fn factors(num: int) -> Option<(int, int)> { for divisor in range(2, num / 2) { if num % divisor == 0 { retu...
None => { primes.insert(numerator); return primes } } } } fn main() { let num = 600851475143; println!("{}", prime_factors(num).iter().max().unwrap()); }
primes.insert(a); numerator = b; }
conditional_block
p3.rs
/// ### Largest prime factor /// ## Problem 3 /// The prime factors of 13195 are 5, 7, 13 and 29. /// /// What is the largest prime factor of the number 600851475143? use std::collections::TreeSet; fn factors(num: int) -> Option<(int, int)> { for divisor in range(2, num / 2) { if num % divisor == 0 { retu...
fn main() { let num = 600851475143; println!("{}", prime_factors(num).iter().max().unwrap()); }
} } } }
random_line_split
p3.rs
/// ### Largest prime factor /// ## Problem 3 /// The prime factors of 13195 are 5, 7, 13 and 29. /// /// What is the largest prime factor of the number 600851475143? use std::collections::TreeSet; fn factors(num: int) -> Option<(int, int)> {
fn prime_factors(num: int) -> TreeSet<int> { let mut numerator = num; let mut primes = TreeSet::<int>::new(); loop { match factors(numerator) { Some((a, b)) => { primes.insert(a); numerator = b; } None => { primes.insert(numerator); return primes } ...
for divisor in range(2, num / 2) { if num % divisor == 0 { return Some((divisor, num / divisor)) } } None }
identifier_body
router.rs
//! Routing entity for handling endpoints //! //! This module is intended for matching and converting a passed URLs by a client //! in request into certain queue/topic names. //! use std::clone::Clone; use std::collections::HashMap; use crate::engine::router::endpoint::ReadOnlyEndpoint; use crate::error::{PathfinderE...
() { let router = get_router(&"./tests/files/config_with_invalid_endpoints.yaml"); let result_match = router.match_url(&"/api/matchmaking/search"); assert_eq!(result_match.is_err(), true); } }
test_routers_match_url_returns_an_error_for_an_unknown_url
identifier_name
router.rs
//! Routing entity for handling endpoints //! //! This module is intended for matching and converting a passed URLs by a client //! in request into certain queue/topic names. //! use std::clone::Clone; use std::collections::HashMap; use crate::engine::router::endpoint::ReadOnlyEndpoint; use crate::error::{PathfinderE...
Ok(endpoint) } false => Err(PathfinderError::EndpointNotFound(url.to_string())) } } } #[cfg(test)] mod tests { use crate::config::get_config; use crate::engine::router::{extract_endpoints, Router}; fn get_router(file_path: &str) -> Box<Router> { ...
match self.endpoints.contains_key(url) { true => { let endpoint = self.endpoints[url].clone();
random_line_split
at_exit_imp.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 ...
use unstable::sync::Exclusive; use slice::OwnedVector; use vec::Vec; type Queue = Exclusive<Vec<proc():Send>>; // You'll note that these variables are *not* atomic, and this is done on // purpose. This module is designed to have init() called *once* in a // single-task context, and then run() is called only once in a...
use ptr::RawPtr;
random_line_split
at_exit_imp.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 run() { let vec = unsafe { rtassert!(!RUNNING); rtassert!(!QUEUE.is_null()); RUNNING = true; let state: Box<Queue> = cast::transmute(QUEUE); QUEUE = 0 as *mut Queue; let mut vec = None; state.with(|arr| { vec = Some(mem::replace(arr, vec!(...
{ unsafe { rtassert!(!RUNNING); rtassert!(!QUEUE.is_null()); let state: &mut Queue = cast::transmute(QUEUE); let mut f = Some(f); state.with(|arr| { arr.push(f.take_unwrap()); }); } }
identifier_body
at_exit_imp.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { unsafe { rtassert!(!RUNNING); rtassert!(QUEUE.is_null()); let state: Box<Queue> = box Exclusive::new(vec!()); QUEUE = cast::transmute(state); } } pub fn push(f: proc():Send) { unsafe { rtassert!(!RUNNING); rtassert!(!QUEUE.is_null()); let state: ...
init
identifier_name
method-ambig-two-traits-cross-crate.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...
} fn main() { 1_usize.me(); } //~ ERROR E0034
{ *self }
identifier_body
method-ambig-two-traits-cross-crate.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...
trait me2 { fn me(&self) -> usize; } impl me2 for usize { fn me(&self) -> usize { *self } } fn main() { 1_usize.me(); } //~ ERROR E0034
random_line_split
method-ambig-two-traits-cross-crate.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...
(&self) -> usize { *self } } fn main() { 1_usize.me(); } //~ ERROR E0034
me
identifier_name
test-s3-getting-started.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::{Client, Error, Region}; use uuid::Uuid; #[ignore] #[tokio::test]
Err(_e) => assert!(false), _ => assert!(true), } } async fn run_s3_operations( region: Region, client: Client, bucket_name: String, file_name: String, key: String, target_key: String, ) -> Result<(), Error> { s3_service::create_bucket(&client, &bucket_name, region.as_ref...
async fn test_it_runs() { let (region, client, bucket_name, file_name, key, target_key) = setup().await; match run_s3_operations(region, client, bucket_name, file_name, key, target_key).await {
random_line_split
test-s3-getting-started.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::{Client, Error, Region}; use uuid::Uuid; #[ignore] #[tokio::test] async fn test_it_runs() { let (region, client, bucket_name, file...
( region: Region, client: Client, bucket_name: String, file_name: String, key: String, target_key: String, ) -> Result<(), Error> { s3_service::create_bucket(&client, &bucket_name, region.as_ref()).await?; s3_service::upload_object(&client, &bucket_name, &file_name, &key).await?; s3_...
run_s3_operations
identifier_name
test-s3-getting-started.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::{Client, Error, Region}; use uuid::Uuid; #[ignore] #[tokio::test] async fn test_it_runs() { let (region, client, bucket_name, file...
{ let region_provider = RegionProviderChain::first_try(Region::new("us-west-2")); let region = region_provider.region().await.unwrap(); let shared_config = aws_config::from_env().region(region_provider).load().await; let client = Client::new(&shared_config); let bucket_name = format!("{}{}", "doc-...
identifier_body
uploaded_file.rs
// Copyright © 2015 by Michael Dilger (of New Zealand) // This code is licensed under the MIT license (see LICENSE-MIT for details) use std::path::PathBuf; use std::ops::Drop; use mime::Mime; use tempdir::TempDir; use error::Error; use textnonce::TextNonce; /// An uploaded file that was received as part of `multipart...
path: path, filename: None, content_type: content_type, size: 0, tempdir: tempdir, }) } } impl Drop for UploadedFile { fn drop(&mut self) { let _ = ::std::fs::remove_file(&self.path); let _ = ::std::fs::remove_dir(&self.tempdir...
let tempdir = try!(TempDir::new("formdata")).into_path(); let mut path = tempdir.clone(); path.push(TextNonce::sized_urlsafe(32).unwrap().into_string()); Ok(UploadedFile {
random_line_split
uploaded_file.rs
// Copyright © 2015 by Michael Dilger (of New Zealand) // This code is licensed under the MIT license (see LICENSE-MIT for details) use std::path::PathBuf; use std::ops::Drop; use mime::Mime; use tempdir::TempDir; use error::Error; use textnonce::TextNonce; /// An uploaded file that was received as part of `multipart...
&mut self) { let _ = ::std::fs::remove_file(&self.path); let _ = ::std::fs::remove_dir(&self.tempdir); } }
rop(
identifier_name
create_rating.rs
use super::*; use diesel::connection::Connection; pub fn create_rating( connections: &sqlite::Connections, indexer: &mut dyn PlaceIndexer, rate_entry: usecases::NewPlaceRating, ) -> Result<(String, String)> { // Add new rating to existing entry let (rating_id, comment_id, place, status, ratings) =...
})?; Ok((rating_id, comment_id, place, status, ratings)) } Err(err) => { prepare_err = Some(err); Err(diesel::result::Error::RollbackTransaction) } ...
diesel::result::Error::RollbackTransaction
random_line_split
create_rating.rs
use super::*; use diesel::connection::Connection; pub fn
( connections: &sqlite::Connections, indexer: &mut dyn PlaceIndexer, rate_entry: usecases::NewPlaceRating, ) -> Result<(String, String)> { // Add new rating to existing entry let (rating_id, comment_id, place, status, ratings) = { let connection = connections.exclusive()?; let mut pr...
create_rating
identifier_name
create_rating.rs
use super::*; use diesel::connection::Connection; pub fn create_rating( connections: &sqlite::Connections, indexer: &mut dyn PlaceIndexer, rate_entry: usecases::NewPlaceRating, ) -> Result<(String, String)>
Err(diesel::result::Error::RollbackTransaction) } } }) .map_err(|err| { if let Some(err) = prepare_err { err } else { RepoError::from(err).into() } ...
{ // Add new rating to existing entry let (rating_id, comment_id, place, status, ratings) = { let connection = connections.exclusive()?; let mut prepare_err = None; connection .transaction::<_, diesel::result::Error, _>(|| { match usecases::prepare_new_rating(...
identifier_body
datetime.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use chrono::{FixedOffset, TimeZone}; use lazy_static::lazy_static; use mononoke_types::DateTime; /// Return a `DateTime` corresponding to ...
(year: i32, offset: i32) -> DateTime { DateTime::new(FixedOffset::west(offset).ymd(year, 1, 1).and_hms(0, 0, 0)) } pub const PST_OFFSET: i32 = 7 * 3600; lazy_static! { /// 1970-01-01 00:00:00 UTC. pub static ref EPOCH_ZERO: DateTime = DateTime::from_timestamp(0, 0).unwrap(); /// 1970-01-01 00:00:00 UT...
day_1_tz
identifier_name
datetime.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use chrono::{FixedOffset, TimeZone}; use lazy_static::lazy_static; use mononoke_types::DateTime; /// Return a `DateTime` corresponding to ...
/// 1900-01-01 00:00:00 UTC. pub static ref YEAR_1900: DateTime = day_1_utc(1900); /// 1900-01-01 00:00:00 UTC-07. pub static ref YEAR_1900_PST: DateTime = day_1_tz(1900, PST_OFFSET); /// 2000-01-01 00:00:00 UTC. pub static ref YEAR_2000: DateTime = day_1_utc(2000); /// 2000-01-01 00:00:00...
pub static ref EPOCH_ZERO_PST: DateTime = DateTime::from_timestamp(0, PST_OFFSET).unwrap();
random_line_split
datetime.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use chrono::{FixedOffset, TimeZone}; use lazy_static::lazy_static; use mononoke_types::DateTime; /// Return a `DateTime` corresponding to ...
/// Return a `DateTime` corresponding to <year>-01-01 00:00:00 UTC, /// with the specified offset applied. pub fn day_1_tz(year: i32, offset: i32) -> DateTime { DateTime::new(FixedOffset::west(offset).ymd(year, 1, 1).and_hms(0, 0, 0)) } pub const PST_OFFSET: i32 = 7 * 3600; lazy_static! { /// 1970-01-01 00:...
{ DateTime::new(FixedOffset::west(0).ymd(year, 1, 1).and_hms(0, 0, 0)) }
identifier_body
enum_list.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // 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, inc...
pub fn len(&self) -> u32 { self.reader.len() } } impl <'a, T : FromU16> FromPointerReader<'a> for Reader<'a, T> { fn get_from_pointer(reader : &PointerReader<'a>) -> Result<Reader<'a, T>> { Ok(Reader { reader : try!(reader.get_list(TwoBytes, ::std::ptr::null())), marker : ::std::...
{ Reader::<'b, T> { reader : reader, marker : ::std::marker::PhantomData } }
identifier_body
enum_list.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // 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, inc...
(&self, index : u32) -> ::std::result::Result<T, NotInSchema> { assert!(index < self.len()); let result : u16 = PrimitiveElement::get(&self.reader, index); FromU16::from_u16(result) } } pub struct Builder<'a, T> { marker : ::std::marker::PhantomData<T>, builder : ListBuilder<'a> } ...
get
identifier_name
enum_list.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // 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, inc...
FromU16::from_u16(result) } } impl <'a, T> ::traits::SetPointerBuilder<Builder<'a, T>> for Reader<'a, T> { fn set_pointer_builder<'b>(pointer : ::private::layout::PointerBuilder<'b>, value : Reader<'a, T>) -> Result<()> { pointer.set_list(&value.reader) } }
impl <'a, T : ToU16 + FromU16> Builder<'a, T> { pub fn get(&self, index : u32) -> ::std::result::Result<T, NotInSchema> { assert!(index < self.len()); let result : u16 = PrimitiveElement::get_from_builder(&self.builder, index);
random_line_split
mod.rs
//! Implementation of mio for Windows using IOCP //! //! This module uses I/O Completion Ports (IOCP) on Windows to implement mio's //! Unix epoll-like interface. Unfortunately these two I/O models are //! fundamentally incompatible: //! //! * IOCP is a completion-based model where work is submitted to the kernel and /...
}
{ Err(io::Error::last_os_error()) }
conditional_block