text
stringlengths
8
4.13M
use failure::Error; pub mod maybe_unavaliable; pub use self::maybe_unavaliable::MaybeUnavailable; /// Returns a string describing the error and the full chain. pub fn format_error(error: &Error) -> String { let mut buf = format!("Error: {}\n", error); for cause in error.iter_causes() { buf += &format...
use anyhow::{anyhow, Result}; use ropey::Rope; use std::path::PathBuf; use crate::import_string; use crate::parser::{ImportFinder, Lang}; fn infer_langauge_from_suffix(file_name: &PathBuf) -> Result<Lang> { let suffix = file_name .extension() .and_then(|os_str| os_str.to_str()) .ok_or_else...
use bitflags::bitflags; bitflags! { /// `GRND_*` flags for use with [`getrandom`]. /// /// [`getrandom`]: crate::rand::getrandom #[repr(transparent)] #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct GetRandomFlags: u32 { /// `GRND_RANDOM` const RANDOM = linux_raw_sy...
use crate::worker::{component::DATABASE, vtable}; use spatialos_sdk_sys::worker::*; use std::{ ffi::{CStr, CString}, ptr, }; pub struct ConnectionParameters { pub worker_type: CString, pub network: NetworkParameters, pub send_queue_capacity: u32, pub receive_queue_capacity: u32, pub log_mes...
use bytes::{Buf, Bytes}; use crate::error::Error; use crate::mssql::io::MssqlBufExt; #[allow(dead_code)] #[derive(Debug)] pub(crate) struct Info { pub(crate) number: u32, pub(crate) state: u8, pub(crate) class: u8, pub(crate) message: String, pub(crate) server: String, pub(crate) procedure: St...
use super::device::IoKitDevice; use super::traits::DataSource; use crate::platform::traits::BatteryDevice; use crate::units::energy::watt_hour; use crate::units::power::milliwatt; use crate::units::{ElectricCharge, ElectricCurrent, ElectricPotential, ThermodynamicTemperature, Time}; use crate::Result; /// This data so...
use std::{collections::HashMap, fmt, path::Path, time::Instant}; use httpserv::*; #[derive(Debug)] pub enum ArgFail { InvalidFormat(String), } impl fmt::Display for ArgFail { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { ArgFail::InvalidFormat(s) => { write!(f, "'{}' is in...
// 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 ...
// "Tifflin" Kernel - Networking Stack // - By John Hodge (thePowersGang) // // Modules/network/tcp.rs //! Transmission Control Protocol (Layer 4) use shared_map::SharedMap; use kernel::sync::Mutex; use kernel::lib::ring_buffer::{RingBuf,AtomicRingBuf}; use core::sync::atomic::{AtomicUsize, Ordering}; use crate::nic::S...
/* Copyright 2020 Timo Saarinen 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 in writing, software d...
// Remove target_arch when upstream metadata generator supports other targets #![cfg(all(windows, target_arch = "x86_64", target_env = "msvc"))] use test_win32_static_simple::*; use windows::core::*; use StaticComponent::Win32::Simple::*; #[test] fn test() -> Result<()> { unsafe { SimpleFunction(); ...
// 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. #[cfg(test)] use { crate::fidl_clone::FIDLClone, crate::input::monitor_mic_mute, crate::registry::service_context::ServiceContext, crate::tests...
use std::mem; use std::sync::Arc; use arraydeque::ArrayDeque; use crossbeam_channel::Receiver; use spin::{Mutex, MutexGuard}; use super::constants::INORDER_QUEUE_SIZE; use super::runq::{RunQueue, ToKey}; pub struct InnerJob<P, B> { // peer (used by worker to schedule/handle inorder queue), // when the peer i...
//! Audio wave. //! //! This modules has all methods and structs required to work with audio waves meant to be played via the [`ndsp`](crate::services::ndsp) service. use super::{AudioFormat, NdspError}; use crate::linear::LinearAllocator; /// Informational struct holding the raw audio data and playback info. /// ///...
#![feature(const_fn)] #![feature(use_nested_groups)] #![feature(duration_extras)] extern crate ggez; extern crate rand; mod coord; mod block; mod color; mod shapes; mod consts; mod square; mod gamestate; use ggez::event; use ggez::Context; use ggez::graphics; use std::time::{Duration, Instant}; use std::thread::sleep...
pub mod to_term; use std::backtrace::Backtrace; use std::convert::TryInto; use std::ops::Range; use anyhow::*; use thiserror::Error; use liblumen_alloc::erts::exception::{self, ArcError, Exception, InternalException}; use liblumen_alloc::erts::term::prelude::*; use liblumen_alloc::Process; pub struct PartRange { ...
use crate::grid_graph::{GridGraph, Node}; use crate::pbf_reader::{read_or_create_graph}; use crate::persistence::navigator::Navigator; use crate::persistence::in_memory_routing_repo::{ShipRoute, RouteRequest}; use crate::dijkstra::{Dijkstra}; use crate::nearest_neighbor::NearestNeighbor; use crate::config::Config; use ...
// Minimize Deviation in Array // https://leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/583/week-5-january-29th-january-31st/3622/ pub struct Solution; use std::collections::BinaryHeap; impl Solution { pub fn minimum_deviation(nums: Vec<i32>) -> i32 { let mut heap = BinaryHeap::wi...
extern crate actix; extern crate futures; extern crate tokio; use actix::Actor; use actix::StreamHandler; use std::io; use tokio::io::WriteHalf; use tokio::net::TcpStream; use crate::codec::{P2PCodec, Request}; pub struct Session { /// Unique session id id: usize, /// Framed wrapper to send messages th...
extern crate oop_sample; use oop_sample::{Draw, Screen, Button}; use std::fmt::Display; struct SelectBox { width: u32, height: u32, options: Vec<String>, } impl Draw for SelectBox { fn draw(&self) { println!("selectbox drawn width: {} height: {} label {:?}", self.width, self.height, self.opti...
// Copyright (c) 2018 Aigbe Research // phy.rs - LTE/5G Physical Layer Implementation in Rust // Compliance: // 3GPP TS 36.211 // 3GPP TS 36.212 // 3GPP TS 36.216 // 3GPP TS 36.213 // 3GPP TS 36.214 // LTE pub use common::*; pub mod common; pub use ts_36_211::*; pub mod ts_36_211; // Ph...
/*! A very simple application which suggests to guess a random number. It shows how derive macro parses generics. Requires the following features: `cargo run --example generic_d --features "combobox"` */ extern crate native_windows_gui as nwg; extern crate native_windows_derive as nwd; use std::fmt::Disp...
use std::collections::HashMap; use std::io::{Read, Result as IOResult}; use crate::StringRead; pub struct Entities { pub entities: Vec<Entity> } impl Entities { pub fn read(read: &mut dyn Read) -> IOResult<Entities> { let mut entities = Vec::<Entity>::new(); let text = read.read_null_terminated_string().u...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[repr(transparent)] #[doc(hidden)] pub struct IKnownPerceptionFrameKindStatics(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IKnownPerceptionFrameKindStatics...
use std::sync::mpsc; use std::sync::mpsc::{Receiver, Sender}; use std::thread; use crate::gui; use crate::i2c; use crate::protocol::{Button, Device, IncomingMsg}; // Represents all messages sent between modules #[derive(Clone, Debug)] pub enum Event { I2C(i2c::I2CEvent), Serial(SerialEvent), Gui(gui::GuiE...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtCore/quuid.h // dst-file: /src/core/quuid.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin => // <= main ...
use std::convert::TryFrom; use std::io; #[derive(Debug, PartialEq)] enum ParamMode { Immediate, Position, } #[derive(Debug, PartialEq)] enum OpCode { Add, Mul, Input, Output, JumpIfTrue, JumpIfFalse, LessThan, Equals, Halt, } #[derive(Debug, PartialEq)] struct Instruction ...
use std::borrow::Cow; use std::collections::{BTreeSet, HashSet}; use serde::{Deserialize, Serialize}; use crate::position_map::PositionMap; use crate::{Error, FieldId, FieldsMap, IndexedPos, SResult}; #[derive(Clone, Debug, Serialize, Deserialize, Default)] pub struct Schema { fields_map: FieldsMap, primary...
use core::ops::{Deref, Range, RangeFrom, RangeFull, RangeTo}; use core::str::{CharIndices, Chars, FromStr}; use nom::error::{ErrorKind, ParseError}; use nom::{ AsBytes, Compare, CompareResult, Err, ExtendInto, FindSubstring, FindToken, IResult, InputIter, InputLength, InputTake, InputTakeAtPosition, Offset, Par...
use protoc_rust::Customize; use std::{fs::create_dir_all, io::Result}; fn main() -> Result<()> { let out_dir = "src/proto/.generated"; create_dir_all(out_dir)?; let result = protoc_rust::run(protoc_rust::Args { out_dir, input: &["proto/chunk_save.proto", "proto/player.proto"], incl...
#![feature(proc_macro_hygiene, decl_macro)] extern crate base64; extern crate chrono; extern crate tempfile; #[macro_use] extern crate diesel; extern crate postgres; #[macro_use] extern crate rocket; #[macro_use] extern crate rocket_contrib; extern crate jpeg_decoder; extern crate multipart; extern crate png; extern c...
/* * File : parse.rs * Purpose: routines for parsing using input into useful data * Program: red * About : command-line text editor * Authors: Tommy Lincoln <pajamapants3000@gmail.com> * License: MIT; See LICENSE! * Notes : Notes on successful compilation * Created: 10/26/2016 */ // Bring in to namespace ...
use P80::graph_converters::unlabeled; use P83::*; pub fn main() { let g = unlabeled::from_term_form( &vec!['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], &vec![ ('a', 'b'), ('a', 'd'), ('b', 'c'), ('b', 'e'), ('c', 'e'), ('d', 'e'), ...
fn main() { println!("🔓 Challenge 1"); println!("Try running: `cargo test chal1`"); println!("Code in 'encoding/src/lib.rs'"); }
use std::convert::TryFrom; use std::num; pub mod error; use error::Error; pub fn parse_input(input: &str) -> Result<Vec<u8>, num::ParseIntError> { input .trim() .chars() .map(|c| c.to_string().parse::<u8>()) .collect::<Result<Vec<u8>, num::ParseIntError>>() } pub struct SpaceImg ...
use file_reader; const INPUT_FILENAME: &str = "input.txt"; const TREE: char = '#'; fn main() { let input_str = match file_reader::file_to_vec(INPUT_FILENAME) { Err(_) => { println!("Couldn't turn file into vec!"); return; }, Ok(v) => v, }; let result = num...
use super::*; use std::fmt; use std::string::ToString; #[derive(Debug, Eq, PartialEq, Hash, Clone)] pub enum AgricolaTile { BuildRoom_BuildStables = 1, StartingPlayer_Food = 2, Grain = 3, Plow = 4, BuildStable_BakeBread = 5, DayLaborer = 6, Sow_BakeBread = 7, Wood = 8, Clay = 9, ...
pub mod client_data; pub mod delta_encoder; pub mod in_message_reader; pub mod network_manager; pub mod protobuf; pub mod service;
// 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 ...
// build-fail // aux-build:main_functions.rs #![feature(imported_main)] extern crate main_functions; pub use main_functions::boilerplate as main; //~ ERROR entry symbol `main` from foreign crate // FIXME: Should be run-pass
use crate::riscv32_core::PrivMode; use crate::riscv32_core::VMMode; use crate::riscv32_core::MemResult; use crate::riscv32_core::AddrT; use crate::riscv32_core::InstT; use crate::riscv64_core::Xlen64T; #[derive(PartialEq, Eq, Copy, Clone)] pub enum TraceType { XRegWrite, XRegRead, // Integer // FRegWrite...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)]...
use quickcheck::{Arbitrary, Gen}; use rand::seq::SliceRandom; use crate::{Code, Code::*, Multihash, MultihashDigest}; const HASHES: [Code; 16] = [ Identity, Sha1, Sha2_256, Sha2_512, Sha3_512, Sha3_384, Sha3_256, Sha3_224, Keccak224, Keccak256, Keccak384, Keccak512, Blake2b256, Blake2b512, Blake2s128, Blake2s...
// NTRUMLS bindings // Written in 2018 by // Vladislav Markushin // //! # Build script // Coding conventions #![deny(non_upper_case_globals)] #![deny(non_camel_case_types)] #![deny(non_snake_case)] #![deny(unused_mut)] #![warn(missing_docs)] extern crate gcc; fn main() { let mut base_config = gcc::Build::new(); ...
use super::*; use bitflags::bitflags; use zircon_object::vm::*; impl Syscall<'_> { /// creates a new mapping in the virtual address space of the calling process. /// - `addr` - The starting address for the new mapping /// - `len` - specifies the length of the mapping /// - `prot ` - describes the desir...
use std::error::Error as StdError; use serde::{Deserialize, Serialize}; pub const INTERNAL_SERVER_ERROR: Fault = Fault::Static(StaticException::InternalServerError); pub const NOT_FOUND: Fault = Fault::Static(StaticException::NotFound); #[derive(Debug, Serialize, Deserialize)] #[serde(tag = "type")] pub enum Fault { ...
/*! * 用于监听Redis的写入操作,据此可以实现数据复制,监控等相关的应用。 * * # 原理 * * 此crate实现了[Redis Replication协议],在运行时,程序将以replica的身份连接到Redis,相当于Redis的一个副本。 * * 所以,在程序连接上某个Redis之后,Redis会将它当前的所有数据以RDB的格式dump一份,dump完毕之后便发送过来,这个RDB中的每一条数据就对应一个[`Event`]`::RDB`事件。 * * 在这之后,Redis接收到来自客户端的写入操作(即Redis命令)后,也会将这个写入操作传播给它的replica,每一个写入操作就对应一个[`Event`]`::AOF...
extern crate protobuf_iter; extern crate byteorder; extern crate libdeflater; pub mod blob_reader; pub use blob_reader::*; pub mod blob; pub use blob::*; pub mod parse; pub use parse::*; pub mod delta; pub mod delimited;
extern crate dotenv; // extern crate envy; #[macro_use] extern crate serde_derive; use std::env; #[derive(Deserialize, Debug)] struct Environment { lang: String, } #[derive(Deserialize, Debug)] struct MailerConfig { email_backend: String, email_from: String, } fn main() { println!("24 Days of Rust,...
// Trim a Binary Search Tree // https://leetcode.com/explore/challenge/card/february-leetcoding-challenge-2021/584/week-1-february-1st-february-7th/3626/ use std::cell::RefCell; use std::rc::Rc; pub struct Solution; // Definition for a binary tree node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub v...
use std::collections::HashMap; #[derive(Debug)] pub struct Config { pub debug: bool, pub render_screen: bool, pub initial_color: u32, pub play_sound: bool, } impl Config { pub fn new(config_name: &str) -> Self { let mut config = config::Config::default(); config.merge(config::File:...
use crate::impl_pnext; use crate::prelude::*; use std::marker::PhantomData; use std::os::raw::{c_char, c_void}; use std::ptr; #[repr(C)] #[derive(Debug)] pub struct VkDeviceCreateInfo<'a> { lt: PhantomData<&'a ()>, pub sType: VkStructureType, pub pNext: *const c_void, pub flags: VkDeviceCreateFlagBits...
#![no_main] #![feature(start)] extern crate olin; use olin::entrypoint; use serde_json::{from_slice, to_string, Value}; entrypoint!(); fn main() -> Result<(), std::io::Error> { let input = include_bytes!("./bigjson.json"); if let Ok(val) = from_slice(input) { let v: Value = val; if let Err(...
// Quiet diesel warnings https://github.com/diesel-rs/diesel/issues/1785 #![allow(proc_macro_derive_resolution_fallback)] // Force these as errors so that they are not lost in all the diesel warnings #![deny(unreachable_patterns)] #![deny(unknown_lints)] #![deny(unused_variables)] #![deny(unused_imports)] // Unused res...
use crate::{ geo::{Geo, HitResult, HitTemp, Texture, TextureRaw}, linalg::{Ray, Transform, Vct}, Deserialize, Serialize, EPS, }; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Plane { pub transform: Transform, pub texture: Texture, } impl Plane { pub fn new(texture: Texture, transf...
//! # quicksilver //! ![Quicksilver Logo](./logo.svg) //! //! [![Build Status](https://travis-ci.org/ryanisaacg/quicksilver.svg)](https://travis-ci.org/ryanisaacg///! //! //! quicksilver) //! [![Crates.io](https://img.shields.io/crates/v/quicksilver.svg)](https://crates.io/crates/quicksilver) //! [![Docs Status](https...
use graph_map::GraphMMap; use declarative_dataflow::server::Server; use declarative_dataflow::plan::{Plan, Join}; use declarative_dataflow::{q, Binding, AttributeConfig, InputSemantics, Rule, Datom, Value}; use Value::Eid; fn main() { let filename = std::env::args().nth(1).unwrap(); let batching = std::env::a...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[repr(transparent)] #[doc(hidden)] pub struct IXsltProcessor(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IXsltProcessor { type Vtable = IXsltProcessor_...
use std::convert::TryInto; //use std::iter::FromIterator; fn main() { let fire = "fire"; println!("Name: {}", fire[0..2].to_string()); let fi_re = "fire"; let s = fi_re.get(0..2); println!("Name: {}", fi_re[0..2].to_string()); let name = "Jürgen"; //println!("Name: {}", name[0..2].to_stri...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[cfg(feature = "Win32_Storage_Xps_Printing")] pub mod Printing; #[link(name = "windows")] extern "system" { #[cfg(feature = "Win32_Graphics_Gdi")] pub fn AbortDoc(hdc: super::super::Graphics::Gdi:...
use ring::{aead, digest, pbkdf2}; use crate::error::{ErrorKind, Result}; use crate::types::GrinboxAddress; use crate::utils::from_hex; use crate::utils::secp::{PublicKey, Secp256k1, SecretKey}; #[derive(Debug, Serialize, Deserialize)] pub struct GrinboxMessage { #[serde(default)] pub destination: Option<GrinboxAddr...
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 }; use crate::{instruction::StakingInstruction, error::St...
#![feature(proc_macro_hygiene, decl_macro)] #![feature(async_closure)] use challenges::chal31; use hyper::{self, Client}; use rocket::{self, get, routes}; use rocket::{ config::{Config, Environment, LoggingLevel}, http::{RawStr, Status}, }; use std::thread; use std::time::{Duration, Instant}; // NOTE: when us...
use PT_FIRSTMACH; pub type c_long = i32; pub type c_ulong = u32; pub type c_char = u8; pub type __cpu_simple_lock_nv_t = ::c_int; pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2;
use std::f64::consts::SQRT_2; use enumset::EnumSetType; use crate::expansion_policy::ExpansionPolicy; use crate::node_pool::NodePool; use crate::{astar_unchecked, Owner}; /// Indicates that the implementing type guarantees the following invariants: /// /// If `Self` is a `NodePool<(i32, i32)>`: /// - All ids from `(...
// 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. //! Helpers for working with streams. use { futures::{ready, Stream, StreamExt}, std::{ future::Future, pin::Pin, task::{C...
/* * Multiples of 3 and 5 * ==================== * If we list all the natural numbers below 10 that are multiples of 3 or 5, we * get 3, 5, 6 and 9. The sum of these multiples is 23. * * Find the sum of all the multiples of 3 or 5 below 1000. */ trait NumberTheory { fn divides(&self, n: u32) -> bool; } ...
use crate::graph::JsGraph; use crate::layout::force_simulation::coordinates::JsCoordinates; use js_sys::{Function, Reflect}; use petgraph_layout_force::link_force::LinkArgument; use petgraph_layout_force_simulation::Force; use petgraph_layout_grouped_force::force::group_many_body_force::GroupManyBodyForceArgument; use ...
// Copyright lowRISC contributors. // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 //! Algorithm-generic signature traits. /// An error returned by a signature operation. /// /// This type serves as a combination of built-in error types known to /// M...
use ::{WeakTypeContainer, FieldReference}; #[derive(Debug)] /// Used to reference a specific property of another field. pub struct FieldPropertyReference { pub reference: FieldReference, pub reference_node: Option<WeakTypeContainer>, pub property: String, } impl FieldPropertyReference { }
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[link(name = "windows")] extern "system" {} pub type Geofence = *mut ::core::ffi::c_void; pub type GeofenceMonitor = *mut ::core::ffi::c_void; #[repr(transparent)] pub struct GeofenceMonitorStatus(pub i32...
use std::fs::{create_dir_all, File}; use std::io; use std::io::prelude::*; use std::path::{Path, PathBuf}; use amethyst::utils::app_root_dir::application_root_dir; pub fn file<S>(path: S) -> String where S: ToString, { use amethyst::utils::app_root_dir::application_dir; let path = if cfg!(target_os = "wi...
pub mod qtouchdevice; pub use self::qtouchdevice::QTouchDevice; pub mod qwindow; pub use self::qwindow::QWindow; pub mod qgenericplugin; pub use self::qgenericplugin::QGenericPlugin; pub mod qsyntaxhighlighter; pub use self::qsyntaxhighlighter::QSyntaxHighlighter; pub mod qbrush; pub use self::qbrush::QRadialGradie...
/* 为了不让 common 出现在测试输出中,我们将创建 tests/common/mod.rs , 而不是创建 tests/common.rs 。这是一种 Rust 的命名规范, 这样命名告诉 Rust 不要将 common 看作一个集成测试文件。 将 setup 函数代码移动到 tests/common/mod.rs 并删除 tests/common.rs 文件之后, 测试输出中将不会出现这一部分。tests 目录中的子目录不会被作为单独的 crate 编译或作为一个测试结果部分出现在测试输出中。 一旦拥有了 tests/common/mod.rs,就可以将其作为模块以便在任何集成测试文件中使用。 */ pub fn se...
use super::Part; use crate::codec::{Decode, Encode}; use crate::{remote_type, RemoteObject, Vector3}; remote_type!( /// A control surface. Obtained by calling `Part::control_surface().` object SpaceCenter.ControlSurface { properties: { { Part { /// Returns the part object for th...
use { super::{ChunkVec, Vox, VoxType, VoxVec, WorldVec, CHUNK_SIDE, CHUNK_VOX_COUNT}, crate::proto::{ chunk_save::{ChunkSave, ChunkSaveContents}, ReadProto, WriteProto, }, std::{ convert::TryFrom, iter::Iterator, ops::{Index, IndexMut}, }, }; #[derive(Debug, ...
extern crate proconio; use proconio::input; fn main() { input! { n: usize, d: i64, pts: [(i64, i64); n], } println!( "{}", pts.iter() .filter(|(x, y)| x * x + y * y <= d * d) .collect::<Vec<_>>() .len() ); }
#[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - USART Configuration register. Basic USART configuration settings that typically are not changed during operation."] pub cfg: CFG, #[doc = "0x04 - USART Control register. USART control settings that are more likely to change du...
#![deny(warnings)] use std::task::{Context, Poll}; use futures_util::future; use hyper::service::Service; use hyper::{Body, Request, Response, Server}; const ROOT: &str = "/"; #[derive(Debug)] pub struct Svc; impl Service<Request<Body>> for Svc { type Response = Response<Body>; type Error = hyper::Error; ...
use crate::world::space::*; #[derive(Debug,Clone,Copy,PartialEq,Eq,PartialOrd,Ord,Hash)] pub enum Size { Tiny, Small, Medium, Large, Huge, Gargantuan, } impl Size { pub fn space(self) -> Squares { use Size::*; Squares(match self { Tiny => 0, Small | ...
//! Serial port implementation for Unix operating systems. extern crate serial_core as core; extern crate libc; extern crate termios; extern crate ioctl_rs as ioctl; pub use tty::*; mod error; mod poll; mod tty;
use std::io::Read; fn main() { let mut buf = String::new(); // 標準入力から全部bufに読み込む std::io::stdin().read_to_string(&mut buf).unwrap(); // 行ごとのiterが取れる let mut iter = buf.split_whitespace(); let y: usize = iter.next().unwrap().parse().unwrap(); let x: usize = iter.next().unwrap().parse().unwr...
use color_eyre::eyre::{Result, WrapErr}; use git_conventional::{Commit, FEAT, FIX}; use crate::changelog::{Changelog, Version}; use crate::git::get_commit_messages_after_last_tag; use crate::semver::{bump_version, get_version, Rule}; #[derive(Debug)] struct ConventionalCommits { rule: Rule, features: Vec<Stri...
use std::collections::VecDeque; use proconio::input; fn mpow(a: u64, x: u64, m: u64) -> u64 { if x == 0 { 1 % m } else if x == 1 { a % m } else if x % 2 == 0 { mpow(a * a % m, x / 2, m) } else { a * mpow(a, x - 1, m) % m } } fn main() { input! { q: usiz...
use serde::{Deserialize, Serialize}; use std::collections::BTreeSet; use std::io; use std::path::Path; use walkdir::WalkDir; type Listing = BTreeSet<String>; #[derive(Deserialize, Serialize)] pub struct Listings { pub d: Listing, pub g: Listing, } fn listdir(base_path: &Path, sub: &str) -> Result<Listing, st...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - power control register"] pub cr1: CR1, #[doc = "0x04 - power control/status register"] pub csr1: CSR1, #[doc = "0x08 - power control register"] pub cr2: CR2, #[doc = "0x0c - power control/status register"] p...
use serenity::model::prelude::{Activity, OnlineStatus, Ready}; use serenity::model::Permissions; use serenity::prelude::Context; pub struct ReadyEvent; impl ReadyEvent { pub async fn run(ctx: &Context, ready: &Ready) { let perms = Permissions::from_bits(0).unwrap(); let user = &ready.user; ...
use failure::Fail; use typed_igo::conjugation::*; #[derive(Debug, Fail, Clone, PartialEq, Eq, Hash)] pub enum ConjugationTransformError { #[fail( display = "This conjugation has no possible suffixes: {:?}", conjugation )] Unsupported { conjugation: Conjugation }, #[fail( displa...
#[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::_3_GENB { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, ...
//! Mii data. //! //! This module contains the structs that represent all the data of a Mii. //! //! Have a look at the [`MiiSelector`](crate::applets::mii_selector::MiiSelector) applet to learn how to ask the user for a specific Mii. /// Region lock of the Mii. #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Re...
pub struct App {} pub enum Msg {} impl yew::Component for App { type Message = Msg; type Properties = (); fn create(_: &yew::Context<Self>) -> Self { App {} } fn update(&mut self, _: &yew::Context<Self>, _: Self::Message) -> bool { true } fn view(&self, _: &yew::Context<S...
mod server; use domain::DomainError; pub use server::*; use warp::reject::Reject; #[derive(Debug)] struct ApiError(DomainError); impl From<DomainError> for ApiError { fn from(err: DomainError) -> Self { Self(err) } } impl Reject for ApiError {}
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 #![allow(dead_code)] #[macro_use] extern crate async_trait; extern crate serde_derive; #[macro_use] extern crate log; #[macro_use] extern crate trace_time; #[macro_use] extern crate prometheus; extern crate transaction_pool as tx_po...
use serde::{Deserialize, Serialize}; use crate::hook::Hook; #[derive(Debug, Serialize, Deserialize)] pub struct StreamSquareHook { pub (crate) ask_stream_start: Hook, pub (crate) tell_stream_started: Hook, }
use nalgebra::geometry::{Isometry3, Point3, Rotation3, Translation, UnitQuaternion}; use nalgebra::{ allocator::Allocator, storage::{Owned, Storage}, DefaultAllocator, RealField, }; use nalgebra::{convert, Dim, OMatrix, SMatrix, Unit, Vector3, U3}; #[cfg(feature = "serde-serialize")] use serde::{Deserializ...
use std::{cell::RefCell, rc::Rc}; use crate::binding::http::builder::Builder; use crate::binding::{ http::{header_prefix, SPEC_VERSION_HEADER}, CLOUDEVENTS_JSON_HEADER, }; use crate::event::SpecVersion; use crate::message::{BinarySerializer, MessageAttributeValue, Result, StructuredSerializer}; macro_rules! s...
use core::fmt; #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Debug)] pub enum Abi { Rust, C { unwind: bool }, // Single platform ABIs Cdecl { unwind: bool }, Stdcall { unwind: bool }, Fastcall { unwind: bool }, Vectorcall { unwind: bool }, Thiscall { unwind: bool }, A...
use futures::{ future::{self, Either, FutureResult}, prelude::*, stream::{self, Chain, IterOk, Once} }; use futures::compat::Compat; use get_if_addrs::{IfAddr, get_if_addrs}; use ipnet::{IpNet, Ipv4Net, Ipv6Net}; use libp2p_core::{ Transport, multiaddr::{Protocol, Multiaddr}, transport::{Listene...
// Copyright 2018 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; use std::fmt::{self, Debug, Display, Formatter}; use std::hash::Hash; use byteorder::{ByteOrder, NetworkEndian}; use packet::{PacketBuilder, Pars...
// 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 ...