text
stringlengths
8
4.13M
#![feature(core_intrinsics)] fn get_name<T>(_t: &T) -> String { unsafe { (*std::intrinsics::type_name::<T>()).to_string() } } fn main() { println!("{}", get_name(&get_name::<i32>)); }
// 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 ...
#[doc = "Reader of register EM23PERNORETAINSTATUS"] pub type R = crate::R<u32, super::EM23PERNORETAINSTATUS>; #[doc = "Reader of field `ACMP0LOCKED`"] pub type ACMP0LOCKED_R = crate::R<bool, bool>; #[doc = "Reader of field `ACMP1LOCKED`"] pub type ACMP1LOCKED_R = crate::R<bool, bool>; #[doc = "Reader of field `PCNT0LOC...
// 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 ...
// still prototyping so having one state driving everything for RenderToWindow extern crate amethyst; use prelude::*; struct GameState { } impl SimpleState for GameState { }
use tui::style::{Color, Style}; use tui::widgets::Text; #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] pub enum Item { KeyCard, Crowbar, } #[derive(Debug)] pub struct Player { pub health: i32, pub attack_strength: i32, pub items: Vec<Item>, } impl Player { pub fn format_player_info(&self)...
mod messages; mod ws; mod coordinator; mod worker_client; mod uuid; use actix::*; use actix_web::{ web, App, // HttpResponse, HttpServer, // Responder, Result }; use actix_files::{Files,NamedFile}; pub use coordinator::Coordinator; pub use worker_client::{ WorkerClient }; use ws::websocket...
//! Consensus module. //! //! Low level consensus module for communicating with the consensus layer. use std::str::FromStr; use thiserror::Error; use oasis_core_runtime::{ common::versioned::Versioned, consensus::{ roothash::{Message, StakingMessage}, staking, staking::Account as Conse...
use std::io::Cursor; use gfx::Factory; use gfx_device_gl::CommandBuffer; use gfx_device_gl::Resources; pub type RgbSurfaceFormat = gfx::format::R8_G8_B8_A8; pub type YuvSurfaceFormat = gfx::format::R8; pub type ColorFormat = (RgbSurfaceFormat, gfx::format::Unorm); /// /// Can be used to replace parts of or a whole t...
use std::fs; fn read_input(f: &str) -> Vec<usize> { let input = fs::read_to_string(f).expect("can't read input file"); input.split(",").map(|x| x.parse().unwrap()).collect() } fn run(input: &[usize]) -> Vec<usize> { let mut mem: Vec<usize> = input.into(); let mut pointer = 0; while pointer < mem....
pub mod delete; pub mod get; pub mod leave; pub mod peers; pub mod search; pub mod serve; pub mod set;
fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let a: Vec<char> = rd.get_chars(); let b: Vec<char> = rd.get_chars(); let n = a.len(); let diffs: Vec<usize> = (0..n).filter(|&i| a[i] != b[i]).collect(); if diffs.len() > 6 { println!("NO"); ...
#[macro_use] extern crate serde_derive; extern crate mio; extern crate serde; extern crate serde_bencode; extern crate serde_bytes; extern crate sha1; pub mod metainfo; pub mod peermsg; use std::collections::HashMap; use std::error::Error; use std::io; use std::io::prelude::*; use std::net::SocketAddr; use mio::*; ...
# ! [ doc = "Debug support" ] # [ doc = r" Register block" ] # [ repr ( C ) ] pub struct Dbgmcu { # [ doc = "0x00 - MCU Device ID Code Register" ] pub idcode: Idcode, # [ doc = "0x04 - Debug MCU Configuration Register" ] pub cr: Cr, # [ doc = "0x08 - APB Low Freeze Register" ] pub apblfz: Apblfz...
use std::ops::{Deref, DerefMut}; use controlled::Controlled; use lens::LensWrap; use crate::{ controllers::TypedController, lens::Lens, math::{Size, Vector2}, Backend, BoxConstraints, }; use self::styled::Styled; pub mod controlled; pub mod lens; pub mod pod; pub mod styled; pub trait CoreExt<T, B:...
use crate::{builtins::PyBaseExceptionRef, convert::ToPyException, VirtualMachine}; #[cfg(feature = "rustpython-codegen")] pub use rustpython_codegen::CompileOpts; #[cfg(feature = "rustpython-compiler")] pub use rustpython_compiler::*; #[cfg(not(feature = "rustpython-compiler"))] pub use rustpython_compiler_core as co...
// Copyright 2016 PingCAP, Inc. // // 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 i...
use std::{cell::RefCell, collections::HashMap, fmt::Debug, ops::Deref, rc::Rc}; use crate::ast::{Expression, FunctionDefinition, LValue, Program, Statement, Type}; #[derive(Debug, Clone)] pub enum SemanticError<'a> { AlreadyDeclared, MustBePreviouslyDeclared, MustBeAFunction, TypeOfParametersIncorrect...
use config::Config; use errors::*; use clap::{App, Arg, ArgMatches, SubCommand}; pub fn setup<'a, 'b>() -> App<'a, 'b> { SubCommand::with_name("auth") .about("Authorizes a user to update a domain") .arg( Arg::with_name("USER") .help("Specifies the user") ...
use std::fs; fn get_adjacent_seats (x: i32, y: i32, map: &Vec<Vec<char>>) -> Vec<char> { let mut seats: Vec<char> = vec![]; for i in -1..2 { if i + x < 0 || x + i >= map.len() as i32 { continue; } let line = &map[(x + i) as usize]; for j in -1..2 { if j ...
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
//! Models that manage data and logic used by the application service. /// The database connection pool mod connection_pool; /// A list of Events that are received from the Matirx homeserver. mod events; /// A Rocket.Chat channel or group mod rocketchat_room; /// `RocketchatServer` entry mod rocketchat_server; /// `Ro...
#[doc = "Reader of register ACRIS"] pub type R = crate::R<u32, super::ACRIS>; #[doc = "Reader of field `IN0`"] pub type IN0_R = crate::R<bool, bool>; #[doc = "Reader of field `IN1`"] pub type IN1_R = crate::R<bool, bool>; impl R { #[doc = "Bit 0 - Comparator 0 Interrupt Status"] #[inline(always)] pub fn in0...
#![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; mod board; use wasm_bindgen::prelude::*; use board::Board; #[wasm_bindgen] extern { fn alert(s: &str); #[wasm_bindgen(js_namespace = console)] fn log(s: &str); #[wasm_bindgen(js_namespace = console, js_name = lo...
extern crate regex; mod ast; mod evaluator; mod lexer; mod parser; mod token; mod utils; use evaluator::Evaluator; use lexer::Lexer; use parser::Parser; use std::env; use std::fs; use std::process; use utils::EvalError; fn main() { let args: Vec<String> = env::args().collect(); let file_path = match args.get...
// 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. #[macro_use] extern crate zerocopy; fn main() {} #[derive(FromBytes)] union Foo {} #[derive(Unaligned)] union Bar {}
#[cfg(feature = "sgx")] use std::prelude::v1::*; use std::sync::Arc; use crate::page_cache::{PageEntry, PageEntryInner}; use crate::util::lru_list::{LruEntry, LruList}; pub struct PageLruList { inner: LruList<PageEntryInner>, } impl PageLruList { pub fn new() -> Self { let inner = LruList::new(); ...
use crate::integer::Integer; use core::ops::AddAssign; // AddAssign The addition assignment operator +=. // ['Integer', 'Integer', 'Integer::add_assign', 'no', [], ['ref']] impl AddAssign<Integer> for Integer { fn add_assign(&mut self, rhs: Integer) { Integer::add_assign(self, &rhs) } } // ['Integ...
#[doc = "Reader of register MIS"] pub type R = crate::R<u32, super::MIS>; #[doc = "Reader of field `WDTMIS`"] pub type WDTMIS_R = crate::R<bool, bool>; impl R { #[doc = "Bit 0 - Watchdog Masked Interrupt Status"] #[inline(always)] pub fn wdtmis(&self) -> WDTMIS_R { WDTMIS_R::new((self.bits & 0x01) !...
#![feature(proc_macro_diagnostic)] #![feature(proc_macro_def_site)] #![feature(box_syntax)] #![feature(box_patterns)] extern crate proc_macro; mod bif; mod option_group; mod utils; use proc_macro::TokenStream; use syn::parse_macro_input; use syn::AttributeArgs; use self::option_group::{OptionGroupConfig, OptionGrou...
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 use anyhow::{bail, Result}; use starcoin_executor::TransactionExecutor; use starcoin_state_api::AccountStateReader; use starcoin_types::account_address::AccountAddress; use starcoin_types::transaction::authenticator::AuthenticationK...
//! Utility functions for masking data frame payload data use rand; use std::io::Write; use std::io::Result as IoResult; use std::mem; #[cfg(feature = "nightly")] extern crate packed_simd as simd; /// Struct to pipe data into another writer, /// while masking the data being written pub struct Masker<'w> { key: [u8; 4...
#[doc = "Writer for register BRR"] pub type W = crate::W<u32, super::BRR>; #[doc = "Register BRR `reset()`'s with value 0"] impl crate::ResetValue for super::BRR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Port Reset bit\n\nValue on reset: 0"] #[derive(Cl...
use byteorder::WriteBytesExt; use naia_shared::{ActorType, Event, EventPacketWriter, EventType, ManagerType, Manifest}; /// Handles writing of Event & Actor data into an outgoing packet pub struct ServerPacketWriter { event_writer: EventPacketWriter, /// bytes representing outgoing Actor messages / updates ...
#[doc = "Reader of register DEN"] pub type R = crate::R<u32, super::DEN>; #[doc = "Writer for register DEN"] pub type W = crate::W<u32, super::DEN>; #[doc = "Register DEN `reset()`'s with value 0"] impl crate::ResetValue for super::DEN { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { ...
use ggez::{self, error::GameResult, graphics}; use std::clone::Clone; use std::marker::PhantomData; pub trait Gui { fn update(&mut self, mouse_x: f32, mouse_y: f32) -> GameResult<()>; fn draw(&mut self, ctx: &mut ggez::Context, font: &graphics::Font, mouse_x: f32, mouse_y: f32) -> GameResult<()>; fn mous...
use cipher::{cbc::AES_128_CBC, Cipher}; use std::collections::HashMap; const ZERO_IV: [u8; 16] = *b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; pub struct Server { key: Vec<u8>, } impl Server { pub fn new(key: &[u8]) -> Server { Server { key: key.to_vec() } } pub fn ver...
pub mod pb { tonic::include_proto!("grpc.examples.echo"); } use futures::Stream; use pb::{EchoRequest, EchoResponse}; use std::pin::Pin; use tonic::{body::BoxBody, transport::Server, Request, Response, Status, Streaming}; use tower::Service; type EchoResult<T> = Result<Response<T>, Status>; type ResponseStream = ...
#[doc = "Reader of register EPINFO"] pub type R = crate::R<u8, super::EPINFO>; #[doc = "Reader of field `TXEP`"] pub type TXEP_R = crate::R<u8, u8>; #[doc = "Reader of field `RXEP`"] pub type RXEP_R = crate::R<u8, u8>; impl R { #[doc = "Bits 0:3 - TX Endpoints"] #[inline(always)] pub fn txep(&self) -> TXEP_...
use super::{CelestialBody, Node, Vessel}; use crate::codec::{Decode, Encode}; use crate::{remote_type, RemoteEnum, RemoteObject}; remote_type!( /// Controls the game’s camera. Obtained by calling `SpaceCenter::camera()`. object SpaceCenter.Camera { properties: { { Mode { /// Ret...
// 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 crate::analysis::{fixed_point, LocationSet}; use crate::il; use crate::Error; use std::collections::HashMap; /// Compute reaching definitions for the given function. pub fn reaching_definitions( function: &il::Function, ) -> Result<HashMap<il::ProgramLocation, LocationSet>, Error> { let rda = ReachingDefin...
//! Implementations of OpenAPI `oneOf` and `anyOf` types, assuming rules are just types #[cfg(feature = "conversion")] use frunk_enum_derive::LabelledGenericEnum; use serde::{ de::Error, Deserialize, Deserializer, Serialize, Serializer, __private::de::{Content, ContentRefDeserializer}, }; use std::str::From...
static SONG:[&str; 12] = [ "On the PLACEHOLDER day of Christmas my true love sent to me A partridge in a pear tree", "On the PLACEHOLDER day of Christmas my true love sent to me Two turtle doves And a partridge in a pear tree", "On the PLACEHOLDER day of Christmas my true love sent to me Three French hens, two turtle d...
extern crate byteorder; use std::error::Error; use std::fmt; use std::fmt::{Debug, Display, Formatter}; use crate::tftp::shared::ack_packet::AckPacket; use crate::tftp::shared::data_packet::DataPacket; use crate::tftp::shared::err_packet::ErrorPacket; use crate::tftp::shared::request_packet::*; use self::byteorder::...
pub fn main() { let mut hello = String::from("안녕하세요"); hello.push_str(" world"); hello.push('!'); println!("{}", hello); for c in hello.chars() { print!("{},", c); } println!(); for b in hello.bytes() { print!("{},", b); } println!(); let s1 = String::from("...
//! Type wrappers and convenience functions for 2D collision detection pub use collision::algorithm::minkowski::GJK2; pub use collision::primitive::{Circle, ConvexPolygon, Particle2, Rectangle}; pub use core::collide2d::*; pub use core::{CollisionMode, CollisionStrategy}; use cgmath::Point2; use collision::dbvt::{Dy...
use crate::ray::Ray; use crate::vec3::{Vec3, Color, random_unit_vector, reflect, refract}; use crate::hittable::{HitRecord}; use rand::prelude::*; #[derive(Copy, Clone)] pub enum Material { Lambertian { albedo: Color }, Metal { albedo: Color, fuzz: f32 }, Dielectric { ref_idx: f32 }, } #[derive(Copy, Clo...
// revisions: full min #![cfg_attr(full, feature(const_generics))] #![feature(const_generics_defaults)] #![allow(incomplete_features)] struct Foo<const N: usize, const M: usize = { N + 1 }>; //[full]~^ ERROR constant expression depends on a generic parameter //[min]~^^ ERROR generic parameters may not be used in const...
use ethabi::{ParamType, Token}; use hex::ToHex; use bridge_common::prover::{EthAddress, EthEvent, EthEventParams}; /// Data that was emitted by the Ethereum Locked event. #[derive(Debug, Eq, PartialEq)] pub struct TokenMetadataEvent { pub metadata_connector: EthAddress, pub token: String, pub name: String...
/* * @lc app=leetcode.cn id=9 lang=rust * * [9] 回文数 * * https://leetcode-cn.com/problems/palindrome-number/description/ * * algorithms * Easy (56.68%) * Likes: 904 * Dislikes: 0 * Total Accepted: 234.8K * Total Submissions: 412.3K * Testcase Example: '121' * * 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都...
use super::{InterLink, LinkId}; use rust_src::{a_star_search, dijkstra_search, Cost, Dir, Materials, Path, Point}; use std::collections::HashMap; pub const CHUNK_SIZE: usize = 8; #[derive(Debug)] pub struct Chunk { pub pos: Point, pub links: Vec<LinkId>, } impl Chunk { pub fn new( pos: Point, materials: &Mate...
use std::io::{stdin, self, Write}; fn main() { let mut s = String::new(); let mut s2 = String::new(); let mut country = String::new(); let mut country_int: u8 = 0; while country_int != 1 && country_int != 2 { print!("Enter 1 for US or 2 for UK: "); io::stdout().flush().unwrap(); ...
#[doc = "Reader of register ADCCTRL"] pub type R = crate::R<u32, super::ADCCTRL>; #[doc = "Writer for register ADCCTRL"] pub type W = crate::W<u32, super::ADCCTRL>; #[doc = "Register ADCCTRL `reset()`'s with value 0"] impl crate::ResetValue for super::ADCCTRL { type Type = u32; #[inline(always)] fn reset_va...
mod actions; mod collections; mod config; mod exts; mod mqtt; mod nlu; mod queries; mod signals; mod skills; mod stt; #[cfg(test)] mod tests; mod tts; mod vars; // Standard library use std::rc::Rc; // This crate use crate::config::Config; use crate::exts::LockIt; use crate::signals::SIG_REG; use crate::skills::load_s...
#[cfg(test)] mod tests { #[test] fn it_works() { } } use std::fmt; #[derive(Debug, Copy, Clone)] pub enum Token { OpenParen, CloseParen, Var(u32), Abs(u32), Compose } pub fn string_to_tokens<I: IntoIterator<Item=char>>(s: I, names: &mut Vec<String>) -> Vec<Token> { //TODO: make errors...
use data::avatar::Avatar; use std::rc::Rc; use std::cell::RefCell; use rustc_serialize::json::{ToJson, Json}; pub struct User { pub id: u64, name: String, avatar: Option<Rc<RefCell<Avatar>>> } impl User { pub fn new(name: &str) -> User{ User{id: 0, name: name.to_string(), avatar: Option::None} } pub fn _new...
use std::{ path::PathBuf, fmt::{self, Formatter, Display}, fs::{self, File}, collections::{hash_map, HashMap}, io::{self, Read, Seek, SeekFrom, BufReader, BufWriter}, time }; use structopt::StructOpt; use rand::{ prelude::*, distributions::Alphanumeric }; use serde::{Serializer, ser::Se...
use crate::algorithm::centroid::Centroid; use crate::algorithm::map_coords::MapCoords; use crate::{Line, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon}; use num_traits::{Float, FromPrimitive}; use std::iter::Sum; #[inline] fn rotate_inner<T>(x: T, y: T, x0: T, y0: T, sin_theta: T, cos_theta: T)...
use solana_program::sysvar::clock::Clock; use solana_program::{ account_info::{next_account_info, AccountInfo}, entrypoint::ProgramResult, program_error::ProgramError, msg, pubkey::Pubkey, program_pack::{Pack, IsInitialized}, sysvar::{rent::Rent, Sysvar}, program::{invoke, invok...
use sqlx::postgres::PgPool; use std::{collections::HashMap, sync::Arc}; use tokio::sync::RwLock; use uuid::Uuid; use crate::handlers::rpc::client::Client; #[derive(Clone, Debug)] pub struct Environment { pool: Arc<PgPool>, clients: Arc<RwLock<HashMap<Uuid, Client>>>, } impl Environment { pub async fn new...
use naia_socket_shared::LinkConditionerConfig; use std::{default::Default, time::Duration}; /// Contains Config properties which will be shared by Server and Client #[derive(Clone, Debug)] pub struct SharedConfig { /// The duration between each tick pub tick_interval: Duration, /// Configuration used to si...
use super::script::PythonScripts; use crate::code::AddScripts; use crate::error::Result; use crate::nodes::NodeRoot; pub use n3_program::externs::ExternCode; impl AddScripts for ExternCode { fn add_scripts(&self, root: &NodeRoot, scripts: &mut PythonScripts) -> Result<()> { let name = &self.data.name; ...
//! Different behavior for enemies. //! use super::{avoid, go_to_path_point, halt, seek}; use crate::core::colors; use crate::core::random::RandomGenerator; use crate::core::transform::Transform; use crate::gameplay::collision::{CollisionLayer, CollisionWorld}; use crate::gameplay::physics::DynamicBody; use crate::rend...
use std::fs; use std::time::Instant; fn main() { let start = Instant::now(); let mut tst_ship = Ship::from_file("example.txt"); let mut ship = Ship::from_file("input.txt"); // part 1 tst_ship.follow_instructions(1); assert_eq!(tst_ship.manhattan_distance(), 25); ship.follow_instructions(1...
// verify-helper: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0516 use spella::algebra::{AssociativeMagma, InvertibleMagma, Magma, UnitalMagma}; use spella::io::Scanner; use spella::sequences::CumulativeSum; use std::cmp; use std::io::{self, prelude::*}; use std::iter::FromIterator; #[derive(Clo...
pub mod area; pub mod collapsing_header; pub mod frame; pub mod menu; pub mod popup; pub mod resize; pub mod scroll_area; pub mod window; pub use { area::Area, collapsing_header::CollapsingHeader, frame::Frame, popup::*, resize::Resize, scroll_area::ScrollArea, window::Window, };
// 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_update_channel::{ProviderRequest, ProviderRequestStream}, fuchsia_syslog::fx_log_warn, futu...
#![deny(missing_debug_implementations)] #![feature(async_await, await_macro, futures_api)] #![forbid(unsafe_code)] pub extern crate deck_core as core; use std::fmt::Debug; use std::future::Future; use std::pin::Pin; use deck_core::{Manifest, ManifestId}; // NOTE: All this noise has been to work fine with a simple `...
#[derive(Debug, Copy, Clone)] #[repr(i16)] pub enum TypeFormat { Text = 0, Binary = 1, } impl From<i16> for TypeFormat { fn from(code: i16) -> TypeFormat { match code { 0 => TypeFormat::Text, 1 => TypeFormat::Binary, _ => unreachable!(), } } }
use std::io::stdin; fn main() { println!("I am main function"); let x = { let a = 7; let b = 8; a + b // if semi colon is added, then it becomes an expression and not a return statement }; println!("{}", x); test_function(); println!("{}", add(3, 5)); println!("...
#[doc = "Reader of register ROUTELOC1"] pub type R = crate::R<u32, super::ROUTELOC1>; #[doc = "Writer for register ROUTELOC1"] pub type W = crate::W<u32, super::ROUTELOC1>; #[doc = "Register ROUTELOC1 `reset()`'s with value 0"] impl crate::ResetValue for super::ROUTELOC1 { type Type = u32; #[inline(always)] ...
use runestick::Id; use std::cell::Cell; use std::rc::Rc; #[derive(Default, Debug, Clone)] pub(crate) struct Gen { id: Rc<Cell<Id>>, } impl Gen { /// Construct a new shared generator. pub(crate) fn new() -> Self { Self { id: Rc::new(Cell::new(Id::initial())), } } /// Ge...
use crate::io::Buf; use crate::postgres::database::Postgres; use byteorder::NetworkEndian; use std::ops::Range; #[derive(Debug)] pub(crate) struct DataRow<'c> { values: &'c [Option<(u32, u32)>], buffer: &'c [u8], } impl<'c> DataRow<'c> { pub(crate) fn len(&self) -> usize { self.values.len() } ...
#![cfg_attr(not(feature = "std"), no_std)] use frame_support::{ codec::{Decode, Encode}, debug, decl_error, decl_event, decl_module, decl_storage, ensure, StorageMap, }; use frame_system::ensure_signed; use sp_runtime::print; use sp_std::vec::Vec; #[derive(Encode, Decode, Default, Clone, PartialEq)] pub struc...
struct EthernetPacket { / } struct IPv4Packet<U> { // } struct IPv6Packet<V> { } struct UDPPacket<W> { }
use winapi::shared::winerror::{HRESULT, SUCCEEDED}; use winapi::Interface; use wio::com::ComPtr; #[derive(Debug)] pub struct Error(HRESULT); pub unsafe fn wrap<T, U, F>(hr: HRESULT, ptr: *mut T, f: F) -> Result<U, Error> where F: Fn(ComPtr<T>) -> U, T: Interface, { if SUCCEEDED(hr) { Ok(f(ComPtr:...
use rumble::api::Central; use rumble::api::Peripheral; use rumble::bluez::manager::Manager; use std::thread; use std::time::Duration; fn main() { let manager = Manager::new().unwrap(); let adapters = manager.adapters().unwrap(); let mut adapter = adapters.into_iter().nth(0).unwrap(); adapter = manag...
// Buttplug Rust Source Code File - See https://buttplug.io for more info. // // Copyright 2016-2020 Nonpolynomial Labs LLC. All rights reserved. // // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. //! Implementation of internal Buttplug Client event loo...
// x86_64 pub const MEMORY_OFFSET: usize = 0; pub const KERNEL_OFFSET: usize = 0xffffff00_00000000; pub const PHYSICAL_MEMORY_OFFSET: usize = 0xffff8000_00000000; pub const KERNEL_HEAP_SIZE: usize = 16 * 1024 * 1024; // 16 MB pub const PAGE_SIZE: usize = 1 << 12; pub const KERNEL_PM4: usize = (KERNEL_OFFSET >> 39) & ...
pub trait Lazy { type Type; fn need(&self) -> &Self::Type; fn need_mut(&mut self) -> &mut Self::Type; } impl<T> Lazy for Option<T> { type Type = T; fn need(&self) -> &Self::Type { self.as_ref().unwrap() } fn need_mut(&mut self) -> &mut Self::Type { self.as_mut().unwrap() } }
#[macro_use] extern crate glium; extern crate specs; extern crate nalgebra; extern crate common; extern crate time; #[allow(dead_code)] mod renderer; #[allow(dead_code)] mod component; #[allow(dead_code)] mod state; use std::io::prelude::*; use std::net::{TcpStream, UdpSocket, SocketAddr}; use glium::backend::glutin_...
use super::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub struct TimePointSec { utc_seconds: u32, }
#[doc = "Reader of register TIMCCR"] pub type R = crate::R<u32, super::TIMCCR>; #[doc = "Writer for register TIMCCR"] pub type W = crate::W<u32, super::TIMCCR>; #[doc = "Register TIMCCR `reset()`'s with value 0"] impl crate::ResetValue for super::TIMCCR { type Type = u32; #[inline(always)] fn reset_value() ...
use anyhow::{bail, Result}; use assembler::assemble; use std::fs; fn main() -> Result<()> { let mut args = std::env::args().skip(1); let (input_path, output_path) = if let (Some(i), Some(o)) = (args.next(), args.next()) { (i, o) } else { bail!("Usage: <input_path> <output_path>"); }; ...
// 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 ...
mod xml_parse_lib; use std::collections::HashMap; use std::fs::File; use std::io::{BufReader, Read}; use xml_parse_lib::*; fn main() { let mut ascii_map: HashMap<u8, char> = HashMap::new(); let mut tag_buff: Vec<char> = Vec::new(); ascii_map.insert(32, ' '); ascii_map.insert(33, '!'); ascii_map.ins...
use std::f32; use std::io; extern crate image; use image::{ImageBuffer, Rgba}; extern crate rand; use rand::prelude::*; mod math; use math::Vec3; fn clip(f: f32) -> f32 { if f > 1.0 { 1.0 } else if f < 0.0 { 0.0 } else { f } } fn color(r: f32, g: f32, b: f32, a: f32) -> Rgba...
fn task1(step: usize) -> i32 { let mut v = Vec::new(); v.push(0); let mut pos = 0 as usize; for i in 0..2017 { pos = (pos + step) % v.len() + 1; v.insert(pos, i + 1); } v[pos + 1] } fn task2(step: usize) -> i32 { let mut zeropos = 0; let mut res = 0; ...
// 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, VecDeque, }; use std::hash::Hash; use std::io::{ Cursor, Read, Result as IOResult, Seek, SeekFrom, }; use std::sync::atomic::{ AtomicBool, AtomicU32, Ordering, }; use std::sync::{ Arc, Condvar, Mutex, RwLock, Weak, }; use cros...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtWidgets/qmenubar.h // dst-file: /src/widgets/qmenubar.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin =>...
extern crate quicksilver; use quicksilver::{ Result, geom::{Shape, Vector, Rectangle}, graphics::{Background, Background::Img, Background::Col, Color, Font, FontStyle, Image, PixelFormat}, lifecycle::{Asset, Window}, }; extern crate naive_gui; use naive_gui::{ Gui, Widget, Drawer, }; pub s...
//! An InfluxDB IOx API client. #![deny( rustdoc::broken_intra_doc_links, rustdoc::bare_urls, rust_2018_idioms, missing_debug_implementations, unreachable_pub )] #![warn( missing_docs, clippy::todo, clippy::dbg_macro, clippy::clone_on_ref_ptr, // See https://github.com/influxdata...
use winapi::shared::ntdef::HANDLE; use winapi::um::handleapi::*; use winapi::um::errhandlingapi::*; use std::ptr::null_mut; #[repr(C)] #[derive(Debug)] pub struct KernelHandle(HANDLE); #[derive(Debug, Clone, Copy)] pub struct Win32Error(u32); impl Drop for KernelHandle { fn drop(&mut self) { if self.0 as...
//! A dynamically sized, multi-channel interleaved audio buffer. use crate::wrap; use audio_core::{ AsInterleaved, AsInterleavedMut, Buf, Channels, ChannelsMut, ExactSizeBuf, InterleavedBuf, ResizableBuf, Sample, }; use std::cmp; use std::fmt; use std::hash; use std::marker; use std::ptr; mod channel; pub use...
mod platform; mod version; pub use block::Block; pub use entry::Entry; pub use header::Header; pub use patch::Patch; pub use platform::Platform; pub use region::Region; pub use version::Version; pub(crate) mod block; mod entry; pub mod files; mod header; pub mod index; mod patch; mod region; pub mod decrypt; pub mod ...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[link(name = "windows")] extern "system" {} pub type IImageScannerFormatConfiguration = *mut ::core::ffi::c_void; pub type IImageScannerSourceConfiguration = *mut ::core::ffi::c_void; pub type ImageScanne...
use async_graphql::*; #[tokio::test] pub async fn test_interface_simple_object() { #[derive(SimpleObject)] struct MyObj { id: i32, title: String, } #[derive(Interface)] #[graphql(field(name = "id", type = "&i32"))] enum Node { MyObj(MyObj), } struct Query; ...
use gimli::X86_64; use crate::registers::Registers; type UnwindPayload<'a> = &'a mut dyn FnMut(Registers); pub fn registers<F>(mut f: F) where F: FnMut(Registers) { let mut f = &mut f as UnwindPayload; unsafe { unwind_trampoline(&mut f) }; } #[allow(improper_ctypes)] // trampoline just forwards the ptr exter...