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
qquote.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} let abc = quote_expr!(cx, 23); check!(expr_to_string, abc, *quote_expr!(cx, $abc); "23"); let ty = quote_ty!(cx, isize); check!(ty_to_string, ty, *quote_ty!(cx, $ty); "isize"); let item = quote_item!(cx, static x: $ty = 10;).unwrap(); check!(item_to_string, item, quote_item!(cx, $item)....
{ let ps = syntax::parse::new_parse_sess(); let mut cx = syntax::ext::base::ExtCtxt::new( &ps, vec![], syntax::ext::expand::ExpansionConfig::default("qquote".to_string())); cx.bt_push(syntax::codemap::ExpnInfo { call_site: DUMMY_SP, callee: syntax::codemap::NameAndSpan { ...
identifier_body
qquote.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let ps = syntax::parse::new_parse_sess(); let mut cx = syntax::ext::base::ExtCtxt::new( &ps, vec![], syntax::ext::expand::ExpansionConfig::default("qquote".to_string())); cx.bt_push(syntax::codemap::ExpnInfo { call_site: DUMMY_SP, callee: syntax::codemap::NameAndSpan { ...
main
identifier_name
qquote.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// ignore-cross-compile #![feature(quote, rustc_private)] extern crate syntax; use syntax::codemap::DUMMY_SP; use syntax::print::pprust::*; fn main() { let ps = syntax::parse::new_parse_sess(); let mut cx = syntax::ext::base::ExtCtxt::new( &ps, vec![], syntax::ext::expand::ExpansionConfig::...
random_line_split
response_type.rs
use ffi; use glib::translate::{FromGlib, ToGlib, ToGlibPtr, ToGlibPtrMut, from_glib}; use glib::value::{FromValue, FromValueOptional, SetValue}; use glib::{StaticType, Type, Value}; use gobject_ffi; #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub enum ResponseType { None, Reject, Ac...
unsafe fn from_value_optional(value: &Value) -> Option<Self> { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for ResponseType { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for ResponseT...
impl<'a> FromValueOptional<'a> for ResponseType {
random_line_split
response_type.rs
use ffi; use glib::translate::{FromGlib, ToGlib, ToGlibPtr, ToGlibPtrMut, from_glib}; use glib::value::{FromValue, FromValueOptional, SetValue}; use glib::{StaticType, Type, Value}; use gobject_ffi; #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub enum
{ None, Reject, Accept, DeleteEvent, Ok, Cancel, Close, Yes, No, Apply, Help, Other(u16), #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl ToGlib for ResponseType { type GlibType = ffi::GtkResponseType; fn to_glib(&self) -> ffi::GtkResponseType { ...
ResponseType
identifier_name
response_type.rs
use ffi; use glib::translate::{FromGlib, ToGlib, ToGlibPtr, ToGlibPtrMut, from_glib}; use glib::value::{FromValue, FromValueOptional, SetValue}; use glib::{StaticType, Type, Value}; use gobject_ffi; #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub enum ResponseType { None, Reject, Ac...
} impl SetValue for ResponseType { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } }
{ from_glib(gobject_ffi::g_value_get_enum(value.to_glib_none().0)) }
identifier_body
issue-23620-invalid-escapes.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let _ = b"\u{a66e}"; //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string let _ = b'\u{a66e}'; //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string let _ = b'\u'; //~^ ERROR incorrect unicode escape sequence //~^^ ERROR unicode e...
main
identifier_name
issue-23620-invalid-escapes.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let _ = '\xxy'; //~^ ERROR invalid character in numeric character escape: x //~^^ ERROR invalid character in numeric character escape: y let _ = b"\u{a4a4} \xf \u"; //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string //~^^ ERROR invalid character in numeric charact...
{ let _ = b"\u{a66e}"; //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string let _ = b'\u{a66e}'; //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string let _ = b'\u'; //~^ ERROR incorrect unicode escape sequence //~^^ ERROR unicode esca...
identifier_body
issue-23620-invalid-escapes.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
fn main() { let _ = b"\u{a66e}"; //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string let _ = b'\u{a66e}'; //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string let _ = b'\u'; //~^ ERROR incorrect unicode escape sequence //~^^ ERROR u...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
comm.rs
use serial::prelude::*; use serial::{self, SystemPort}; use events::{EventManager, Event, EventType}; use std::sync::{Arc, Mutex}; use std::thread::{self, JoinHandle}; use std::time::Duration; use std::io::{Read, Write}; pub struct SerialComm { port: SystemPort, db: Arc<Mutex<EventManager>>, thread: Opti...
let node_id = buffer[2]; let bat_lvl = buffer[3]; match buffer[1] { 0 => { let is_pir = buffer[4]; let id = buffer[5]; let event = Event::new( node_id,...
{ println!("Received garbage"); continue; }
conditional_block
comm.rs
use serial::prelude::*; use serial::{self, SystemPort}; use events::{EventManager, Event, EventType}; use std::sync::{Arc, Mutex}; use std::thread::{self, JoinHandle}; use std::time::Duration; use std::io::{Read, Write}; pub struct SerialComm { port: SystemPort, db: Arc<Mutex<EventManager>>, thread: Optio...
data[5] = bitmask; data[6] = 1; self.port.write_all(&data).unwrap(); } pub fn update_switch_pir_time(&mut self, device_id: u8, switch_id: u8, pir_time: u16) { let mut data = [0; 7]; data[0] = 123; data[1] = 2; data[2] = device_id; data[3] = switch...
} }
random_line_split
comm.rs
use serial::prelude::*; use serial::{self, SystemPort}; use events::{EventManager, Event, EventType}; use std::sync::{Arc, Mutex}; use std::thread::{self, JoinHandle}; use std::time::Duration; use std::io::{Read, Write}; pub struct SerialComm { port: SystemPort, db: Arc<Mutex<EventManager>>, thread: Opti...
(&mut self, device_id: u8, switch_id: u8, pir_time: u16) { let mut data = [0; 7]; data[0] = 123; data[1] = 2; data[2] = device_id; data[3] = switch_id; data[4] = (pir_time>>8) as u8; data[5] = (pir_time & 0xFF) as u8; self.port.write_all(&data).unwrap(); ...
update_switch_pir_time
identifier_name
comm.rs
use serial::prelude::*; use serial::{self, SystemPort}; use events::{EventManager, Event, EventType}; use std::sync::{Arc, Mutex}; use std::thread::{self, JoinHandle}; use std::time::Duration; use std::io::{Read, Write}; pub struct SerialComm { port: SystemPort, db: Arc<Mutex<EventManager>>, thread: Opti...
if pir.0 == source { bitmask |= 1<<pir.1; } } data[5] = bitmask; data[6] = 1; self.port.write_all(&data).unwrap(); } pub fn update_switch_pir_time(&mut self, device_id: u8, switch_id: u8, pir_time: u16) { let mut data = [0; 7]; ...
{ let mut data = [0; 7]; data[0] = 123; data[1] = 1; data[2] = device_id; data[3] = switch_id; data[4] = source; // Button configuration let mut bitmask = 0; for button in buttons { if button.0 == source { bitmask |= 1<<...
identifier_body
c-variadic.rs
// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C no-prepopulate-passes // #![crate_type = "lib"] #![feature(c_variadic)] #![feature(c_unwind)] #![no_std] use core::ffi::VaList; extern "C" { fn foreign_c_variadic_0(_: i32,...); fn foreign_c_variadic_1(_: VaList,...); } pub unsaf...
(ap: VaList) { // CHECK: call void ({{.*}}*,...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 42) foreign_c_variadic_1(ap, 42i32); } pub unsafe extern "C" fn use_foreign_c_variadic_1_2(ap: VaList) { // CHECK: call void ({{.*}}*,...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 2, [[PARAM]] 42) foreign_c_v...
use_foreign_c_variadic_1_1
identifier_name
c-variadic.rs
// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C no-prepopulate-passes // #![crate_type = "lib"] #![feature(c_variadic)] #![feature(c_unwind)] #![no_std] use core::ffi::VaList; extern "C" { fn foreign_c_variadic_0(_: i32,...); fn foreign_c_variadic_1(_: VaList,...); } pub unsaf...
pub unsafe extern "C" fn use_foreign_c_variadic_1_2(ap: VaList) { // CHECK: call void ({{.*}}*,...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 2, [[PARAM]] 42) foreign_c_variadic_1(ap, 2i32, 42i32); } pub unsafe extern "C" fn use_foreign_c_variadic_1_3(ap: VaList) { // CHECK: call void ({{.*}}*,...) @for...
{ // CHECK: call void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 42) foreign_c_variadic_1(ap, 42i32); }
identifier_body
c-variadic.rs
// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C no-prepopulate-passes // #![crate_type = "lib"] #![feature(c_variadic)] #![feature(c_unwind)] #![no_std] use core::ffi::VaList; extern "C" { fn foreign_c_variadic_0(_: i32,...); fn foreign_c_variadic_1(_: VaList,...); } pub unsaf...
// defined C-variadic. pub unsafe fn test_c_variadic_call() { // CHECK: call [[RET:(signext )?i32]] (i32,...) @c_variadic([[PARAM]] 0) c_variadic(0); // CHECK: call [[RET]] (i32,...) @c_variadic([[PARAM]] 0, [[PARAM]] 42) c_variadic(0, 42i32); // CHECK: call [[RET]] (i32,...) @c_variadic([[PARAM]] 0...
// Ensure that we generate the correct `call` signature when calling a Rust
random_line_split
regions-free-region-ordering-caller.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn call2<'a, 'b>(a: &'a uint, b: &'b uint) { let z: Option<&'b &'a uint> = None; //~^ ERROR pointer has a longer lifetime than the data it references } fn call3<'a, 'b>(a: &'a uint, b: &'b uint) { let y: Paramd<'a> = Paramd { x: a }; let z: Option<&'b Paramd<'a>> = None; //~^ ERROR pointer has a ...
{ let y: uint = 3; let z: &'a &'blk uint = &(&y); //~^ ERROR pointer has a longer lifetime than the data it references }
identifier_body
regions-free-region-ordering-caller.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 ...
struct Paramd<'self> { x: &'self uint } fn call1<'a>(x: &'a uint) { let y: uint = 3; let z: &'a &'blk uint = &(&y); //~^ ERROR pointer has a longer lifetime than the data it references } fn call2<'a, 'b>(a: &'a uint, b: &'b uint) { let z: Option<&'b &'a uint> = None; //~^ ERROR pointer has a long...
// except according to those terms. // Test various ways to construct a pointer with a longer lifetime // than the thing it points at and ensure that they result in // errors. See also regions-free-region-ordering-callee.rs
random_line_split
regions-free-region-ordering-caller.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 ...
<'self> { x: &'self uint } fn call1<'a>(x: &'a uint) { let y: uint = 3; let z: &'a &'blk uint = &(&y); //~^ ERROR pointer has a longer lifetime than the data it references } fn call2<'a, 'b>(a: &'a uint, b: &'b uint) { let z: Option<&'b &'a uint> = None; //~^ ERROR pointer has a longer lifetime th...
Paramd
identifier_name
glyph_item_iter.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib::translate::*; use pango_sys; use GlyphItem; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct GlyphItemIter(Boxed<pango_sys::PangoG...
(&mut self) -> bool { unsafe { from_glib(pango_sys::pango_glyph_item_iter_next_cluster( self.to_glib_none_mut().0, )) } } pub fn prev_cluster(&mut self) -> bool { unsafe { from_glib(pango_sys::pango_glyph_item_iter_prev_cluster( ...
next_cluster
identifier_name
glyph_item_iter.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib::translate::*; use pango_sys; use GlyphItem; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct GlyphItemIter(Boxed<pango_sys::PangoG...
pub fn init_start(&mut self, glyph_item: &mut GlyphItem, text: &str) -> bool { unsafe { from_glib(pango_sys::pango_glyph_item_iter_init_start( self.to_glib_none_mut().0, glyph_item.to_glib_none_mut().0, text.to_glib_none().0, )) ...
{ unsafe { from_glib(pango_sys::pango_glyph_item_iter_init_end( self.to_glib_none_mut().0, glyph_item.to_glib_none_mut().0, text.to_glib_none().0, )) } }
identifier_body
glyph_item_iter.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib::translate::*; use pango_sys; use GlyphItem; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct GlyphItemIter(Boxed<pango_sys::PangoG...
)) } } pub fn init_start(&mut self, glyph_item: &mut GlyphItem, text: &str) -> bool { unsafe { from_glib(pango_sys::pango_glyph_item_iter_init_start( self.to_glib_none_mut().0, glyph_item.to_glib_none_mut().0, text.to_glib_...
from_glib(pango_sys::pango_glyph_item_iter_init_end( self.to_glib_none_mut().0, glyph_item.to_glib_none_mut().0, text.to_glib_none().0,
random_line_split
main.rs
extern crate nt; extern crate time; extern crate getopts; use std::io::Read; use getopts::{Options,Matches}; use nt::core::Note; use nt::core::persistence::Store; use nt::core::editor; use nt::core::persistence::Search; use nt::core::persistence::sqlite::SQLiteStore; // Whether new notes should be read from stdin. I...
{ let brief = format!("Usage: {} [options]", program); print!("{}", opts.usage(&brief)); }
identifier_body
main.rs
extern crate nt; extern crate time; extern crate getopts; use std::io::Read; use getopts::{Options,Matches}; use nt::core::Note; use nt::core::persistence::Store; use nt::core::editor; use nt::core::persistence::Search; use nt::core::persistence::sqlite::SQLiteStore; // Whether new notes should be read from stdin. I...
(program: &str, opts: Options) { let brief = format!("Usage: {} [options]", program); print!("{}", opts.usage(&brief)); }
print_usage
identifier_name
main.rs
extern crate nt; extern crate time; extern crate getopts;
use std::io::Read; use getopts::{Options,Matches}; use nt::core::Note; use nt::core::persistence::Store; use nt::core::editor; use nt::core::persistence::Search; use nt::core::persistence::sqlite::SQLiteStore; // Whether new notes should be read from stdin. If unset, the system editor // is used. const READ_FROM_STD...
random_line_split
macros.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 ...
) // Some basic logging. Enabled by passing `--cfg rtdebug` to the libstd build. macro_rules! rtdebug ( ($($arg:tt)*) => ( { if cfg!(rtdebug) { rterrln!($($arg)*) } }) ) macro_rules! rtassert ( ( $arg:expr ) => ( { if ::macros::ENFORCE_SANITY { if!$arg { ...
random_line_split
macros.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 std::intrinsics; unsafe { intrinsics::abort() } } }
t() -
identifier_name
macros.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 std::intrinsics; unsafe { intrinsics::abort() } } }
identifier_body
notify.rs
quick_error! { /// Error when waking up a connection /// /// In most cases it's okay to panic on this error #[derive(Debug)] pub enum WakeupError { /// I/O error when sending data to internal pipe /// /// We discard the io error as there no practical reason for this ...
use mio::Token; use mio::deprecated::Sender; use handler::{Notify};
random_line_split
notify.rs
use mio::Token; use mio::deprecated::Sender; use handler::{Notify}; quick_error! { /// Error when waking up a connection /// /// In most cases it's okay to panic on this error #[derive(Debug)] pub enum WakeupError { /// I/O error when sending data to internal pipe /// /// W...
(token: Token, channel: &Sender<Notify>) -> Notifier { Notifier { token: token, channel: channel.clone() } } impl Notifier { /// Wakeup a state machine /// /// pub fn wakeup(&self) -> Result<(), WakeupError> { use mio::deprecated::NotifyError::*; match self.chann...
create_notifier
identifier_name
ln.rs
#![crate_name = "uu_ln"] /* * This file is part of the uutils coreutils package. * * (c) Joseph Crail <jbcrail@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; #[macro_use] extern crate uucore; u...
{ NoBackup, SimpleBackup, NumberedBackup, ExistingBackup, } pub fn uumain(args: Vec<String>) -> i32 { let mut opts = getopts::Options::new(); opts.optflag("b", "", "make a backup of each file that would otherwise be overwritten or removed"); opts.optflagopt("", "backup", "make a backup of...
BackupMode
identifier_name
ln.rs
#![crate_name = "uu_ln"] /* * This file is part of the uutils coreutils package. * * (c) Joseph Crail <jbcrail@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; #[macro_use] extern crate uucore; u...
{ match fs::symlink_metadata(path) { Ok(m) => m.file_type().is_symlink(), Err(_) => false } }
identifier_body
ln.rs
#![crate_name = "uu_ln"] /* * This file is part of the uutils coreutils package. * * (c) Joseph Crail <jbcrail@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; #[macro_use] extern crate uucore; u...
if!new_path.exists() { return new_path; } i += 1; } } fn existing_backup_path(path: &PathBuf, suffix: &str) -> PathBuf { let test_path = simple_backup_path(path, &".~1~".to_owned()); if test_path.exists() { return numbered_backup_path(path); } simple_back...
random_line_split
derivable.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 std::fmt::Debug; use anyhow::Result; use async_trait::async_trait; use context::CoreContext; use futures::future::try_join; use futures::stream::{self, StreamExt, TryStreamExt}; use mononoke_types::{BonsaiChangeset, ChangesetId}; use crate::context::DerivationContext; use derived_data_service_if::types::DerivedD...
use std::any::TypeId; use std::collections::{HashMap, HashSet};
random_line_split
derivable.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 std::any::TypeId; use std::collections::{HashMap, HashSet}; use std::fmt::Debug; use anyhow::Result; use async_trait::async_trait; use...
else { Rest::check_dependencies(ctx, derivation_ctx, csid, visited).await } } } #[macro_export] macro_rules! dependencies { () => { () }; ($dep:ty) => { ( $dep, () ) }; ($dep:ty, $( $rest:tt )*) => { ( $dep, dependencies!($( $rest )*) ) }; }
{ try_join( derivation_ctx.fetch_dependency::<Derivable>(ctx, csid), Rest::check_dependencies(ctx, derivation_ctx, csid, visited), ) .await?; Ok(()) }
conditional_block
derivable.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 std::any::TypeId; use std::collections::{HashMap, HashSet}; use std::fmt::Debug; use anyhow::Result; use async_trait::async_trait; use...
( ctx: &CoreContext, derivation_ctx: &DerivationContext, changeset_ids: &[ChangesetId], ) -> Result<HashMap<ChangesetId, Self>> { stream::iter(changeset_ids.iter().copied().map(|csid| async move { let maybe_derived = Self::fetch(ctx, derivation_ctx, csid).await?; ...
fetch_batch
identifier_name
derivable.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 std::any::TypeId; use std::collections::{HashMap, HashSet}; use std::fmt::Debug; use anyhow::Result; use async_trait::async_trait; use...
} #[macro_export] macro_rules! dependencies { () => { () }; ($dep:ty) => { ( $dep, () ) }; ($dep:ty, $( $rest:tt )*) => { ( $dep, dependencies!($( $rest )*) ) }; }
{ let type_id = TypeId::of::<Derivable>(); if visited.insert(type_id) { try_join( derivation_ctx.fetch_dependency::<Derivable>(ctx, csid), Rest::check_dependencies(ctx, derivation_ctx, csid, visited), ) .await?; Ok(()) ...
identifier_body
webglprogram.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::{CanvasMsg, CanvasWebGLMsg...
let (sender, receiver) = ipc::channel().unwrap(); self.renderer .send(CanvasMsg::WebGL(CanvasWebGLMsg::GetAttribLocation(self.id, String::from(name), sender))) .unwrap(); Ok(receiver.recv().unwrap()) } /// glGetUniformLocation pub fn get_uniform_location(&sel...
{ return Ok(None); }
conditional_block
webglprogram.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::{CanvasMsg, CanvasWebGLMsg...
/// glLinkProgram pub fn link(&self) { self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::LinkProgram(self.id))).unwrap(); } /// glUseProgram pub fn use_program(&self) { self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::UseProgram(self.id))).unwrap(); } /// glAttachSha...
{ if !self.is_deleted.get() { self.is_deleted.set(true); let _ = self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteProgram(self.id))); } }
identifier_body
webglprogram.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::{CanvasMsg, CanvasWebGLMsg...
{ webgl_object: WebGLObject, id: u32, is_deleted: Cell<bool>, fragment_shader: MutNullableHeap<JS<WebGLShader>>, vertex_shader: MutNullableHeap<JS<WebGLShader>>, #[ignore_heap_size_of = "Defined in ipc-channel"] renderer: IpcSender<CanvasMsg>, } impl WebGLProgram { fn new_inherited(ren...
WebGLProgram
identifier_name
webglprogram.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::{CanvasMsg, CanvasWebGLMsg...
// shader. if shader_slot.get().is_some() { return Err(WebGLError::InvalidOperation); } shader_slot.set(Some(shader)); self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::AttachShader(self.id, shader.id()))).unwrap(); Ok(()) } /// glBindAttribLocat...
}; // TODO(ecoal95): Differentiate between same shader already assigned and other previous
random_line_split
default.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...
} Named(ref fields) => { let default_fields = fields.iter().map(|&(ident, span)| { cx.field_imm(span, ident, default_call(span)) }).collect(); cx.expr_struct_ident(trait_span, substr.type_ident, default_...
{ let exprs = fields.iter().map(|sp| default_call(*sp)).collect(); cx.expr_call_ident(trait_span, substr.type_ident, exprs) }
conditional_block
default.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...
}) }; trait_def.expand(cx, mitem, item, push) } fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> { let default_ident = vec!( cx.ident_of("std"), cx.ident_of("default"), cx.ident_of("Default"), cx.ident_of("default") ...
{ let inline = cx.meta_word(span, InternedString::new("inline")); let attrs = vec!(cx.attribute(span, inline)); let trait_def = TraitDef { span: span, attributes: Vec::new(), path: Path::new(vec!("std", "default", "Default")), additional_bounds: Vec::new(), generics: ...
identifier_body
default.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...
use ast::{MetaItem, Item, Expr}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use parse::token::InternedString; use ptr::P; pub fn expand_deriving_default<F>(cx: &mut ExtCtxt, span: Span, ...
random_line_split
default.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...
<F>(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Item, push: F) where F: FnOnce(P<Item>), { let inline = cx.meta_word(span, InternedString::new("inline")); let at...
expand_deriving_default
identifier_name
main.rs
#[macro_use] extern crate lazy_static; extern crate regex; extern crate rand; mod parser; mod eval; mod error; mod common_util; mod syntax_tree; use std::io::prelude::*; use std::io; use parser::*; use eval::*; /// Works like the println macro, but prints to the stderr instead of stdout. macro_rules! println_to_std...
let token_res = tokenize(&input as &str); //println!("Tokens: {:?} ", token_res); // DEBUG match token_res { Ok(tk_vec) => { let ast_res = parse_cmd(&tk_vec); match ast_res { Ok(cmd) => { //println!("AST: {:?} ", exp); // TODO let val_res = eval_cmd(&cmd, &mut env); match val...
else { input = temp; } } }
random_line_split
main.rs
#[macro_use] extern crate lazy_static; extern crate regex; extern crate rand; mod parser; mod eval; mod error; mod common_util; mod syntax_tree; use std::io::prelude::*; use std::io; use parser::*; use eval::*; /// Works like the println macro, but prints to the stderr instead of stdout. macro_rules! println_to_std...
() { let mut input; let max_call_depth = 100; let mut env = RollerEnv::new(max_call_depth); // The REP loop // Currently there is no way to exit other than the interrupt signal (ctrl + c) loop { print!("> "); // flush so our prompt is visible io::stdout().flush().ok().expect("Couldn't flush stdout"); l...
main
identifier_name
main.rs
#[macro_use] extern crate lazy_static; extern crate regex; extern crate rand; mod parser; mod eval; mod error; mod common_util; mod syntax_tree; use std::io::prelude::*; use std::io; use parser::*; use eval::*; /// Works like the println macro, but prints to the stderr instead of stdout. macro_rules! println_to_std...
}, // EOF encountered Ok(0) => break, // Read some bytes Ok(_) => { if temp.trim().is_empty() { // ignore empty lines continue; } else { input = temp; } } } let token_res = tokenize(&input as &str); //println!("Tokens: {:?} ", token_res); // DEBUG match token_r...
{ let mut input; let max_call_depth = 100; let mut env = RollerEnv::new(max_call_depth); // The REP loop // Currently there is no way to exit other than the interrupt signal (ctrl + c) loop { print!("> "); // flush so our prompt is visible io::stdout().flush().ok().expect("Couldn't flush stdout"); let ...
identifier_body
lib.rs
//! The OTLP Exporter supports exporting trace and metric data in the OTLP //! format to the OpenTelemetry collector or other compatible backend. //! //! The OpenTelemetry Collector offers a vendor-agnostic implementation on how //! to receive, process, and export telemetry data. In addition, it removes //! the need to...
} /// Create a new pipeline builder with the recommended configuration. /// /// ## Examples /// /// ```no_run /// fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync +'static>> { /// let tracing_builder = opentelemetry_otlp::new_pipeline() /// .tracing(); /// /// Ok(()) /// } ///...
{ HttpExporterBuilder::default() }
identifier_body
lib.rs
//! The OTLP Exporter supports exporting trace and metric data in the OTLP //! format to the OpenTelemetry collector or other compatible backend. //! //! The OpenTelemetry Collector offers a vendor-agnostic implementation on how //! to receive, process, and export telemetry data. In addition, it removes //! the need to...
}, } } } impl ExportError for Error { fn exporter_name(&self) -> &'static str { "otlp" } } /// The communication protocol to use when exporting data. #[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Copy, Debug)] pub enum Protocol { /// GR...
{ "".to_string() }
conditional_block
lib.rs
//! The OTLP Exporter supports exporting trace and metric data in the OTLP //! format to the OpenTelemetry collector or other compatible backend. //! //! The OpenTelemetry Collector offers a vendor-agnostic implementation on how //! to receive, process, and export telemetry data. In addition, it removes //! the need to...
(time: SystemTime) -> u64 { time.duration_since(UNIX_EPOCH) .unwrap_or_else(|_| Duration::from_secs(0)) .as_nanos() as u64 }
to_nanos
identifier_name
lib.rs
//! The OTLP Exporter supports exporting trace and metric data in the OTLP //! format to the OpenTelemetry collector or other compatible backend. //! //! The OpenTelemetry Collector offers a vendor-agnostic implementation on how
//! Prometheus, etc.) sending to multiple open-source or commercial back-ends. //! //! Currently, this crate only support sending tracing data or metrics in OTLP //! via grpc and http(in binary format). Supports for other format and protocol //! will be added in the future. The details of what's currently offering in t...
//! to receive, process, and export telemetry data. In addition, it removes //! the need to run, operate, and maintain multiple agents/collectors in //! order to support open-source telemetry data formats (e.g. Jaeger,
random_line_split
lib.rs
#![allow(dead_code)] struct ExampleGroup { name: &'static str, examples: Vec<Example>, } struct Example { name: &'static str, body: Box<Fn() -> bool>,
pub fn it<B: Fn() -> bool +'static>(&mut self, name: &'static str, body: B) { self.examples.push(Example { name: name, body: Box::new(body), }); } pub fn run(&self) { for example in self.examples.iter() { let result = example.run(); p...
} impl ExampleGroup {
random_line_split
lib.rs
#![allow(dead_code)] struct ExampleGroup { name: &'static str, examples: Vec<Example>, } struct Example { name: &'static str, body: Box<Fn() -> bool>, } impl ExampleGroup { pub fn it<B: Fn() -> bool +'static>(&mut self, name: &'static str, body: B) { self.examples.push(Example { ...
(&self) -> bool { (self.body)() } } pub fn describe<B: Fn(&mut ExampleGroup)>(name: &'static str, body: B) { let example_group = &mut ExampleGroup { name: name, examples: vec![], }; body(example_group); example_group.run(); }
run
identifier_name
lib.rs
#![allow(dead_code)] struct ExampleGroup { name: &'static str, examples: Vec<Example>, } struct Example { name: &'static str, body: Box<Fn() -> bool>, } impl ExampleGroup { pub fn it<B: Fn() -> bool +'static>(&mut self, name: &'static str, body: B) { self.examples.push(Example { ...
} } impl Example { pub fn run(&self) -> bool { (self.body)() } } pub fn describe<B: Fn(&mut ExampleGroup)>(name: &'static str, body: B) { let example_group = &mut ExampleGroup { name: name, examples: vec![], }; body(example_group); example_group.run(); }
{ "FAILED" }
conditional_block
field_isempty.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the ...
}
{ e.get_header() .read(&self.header_field_path[..]) .map(|v| { match v { Some(&Value::Array(ref a)) => a.is_empty(), Some(&Value::String(ref s)) => s.is_empty(), Some(&Value::Table(ref t)) => t.is_empty(), ...
identifier_body
field_isempty.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the ...
(&self, e: &Entry) -> bool { e.get_header() .read(&self.header_field_path[..]) .map(|v| { match v { Some(&Value::Array(ref a)) => a.is_empty(), Some(&Value::String(ref s)) => s.is_empty(), Some(&Value::Table(ref...
filter
identifier_name
field_isempty.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the ...
// This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Pub...
// 2.1 of the License. //
random_line_split
frequency.rs
use envelope; use pitch; /// Types for generating the frequency given some playhead position. pub trait Frequency { /// Return the frequency given some playhead percentage through the duration of the Synth. /// - 0.0 < perc < 1.0l fn hz_at_playhead(&self, perc: f64) -> f64; /// Return the frequency as...
(&self) -> Dynamic { use std::iter::once; if let Dynamic::Hz(hz) = *self { let perc = pitch::Hz(hz as f32).perc(); return Dynamic::Envelope({ once(envelope::Point::new(0.0, perc, 0.0)) .chain(once(envelope::Point::new(1.0, perc, 0.0))) ...
to_env
identifier_name
frequency.rs
use envelope; use pitch; /// Types for generating the frequency given some playhead position. pub trait Frequency { /// Return the frequency given some playhead percentage through the duration of the Synth. /// - 0.0 < perc < 1.0l fn hz_at_playhead(&self, perc: f64) -> f64; /// Return the frequency as...
self.clone() } /// Convert the dynamic to its Hz variant. pub fn to_hz(&self) -> Dynamic { if let Dynamic::Envelope(ref env) = *self { use pitch::{LetterOctave, Letter}; // Just convert the first point to the constant Hz. return match env.points.iter().n...
{ let perc = pitch::Hz(hz as f32).perc(); return Dynamic::Envelope({ once(envelope::Point::new(0.0, perc, 0.0)) .chain(once(envelope::Point::new(1.0, perc, 0.0))) .collect() }) }
conditional_block
frequency.rs
use envelope; use pitch; /// Types for generating the frequency given some playhead position. pub trait Frequency { /// Return the frequency given some playhead percentage through the duration of the Synth. /// - 0.0 < perc < 1.0l fn hz_at_playhead(&self, perc: f64) -> f64; /// Return the frequency as...
#[inline] fn freq_perc_at_playhead(&self, perc: f64) -> f64 { pitch::Hz(self.hz_at_playhead(perc) as f32).perc() } } /// Alias for the Envelope used. pub type Envelope = envelope::Envelope; /// A type that allows dynamically switching between constant and enveloped frequency. #[derive(Debug, Clone...
random_line_split
mod.rs
//! General purpose I/O pub mod crh; pub mod crl; use volatile::{RO, RW, WO}; #[repr(C)] pub struct Gpio { /// Configuration register low /* 0x00 */ pub crl: RW<crl::Register>, /// Configuration register high /* 0x04 */ pub crh: RW<crh::Register>, /* 0x08 */ idr: RO<u32>, /* 0x0C */ odr: RW<u...
{ _10MHz, _2MHz, _50MHz, }
Speed
identifier_name
mod.rs
//! General purpose I/O pub mod crh; pub mod crl; use volatile::{RO, RW, WO}; #[repr(C)] pub struct Gpio { /// Configuration register low /* 0x00 */ pub crl: RW<crl::Register>, /// Configuration register high /* 0x04 */ pub crh: RW<crh::Register>, /* 0x08 */ idr: RO<u32>, /* 0x0C */ odr: RW<u...
/// Port bit set/reset register /* 0x10 */ pub bsrr: WO<bsrr::Register>, /* 0x14 */ brr: WO<u32>, /* 0x18 */ lckr: RW<u32>, } reg!(bsrr: u32 { BS0: 0, BS1: 1, BS2: 2, BS3: 3, BS4: 4, BS5: 5, BS6: 6, BS7: 7, BS8: 8, BS9: 9, BS10: 10, BS11: 11, BS12: 12...
random_line_split
lib.rs
//! Generate Rust bindings for C and C++ libraries. //! //! Provide a C/C++ header file, receive Rust FFI code to call into C/C++ //! functions and use types defined in the header. //! //! See the [Builder](./struct.Builder.html) struct for usage. #![crate_name = "bindgen"] #![crate_type = "dylib"] #![cfg_attr(featur...
<T: Borrow<str>>(mut self, arg: T) -> Builder { self.options.whitelisted_functions.insert(&arg); self } /// Whitelist the given variable so that it (and all types that it /// transitively refers to) appears in the generated bindings. pub fn whitelisted_var<T: Borrow<str>>(mut self, arg:...
whitelisted_function
identifier_name
lib.rs
//! Generate Rust bindings for C and C++ libraries. //! //! Provide a C/C++ header file, receive Rust FFI code to call into C/C++ //! functions and use types defined in the header. //! //! See the [Builder](./struct.Builder.html) struct for usage. #![crate_name = "bindgen"] #![crate_type = "dylib"] #![cfg_attr(featur...
/// Parse one `Item` from the Clang cursor. pub fn parse_one(ctx: &mut BindgenContext, cursor: clang::Cursor, parent: Option<ItemId>, children: &mut Vec<ItemId>) -> clangll::Enum_CXVisitorResult { if!filter_builtins(ctx, &cursor) { return CXChildVisit_Con...
{ let (file, _, _, _) = cursor.location().location(); match file.name() { None => ctx.options().builtins, Some(..) => true, } }
identifier_body
lib.rs
//! Generate Rust bindings for C and C++ libraries. //! //! Provide a C/C++ header file, receive Rust FFI code to call into C/C++ //! functions and use types defined in the header. //! //! See the [Builder](./struct.Builder.html) struct for usage. #![crate_name = "bindgen"] #![crate_type = "dylib"] #![cfg_attr(featur...
} CXChildVisit_Continue } /// Parse the Clang AST into our `Item` internal representation. fn parse(context: &mut BindgenContext) { use clang::Diagnostic; use clangll::*; for d in context.translation_unit().diags().iter() { let msg = d.format(Diagnostic::default_opts()); let is_er...
{ cursor.visit(|child, _| parse_one(ctx, *child, parent, children)); }
conditional_block
lib.rs
//! Generate Rust bindings for C and C++ libraries. //! //! Provide a C/C++ header file, receive Rust FFI code to call into C/C++ //! functions and use types defined in the header. //! //! See the [Builder](./struct.Builder.html) struct for usage. #![crate_name = "bindgen"] #![crate_type = "dylib"] #![cfg_attr(featur...
/// Whitelist the given variable so that it (and all types that it /// transitively refers to) appears in the generated bindings. pub fn whitelisted_var<T: Borrow<str>>(mut self, arg: T) -> Builder { self.options.whitelisted_vars.insert(&arg); self } /// Add a string to prepend to ...
self }
random_line_split
liballoc_boxed_test.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
#[test] fn i64_slice() { let slice: &[i64] = &[i64::MIN, -2, -1, 0, 1, 2, i64::MAX]; let boxed: Box<[i64]> = Box::from(slice); assert_eq!(&*boxed, slice) } #[test] fn str_slice() { let s = "Hello, world!"; let boxed: Box<str> = Box::from(s); assert_eq!(&*boxed, s) }
{ let slice: &[f64] = &[-1.0, 0.0, 1.0, f64::INFINITY]; let boxed: Box<[f64]> = Box::from(slice); assert_eq!(&*boxed, slice) }
identifier_body
liballoc_boxed_test.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { let a = Box::new(5); let b: Box<i32> = a.clone(); assert!(a == b); } #[derive(PartialEq, Eq)] struct Test; #[test] fn any_move() { let a = Box::new(8) as Box<Any>; let b = Box::new(Test) as Box<Any>; match a.downcast::<i32>() { Ok(a) => { assert!(a == Box::new(8)); ...
test_owned_clone
identifier_name
liballoc_boxed_test.rs
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} #[test] fn f64_slice() { let slice: &[f64] = &[-1.0, 0.0, 1.0, f64::INFINITY]; let boxed: Box<[f64]> = Box::from(slice); assert_eq!(&*boxed, slice) } #[test] fn i64_slice() { let slice: &[i64] = &[i64::MIN, -2, -1, 0, 1, 2, i64::MAX]; let boxed: Box<[i64]> = Box::from(slice); assert_eq!(&*bo...
assert_eq!(19, y.get()); }
random_line_split
vector.rs
/* * Copyright 2018 Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applica...
impl super::SafeSliceAccess for f32 {} impl super::SafeSliceAccess for f64 {} } #[cfg(target_endian = "little")] pub use self::le_safe_slice_impls::*; pub fn follow_cast_ref<'a, T: Sized + 'a>(buf: &'a [u8], loc: usize) -> &'a T { let sz = size_of::<T>(); let buf = &buf[loc..loc + sz]; let ptr = ...
impl super::SafeSliceAccess for i32 {} impl super::SafeSliceAccess for i64 {}
random_line_split
vector.rs
/* * Copyright 2018 Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applica...
(buf: &'a [u8], loc: usize) -> Self::Inner { let len = read_scalar::<UOffsetT>(&buf[loc..loc + SIZE_UOFFSET]) as usize; let slice = &buf[loc + SIZE_UOFFSET..loc + SIZE_UOFFSET + len]; let s = unsafe { from_utf8_unchecked(slice) }; s } } #[cfg(target_endian = "little")] fn follow_sli...
follow
identifier_name
vector.rs
/* * Copyright 2018 Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applica...
impl<'a> Follow<'a> for &'a str { type Inner = &'a str; fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { let len = read_scalar::<UOffsetT>(&buf[loc..loc + SIZE_UOFFSET]) as usize; let slice = &buf[loc + SIZE_UOFFSET..loc + SIZE_UOFFSET + len]; let s = unsafe { from_utf8_unchecked(...
{ let sz = size_of::<T>(); let buf = &buf[loc..loc + sz]; let ptr = buf.as_ptr() as *const T; unsafe { &*ptr } }
identifier_body
v8.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 interfaces::{cef_v8accessor_t, cef_v8context_t, cef_v8handler_t, cef_v8stack_trace_t}; use interfaces::{cef_v8...
fn cef_v8value_create_array(_length: libc::c_int) -> *mut cef_v8value_t fn cef_v8value_create_function(_name: *const cef_string_t, _handler: *mut cef_v8handler_t) -> *mut cef_v8value_t fn cef_v8stack_trace_get_current(_frame_limit: libc::c_int) -> *mut cef_v8stack_trace_t ...
fn cef_v8value_create_uint(_value: u32) -> *mut cef_v8value_t fn cef_v8value_create_double(_value: c_double) -> *mut cef_v8value_t fn cef_v8value_create_date(_date: *const cef_time_t) -> *mut cef_v8value_t fn cef_v8value_create_string(_value: *const cef_string_t) -> *mut cef_v8value_t fn cef_v8value...
random_line_split
main.rs
use std::env; use std::path::PathBuf; use std::process::Command; fn main() -> std::io::Result<()> { let dist = env::var("CODEQL_DIST").expect("CODEQL_DIST not set"); let db = env::var("CODEQL_EXTRACTOR_QL_WIP_DATABASE") .expect("CODEQL_EXTRACTOR_QL_WIP_DATABASE not set"); let codeql = if env::consts...
else { "codeql" }; let codeql: PathBuf = [&dist, codeql].iter().collect(); let mut cmd = Command::new(codeql); cmd.arg("database") .arg("index-files") .arg("--size-limit=5m") .arg("--language=ql") .arg("--working-dir=.") .arg(db); let mut has_include_dir ...
{ "codeql.exe" }
conditional_block
main.rs
use std::env; use std::path::PathBuf; use std::process::Command; fn
() -> std::io::Result<()> { let dist = env::var("CODEQL_DIST").expect("CODEQL_DIST not set"); let db = env::var("CODEQL_EXTRACTOR_QL_WIP_DATABASE") .expect("CODEQL_EXTRACTOR_QL_WIP_DATABASE not set"); let codeql = if env::consts::OS == "windows" { "codeql.exe" } else { "codeql" ...
main
identifier_name
main.rs
use std::env; use std::path::PathBuf; use std::process::Command; fn main() -> std::io::Result<()> { let dist = env::var("CODEQL_DIST").expect("CODEQL_DIST not set"); let db = env::var("CODEQL_EXTRACTOR_QL_WIP_DATABASE") .expect("CODEQL_EXTRACTOR_QL_WIP_DATABASE not set"); let codeql = if env::consts...
.arg("--include=**/qlpack.yml"); } let exit = &cmd.spawn()?.wait()?; std::process::exit(exit.code().unwrap_or(1)) }
if !has_include_dir { cmd.arg("--include-extension=.ql") .arg("--include-extension=.qll") .arg("--include-extension=.dbscheme")
random_line_split
main.rs
use std::env; use std::path::PathBuf; use std::process::Command; fn main() -> std::io::Result<()>
.unwrap_or_default() .split('\n') { if let Some(stripped) = line.strip_prefix("include:") { cmd.arg("--include").arg(stripped); has_include_dir = true; } else if let Some(stripped) = line.strip_prefix("exclude:") { cmd.arg("--exclude").arg(stripped);...
{ let dist = env::var("CODEQL_DIST").expect("CODEQL_DIST not set"); let db = env::var("CODEQL_EXTRACTOR_QL_WIP_DATABASE") .expect("CODEQL_EXTRACTOR_QL_WIP_DATABASE not set"); let codeql = if env::consts::OS == "windows" { "codeql.exe" } else { "codeql" }; let codeql: Path...
identifier_body
mod.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use extract_graphql::extract; use extract_graphql::JavaScriptSourceFeature; use fixture_tests::Fixture; pub fn
(fixture: &Fixture<'_>) -> Result<String, String> { Ok(extract(fixture.content) .into_iter() .map(|source| match source { JavaScriptSourceFeature::GraphQLSource(s) => { format!( "graphql - line: {}, column: {}, text: <{}>", s.line_ind...
transform_fixture
identifier_name
mod.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use extract_graphql::extract; use extract_graphql::JavaScriptSourceFeature; use fixture_tests::Fixture; pub fn transform_fixture...
{ Ok(extract(fixture.content) .into_iter() .map(|source| match source { JavaScriptSourceFeature::GraphQLSource(s) => { format!( "graphql - line: {}, column: {}, text: <{}>", s.line_index, s.column_index, s.text ) ...
identifier_body
mod.rs
*/ use extract_graphql::extract; use extract_graphql::JavaScriptSourceFeature; use fixture_tests::Fixture; pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> { Ok(extract(fixture.content) .into_iter() .map(|source| match source { JavaScriptSourceFeature::GraphQLSo...
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree.
random_line_split
ascent.rs
<'grammar, W: Write>( grammar: &'grammar Grammar, user_start_symbol: NonterminalString, start_symbol: NonterminalString, states: &[LR1State<'grammar>], action_module: &str, out: &mut RustWrite<W>, ) -> io::Result<()> { let graph = StateGraph::new(&states); let mut ascent = CodeGenerator:...
compile
identifier_name
ascent.rs
/// returns the (optional, fixed) -- number of optional /// items in stack prefix and numer of fixed fn optional_fixed_lens(&self) -> (usize, usize) { (self.len_optional, self.len() - self.len_optional) } fn is_not_empty(&self) -> bool { self.len() > 0 } fn optional(&self...
{ self.all.len() }
identifier_body
ascent.rs
.any(|&(ref t, _)| t.contains(&Token::Terminal(terminal.clone()))) }); rust!(self.out, "let {}expected = vec![", self.prefix); for terminal in successful_terminals { rust!(self.out, "r###\"{}\"###.to_string(),", terminal); } rust!(self.out, "];"); //...
// identify the "start" location for this production; this
random_line_split
set_part_quantity_mutation.rs
use async_graphql::{ ID, Context, FieldResult, }; use async_graphql::validators::{IntGreaterThan}; // use eyre::{ // eyre, // // Result, // // Context as _, // }; use printspool_json_store::{ Record, }; use crate::{ part::Part, }; #[derive(Default)] pub struct
; #[derive(async_graphql::InputObject, Debug)] struct SetPartQuantityInput { #[graphql(name="partID")] part_id: ID, #[graphql(validator( IntGreaterThan(value = "0") ))] quantity: i32, } #[async_graphql::Object] impl SetPartQuantityMutation { /// Move a job in the print queue async ...
SetPartQuantityMutation
identifier_name
set_part_quantity_mutation.rs
use async_graphql::{ ID, Context, FieldResult, }; use async_graphql::validators::{IntGreaterThan};
use printspool_json_store::{ Record, }; use crate::{ part::Part, }; #[derive(Default)] pub struct SetPartQuantityMutation; #[derive(async_graphql::InputObject, Debug)] struct SetPartQuantityInput { #[graphql(name="partID")] part_id: ID, #[graphql(validator( IntGreaterThan(value = "0") ...
// use eyre::{ // eyre, // // Result, // // Context as _, // };
random_line_split
flow.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later ve...
fn execute_queue(&mut self) { let current_time = time::precise_time_ns(); let events = self.queue .iter() .filter(|&(_, due_at)| *due_at < current_time) .map(|(event, _)| event.clone()) .collect::<Vec<QueuedEvent>>(); for event in events { ...
}
random_line_split
flow.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later ve...
} fn reset_view(&mut self) { let buffer = self.buffers.selected_item(); self.frame.print(&mut buffer.with_lines(&self.lines), None); } fn reset_view_or_redo_search(&mut self) { self.reset_view(); if self.frame.navigation.state == NavigationState::Search { ...
{ let offset = self.frame.rendered_lines.last_lines_height(count); self.scroll(Offset::Line(offset)); }
conditional_block
flow.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later ve...
(&mut self) { self.reset_view(); if self.frame.navigation.state == NavigationState::Search { self.perform_search(Highlight::Current); } } fn enqueue(&mut self, event: QueuedEvent, offset_time: u64) { let entry = self.queue.entry(event).or_insert(0); *entry =...
reset_view_or_redo_search
identifier_name
flow.rs
/** * Flow - Realtime log analyzer * Copyright (C) 2016 Daniel Mircea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later ve...
let pending_lines = mutex_guarded_lines.drain(..).collect(); self.append_incoming_lines(pending_lines); } } }; } } fn select_menu_item(&mut self, direction: Direction) { match direction { ...
{ while running!() { match self.frame.watch() { Event::SelectMenuItem(direction) => self.select_menu_item(direction), Event::ScrollContents(offset) => self.scroll(offset), Event::Navigation(state) => { if self.frame.navigation.chang...
identifier_body
vec_pad_left.rs
use malachite_base::vecs::vec_pad_left; use malachite_base_test_util::bench::bucketers::triple_1_vec_len_bucketer; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use malachite_base_test_util::generators::unsigned_vec_unsigned_...
println!( "xs := {:?}; vec_pad_left(&mut xs, {}, {}); xs = {:?}", old_xs, pad_size, pad_value, xs ); } } fn benchmark_vec_pad_left(gm: GenMode, config: GenConfig, limit: usize, file_name: &str) { run_benchmark( "vec_pad_left(&mut [T], usize, T)", Benchmar...
.take(limit) { let old_xs = xs.clone(); vec_pad_left(&mut xs, pad_size, pad_value);
random_line_split
vec_pad_left.rs
use malachite_base::vecs::vec_pad_left; use malachite_base_test_util::bench::bucketers::triple_1_vec_len_bucketer; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use malachite_base_test_util::generators::unsigned_vec_unsigned_...
(gm: GenMode, config: GenConfig, limit: usize, file_name: &str) { run_benchmark( "vec_pad_left(&mut [T], usize, T)", BenchmarkType::Single, unsigned_vec_unsigned_unsigned_triple_gen_var_1::<u8, usize, u8>().get(gm, &config), gm.name(), limit, file_name, &tripl...
benchmark_vec_pad_left
identifier_name
vec_pad_left.rs
use malachite_base::vecs::vec_pad_left; use malachite_base_test_util::bench::bucketers::triple_1_vec_len_bucketer; use malachite_base_test_util::bench::{run_benchmark, BenchmarkType}; use malachite_base_test_util::generators::common::{GenConfig, GenMode}; use malachite_base_test_util::generators::unsigned_vec_unsigned_...
fn benchmark_vec_pad_left(gm: GenMode, config: GenConfig, limit: usize, file_name: &str) { run_benchmark( "vec_pad_left(&mut [T], usize, T)", BenchmarkType::Single, unsigned_vec_unsigned_unsigned_triple_gen_var_1::<u8, usize, u8>().get(gm, &config), gm.name(), limit, ...
{ for (mut xs, pad_size, pad_value) in unsigned_vec_unsigned_unsigned_triple_gen_var_1::<u8, usize, u8>() .get(gm, &config) .take(limit) { let old_xs = xs.clone(); vec_pad_left(&mut xs, pad_size, pad_value); println!( "xs := {:?}; vec_pad_left(...
identifier_body
lib.rs
// Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! Emulates virtual and hardware devices. mod bus; mod cmos; #[cfg(feature = "direct")] pub mod direct_io; #[cfg(feature = "direct")] pub mod direct_...
{ NoIommu, VirtioIommu, CoIommu, } use std::str::FromStr; impl FromStr for IommuDevType { type Err = ParseIommuDevTypeResult; fn from_str(s: &str) -> Result<Self, Self::Err> { match s { "off" => Ok(IommuDevType::NoIommu), "viommu" => Ok(IommuDevType::VirtioIommu), ...
IommuDevType
identifier_name
lib.rs
// Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! Emulates virtual and hardware devices. mod bus; mod cmos; #[cfg(feature = "direct")] pub mod direct_io; #[cfg(feature = "direct")] pub mod direct_...
#[derive(Copy, Clone, Eq, PartialEq)] pub enum IommuDevType { NoIommu, VirtioIommu, CoIommu, } use std::str::FromStr; impl FromStr for IommuDevType { type Err = ParseIommuDevTypeResult; fn from_str(s: &str) -> Result<Self, Self::Err> { match s { "off" => Ok(IommuDevType::NoIomm...
pub enum ParseIommuDevTypeResult { NoSuchType, }
random_line_split
lib.rs
#![feature(type_ascription)] mod problem27 { // palindrome detector for Strings pub fn palindrome(s: &str) -> bool { let c = s.chars(); // c.collect::<Vec<_>>() == c.rev().collect::<Vec<_>>() c.clone().eq(c.rev()) } } mod problem28 { // flatten for vectors #[derive(Debug,Cl...
}; // ["a", ["b", "c"], "d"] let s1 = Seq::Sequence(vec![Seq::Item("a"), Seq::Sequence(vec![Seq::Item("b"), Seq::Item("c")]), Seq::Item("d")]); println!("flatten({:?}) = {:?}", s1, flatten(s1.clone())); assert_eq!(flatten(s1), vec!["a", "b", "c", "d"]) } #[tes...
tten, Seq
identifier_name
lib.rs
#![feature(type_ascription)] mod problem27 { // palindrome detector for Strings pub fn palindrome(s: &str) -> bool { let c = s.chars(); // c.collect::<Vec<_>>() == c.rev().collect::<Vec<_>>() c.clone().eq(c.rev()) } } mod problem28 { // flatten for vectors #[derive(Debug,Cl...
inner(s, &mut res); res } } mod problem29 { // Given a string, keep its capital letters: // "Hello World!" -> "HW" fn is_capital(&c: &char) -> bool { c >= 'A' && c <= 'Z' } pub fn capitals(s:&str) -> String { s.chars().filter(is_capital).collect() } } mod ...
{ match s { Seq::Item(a) => acc.push(a), Seq::Sequence(ss) => { for i in ss { inner(i, acc) } }, } }
identifier_body
lib.rs
#![feature(type_ascription)] mod problem27 { // palindrome detector for Strings pub fn palindrome(s: &str) -> bool { let c = s.chars(); // c.collect::<Vec<_>>() == c.rev().collect::<Vec<_>>() c.clone().eq(c.rev()) } } mod problem28 { // flatten for vectors
pub enum Seq<T> { Item(T), Sequence(Vec<Seq<T>>) } pub fn flatten<T>(s: Seq<T>) -> Vec<T> { let mut res = vec![]; fn inner<T>(s: Seq<T>, acc: &mut Vec<T>) { match s { Seq::Item(a) => acc.push(a), Seq::Sequence(ss) => { for i in ss ...
#[derive(Debug,Clone)]
random_line_split
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 ...
} else { ptr::null() }; let mut roots = HashSet::new(); for walk_gc_roots(need_cleanup, sentinel) |root, tydesc| { // Track roots to avoid double frees. if roots.contains(&*root) { loop; } roots.insert(*root); ...
{ unsafe { // Abort when GC is disabled. if get_safe_point_count() == 0 { return; } // Leave a sentinel on the stack to mark the current frame. The // stack walker will ignore any frames above the sentinel, thus // avoiding collecting any memory being use...
identifier_body
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 ...
() -> uint { let module_meta = rustrt::rust_gc_metadata(); return *module_meta; } struct SafePoint { sp_meta: *Word, fn_meta: *Word, } // Returns the safe point metadata for the given program counter, if // any. unsafe fn is_safe_point(pc: *Word) -> Option<SafePoint> { let module_meta = rustrt::ru...
get_safe_point_count
identifier_name