text
stringlengths
8
4.13M
use metadata::SpMetadata; use session::SpSession; use track::sp_track; use types::sp_error; use types::sp_error::*; use std::ffi::CStr; use std::rc::Rc; use libc::c_char; use librespot::link::Link; #[allow(non_camel_case_types)] pub type sp_link = Rc<Link>; #[no_mangle] pub unsafe extern "C" fn sp_link_create_from_st...
pub mod all; pub mod convert; pub mod extract; pub mod filter; pub mod trigger; pub use all::All; pub use convert::Convert; pub use extract::Extract; pub use filter::Filter; pub use trigger::Trigger; use super::{convert_output, PythonOutput, StreamsonError}; use pyo3::prelude::*; use streamson_lib::strategy; pub tra...
#[doc = "Register `DAINT` reader"] pub type R = crate::R<DAINT_SPEC>; #[doc = "Field `IEPINT` reader - IN endpoint interrupt bits"] pub type IEPINT_R = crate::FieldReader<u16>; #[doc = "Field `OEPINT` reader - OUT endpoint interrupt bits"] pub type OEPINT_R = crate::FieldReader<u16>; impl R { #[doc = "Bits 0:15 - I...
use core::cmp::max; use rand::seq::SliceRandom; use rand::thread_rng; use std::collections::HashSet; /// Solves the Day 19 Part 1 puzzle with respect to the given input. pub fn part_1(input: String) { let mut scanners: Vec<Vec<Vec<isize>>> = parse_input(input); let merges = scanners.len() - 1; for _ in 0....
mod client_context; pub use client_context::*; cfg_if::cfg_if! { if #[cfg(feature = "resolver_v1")] { mod resolver_context_v1; pub use resolver_context_v1::ResolverContext; } else if #[cfg(feature = "resolver_v2")] { mod resolver_context_v2; pub use resolver_context_v2::Resolver...
use crate::client::{Client, InitError}; use crate::net::{Addr, BasicConnector, Connector}; use multichat_proto::{Config, ServerInit, Version}; use std::convert::TryInto; use std::error; use std::fmt::{self, Debug, Display, Formatter}; use std::io::Error; use std::num::NonZeroUsize; use tokio::net::TcpStream; #[cfg(fea...
enum Message { Quit, Move { x: i32, y: i32 }, Write(String), ChangeColor(i32, i32, i32), } impl Message { fn call(&self) { self.Write(String::from("Hello")); } } fn main() { let m = Message::Write(String::from("World")); m.call(); }
//! Tokenizers //! //! This module holds the functions that recognize tokens from an input text. //! These functions are designed to be used by grammar-aware parsers to //! translate an input text into components of `ysh` data structures. The token //! producers have no awareness of any language rules other than the sy...
#![cfg_attr(not(test), no_std)] #![cfg_attr(not(test), no_main)] extern crate alloc; extern crate raw_cpuid; use alloc::{boxed::Box, vec, vec::Vec, rc::Rc}; use bootloader::{entry_point, BootInfo}; use core::panic::PanicInfo; use raw_cpuid::{CpuId,CacheType}; use mtos::*; entry_point!(kernel_main); #[cfg(not(test)...
// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{counters, PeerId}; use config::config::{NodeConfig, StateSyncConfig}; use execution_proto::proto::{ execution::{ExecuteChunkRequest, ExecuteChunkResponse}, execution_grpc::ExecutionClient, }; use failure::prelude::*...
//! How to use `arg_enum!` with `StructOpt`. //! //! Running this example with --help prints this message: //! ----------------------------------------------------- //! structopt 0.3.25 //! //! USAGE: //! enum_in_args <i> //! //! FLAGS: //! -h, --help Prints help information //! -V, --version Print...
use std::process; use {Csv, CsvData, qcheck}; use workdir::Workdir; fn no_headers(cmd: &mut process::Command) { cmd.arg("--no-headers"); } fn pad(cmd: &mut process::Command) { cmd.arg("--pad"); } fn run_cat<X, Y, Z, F>(test_name: &str, which: &str, rows1: X, rows2: Y, modify_cmd: F) -...
mod peripheral; use futures::FutureExt; use serde::Deserialize; use warp::{filters::BoxedFilter, path, Filter, Rejection}; use crate::response::{Response, ResponseBuilder}; use crate::utils::deserialize_some; use crate::PgPooled; use crate::{helpers, models, problem, views}; pub fn router(pg: BoxedFilter<(crate::PgP...
use bevy::prelude::*; use crate::MainCamera; pub fn mouse_system( windows: Res<Windows>, mut mouse_state: ResMut<MouseState>, q_camera: Query<&Transform, With<MainCamera>> ) { let window = windows.get_primary().unwrap(); // check if the cursor is in the primary window if let Some(pos) = windo...
use tokio::stream::StreamExt; use tokio::net::TcpStream; use tokio::prelude::*; use tokio::net::TcpListener; use futures::channel::mpsc; use futures::executor; use futures::executor::*; use std::str; #[tokio::main] async fn main() { let addr = "127.0.0.1:8080"; let mut listener = TcpListener::bind(addr).awa...
#![warn( warnings, future_incompatible, nonstandard_style, rust_2018_compatibility, rust_2018_idioms, rustdoc, unused )] pub mod particle; pub mod vec;
extern crate rand; use hlt::command::Command; use hlt::game::Game; use std::env; use std::time::SystemTime; use std::time::UNIX_EPOCH; use std::collections::HashMap; mod hlt; fn main() { let args: Vec<String> = env::args().collect(); let rng_seed: u64 = if args.len() > 1 { args[1].parse().unwrap() ...
extern crate image; extern crate imageproc; extern crate rand; mod maze; mod square; use maze::Maze; use std::env; fn main() { let mut args = env::args().skip(1); let mut width = 100; if let Some(arg) = args.next() { width = arg.parse::<usize>().expect("Invalid width value."); } let mut h...
// Partially generated by fl2rust #[macro_use] extern crate lazy_static; extern crate regex; use fltk::*; use regex::Regex; use std::cell::RefCell; use std::rc::Rc; lazy_static! { static ref RE: Regex = Regex::new(r"([A-z]+), ([A-z]+)").unwrap(); } #[derive(Debug, Clone, Default)] pub struct UserInterface { ...
use crate::error::NiaServerError; use crate::error::NiaServerResult; use crate::protocol::Serializable; use crate::protocol::{NiaActionEnum, NiaConvertable}; use crate::protocol::domain::action::basic_actions::*; use nia_interpreter_core::{Action, SymbolId}; #[derive(Clone, Debug, PartialEq, Eq)] pub struct NiaActio...
pub fn translate_num(num: i32) -> i32 { if num < 10 { return 1; } let s = num.to_string(); let mut prev = (0, 1, 1); for i in 1..s.len() { prev.0 = prev.1; prev.1 = prev.2; let prev_str = &s[i - 1..=i]; if "10" <= prev_str && prev_str <= "25" { pr...
#[derive(Copy, Clone)] pub struct Block { pub id: u8, }
#[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; extern crate ircbot; extern crate irc; extern crate amqp; extern crate env_logger; #[macro_use] extern crate log; use irc::client::server::Server; use irc::client::prelude::Command; use irc::client::prelude::ServerExt; use irc::client...
mod request; pub use request::Request; mod response; pub use response::Response; #[derive(Debug)] enum Method { Get, Post, Put, Patch, Delete, Options, } impl Method { pub fn from_string(text: &str) -> Self { match text { "GET" => Self::Get, "POST" => Self::Post, "PUT" => Self::Pu...
test_normalize! { INPUT="tests/ui/compile-fail-3.rs" " error[E0277]: `*mut _` cannot be shared between threads safely --> /git/trybuild/test_suite/tests/ui/compile-fail-3.rs:7:5 | 7 | thread::spawn(|| { | ^^^^^^^^^^^^^ `*mut _` cannot be shared between threads safely | = help: the trait...
/* * Copyright (c) 2013, David Renshaw (dwrenshaw@gmail.com) * * See the LICENSE file in the capnproto-rust root directory. */ extern mod extra; use std; use std::rand::*; use common::*; use catrank_capnp::*; pub type RequestBuilder = SearchResultList::Builder; pub type ResponseBuilder = SearchResultList::Builde...
extern crate telos; extern crate rustc_serialize; extern crate docopt; use docopt::Docopt; use std::net::TcpStream; const USAGE: &'static str = " conninfo Usage: conninfo [options] <address> <port> conninfo --help Options: --protocols=<protocols> --ciphers=<ciphers> --noverifycert --noverifyname --acc...
//! Partial types and expressions tagged with them, used during parsing and type inference. use std::vec::Vec; use super::ast::*; use super::error::*; /// A partial data type, where some parameters may not be known. #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub enum PartialType { Unknown, Scalar(ScalarKin...
//! This module defines IO functions. use core::fmt; use core::fmt::Write; /// The number of the print char syscall. const PRINT_CHAR_SYSCALL: u64 = 0; /// A dummy struct to implement fmt::Write on. struct StdOut; impl fmt::Write for StdOut { fn write_str(&mut self, s: &str) -> fmt::Result { for charact...
use std::collections::HashSet; impl Solution { pub fn permute_unique(nums: Vec<i32>) -> Vec<Vec<i32>> { fn dfs(nums: &mut Vec<i32>, begin: usize, res: &mut HashSet<Vec<i32>>) { if begin == nums.len() { res.insert(nums.clone()); return; } f...
use hyperloglog::HyperLogLog; use std::fs::File; use std::io::{BufRead, BufReader}; pub fn process_text(inputs: &Vec<&str>, error_rate: f64) -> Result<(), ()> { let mut hll = HyperLogLog::<String>::new(error_rate); for input in inputs { match input { &"-" => process_stdin(&mut hll), ...
use crate::derive_utils::PyFunctionArguments; use crate::exceptions::PyValueError; use crate::prelude::*; use crate::{ class::methods::{self, PyMethodDef}, ffi, types, AsPyPointer, }; use std::os::raw::c_void; /// Represents a builtin Python function object. #[repr(transparent)] pub struct PyCFunction(PyAny); ...
#[doc = "Reader of register MASK"] pub type R = crate::R<u32, super::MASK>; #[doc = "Writer for register MASK"] pub type W = crate::W<u32, super::MASK>; #[doc = "Register MASK `reset()`'s with value 0"] impl crate::ResetValue for super::MASK { type Type = u32; #[inline(always)] fn reset_value() -> Self::Typ...
/* * YNAB API Endpoints * * Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.youneedabudget.com * * The ve...
#[doc = "Register `IDR` reader"] pub type R = crate::R<IDR_SPEC>; #[doc = "Field `IDR0` reader - Port input data (y = 0..15)"] pub type IDR0_R = crate::BitReader; #[doc = "Field `IDR1` reader - Port input data (y = 0..15)"] pub type IDR1_R = crate::BitReader; #[doc = "Field `IDR2` reader - Port input data (y = 0..15)"]...
const VERSES: i32 = 12; fn main() { for i in 1..VERSES+1 { print!("On the "); twelvetide_intro(i); println!(" day of Christmas my true love sent to me"); twelvetide_rest(i); println!(); } } fn twelvetide_intro(rep: i32) { match rep { 1 => print!("first"), ...
use support::*; use self::futures::sync::{mpsc, oneshot}; use self::tokio_core::net::TcpStream; type Request = http::Request<()>; type Response = http::Response<BodyStream>; type BodyStream = Box<Stream<Item=Bytes, Error=String> + Send>; type Sender = mpsc::UnboundedSender<(Request, oneshot::Sender<Result<Response, S...
#[doc = "Reader of register SPINLOCK15"] pub type R = crate::R<u32, super::SPINLOCK15>; impl R {}
use super::*; /// Writes the response to stdout. pub fn write_response<T: Serialize>(msg: T) { if let Ok(s) = serde_json::to_string(&msg) { println!("Content-length: {}\n\n{}", s.len(), s); } } fn loop_read_rpc_message(reader: impl BufRead, sink: &Sender<String>) { let mut reader = reader; loo...
fn main() { let uname = "Mohtashim"; let uname = uname.len(); println!("name changed to integer : {}",uname); }
#![feature(pattern, try_from)] mod tone; mod initial; mod rhyme; mod syllable; mod error; mod format; pub use tone::{ Tone, ToneMark, ToneFormat }; pub use initial::Initial; pub use rhyme::Rhyme; pub use syllable::{ Syllable, SyllableKind, PrimitiveSyllable, NormalSyllable, RhymeSyllable, NasalSyllable, ...
pub fn node_contains_raft_group( node_index: usize, total_nodes: usize, raft_group_id: u16, replicas_per_raft_group: usize, ) -> bool { assert_eq!( total_nodes % replicas_per_raft_group, 0, "{} % {} != 0", total_nodes, replicas_per_raft_group ); // Di...
extern crate toml; // use std::vec; use std::fs::File; use std::fs; use std::io::Write; #[derive(Serialize, Deserialize)] pub struct ConfGlobal { enableColor:bool, repo:Vec<Repo> } #[derive(Serialize, Deserialize)] pub struct Repo { name:String, uri:String, enabled:bool } #[derive(Serialize, D...
fn main() { let name = format!("Firefox"); print_out(name); } fn remove_vowels(name: String) -> String { // Goal #1: What is needed here to make this compile? let output = String::new(); for c in name.chars() { match c { 'a' | 'e' | 'i' | 'o' | 'u' => { // skip v...
use crate::agents::Agents; use crate::navmesh::Navmesh; pub trait Scenario { fn generate(&self) -> (Agents, Navmesh); }
use num::Zero; use std::clone::Clone; use std::iter::FromIterator; use std::ops::Add; trait Measured<M> { fn measure(&self) -> M; } #[derive(Debug)] enum SplayTree<M, T> { Leaf, Fork(Box<SplayTreeFork<M, T>>), } #[derive(Debug)] struct SplayTreeFork<M, T> { left: SplayTree<M, T>, element: T, ...
/// DeleteEmailOption options when deleting email addresses #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct DeleteEmailOption { /// email addresses to delete pub emails: Option<Vec<String>>, } impl DeleteEmailOption { /// Create a builder for this object. #[inline] pub fn build...
// Definition for a binary tree node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[inline] pub fn new(val: i32) -> Self { TreeNode { val, lef...
//! Utilities for bridging time and tasks. use std::future::Future; use std::time::Duration; use futures::stream::Stream; use crate::platform::imp::time as imp; /// Waits until duration has elapsed. #[inline(always)] pub fn sleep(dur: Duration) -> impl Future<Output = ()> { imp::sleep(dur) } /// Creates a Stre...
tonic::include_proto!("geo/geo");
use crate::{ actor::Actor, actor::ActorContainer, message::Message, projectile::ProjectileKind, GameTime, }; use fyrox::{ core::{ algebra::{Matrix3, Point3, Vector3}, color::Color, math::{ray::Ray, Matrix4Ext, Vector3Ext}, pool::{Handle, Pool}, visitor::{Visit, VisitResul...
fn main(){ let mut x=8; println!("{}",x); let x=12; println!("{}",x); let y=15; println!("{}",y); let y="Hello World"; println!("{}",y); }
//! A pointer backed by disk. struct Disk<T> { data: Option<T>, file: PathBuf, } impl<T> Disk<T> { pub fn new(t: T) -> Self { // create temp file // write t to file // return self } } #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); ...
use std::sync::Arc; use std::sync::RwLock; use std::thread::sleep; use std::time::Duration; use rocket::http::Status; use rocket::local::Client; use crate::robot_map::*; use crate::status::robot_state::GlobalRobotState; use super::*; #[cfg(test)] mod initialization; #[cfg(test)] mod switching; #[cfg(test)] mod be...
use std::collections::HashSet; use std::fs::{read_dir, File}; use std::io::prelude::*; use std::io::BufReader; use tokenizers::tokenizer::{Result, Tokenizer}; pub fn tokenize_document(tokenizer: &Tokenizer, document_path: &str) -> Result<Vec<String>> { let file = File::open(document_path)?; let mut buf_reader...
pub mod empty_router; pub mod route; pub mod future; pub mod method_filter; use crate::buffer::MpscBuffer; use std::{ borrow::Cow, convert::Infallible, fmt, future::ready, marker::PhantomData, sync::Arc, task::{Context, Poll}, }; use crate::body::{box_body, BoxBody,}; use crate::service:...
use crate::features::syntax::StatementFeature; use crate::parse::visitor::tests::assert_stmt_feature; #[test] fn debugger() { assert_stmt_feature( "function a() { debugger; }", StatementFeature::DebuggerStatement, ); }
extern crate evm_extensions; use evm_extensions::CodeStream; // //use rstest::rstest; // //use stack::Stack; // // This is encoded as a string. Wouldn't an address be formatted as a pure binary instead? // // https://github.com/paritytech/parity-common/blob/0431acb4f34751af44c664b0b0a6f36b0cd147b3/rlp/tests/tests.rs#...
use ordered_float::OrderedFloat; pub struct Timestamp(OrderedFloat<f64>); impl Timestamp { pub fn to_string(&self) -> String { js_sys::Date::new(&wasm_bindgen::JsValue::from(self.to_f64())) .to_locale_string("ja-JP", object! {}.as_ref()) .as_string() .unwrap_or(String::...
pub mod danbooru; pub mod safebooru; use regex::Regex; pub fn reformat_search_tags(tags: String) -> String { let extra_spaces = Regex::new(r"\s{2,}").unwrap(); let delimiters = Regex::new(r"[,\s]").unwrap(); // Remove excess spaces (2 or more) extra_spaces.replace_all(&tags, ""); // Replace commas...
//! # `event-sauce` //! //! [![Build Status](https://circleci.com/gh/jamwaffles/event-sauce/tree/master.svg?style=shield)](https://circleci.com/gh/jamwaffles/event-sauce/tree/master) //! [![Crates.io](https://img.shields.io/crates/v/event-sauce.svg)](https://crates.io/crates/event-sauce) //! [![Docs.rs](https://docs.rs...
/// A Conway operator to apply to a polyhedron. /// See [https://en.wikipedia.org/wiki/Conway_polyhedron_notation](Conway polyhedron notation) for /// more information. #[derive(Copy, Clone, PartialOrd, PartialEq, Debug)] pub enum Operator { Ambo, Dual, Kis(Kis), } impl From<Operator> for String { fn f...
use andrew::{ shapes::rectangle, text::{self, fontconfig}, Canvas, }; use smithay_client_toolkit::{ default_environment, environment::SimpleGlobal, init_default_environment, output::{with_output_info, OutputInfo}, reexports::{ calloop, client::protocol::{ wl_...
#![crate_name = "xpath"] #![feature(macro_rules)] #![feature(phase)] #![feature(globs)] #[phase(plugin, link)] extern crate document; use self::XPathValue::*; use self::nodeset::Nodeset; use self::nodeset::{Node,ToNode}; use std::collections::HashMap; use std::string; use std::num::Float; use tokenizer::{XPathToken...
use crate::buffering::BufferingBuilder; use crate::storage::{error::Error, Entry, SeriesReader, SeriesTable}; use hyper::body::{Body, Bytes, Sender}; use std::io; use std::sync::Arc; use warp::http::Response; use warp::reject::Rejection; use warp::Filter; async fn export_entries(reader: Arc<SeriesReader>, sender: &mut...
// Copyright 2020 Alex Dukhno // // 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 ...
use seek_forward::{Tell, SeekForward}; /// An extension trait that will seek to meet a specified alignment. pub trait SeekAlignExt { /// Seeks forward to a multiple of `alignment`. /// /// Returns the resulting offset in the stream upon success. fn align_to(&mut self, alignment: u64) -> bare_io::Resul...
use serde_derive::Deserialize; use std::fs::File; use std::io::prelude::*; /// 重复类型 #[derive(Debug, Clone, Deserialize)] pub enum RepeatType { year, month, day, hour, minute, second } /// 任务 #[derive(Debug, Clone, Deserialize)] pub struct Task { // 任务名称 name: String, // 任务类型 ta...
use mcfg::shared::Name; use std::str::FromStr; const CASK_NAMES: &str = include_str!("brew-casks.txt"); const FORMULAE_NAMES: &str = include_str!("brew-formulae.txt"); #[test] fn test_valid_names() { assert!(Name::from_str("hello_world").is_ok()); assert!(Name::from_str("hello-world").is_ok()); assert!(N...
use dotenv::dotenv; use std::env; pub struct EnvironmentValues { pub domain: String, pub database_url: String, pub jwt_private_key: String, pub server_port: i16, pub rust_env: String, pub api_version_date: String } impl EnvironmentValues { fn init() -> Self { dotenv().ok(); ...
use std::{ borrow::Cow, convert::{TryFrom, TryInto}, fmt::Debug, }; use async_trait::async_trait; use serde::{Deserialize, Serialize}; use super::names::InvalidNameError; use crate::{ connection::Connection, document::{Document, Header, KeyId}, schema::{CollectionName, Schematic}, Error, }...
use crate::sema::ast; use inkwell::types::BasicType; use inkwell::values::{BasicValueEnum, FunctionValue, IntValue, PointerValue}; use inkwell::AddressSpace; use inkwell::IntPredicate; use num_traits::ToPrimitive; use super::{Contract, ReturnCode}; pub struct EthAbiEncoder { pub bswap: bool, } impl EthAbiEncoder...
mod common; use crate::common::*; #[derive(Debug, Deserialize)] struct Parent { a: (), b: u8, c: i8, d: [u8; 3], e: Child, // e: Vec<u8>, } #[derive(Debug, Deserialize)] struct Child { a: (), b: u8, c: i8, d: [u8; 3], // e: Vec<u8>, } pub fn start() -> Result<()> { le...
//! Welcome! //! //! # This project is discontinued. //! //! Please note that this was an experimental game library made while I was learning Rust. //! Feel free to request the ownership of the crate on crates.io at [mubelotix@gmail.com](mailto:mubelotix@gmail.com). //! //! The goal of this crate is to help you...
use stdweb::web::{ //document, //HtmlElement, //IParentNode, //Element, CanvasRenderingContext2d, window, //IEventTarget, //IWindowOrWorker, }; use std::collections::HashMap; use std::rc::Rc; use std::cell::RefCell; use stdweb::web::html_element::{ //CanvasElement, ImageElement ...
use std::io::{self, BufRead, BufReader}; use std::fs::File; use std::collections::HashMap; fn count_orbits(tree: &HashMap<String, String>, body: &String) -> i32 { match tree.get(body) { Some(x) => 1 + count_orbits(tree, x), None => 0, } } fn main() -> io::Result<()> { let f = File::open("input.txt")?; ...
use std::convert::TryFrom; pub struct Pokemon { pub number: PokemonNumber, name: PokemonName, types: PokemonTypes, } impl Pokemon { pub fn new(number: PokemonNumber, name: PokemonName, types: PokemonTypes) -> Self { Self { number, name, types, } ...
use bigdecimal::BigDecimal; use chrono::naive::NaiveDateTime; use schema::*; // Models for returned table rows and updates. #[derive(Serialize, Identifiable, Queryable, AsChangeset, Clone, PartialEq, Debug)] #[table_name = "staff"] pub struct Staff { pub id: i32, pub email: String, pub full_name: String, ...
//! Demonstrates how to use riddle-renderer-wgpu on top of a custom //! wgpu based renderer. //! //! Main things of note: //! //! - Use `riddle::renderer::wgpu_ext::*` to get access to the underlying //! WGPU types which are generic over WGPUDevice. //! - Implement WGPUDevice for CustomRenderer is the main piece of w...
/// An enum to represent all characters in the Elymaic block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum Elymaic { /// \u{10fe0}: '𐿠' LetterAleph, /// \u{10fe1}: '𐿡' LetterBeth, /// \u{10fe2}: '𐿢' LetterGimel, /// \u{10fe3}: '𐿣' LetterDaleth, /// \u{10fe4}: '𐿤'...
// サービス全体を通した企業 pub struct DomainCompany { id: i32, // 会社名 name: String, // 会社ロゴ logo: String, // 会社サムネイル thumbnail: String, } impl DomainCompany { pub fn new(id: i32, name: String, logo: String, thumbnail: String) -> DomainCompany { DomainCompany { id, n...
use proconio::input; use std::cmp::min; fn main() { input! { n: u32, a: u32, b: u32, }; let max_num = min(a, b); let min_num = if n >= a + b { 0 } else { a + b - n }; println!("{} {}", max_num, min_num); }
// Copyright 2016 Taku Fukushima. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applic...
use std::fmt; use ::symb::base::{Node, NodeID, NodeData}; use ::symb::graph::{Graph}; #[derive(Debug)] pub struct Cos { inp: NodeID, } impl Cos { pub fn new(x: NodeID) -> Box<Cos> { Box::new(Cos { inp: x, }) } } impl Node for Cos { fn get_inputs(&self) -> Vec<NodeID> { vec...
use aoc_runner_derive::aoc_lib; pub mod day1; pub mod day2; pub mod day3; aoc_lib!{ year = 2020 } #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } }
#[doc = "Reader of register RCC_AHB5RSTCLRR"] pub type R = crate::R<u32, super::RCC_AHB5RSTCLRR>; #[doc = "Writer for register RCC_AHB5RSTCLRR"] pub type W = crate::W<u32, super::RCC_AHB5RSTCLRR>; #[doc = "Register RCC_AHB5RSTCLRR `reset()`'s with value 0"] impl crate::ResetValue for super::RCC_AHB5RSTCLRR { type T...
pub fn flat_to_triples<T: Copy>(a: &[T]) -> Vec<[T; 3]> { if a.len() % 3 != 0 { panic!("No triples!!!!") } let n_trips = (a.len() / 3) as usize; let mut out = Vec::with_capacity(n_trips); for mut i in 0..n_trips { i *= 3; out.push([a[i], a[i + 1], a[i + 2]]) } out } p...
pub struct Label { pub content: String, } impl Label { pub fn new(content: String) -> Label { Label { content } } }
extern crate proc_macro; extern crate syn; #[macro_use] extern crate quote; use proc_macro::TokenStream; use syn::{parse_str, Data, VisPublic, Visibility, DataStruct, Fields}; #[proc_macro_derive(Dumb)] pub fn dumb_macro_derive(input: TokenStream) -> TokenStream { let s = input.to_string(); let ast = parse_st...
use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg}; use crate::state::{State, UserParams, STATE, USERS}; use crate::utils::has_unique_elements; use cosmwasm_std::{ entry_point, BankMsg, Coin, CosmosMsg, Decimal, DepsMut, Env, MessageInfo, Response, Uint128, }; use std::ops::{Add, Mul}; ...
use std::future::Future; use std::pin::Pin; use std::sync::Arc; use async_stream::stream; use async_trait::async_trait; use bytes::{Buf, BufMut, Bytes, BytesMut}; use dashmap::{mapref::entry::Entry, DashMap}; use futures::future::{AbortHandle, Abortable}; use futures::{Sink, SinkExt, Stream, StreamExt}; use tokio::syn...
/// FileDeleteResponse contains information about a repo's file that was deleted #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct FileDeleteResponse { pub commit: Option<crate::file_commit_response::FileCommitResponse>, pub content: Option<crate::file_delete_response::FileDeleteResponseConte...
use std::ops::Deref; #[cfg(feature = "pubsub")] use std::sync::Arc; use async_trait::async_trait; #[cfg(feature = "keyvalue")] use bonsaidb_core::kv::Kv; #[cfg(feature = "pubsub")] use bonsaidb_core::{circulate::Message, pubsub::PubSub, pubsub::Subscriber}; use bonsaidb_core::{ connection::{AccessPolicy, QueryKey}...
mod nc; #[cfg(feature = "redis-connect")] use redis::{ConnectionAddr, ConnectionInfo}; #[cfg(feature = "redis-connect")] use std::iter::once; use std::path::PathBuf; use thiserror::Error; pub use nc::{parse, parse_glob}; use std::fmt::{Display, Formatter}; #[derive(Debug)] pub struct Config { pub database: Datab...
// // Fill pdf with Symag options. // This file is part of raphpdf // // @copyright Copyright (c) 2020-2020 Grégory Muller // @license https://www.apache.org/licenses/LICENSE-2.0 // @link https://github.com/debitux/raphpdf // @since 0.1.0 // extern crate pdf_form_ids; extern crate unidecode; use pdf_fo...
#![cfg(test)] mod benchmarks; use crate::merkle_tree::{MerkleTree, calculate_height}; use crate::hash::*; #[test] fn test_empty_tree_hash() { let db: MerkleTree<u32> = MerkleTree::new(); assert_eq!(&"5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9".to_string(), db.root_hash()....
use actix::{ dev::{MessageResponse, ResponseChannel}, *, }; use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Serialize, Deserialize, Copy, Clone, Eq, PartialEq, Hash)] #[serde(transparent)] pub struct InternalId(u64); impl InternalId { pub fn new(id: u64) -> InternalId { InternalId(id) ...
// 引入 http_body 中的 Body trait 及其 trait对象 // 用于一致性地处理请求或响应中的 Body pub use http_body::{Body as HttpBody, Empty, Full}; // hyper 中定义的结构体,用于接收字节流 pub use hyper::body::Body; pub use bytes::Bytes; use crate::error::Error; use crate::BoxError; pub type BoxBody = http_body::combinators::BoxBody<Bytes, Error>; /// 把 `http_...
//! # Shared PubNub utilities. //! May come in handy when implemeting custom transports. #![deny( clippy::all, clippy::pedantic, missing_docs, missing_debug_implementations, missing_copy_implementations, intra_doc_link_resolution_failure )] #![allow(clippy::doc_markdown)] #![forbid(unsafe_code)...
pub struct ATNConfigSet { configs: Vec<ATNConfig> }