text
stringlengths
8
4.13M
// // Author: Shareef Abdoul-Raheem // File: ast_processor.rs // use crate::ASTNodeLiteral; use crate::ASTNodeRoot; use crate::ASTNodeTag; use crate::ASTNodeText; pub trait IASTProcessor { fn has_error(&mut self) -> bool; fn visit_begin_root(&mut self, root_node: &ASTNodeRoot) -> (); fn visit_begin_tag(&mut s...
pub mod runner; mod core;
//! A generic trait based interface for abstracting over various schemes for //! concurrent memory reclamation. //! //! # Memory Management in Rust //! //! Unlike garbage collected languages such as *Go* or *Java*, memory //! management in *Rust* is primarily scope or ownership based and more akin to //! *C++*. //! Rus...
use anyhow::Context; use pathfinder_common::{BlockHash, BlockHeader, BlockNumber, StarknetVersion}; use crate::{prelude::*, BlockId}; pub(super) fn insert_block_header( tx: &Transaction<'_>, header: &BlockHeader, ) -> anyhow::Result<()> { // Intern the starknet version let version_id = intern_starknet...
use std::error::Error; fn main() -> Result<(), Box<dyn Error>> { let input = 7689; let mut fuel_cells = [[0i32; 300]; 300]; for y in 0..fuel_cells.len() { let row = fuel_cells[y]; let y_coord = y + 1; for x in 0..row.len() { let x_coord = x + 1; let rack_id ...
use influxdb_iox_client::connection::Connection; use influxdb_iox_client::namespace::generated_types::LimitUpdate; use crate::commands::namespace::Result; #[derive(Debug, clap::Parser)] pub struct Config { /// The namespace to update a service protection limit for #[clap(action)] namespace: String, #...
// xfail-stage00 obj foo(@mutable int x) { drop { log "running dtor"; *x = ((*x) + 1); } } fn main() { auto mbox = @mutable 10; { auto x = foo(mbox); } check ((*mbox) == 11); }
use crate::prelude::*; use std::os::raw::c_void; use std::ptr; #[repr(C)] #[derive(Debug)] pub struct VkAccelerationStructureMemoryRequirementsInfoNV { pub sType: VkStructureType, pub pNext: *const c_void, pub r#type: VkAccelerationStructureMemoryRequirementsTypeNV, pub accelerationStructure: VkAccele...
// Copyright 2016 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::mem; use std::num::Int; /// constant-time compare function. /// `a` and `b` may be SECRET, but the length is known. /// precondition: `a.len() == b.len()` pub fn crypto_compare(a: &[u8], b: &[u8]) -> bool { debug_assert_eq!(a.len(), b.len()); let mut diff = 0u8; for i in (0..a.len()) { di...
use crate::{ chromset::LexicalChromRef, properties::{Parsable, Serializable, WithName, WithRegionCore, WithScore, WithStrand}, }; use crate::{ChromName, ChromSetHandle, WithChromSet}; use std::io::{Result, Write}; #[derive(Clone, Copy, PartialEq)] pub struct Bed3<T: ChromName = LexicalChromRef> { pub begin...
extern crate data_encoding; use std::env; use std::io::{self, Read}; use data_encoding::hex; fn decrypt(e_msg: &[u8], key: &str) -> String { String::from_utf8(e_msg.iter().cloned().zip(key.bytes().cycle()).map(|(msg_byte, key_byte)| msg_byte ^ key_byte).collect()).unwrap() } fn main() { if let Some(key) = env::args...
pub mod handy_haversacks_part_1; pub mod handy_haversacks_part_2;
use std::iter; use radix; use rand::{distributions::Alphanumeric, prelude::thread_rng, Rng}; pub fn create_slug_from_id(id: i32) -> String { let id = format!("{}", id); let r = radix::RadixNum::from_str(&id, 10).unwrap(); let r = r.with_radix(36).unwrap(); let mut slug = r.as_str().to_string(); if...
// Copyright 2016 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 color_vec(colors: Vec<[u8; 3]>, intensity: f64) -> Vec<[u8; 3]> { // let mut rendered_color: Vec<[u8; 3]> = Vec::new(); // for color in colors { // rendered_color.push([ // (intensity * f64::from(color[0])) as u8, // (intensity * f64::from(color[1])) as u8, // ...
use std::{fmt, vec}; use indexmap::IndexMap; use serde::{ de::{ self, Deserialize, DeserializeOwned, DeserializeSeed, EnumAccess, Error as DeError, IntoDeserializer, MapAccess, SeqAccess, Unexpected, VariantAccess, Visitor, }, forward_to_deserialize_any, }; use crate::{ConstValue, Name}; ...
use super::*; #[test] fn with_number_atom_reference_function_port_pid_or_tuple_returns_false() { run!( |arc_process| { ( strategy::term::map(arc_process.clone()), strategy::term::number_atom_reference_function_port_pid_or_tuple(arc_process), ) ...
use decoder::MAX_COMPONENTS; use idct::dequantize_and_idct_block; use parser::Component; use std::mem; use std::sync::Arc; pub struct RowData { pub index: usize, pub component: Component, pub quantization_table: Arc<[u16; 64]>, } pub struct Worker { offsets: Box<[usize]>, results: Vec<Vec<u8>>, ...
use std::collections::VecDeque; use flatbuffers::FlatBufferBuilder; use super::{Bytes, LevelId, Timestamp}; use crate::error::Result; use crate::file::FileManager; #[derive(Default, PartialEq, Eq, Debug, Clone, Copy)] pub struct LevelDesc { start: Timestamp, end: Timestamp, id: LevelId, } impl From<prot...
use scanner_proc_macro::insert_scanner; #[insert_scanner] fn main() { let (n, m) = scan!((usize, usize)); let c = (0..n).map(|_| scan!(usize; m)).collect(); solve(n, m, c); } fn solve(n: usize, m: usize, c: Vec<Vec<usize>>) { let k = 1_000_00; let mut cnt = vec![0; k + 1]; let mut d_sum = vec!...
#[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum Clear { All, Bottom, Line, }
#[doc = "Reader of register C1PR2"] pub type R = crate::R<u32, super::C1PR2>; #[doc = "Writer for register C1PR2"] pub type W = crate::W<u32, super::C1PR2>; #[doc = "Register C1PR2 `reset()`'s with value 0"] impl crate::ResetValue for super::C1PR2 { type Type = u32; #[inline(always)] fn reset_value() -> Sel...
// 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 ...
// Based on devicemgmt.wsdl.xml // This file is an example of how generated code will look like. It contains some comments // to see the relation between xml's and Rust code. // Quote from ONVIF core spec (5.5 messages): // // The WSDL message part element is used to define the actual format of the m...
//! C symbols for FFI. #![allow(non_upper_case_globals)] extern crate libc; use std; use std::ffi::CString; use super::layer::Layer; use super::payload::Payload; use super::attr::Attr; use super::context::Context; use super::token::Token; use super::logger::Metadata; macro_rules! def_func { ( $( $x:ident, $y:ty...
#[doc = r"Value read from the register"] pub struct R { bits: u32, } #[doc = r"Value to write to the register"] pub struct W { bits: u32, } impl super::IRQENABLE { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R...
extern crate iris; use iris::portfire; #[cfg(feature="tts")] use iris::tts; fn say(message: &str) { #[cfg(feature="tts")] tts::say(message); #[cfg(not(feature="tts"))] println!("SAYING: {}", message); } fn main() { #[cfg(feature="tts")] tts::init(); say("Discovering portfires"); le...
use common::aoc::{load_input, run_many, print_result, print_time, print_result_multiline}; use common::intcode::{VM, StepResult}; use std::collections::{HashSet, HashMap}; use common::grid::Grid; fn main() { let input = load_input("day11"); let (vm, dur_parse) = run_many(10000, || VM::parse(input.trim_end_mat...
use std::{env, ffi::OsString, fmt, io, path::PathBuf, process::ExitStatus, string::FromUtf8Error}; use crate::{Cmd, CmdData}; /// `Result` from std, with the error type defaulting to xshell's [`Error`]. pub type Result<T, E = Error> = std::result::Result<T, E>; /// An error returned by an `xshell` operation. pub str...
use crate::stdio_server::input::{AutocmdEventType, PluginEvent}; use crate::stdio_server::plugin::{ClapAction, ClapPlugin, PluginId}; use crate::stdio_server::vim::Vim; use crate::tools::ctags::{BufferTag, Scope}; use anyhow::Result; use icon::IconType; use serde::Serialize; use std::collections::HashMap; use std::path...
use borsh::{BorshSerialize,BorshDeserialize}; use crate::{ structs::{CustomerData,DriverData,RecordInstruction,SingleInstruction} }; use{ solana_program::{ log::sol_log_compute_units, account_info::{next_account_info,AccountInfo}, entrypoint, entrypoint::ProgramResult, ...
use std::collections::hash_map::*; use std::fs::File; use std::env; use std::io::{self, BufReader}; use hangouts_json_parser::{raw, Hangouts}; fn usage() { eprintln!("usage: {} <json path> <participant name>", env::args().next().unwrap()); } fn chrono(parts: Result<(i64, u32), std::num::ParseIntError>) -> chrono:...
error_chain! { foreign_links { Io(::std::io::Error) #[cfg(unix)]; SerdeJson(::serde_json::error::Error); } errors { ConanNotInPath { display("Conan was not found in your path.") } ConanInstallFailure(o: ::std::process::Output) { display("conan...
pub struct Instr { pub instr: Vec<i64>, pub input: Vec<i64>, pub output: Vec<i64>, pub relative_base: i64, pub instr_ptr: usize, } #[derive(Debug)] pub enum Mode { Position, Immediate, Relative, } #[derive(Debug)] pub enum Opcode { Add, Mul, Inp, Outp, Halt, Jmp...
// Copyright 2014 The Servo Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ...
use utopia_core::{ math::{Size, Vector2}, widgets::{pod::WidgetPod, TypedWidget, Widget}, Backend, BoxConstraints, CommonPrimitive, }; use super::scrollable::{Scrollable, ScrollableState}; pub struct ScrollView<T, B: Backend> { scroll: Scrollable<T, B>, scrollable_state: ScrollableState, verti...
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { failure::{Error, ResultExt}, fidl_fuchsia_test_hub as fhub, fuchsia_async as fasync, fuchsia_component::client::connect_to_service, }; m...
// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 use executor::Executor; use executor_types::ExecutedTrees; use libra_config::config::NodeConfig; use libra_crypto::{ ed25519::{Ed25519PrivateKey, Ed25519PublicKey}, HashValue, PrivateKey, Uniform, }; use libra_types::{ acco...
use std::fmt::{Formatter, Display, Result}; #[derive(Debug)] struct Color{ r: i32, g: i32, b: i32 } impl Display for Color { fn fmt(&self, f: &mut Formatter) -> Result { let r = &self.r; let g = &self.g; let b = &self.b; write!(f, "RGB ({r},{g},{b}) 0x{r:0>2X}{g:0>2X}{b:0>2X}") } } fn main(...
use crate::decode::Decode; use crate::encode::Encode; use crate::postgres::protocol::TypeId; use crate::postgres::{PgData, PgRawBuffer, PgTypeInfo, PgValue, Postgres}; use crate::types::Type; impl Type<Postgres> for [u8] { fn type_info() -> PgTypeInfo { PgTypeInfo::new(TypeId::BYTEA, "BYTEA") } } impl...
//! Write an algorithm such that if an element in an //! M x N matrix is 0 it's entire row and column //! are set to 0 type Matrix = Vec<Vec<u32>>; pub fn zero_matrix(m: &mut Matrix) { let mut rows = vec![false; m.len()]; let mut cols = vec![false; m[0].len()]; for (i, row) in m.iter().enumerate() { ...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Key register"] pub kr: KR, #[doc = "0x04 - Prescaler register"] pub pr: PR, #[doc = "0x08 - Reload register"] pub rlr: RLR, #[doc = "0x0c - Status register"] pub sr: SR, #[doc = "0x10 - Window register"]...
#[prelude_import] use ::std::prelude::v1::*; /* node_id: 3 hir local_id: 0 */ #[macro_use] extern crate std; /* node_id: 9 hir local_id: 0 */ fn main() ({ ((<Person>::new /* node_id: 15 hir local_id: 5 */)(("not_bind" /* node_id: 16 hir local_id: 6 */), (18 /* ...
//! Wrapper around the `fetch` API. //! //! # Example //! //! ``` //! # use reqwasm::http::Request; //! # async fn no_run() { //! let resp = Request::get("/path") //! .send() //! .await //! .unwrap(); //! assert_eq!(resp.status(), 200); //! # } //! ``` use crate::{js_to_error, Error}; use serde::de::Deseri...
use std::sync::{Arc, Mutex}; use std::task::Waker; use waker_fn::waker_fn; use futures_lit::pin; use crossbeam::sync::Parker; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}: pub struct SpawnBlocking<T>(Arc<Mutex<Shared<T>>>); // The Shared struct serves as a rendezvous between the future a...
use seed::{*, prelude::*}; use crate::{ components::navbar, containers::{favorites, login, search}, router::Route, state::{Model, ModelEvent}, }; /// The root application view. pub fn app(model: &Model) -> Vec<Node<ModelEvent>> { let route = &model.route; let nav = if route != &Route::Init && ...
use actix_web::web; use futures::Future; use survey_manager_core::app_services::commands::SurveyCommands; use domain_patterns::command::Handles; use crate::generate; use crate::error::ApiError; pub fn handle_command_async( cmd: SurveyCommands, ) -> impl Future<Item = String, Error = ApiError> { web::block(move...
use magnesium::*; #[test] fn test_parsing() { let xml = r#" <?xml version="1.0" encoding="UTF-8"?> <registry> <!-- We're gonna pretend that there's a whole file here --> <types> <type>typedef unsigned int <name>GraphicsEnum</name>;</type> </types> <enums group="GraphicPolygons...
use libc::{getpriority, PRIO_PROCESS, getpid, id_t, c_uint, getrlimit, rlimit, RLIMIT_NOFILE, getrusage, rusage, RUSAGE_SELF}; use std::alloc::{alloc, Layout, dealloc}; use std::mem::{size_of, align_of}; fn main() { unsafe { let pri = getpriority(PRIO_PROCESS as c_uint, getpid() as id_t); ...
macro_rules! wolfssl_digest_benches { ( $name:ident, $block_len:expr, $digest_len:expr, $t:ty, $init:expr, $update:expr, $final:expr) => { mod $name { use ffi; use std::mem; digest_benches!($block_len as usize, input, { unsafe { let mu...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[cfg(feature = "Win32_Foundation")] #[inline] pub unsafe fn AssignProcessToJobObject<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param1: ::windows::core::In...
mod reader; pub use self::reader::EventReader;
/* * hurl (https://hurl.dev) * Copyright (C) 2020 Orange * * 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 ...
use crate::helpers; use std::collections::HashMap; pub fn solve(input: String) { let mut lines: Vec<i64> = helpers::file::to_list(&input) .iter() .map(|x| x.parse().unwrap()) .collect(); part1(lines); part2(); } fn count_combinations(input: Vec<i64>) -> HashMap<i64, i64> { let ...
// wre_frame.rs // // Copyright (c) 2019, Univerisity of Minnesota // // Author: Bridger Herman (herma582@umn.edu) //! Useful and necessary macros for the Wasm Rendering Engine #[macro_export] macro_rules! wre_time { () => { *crate::state::WRE_TIME.try_lock().unwrap() }; } #[macro_export] macro_rules...
#![feature(asm)] use std::fs; use std::time::{Duration, Instant}; fn read_input(file_name : &str) -> Vec<usize> { return fs::read_to_string(file_name) .expect("Failed to read input") .split('\n') .filter_map(|x| x.parse::<usize>().ok()) .collect(); } fn find_solution_naive(rows :...
use std::io::{Read, Result as IOResult}; use crate::lump_data::{LumpData, LumpType}; use crate::PrimitiveRead; #[derive(Copy, Clone, Debug, Default)] pub struct Node { pub plane_number: i32, pub children: [i32; 2], pub mins: [i16; 3], pub maxs: [i16; 3], pub first_face: u16, pub faces_count: u16, pub are...
//use std::time::Duration; //use std::thread; //use std::collections::HashSet; //use std::path::Path; use sdl2::pixels::Color; //use sdl2::image::LoadTexture; use sdl2::render::TextureQuery; use std::time::Duration; use std::thread; //use sdl2::event::Event; //use sdl2::keyboard::Keycode; use sdl2::rect::Rect; con...
fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let k: usize = rd.get(); let n: usize = rd.get(); let m: usize = rd.get(); let a: Vec<usize> = rd.get_vec(n); let mut d: Vec<usize> = a.windows(2).map(|w| w[1] - w[0] - 1).collect(); d.sort(); l...
use std::io::TcpStream; use std::io; use std::sync::mpsc::channel; pub fn start() { let username = ask_username(); let mut reader = io::stdin(); let mut stream = TcpStream::connect("0.0.0.0:6262"); let (sender, receiver) = channel(); Thread::spawn(move || send_messages(sender)); Thread::scop...
#![warn(unused_crate_dependencies)] #![allow(clippy::derive_partial_eq_without_eq)] // Workaround for "unused crate" lint false positives. use workspace_hack as _; pub mod proto { tonic::include_proto!("test"); } pub use proto::*;
pub mod runtime; #[macro_export] macro_rules! declare_plugin { ($plugin_type:ty, $constructor:path) => { #[no_mangle] pub extern "C" fn _plugin_create() -> *mut $crate::plugins::runtime::RuntimePlugin { // make sure the constructor is the correct type. let constructor: fn() ...
use serde::Serialize; use domain_patterns::event::DomainEvent; use domain_patterns::message::Message; use domain_patterns::models::{Entity, AggregateRoot}; use uuid::Uuid; use crate::survey::Survey; #[derive(DomainEvent, Serialize)] pub struct SurveyCreatedEvent { pub id: String, pub aggregate_id: String, ...
use std::io; pub struct Operator {} impl Operator { pub fn add(x: i32, y: i32) -> i32 { x + y } pub fn multiply(x: i32, y: i32) -> i32 { x * y } pub fn input() -> i32 { println!("Provide input: "); let mut input = String::new(); io::stdin().read_line(&mut ...
// This module provides the fallback implementation of mmap primitives on platforms which do not provide them #[cfg(any(target_arch = "wasm32", target_arch = "wasm64"))] mod fallback { use alloc::alloc::{AllocError, Layout}; use core::ptr::NonNull; use firefly_system::arch as sys; /// Creates a memory...
use crate::config::{ CameraConfig, DatastructureConfig, GeneralConfig, GeneratorConfig, RaytracerConfig, ShaderConfig, }; use crate::util::vector::Vector; impl Default for GeneralConfig { fn default() -> Self { Self { epsilon: 0.00001, scenename: "test".to_string(), ...
pub struct Solution; impl Solution { pub fn reverse_string(s: &mut Vec<char>) { s.reverse(); } } #[test] fn test0344() { fn case(s: &str, want: &str) { let mut s = s.chars().collect::<Vec<char>>(); Solution::reverse_string(&mut s); let want = want.chars().collect::<Vec<char...
/* UTF-8 中的一个字符可能的长度为 1 到 4 字节,遵循以下的规则: 对于 1 字节的字符,字节的第一位设为0,后面7位为这个符号的unicode码。 对于 n 字节的字符 (n > 1),第一个字节的前 n 位都设为1,第 n+1 位设为0,后面字节的前两位一律设为10。剩下的没有提及的二进制位,全部为这个符号的unicode码。 这是 UTF-8 编码的工作方式: Char. number range | UTF-8 octet sequence (hexadecimal) | (binary) --------------------+---...
pub struct LinearMemory { // linear because it gets treated as one continuous address space pub data: Vec<u8>, } impl LinearMemory { pub fn get(&self, a: u16) -> u8 { self.data[usize::from(a)] } pub fn set(&mut self, a: u16, v: u8) { self.data[usize::from(a)] = v } pub f...
use std::any::Any; use std::cell::{RefCell, RefMut}; type VO<T> = Vec<Option<T>>; #[derive(Default)] pub struct World { entities_count: usize, components_vec_list: Vec<Box<dyn ComponentVec>>, } impl World { pub fn new() -> Self { Self { entities_count: 0, components_vec_li...
// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to ...
use std::collections::HashMap; use std::path::Path; use mail::{Resource, Context}; use mail::file_buffer::FileBuffer; use template::TemplateEngine; use template::{ EmbeddedWithCId, BodyPart, MailParts }; use ::error::{LoadingError, InsertionError}; use ::utils::fix_newlines; use ::spec::TemplateSpec; use ::t...
use std::env; use crate::commands::{LllCommand, LllRunnable}; use crate::context::LllContext; use crate::error::LllError; use crate::ui; use crate::window::LllView; #[derive(Clone, Debug)] pub struct TabSwitch { movement: i32, } impl TabSwitch { pub fn new(movement: i32) -> Self { TabSwitch { movemen...
fn main() { windows::core::build! { Component::Enums::*, }; }
use xshell::{cmd, Shell}; #[test] fn versions_match() { let sh = Shell::new().unwrap(); let read_version = |path: &str| { let text = sh.read_file(path).unwrap(); let vers = text.lines().find(|it| it.starts_with("version =")).unwrap(); let vers = vers.splitn(2, '#').next().unwrap(); ...
//! Payload values. //! //! Type Attr represents an attribute of a Payload. use super::token::Token; use super::range::Range; use super::symbol; use std::slice; extern crate libc; /// A payload object. #[repr(C)] pub struct Payload { typ: Token, len: u32, range: (u32, u32), } impl Payload { /// Adds...
//! Contains the `GenParamsIn` type,for printing generic parameters. use syn::{ token::{Colon, Comma, Const, Star}, GenericParam, Generics, }; use proc_macro2::TokenStream; use quote::{quote, ToTokens}; use crate::utils::NoTokens; /// Used to print (with ToTokens) the generc parameter differently depending ...
// Copyright 2021 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to ...
use crate::context::RpcContext; use crate::v02::types::reply::Transaction; use anyhow::Context; use pathfinder_common::{BlockId, TransactionIndex}; use starknet_gateway_types::reply::transaction::Transaction as GatewayTransaction; #[derive(serde::Deserialize, Debug, PartialEq, Eq)] pub struct GetTransactionByBlockIdAn...
use geoip2_city::CityApiResponse; use std::fmt; use std::fmt::{Display, Formatter}; /// A unique identifier for a datacenter. It consists of a AS Number, ISO-3166 country code, and /// optionally a city name. #[derive(Clone, Debug, Hash, Ord, PartialOrd, Eq, PartialEq)] pub struct DatacenterIdentifier { autonomous...
mod tmp_type_element; mod type_element;
use crate::instruction::Instruction; use crate::register::Register; pub struct Stack { pub i: u16, pub counter: u16, pub registers: Register, pub call_stack: Vec<u16>, pub memory: Vec<u8>, } impl Stack { pub fn get_next_instruction(&mut self) -> Option<Instruction> { if (s...
use byteorder::{WriteBytesExt, BigEndian}; use std::io::{BufWriter, Write, Cursor}; use std::net::TcpStream; use {Packet, QoS, Error, Result, MAX_PAYLOAD_SIZE, SubscribeTopic, SubscribeReturnCodes}; pub trait MqttWrite: WriteBytesExt { fn write_packet(&mut self, packet: &Packet) -> Result<()> { match packe...
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. pub fn serialize_operation_batch_delete_worlds( input: &crate::input::BatchDeleteWorldsInput, ) -> Result<smithy_http::body::SdkBody, smithy_types::Error> { let mut out = String::new(); let mut object = smithy_json::serialize::...
use f::FordFulkerson; use procon_reader::ProconReader; fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let h: usize = rd.get(); let w: usize = rd.get(); let n: usize = rd.get(); let mut g = FordFulkerson::new(h + n + n + w + 2); let source = h + n +...
use crate::prelude::*; use std::os::raw::c_void; use std::ptr; #[repr(C)] #[derive(Debug)] pub struct VkXcbSurfaceCreateInfoKHR { pub sType: VkStructureType, pub pNext: *const c_void, pub flags: VkXcbSurfaceCreateFlagBitsKHR, pub connection: *const c_void, pub window: u32, } impl VkXcbSurfaceCrea...
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor 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 ...
//! Rust implementation of the `CPU_*` macro API. #![allow(non_snake_case)] use super::types::RawCpuSet; use core::mem::size_of_val; #[inline] pub(crate) fn CPU_SET(cpu: usize, cpuset: &mut RawCpuSet) { let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits...
// Copyright 2020 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to ...
use super::SharedVars; use syn::Ident; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum FieldAccessor<'a> { /// Accessible with `self.field_name` Direct, /// Accessible with `fn field_name(&self)->FieldType` Method { name: Option<&'a Ident> }, /// Accessible with `fn field_name(&self)->Option...
//! Converts version 1 of the tags (stored in a JSON file) to version 2 of the //! tag storage (stored in a SQLite3 database). extern crate rusqlite; extern crate serde_json; extern crate walkdir; use rusqlite::Connection; use std::collections::BTreeMap; use std::fs::File; use std::path::Path; use walkdir::{WalkDir};...
pub use self::kt_std::*; pub mod kt_std;
//! Some helpers around Path and PathBuf manipulations. use super::Result; use anyhow::anyhow; use std::path::Path; use std::path::PathBuf; /// Wraps the annoying PathBuf to string conversion in one single call. pub fn path_to_str(path: &PathBuf) -> Result<&str> { Ok(path .to_str() .ok_or(anyhow!(...
pub mod break_handler;
pub use VkFormat::*; #[repr(u32)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum VkFormat { VK_FORMAT_UNDEFINED = 0, VK_FORMAT_R4G4_UNORM_PACK8 = 1, VK_FORMAT_R4G4B4A4_UNORM_PACK16 = 2, VK_FORMAT_B4G4R4A4_UNORM_PACK16 = 3, VK_FORMAT_R5G6B5_UNORM_PACK16 = 4, VK_FORMAT_B5G6R5_UNORM_PACK16 ...
// For explanation of lint checks, run `rustc -W help` // This is adapted from // https://github.com/maidsafe/QA/blob/master/Documentation/Rust%20Lint%20Checks.md #![forbid(bad_style, exceeding_bitshifts, mutable_transmutes, no_mangle_const_items, unknown_crate_types, warnings)] #![deny(deprecated, drop_with_repr_exter...
// xfail-stage0 // -*- rust -*- use std; import std._str; fn main() { auto s = "hello"; auto sb = _str.rustrt.str_buf(s); auto s_cstr = _str.rustrt.str_from_cstr(sb); check (_str.eq(s_cstr, s)); auto s_buf = _str.rustrt.str_from_buf(sb, 5u); check (_str.eq(s_buf, s)); }
use crate::ResponseExt; use hyper::header::{HeaderValue, ALLOW}; use hyper::{Body, Method as HttpMethod, Request, Response, StatusCode}; #[derive(Debug, Clone)] pub struct Method { allow: Vec<HttpMethod>, } impl Method { pub fn new(allow: Vec<HttpMethod>) -> Self { Self { allow } } pub fn res...
#![deny(clippy::all)] use anyhow::{anyhow, Result}; use encoding::hex; pub fn xor(a: &[u8], b: &[u8]) -> Result<Vec<u8>> { if a.len() != b.len() { Err(anyhow!("Invalid input, XOR only on two equal length vector")) } else { Ok(a.iter().zip(b.iter()).map(|(x, y)| x ^ y).collect()) } } /// XO...