text
stringlengths
8
4.13M
use serde::Deserialize; /// Информация о приложении XSolla /// https://developers.xsolla.com/ru/api/v2/getting-started/#api_param_webhooks_payment_settings #[derive(Debug, Deserialize)] pub struct ProjectSettings { pub project_id: i32, pub merchant_id: i32, }
use crate::vector::normalize; use crate::projection::Projection; use crate::transform::{get_rotation, get_translation, inv_transform}; use ndarray::{arr1, Array, Array1, Array2}; use ndarray_linalg::Norm; static EPSILON: f64 = 1e-16; pub fn calc_key_epipole( transform_wk: &Array2<f64>, transform_wr: &Array2<f...
// @author shailendra.sharma use bytes::{Buf, BufMut}; use crate::BitPage; // TODO: this is for backward compatibility of indices... as they gets changed... we can only encode u64 directly const MAX_VALUE: u64 = u64::max_value(); impl BitPage { pub fn encode<W>(value: u64, buf: &mut W) where W: BufM...
use super::*; #[test] fn with_number_atom_reference_function_or_port_returns_true() { run!( |arc_process| { ( strategy::term::pid::local(), strategy::term::number_atom_reference_function_or_port(arc_process.clone()), ) }, |(left, right...
pub struct Config { pub learning_rate: f32, pub iterations_count: u32 } impl Config { pub fn new(learning_rate: f32, iterations_count: u32) -> Config { if learning_rate > 1.0 || learning_rate < 0.0 { panic!("Learning rate should be between 0 and 1!"); } Config { learning_rate, iterations_count...
use crate::api::v1::ceo::auth::model::{InpNew, Login, QueryUser, ReqInfo, SlimUser}; use crate::models::DbExecutor; use crate::utils::jwt::create_token; use crate::utils::validator::Validate; use actix::Addr; use actix_web::{ web::{Data, Json}, Error, HttpResponse, ResponseError, }; use futures::{future::resul...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - JPEG codec control register"] pub confr0: CONFR0, #[doc = "0x04 - JPEG codec configuration register 1"] pub confr1: CONFR1, #[doc = "0x08 - JPEG codec configuration register 2"] pub confr2: CONFR2, #[doc = "0x0c...
// 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 ...
// 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::ast; use crate::compiling::v2::{Assemble as _, Compiler}; use crate::compiling::CompileError; use crate::shared::ResultExt as _; use rune_ssa::{Block, Var}; use runestick::Span; pub(crate) struct Branches<'a> { conditional: Vec<(&'a ast::Block, &'a ast::Condition)>, fallback: Option<&'a ast::Block>,...
use crate::backend::c; use bitflags::bitflags; #[cfg(linux_kernel)] bitflags! { /// `MS_*` constants for use with [`mount`]. /// /// [`mount`]: crate::mount::mount #[repr(transparent)] #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct MountFlags: c::c_ulong { /// `MS_BIND` ...
//! Generic state models for hexagonal grid UIs. pub mod gridview; pub mod scroll; // pub mod change;
//! Wrapper that ignores writes. use std::{fmt::Display, ops::Range, sync::Arc}; use async_trait::async_trait; use bytes::Bytes; use futures::stream::BoxStream; use object_store::{ path::Path, DynObjectStore, GetOptions, GetResult, ListResult, MultipartId, ObjectMeta, ObjectStore, Result, }; use tokio::io::{si...
use std::{borrow::Cow, collections::HashMap, fs::{self, File}, io::{self, BufReader, BufWriter, ErrorKind, BufRead}, path::{Path, PathBuf}}; use log::*; use m3u::{EntryExt, ExtInf}; use path_slash::PathBufExt; use simplelog::{ColorChoice, CombinedLogger, Config, TermLogger, TerminalMode, WriteLogger}; use structopt::S...
use anyhow::Context; use geoip2_city::CityApiResponse; use serde::{Deserialize, Serialize}; use std::net::IpAddr; use time::{Date, OffsetDateTime}; /// Name of the caching database. pub const GEO_DB_CACHE_TREE_NAME: &str = "geolocation_cache"; /// A caching database for geolocation information fetched from MaxMind. p...
use crate::engine::components::player_controlled::PlayerId; use crate::engine::network::client_data::ClientData; // Messages which come from client (Ws) #[derive(Debug)] pub enum WSClientMessage { Connected(PlayerId, ClientData), Disconnected(PlayerId), Packet(PlayerId, Vec<u8>), }
#[allow(unused_imports)] use proconio::{marker::*, *}; #[allow(unused_imports)] use std::{cmp::Ordering, convert::TryInto}; #[fastout] fn main() { input! { d: i32, n: i32, range: [(i32, i32); n], } // diff[i] = i日目の出席者数の前日比 let mut diff = vec![0; (d + 2).try_into().unwrap()]; ...
use regex::Regex; use std::fs::File; use std::io::prelude::*; use std::io::SeekFrom; use std::str::FromStr; pub struct ProcessMemory { pid: usize, maps: Vec<Map>, } impl ProcessMemory { /// Creates a new ProcessMemory struct with the given PID pub fn new(pid: usize) -> ProcessMemory { ...
#![warn(missing_docs)] #![cfg_attr(feature = "cargo-clippy", allow(doc_markdown))] //! A RISC-V simulator implementing RV32G. //! //! ## Usage //! //! The primary workhorse in this crate is the `Interp`. It takes a `CpuState`, `Memory` and //! `Clock`, then simulates a virtual CPU using these resources. `CpuState` is ...
use rand::Rng; static REAL_PI: f64 = 3.141592653589793238462643383279; fn main() { let mut total = 0.0; let mut inside = 0.0; let loops = 1000000000; for _i in 1..(loops+1){ if inside_circle(distance_origo(rand_float(),rand_float())){ inside+=1.0; } total+=1.0; } let aprox_pi: f64 = 4.0*(inside/total);...
//! A `Recipe` is a collection of blocks. Use it to build your program //! and run passes on it. You can also execute code from a `Recipe`. use std::collections::HashMap; use crate::blocks::BasicBlock; /// BasicBlock collection pub struct Recipe<'block> { entry: Option<&'block dyn BasicBlock>, blocks: HashMa...
extern crate serde; extern crate serde_json; // For better and clearer tests #[cfg(test)] #[macro_use] extern crate assert_approx_eq; #[macro_use] extern crate serde_derive; mod units; mod commands; fn main() { let args: Vec<String> = std::env::args().collect(); if args.len() < 2 { eprintln!("Need ...
use app::{ args::Args, middleware::cache::*, routes::{entry::*, fallback::*, rss::*}, state::AppState, templates, }; use axum::{ http::Request, middleware::from_fn_with_state, response::Response, routing::get, Router, Server, }; use clap::Parser; use sea_orm::Database; use std::{io, net::SocketAddr, sync::Arc, ti...
use collections::EntitySet; use engine::{Engine, EngineBuilder}; use scene::Scene; use std::collections::VecDeque; use std::intrinsics; #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] pub struct Entity(u32); impl Entity { pub fn new() -> Entity { Engine::scene().create_entity() } } const MIN_RECYC...
use restaurant::adder; mod common; // 并不需要将 tests/integration_test.rs 中的任何代码标注为 #[cfg(test)] // Cargo 只会在运行 cargo test 时编译这个目录中的文件 #[test] fn it_adds_two() { common::setup(); assert_eq!(4, adder::add_two(2)); }
use proconio::input; fn main() { input! { n: usize, m: usize, a: [usize; m], }; let mut ans = Vec::new(); let mut ord = vec![1]; for x in 1..n { if a.contains(&x) { ord.push(x + 1); } else { ord.reverse(); ans.append(&mut ...
use reckoner::{Integer, Rational, RoundMode}; use std::env; // Compute the value of PI to a selected degree of precision. fn main() { let args: Vec<_> = env::args().collect(); if let Some([iterations, precision]) = args.get(1..=2) { let iterations = iterations .parse() .expect(...
#[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::CONFLAG { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w m...
use std::io; use thiserror::Error; #[derive(Error, Debug)] pub enum DmiError { #[error("IO error")] Io(#[from] io::Error), #[error("Image-processing error")] Image(#[from] image::error::ImageError), #[error("FromUtf8 error")] FromUtf8(#[from] std::string::FromUtf8Error), #[error("ParseInt error")] ...
extern crate dirs; use crate::printer::Print; use crate::reader::ReadInput; use crate::storage::Store; use log::{debug, info, trace}; use std::io; pub mod printer; pub mod reader; pub mod storage; #[derive(Debug)] pub enum PickupCommand { ListItems, AddItem(String), ShowItem(usize), RemoveItem(usize)...
use input::ScanCode; use std::{mem, ptr}; use std::collections::VecDeque; use std::sync::{Arc, Mutex}; use super::input::{register_raw_input, handle_raw_input}; use super::gdi32; use super::ToCU16Str; use super::kernel32; use super::winapi::*; use super::user32; use super::winmm; use window::Message; use window::Messag...
// Copyr1ight 2021 Chiral Ltd. // Licensed under the Apache-2.0 license (https://opensource.org/licenses/Apache-2.0) // This file may not be copied, modified, or distributed // except according to those terms. use crate::core; /// Types pub type VertexMapping = Vec<Vec<usize>>; pub type NeighbourIndexes = Vec<usize>;...
use bevy::prelude::*; use glyph_brush_layout::{HorizontalAlign, VerticalAlign}; use crate::{mesh_system::TextMeshState, TextMeshFont}; pub use ttf2mesh::Quality; #[derive(Default, Bundle, Debug)] pub struct TextMeshBundle { /// Text mesh configuration pub text_mesh: TextMesh, /// Standard bevy [`Transfor...
#[doc = "Reader of register MAPR2"] pub type R = crate::R<u32, super::MAPR2>; #[doc = "Writer for register MAPR2"] pub type W = crate::W<u32, super::MAPR2>; #[doc = "Register MAPR2 `reset()`'s with value 0"] impl crate::ResetValue for super::MAPR2 { type Type = u32; #[inline(always)] fn reset_value() -> Sel...
//! Apollo persisted queries extension. use std::sync::Arc; use async_graphql_parser::types::ExecutableDocument; use futures_util::lock::Mutex; use serde::Deserialize; use sha2::{Digest, Sha256}; use crate::{ extensions::{Extension, ExtensionContext, ExtensionFactory, NextPrepareRequest}, from_value, Request...
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 extern crate chrono; use crypto::{hash::CryptoHash, HashValue}; use crate::cache_storage::CacheStorage; use crate::db_storage::DBStorage; use crate::storage::{InnerStore, StorageInstance, ValueCodec}; use crate::{Storage, TRANSACT...
const INPUT: &str = include_str!("input.txt"); fn part1(input: &'static str) -> i32 { input .lines() .flat_map(|line| line.parse()) .map(|n: i32| n / 3 - 2) .sum() } fn part2(input: &'static str) -> i32 { input .lines() .flat_map(|line| line.parse()) .fl...
use crate::widgets::UserInterface; use crate::{Backend, GlobalState}; use anyhow::Result; use futures::task::SpawnExt; use iced_native::program; use iced_wgpu::{wgpu, Renderer}; use iced_winit::{conversion, futures, winit, Debug}; use winit::{dpi::PhysicalPosition, event::ModifiersState}; pub(crate) struct Frontend { ...
#[repr(C)] #[derive(Debug, Clone)] pub struct VkExtent3D { pub width: u32, pub height: u32, pub depth: u32, }
#[cfg(all(not(target_arch = "wasm32"), test))] mod test; use std::convert::TryInto; use std::u8; use anyhow::*; use liblumen_alloc::erts::exception; use liblumen_alloc::erts::process::Process; use liblumen_alloc::erts::term::prelude::*; use crate::binary::to_term::Options; use crate::runtime::distribution::external...
use std::io::prelude::*; use error::ObjResult; pub fn lex<T, F>(input: T, mut callback: F) -> ObjResult<()> where T: BufRead, F: FnMut(&str, &[&str]) -> ObjResult<()> { for line in input.lines() { let line = try!(line); let line = line.split('#').next().unwrap(); // Remove comments let ...
use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::HashMap; use std::f32::consts::{PI, SQRT_2}; use std::fs::File; use std::path::Path; use std::str::FromStr; use self::OrthoRotation::*; use crate::array::*; use crate::cube; use gfx_voxel::texture::AtlasBuilder; use rustc_serialize::json...
//! Contains the ffi-safe equivalent of `std::ops::Range*` types. use std::ops::{Range, RangeFrom, RangeInclusive, RangeTo, RangeToInclusive}; //////////////////////////////////////////////////////////////// macro_rules! impl_into_iterator { ( $from: ident, $to: ident ) => { impl<T> IntoIterator for $fro...
extern crate aoc; use std::collections::hash_map::Entry; use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; use std::io::{self, BufReader}; use std::num::ParseIntError; use std::str::FromStr; #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] struct Date { year: u16, month: ...
use crate::data_set_parser::parse_full; use crate::encoding::ExplicitBigEndian; use crate::encoding::ExplicitLittleEndian; use crate::encoding::ImplicitLittleEndian; use crate::handler::Handler; use crate::meta_information; use crate::meta_information::MetaInformation; use crate::value_parser::ParseError; /// Parses a...
use super::super::*; use kernel_hal::{ ColorDepth, ColorFormat, FramebufferInfo, HalError, PageTableTrait, PhysAddr, VirtAddr, FRAME_BUFFER, }; use riscv::addr::Page; use riscv::asm::sfence_vma_all; use riscv::paging::{PageTableFlags as PTF, *}; use riscv::register::{satp, sie, stval, time}; //use crate::sbi; u...
use proconio::{input, marker::Chars}; fn main() { input! { mut s: Chars, }; for i in 0..(s.len() / 2) { s.swap(i * 2, i * 2 + 1); } for b in s { print!("{}", b); } println!(); }
use std::{convert::TryInto, str::Chars}; use parser::T; use rowan::{TextRange, TextSize}; use crate::{ SyntaxError, SyntaxKind::{self}, }; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Token { /// The kind of token. pub kind: SyntaxKind, /// The length of the toke...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtGui/qaccessiblebridge.h // dst-file: /src/gui/qaccessiblebridge.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main bloc...
use crate::irust::{IRust, Result}; use crossterm::style::Color; use irust_repl::{CompileMode, Edition, Executor, MainResult, ToolChain, DEFAULT_EVALUATOR}; use serde::{Deserialize, Serialize}; use std::io::{Read, Write}; #[derive(Deserialize, Serialize, Clone, Debug)] pub struct Options { add_irust_cmd_to_history:...
// 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. extern crate serde; extern crate serde_json; use log::warn; use std::fs::{self, File}; use std::io::{BufReader, BufWriter, Write}; use std::path::{Path, P...
use std::f32; use std::ffi::{ c_void, CStr, CString, }; use std::os::raw::c_char; use std::sync::Arc; use ash::extensions::khr::Surface as KhrSurface; use ash::vk; use sourcerenderer_core::graphics::{ Adapter, AdapterType, }; use crate::bindless::BINDLESS_TEXTURE_COUNT; use crate::queue::VkQueueIn...
fn main() { let n: u32 = read(); let reader: Box<Iterator<Item = i32>> = Box::new(ReadLines::new(n, 0)); println!("{}", maximum_profit(reader)); } fn maximum_profit(reader: Box<Iterator<Item = i32>>) -> i32 { let mut min = i32::max_value(); let mut profit = i32::min_value(); for e in reader ...
pub use self::displaystruct::DisplayStruct; mod displaystruct;
use crate::Player; use game_camera::CameraSystem; use game_core::{GameStage, GlobalMode, ModeEvent, modes::ModeExt}; use game_lib::bevy::{ecs as bevy_ecs, prelude::*}; use game_physics::PhysicsPlugin; use game_tiles::TileSystem; #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, SystemLabel)] pub struct ControllerPlugi...
use abi; pub use super::abi_types::AbiFunction; use hashmap_core::HashMap; // TODO: Verify function signatures so we don't // throw bad data at functions and crash everything. abi_map! { ABI_MAP, // testing exit: { // eventually will exit maybe, right now is just for testing params: [I64]...
// Copyright 2018 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 ...
#![doc( html_logo_url = "https://varlink.org/images/varlink.png", html_favicon_url = "https://varlink.org/images/varlink-small.png" )] #![allow(unused_imports)] pub mod org_varlink_resolver; pub mod org_varlink_service;
use P58::*; pub fn main() { let trees = symmetric_balanced_trees(5, 'x'); for tree in trees { println!("{}", tree); } }
use crate::block::{Block, Transaction}; use std::collections::HashSet; use std::net::{AddrParseError, SocketAddr}; #[derive(Debug, Clone)] pub struct Chain { pub blocks: Vec<Block>, pub transactions: Vec<Transaction>, pub nodes: HashSet<SocketAddr>, } impl Chain { pub fn new() -> Self { Chain { bloc...
use async_graphql::*; #[tokio::test] pub async fn test_directive_skip() { struct Query; #[Object] impl Query { pub async fn value(&self) -> i32 { 10 } } let schema = Schema::new(Query, EmptyMutation, EmptySubscription); let data = schema .execute( ...
//! Materials represent a shader and its configurable properties. //! //! # Shader Properties //! //! Shaders can have three kinds of //! input values: Vertex attributes, varying attributes, and uniform attributes. Vertex attributes //! are values that are different for each vertex of the mesh being rendered, e.g. the ...
// 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 std::env; use telegram_bot::{Api, CanSendMessage, ChatId, Error}; #[tokio::main] async fn main() -> Result<(), Error> { dotenv::dotenv().ok(); let token = env::var("TOKEN").expect("TOKEN is not set"); let chat_id = env::var("CHAT_ID").expect("TOKEN is not set"); let chat_id = chat_id.parse::<i64>...
pub fn insertion_sort<T: PartialOrd>(v: &mut Vec<T>) -> &Vec<T> { if v.len() <= 1 { return v; } for i in 1..v.len() { for j in (1..=i).rev() { // compare v[j] with v[j-1] if v[j] < v[j-1] { v.swap(j, j-1); } else { break; ...
// Bring in the standard library module to accesss `args` // std::env::args_os could be used to recognize non-ASCII values use std::env; // Bring in the standard library module to handle exiting process use std::process; use minigrep; use minigrep::Config; // The majority of the functionality in a Rust program should...
// 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 zerocopy::{AsBytes, FromBytes}; #[repr(C)] #[derive(AsBytes, FromBytes, PartialEq, Eq, Clone, Copy, Debug, Default)] pub struct StatusCode(pub u16); ...
use std::collections::HashMap; use std::process::{Command, Output}; use std::str; use std::sync::mpsc::{Sender, Receiver}; use std::thread; use std::thread::{JoinHandle, sleep}; use crate::executable_command::ExecutableCommand; use crate::tasks::Task; use std::time::{SystemTime, Duration}; use log::{trace, info, warn}...
use crate::proxy::{buffer, http, pending}; use crate::Error; pub use linkerd2_router::Make; pub use linkerd2_stack::{self as stack, layer, map_target, Layer, LayerExt, Shared}; pub use linkerd2_timeout::stack as timeout; use std::time::Duration; use tower::layer::util::{Identity, Stack as Pair}; use tower::limit::concu...
// 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}; use fidl_fuchsia_update::{ Initiator, ManagerMarker, MonitorEvent, MonitorMarker, MonitorProxy, Options, State, }; use...
//! Conversions from scalar types to radix keys, which can be sorted bitwise. use core::mem; #[derive(Clone, Copy, PartialEq, Eq)] pub(crate) struct RadixKey<const W: usize>([u8; W]); impl<const W: usize> RadixKey<W> { // The key is a byte array, we can access any byte (digit) using an index. // // Here'...
// 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 std::{ cell::{Cell, RefCell}, collections::{BTreeMap, HashSet}, mem, ops::{Index, IndexMut, Range}, ptr, }; #[cfg(feature = "traci...
mod gen_sine; mod gen_saw; pub use self::gen_sine::GenSine; pub use self::gen_saw::GenSaw;
mod utils; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use web_sys::{CanvasRenderingContext2d, OffscreenCanvas}; use serde::{Serialize, Deserialize}; use tic_tac_toe::{ TicTacToeGame, PlayerType, GameState, WinningPattern }; #[derive(Serialize, Deserialize)] pub struct Coordinates { pub x: f64, pub y...
use std::iter::repeat; /// Scans n first lines to collect info about longest values in each column. pub fn analyze(lines: &[String], sep: &str) -> Vec<usize> { let mut columns_to_lengths: Vec<Vec<usize>> = Vec::new(); for line in lines { let column_value_lenghts = line .split(sep) ...
pub use self::mailer::Mailer; pub mod mailer; pub mod organization_invites; pub mod tickets; pub mod user;
use metrohash::MetroHash64; use std::hash::Hasher; const MIN_LUMINANCE: f64 = 100.0; pub type RGB = (u8, u8, u8); pub fn colour_dist((ir1, ig1, ib1): (u8, u8, u8), (ir2, ig2, ib2): (u8, u8, u8)) -> f64 { let (r1, g1, b1) = (ir1 as f64, ig1 as f64, ib1 as f64); let (r2, g2, b2) = (ir2 as f64, ig2 as f64, ib2 ...
use std::env; use std::fs::File; use std::io::{Read, Result}; extern crate bit_vec; extern crate byteorder; mod gameboy; fn read_bin(path: String) -> Result<Vec<u8>> { let mut file_buf = Vec::new(); File::open(path)?.read_to_end(&mut file_buf)?; Ok(file_buf) } fn main() -> Result<()> { let bios_rom ...
extern crate xmlparser as xml; #[macro_use] mod token; use token::*; test!(element_01, "<a/>", Token::ElementStart("", "a"), Token::ElementEnd(ElementEnd::Empty) ); test!(element_02, "<a></a>", Token::ElementStart("", "a"), Token::ElementEnd(ElementEnd::Open), Token::ElementEnd(ElementEnd::Close(...
use crate::math::{Aabb, OrthoNormalBasis, Ray, Unit3, Vec3, EPSILON}; #[derive(Debug, Clone, Copy)] pub struct RawHitInfo { pub t: f64, pub outward_normal: Unit3, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum HitSide { Inside, Outside, } pub struct HitInfo { pub point: Vec3, pub bas...
#[cfg(feature = "stm32f4xx-hal")] use stm32f4xx_hal::stm32; #[cfg(feature = "stm32f7xx-hal")] use stm32f7xx_hal::pac as stm32; use stm32::ethernet_mac::{MACMIIAR, MACMIIDR}; /// Station Management Interface pub struct SMI<'a> { macmiiar: &'a MACMIIAR, macmiidr: &'a MACMIIDR, } impl<'a> SMI<'a> { /// Allo...
pub type GstPlayFlags = i32; #[allow(unused)] pub const GST_PLAY_FLAG_VIDEO: GstPlayFlags = 0b00_0000_0001; #[allow(unused)] pub const GST_PLAY_FLAG_AUDIO: GstPlayFlags = 0b00_0000_0010; #[allow(unused)] pub const GST_PLAY_FLAG_TEXT: GstPlayFlags = 0b00_0000_0100; #[allow(unused)] pub const GST_PLAY_FLAG_DOWNLOAD: GstP...
#[macro_use] pub mod utils; pub mod style; pub mod builder; pub mod window;
#![cfg_attr(not(feature = "std"), no_std)] /// A runtime module template with necessary imports /// Feel free to remove or edit this file as needed. /// If you change the name of this file, make sure to update its references in runtime/src/lib.rs /// If you remove this file, you can remove those references /// For m...
use crate::token::Token; use crate::token_type::{TokenType, KEYWORDS}; #[derive(Default)] pub struct Lexer { input: Vec<char>, position: usize, read_position: usize, examining_char: Option<char>, } impl Lexer { pub fn new(input: String) -> Self { let mut lexer = Self { input: i...
use core::any::TypeId; use core::fmt; use core::hash::{Hash, Hasher}; use firefly_binary::{Bitstring, Selection}; use crate::term::OpaqueTerm; /// A slice of another binary or bitstring value #[repr(C)] pub struct BitSlice { /// This a thin pointer to the original term we're borrowing from /// This is necess...
use crate::cursor::Cursor; use crate::ecc::PrivateKey; use crate::genio::{Read, Write}; use crate::helpers::{encode_varint, hash_256, read_varint, SIGHASH_ALL}; use crate::script::{Script, ScriptElement}; use crate::serialization::Serialization; use bigint::U256; use core::fmt; //todo: implement tx.fee() //A Bitcoin ...
extern crate ecs; #[macro_use] extern crate ecs_derive; use ecs::component::storage::VecStorage; use ecs::component::Component; use std::any::TypeId; #[derive(Component)] #[Storage(VecStorage)] struct MyComponent(i32); #[test] fn storage_match() { assert_eq!( TypeId::of::<VecStorage<MyComponent>>(), ...
use crate::Part; use regex::Regex; struct Password { min: usize, max: usize, rule: char, password: String, } pub fn run(part: Part, input_str: &str) { let re = Regex::new(r"(?P<min>\d+)-(?P<max>\d+) (?P<rule>[a-z]): (?P<password>.+)").unwrap(); let input: Vec<Password> = input_str.split('\n') ...
#[doc = "Reader of register HB8TIME4"] pub type R = crate::R<u32, super::HB8TIME4>; #[doc = "Writer for register HB8TIME4"] pub type W = crate::W<u32, super::HB8TIME4>; #[doc = "Register HB8TIME4 `reset()`'s with value 0"] impl crate::ResetValue for super::HB8TIME4 { type Type = u32; #[inline(always)] fn re...
use std::fmt::{Display, Debug}; fn main() { let tweet = Tweet { username: String::from("horse_ebooks"), content: String::from("of course, as you probably already know, people"), reply: false, retweet: false, }; println!("1 new tweet: {}", tweet.summarize()); } pub trait Su...
type PartialResult<T, E> = Result<T, Result<(T, E), E>>; #[derive(Clone, Debug)] pub enum EventStatus { Success, Partial, Failure, } impl<T, E> From<&PartialResult<T, E>> for EventStatus { fn from(r: &PartialResult<T, E>) -> Self { match r { Ok(_) => EventStatus::Success, ...
#[actix::main] async fn main() { async { 1 }.await; }
use std::fmt; use chrono::{DateTime, Utc}; use chrono::serde::ts_seconds; use serde::Deserialize; #[derive(Deserialize, Debug)] #[serde(untagged)] pub enum CityResponse { City(City), ApiError(ApiError), } #[derive(Deserialize, Debug)] pub struct City { pub base: Option<String>, pub clouds: Option<Clo...
use procon_reader::ProconReader; fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let t: usize = rd.get(); for _ in 0..t { let k: usize = rd.get(); solve(k); } } fn solve(k: usize) { fn dislike(x: usize) -> bool { x % 3 == 0 || x....
macro_rules! constuct_cipher { ($name:ident, $sbox:expr) => { #[derive(Clone, Copy)] pub struct $name<'a> { c: Gost89<'a> } impl<'a> BlockCipher for $name<'a> { type BlockSize = U8; #[inline] fn encrypt_block(&self, block: &mut Bloc...
use juniper::graphql_object; struct Obj; #[graphql_object] impl Obj {} fn main() {}
use std::cell::RefCell; use std::rc::Rc; use super::{Parse, ParseOption, ParseList, ParseCollect, FromCommandLine}; use super::action::Action; use super::action::{TypedAction, IArgAction, IArgsAction}; use super::action::ParseResult; use super::action::ParseResult::{Parsed, Error}; use super::action::Action::{Single, ...
use proc_macro::TokenStream; mod proto; /// Declares a new enum which is compatible with the `arcorn::{enwrap, unwrap, is}` API. /// /// Any expansion of the macro satisfies the following properties: /// * Enums: /// * Each enum is wrapped as an `Option` inside a struct (prost requirement). /// * Each enum implem...
use async_h1::{ client::Encoder, server::{ConnectionStatus, Server}, }; use async_std::io::{Read as AsyncRead, Write as AsyncWrite}; use http_types::{Request, Response, Result}; use std::{ fmt::{Debug, Display}, future::Future, io, pin::Pin, sync::RwLock, task::{Context, Poll, Waker}, };...