text
stringlengths
8
4.13M
use thiserror::Error as ThisError; use ukis_clickhouse_arrow_grpc::{ClickhouseException, Error as CAGError}; #[derive(ThisError, Debug)] pub enum Error { #[error(transparent)] Polars(#[from] polars::error::PolarsError), #[error(transparent)] H3ronPolars(#[from] h3ron_polars::error::Error), #[err...
pub trait Entity { fn dormant_begin(); fn dormant_end(); }
use std::slice; use std::iter::repeat; use std::ops::{Index, IndexMut}; use super::{BOX_WIDTH, BOX_HEIGHT}; use super::{Colorspace, ColorRGBA}; #[derive(Copy, Clone, Debug)] pub struct Rect { left: usize, width: usize, top: usize, height: usize, } #[derive(Copy, Clone, Debug)] pub struct Size { w...
pub mod model; pub mod analysis; pub mod types; use na::{Matrix, Real, Dim}; use na::storage::Storage; pub fn max<N : Real, C : Dim, R: Dim, S : Storage<N, C, R>>(mat : &Matrix<N, C, R, S>) -> N { mat.iter().fold(N::zero(), |store, item| { store.max(*item) }) }
use super::*; #[derive(Clone)] pub struct ModuleRef(pub Row); impl ModuleRef { pub fn name(&self) -> &'static str { self.0.str(0) } }
fn main() { step_1(); step_2(); step_3(); } fn step_1() { let mut s = String::from("hello world"); let word = first_word(&s); println!("1こ目のワード {}", word); s.clear(); println!("空のはず [{}]", s); } fn first_word(s: &String) -> &str { let bytes = s.as_bytes(); for (i, &item) in byt...
use std::{fmt, io::{Bytes, Read}}; use crate::{data::Message, user::User}; #[derive(Debug,Clone)] pub enum PacketError{ DisconnectError, ParseError, } //에러 세분화 해야함.(CannatParse, WrongCommand, ...) impl fmt::Display for PacketError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match sel...
#[macro_use] extern crate nom; #[macro_use] extern crate log; pub mod client; mod event; mod parser; mod stream; mod utils;
// Standard library use std::collections::HashMap; use std::sync::{Arc, Mutex}; // This crate use crate::actions::{Action, ActionAnswer, ActionContext, ACT_REG}; use crate::exts::LockIt; use crate::signals::{order::mqtt::MSG_OUTPUT, SIG_REG}; use crate::skills::hermes::messages::IntentMessage; use crate::skills::Skill...
extern crate rand; extern crate rand_chacha; use criterion::{criterion_group, Criterion}; use kvs::thread_pool::{RayonThreadPool, SharedQueueThreadPool, ThreadPool}; use kvs::{KvStore, SledKvStore}; use kvs::{KvsClient, KvsServer}; use std::net::TcpStream; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::sync::mp...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - UART Data"] pub dr: DR, _reserved_1_ecr: [u8; 4usize], _reserved2: [u8; 16usize], #[doc = "0x18 - UART Flag"] pub fr: FR, _reserved3: [u8; 4usize], #[doc = "0x20 - UART IrDA Low-Power Register"] pub ilpr...
pub mod storage_contract; pub mod storage_instruction; pub mod storage_processor; pub const SLOTS_PER_SEGMENT: u64 = 16; pub fn get_segment_from_slot(slot: u64) -> usize { (slot / SLOTS_PER_SEGMENT) as usize } const STORAGE_PROGRAM_ID: [u8; 32] = [ 6, 162, 25, 123, 127, 68, 233, 59, 131, 151, 21, 152, 162, 1...
#[doc = "Reader of register CR2"] pub type R = crate::R<u32, super::CR2>; #[doc = "Writer for register CR2"] pub type W = crate::W<u32, super::CR2>; #[doc = "Register CR2 `reset()`'s with value 0x80"] impl crate::ResetValue for super::CR2 { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type {...
use crate::handlers::types::*; use pusher::PusherBuilder; pub async fn push_user_message(channel: &String, event: &String, message: &UserMessage) { let pusher_url = format!( "http://{}:{}@api-{}.pusher.com/apps/{}", std::env::var("PUSHER_KEY").expect("PUSHER KEY not set"), std::env::var("PU...
use crate::{CoordinateType, Point}; use std::iter::FromIterator; /// A collection of [`Point`s](struct.Point.html). /// /// # Examples /// /// Iterating over a `MultiPoint` yields the `Point`s inside. /// /// ``` /// use geo_types::{MultiPoint, Point}; /// let points: MultiPoint<_> = vec![(0., 0.), (1., 2.)].into(); /...
// spell-checker:ignore logoption openlog setlogmask upto pub(crate) use syslog::make_module; #[pymodule(name = "syslog")] mod syslog { use crate::common::lock::PyRwLock; use crate::vm::{ builtins::{PyStr, PyStrRef}, function::{OptionalArg, OptionalOption}, utils::ToCString, Py...
#[doc = "Reader of register DC0"] pub type R = crate::R<u32, super::DC0>; #[doc = "Flash Size\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] #[repr(u16)] pub enum FLASHSZ_A { #[doc = "3: 8 KB of Flash"] _8KB = 3, #[doc = "7: 16 KB of Flash"] _16KB = 7, #[doc = "15: 32 KB of Flash"] ...
use ::AB_JTM; fn assert_ab_jtm(t1: AB_JTM, t2: AB_JTM) { assert_eq!(t1.ab_sec, t2.ab_sec); assert_eq!(t1.ab_min, t2.ab_min); assert_eq!(t1.ab_hour, t2.ab_hour); assert_eq!(t1.ab_days, t2.ab_days); } #[test] fn it_has_a_valid_initializer() { let t1 = AB_JTM::new(); let t2 = AB_JTM { ab_...
/// Chain two functions. /// /// Takes functions `f` and `g` and returns `g ∘ f` (in other words something /// _like_ `|a: A| g(f(a))`. /// /// # Examples: /// ``` /// use fntools::unstable::chain; /// /// let add_two = |a: i32| a + 2; /// let add_three = |a: i32| a + 3; /// let add_five = chain(add_two, add_three); //...
#[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Enable RADIO in TX mode"] pub tasks_txen: TASKS_TXEN, #[doc = "0x04 - Enable RADIO in RX mode"] pub tasks_rxen: TASKS_RXEN, #[doc = "0x08 - Start RADIO"] pub tasks_start: TASKS_START, #[doc = "0x0c - Stop RADIO...
use std::collections::HashMap; use std::fmt; use std::fmt::Formatter; use std::marker::PhantomData; use serde::{Deserialize, Deserializer}; use serde::de::{MapAccess, SeqAccess, Visitor}; use serde::Serialize; fn format_bool<'de, D>(deserializer: D) -> Result<bool, D::Error> where D: Deserializer<'de>, { let s = ...
extern crate iron; extern crate router; extern crate persistent; extern crate bodyparser; extern crate formdata; extern crate multipart; extern crate hyper; extern crate hyper_native_tls; extern crate params; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate serde; extern crate toml; exte...
extern crate paillier; #[cfg(not(feature="keygen"))] fn main() { println!("*** please run with 'keygen' feature ***") } #[cfg(feature="keygen")] fn main() { use paillier::{AbstractPaillier, BigInteger, integral}; // could be a specific type such as RampBigInteger as well use paillier::coding::*; us...
use cell_extras::atomic_init_cell::AtomicInitCell; use cell_extras::atomic_ref_cell::AtomicRefCell; use engine::{self, EngineMessage}; use math::*; use polygon::light::*; use std::mem; use std::sync::Arc; // TODO: This shouldn't be fully public, only public within the crate. pub type LightInner = Arc<(AtomicInitCell<L...
use std::io; fn main() { let mut buf = String::new(); io::stdin().read_line(&mut buf).unwrap(); let n: usize = buf.trim().parse().unwrap(); let s: Vec<char> = { buf = String::new(); io::stdin().read_line(&mut buf).unwrap(); buf.trim().chars().collect() }; let mut r_cou...
fn use_pointer(x : &u32) { println!("x = {}, Address of x = {:p}", x, &x); } fn main() { let x:u32 = 1; println!("x = {}, Address of x = {:p}", x, &x); use_pointer(&x); let a:u32 = 1; let b = &a; println!("{}", *b); println!("{:p}", b); println!("{}", b); }
pub use libra_language_e2e_tests::compile::*;
/// https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life /// /// Stepping takes about 24 nanoseconds per cell on my /// somewhat slow laptop. use std::fmt::{Display, Formatter, Error}; use std::ops::{Index, IndexMut}; use std::time::Instant; struct Board { cells: Vec<bool>, size: usize } impl Board { fn...
use anyhow::{anyhow, Result}; use ropey::Rope; use tree_sitter::{Language, Parser, Query, QueryCursor, Tree}; use tree_sitter_typescript::{language_tsx, language_typescript}; const QUERY: &str = "(import_statement (string) @import)(export_statement (string) @import)"; pub enum Lang { TypeScript, TypeScriptTsx...
// 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 ...
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 mod transfer; pub use transfer::*;
use num::ToPrimitive; use time::now_utc; use std::io::Write; use std::fs; use std::path; use postgres; use std::collections; pub fn gen_timecode() -> String { now_utc().strftime("%y%m%d%H%M%S").unwrap().to_string() } pub fn gen_full_name(name: &str) -> String { format!("_{}_{}", gen_timecode(), name) } pub f...
// 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 ...
// Copyright 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; use super::element; use super::bond; /// Hash atom charge /// Postive charge value > 200, Ne...
#[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Start generation of key-stream. This operation will stop by itself when completed."] pub tasks_ksgen: TASKS_KSGEN, #[doc = "0x04 - Start encryption/decryption. This operation will stop by itself when completed."] pub tasks...
extern crate phf_codegen; extern crate unicase; use phf_codegen::Map as PhfMap; use unicase::UniCase; use std::fs::File; use std::io::prelude::*; use std::io::BufWriter; use std::path::Path; use std::env; use std::collections::BTreeMap; use mime_types::MIME_TYPES; #[path="src/mime_types.rs"] mod...
extern crate clap; extern crate dirs; use std::error::Error; use std::fs::File; use std::process; use std::io::prelude::*; use std::process::Command; use std::os::unix::process::CommandExt; pub fn run(args: clap::ArgMatches) -> Result<(), Box<dyn Error>> { // .gdbs, .gbdibit へのパス let mut path_to_gdbs = dirs:...
use super::*; use rand::{thread_rng, Rng}; use display::{Display, DisplayWeapon}; use inflector::Inflector; use rustache::*; use std::io::Cursor; pub enum Results { Begin { log: String }, Round { log: String }, End { log: String, winner: CombatantId, duration: i32, }, } /// The...
pub struct ModelTexture { texture_id: u32, } impl ModelTexture { pub fn new(texture_id: u32) -> ModelTexture { ModelTexture { texture_id } } pub fn get_texture_id(&self) -> &u32 { &self.texture_id } }
use regex::Regex; use std::error::Error; use std::io::Read; use std::fs::File; fn inc(lights: &mut [[u16; 1000]; 1000], amount: u16, x1: usize, x2: usize, y1: usize, y2: usize) { for x in x1..(x2+1) { for y in y1..(y2+1) { lights[x][y] += amount; } } } fn dec(lights: &mut [[u16; 10...
use std::time::Duration; use anyhow::Result; use bytes::Bytes; use lfan::preconfig::concurrent::{new_ttl_cache, TTLLRUCache}; use menmos_client::{Client, Meta, Query, QueryResponse}; static META_TTL: Duration = Duration::from_secs(30 * 60); // 30 min. static QUERY_TTL: Duration = Duration::from_secs(30); pub struct ...
use crate::core::colors::RgbaColor; use crate::render::ui::gui::{HorizontalAlign, VerticalAlign}; use crate::render::ui::text::Text; use crate::render::ui::{DrawData, Gui, Panel}; use glfw::MouseButton; pub struct Button { /// Text of the button text: String, /// dimension of the button. If none, will use ...
use diesel::{self, prelude::*}; use rocket_contrib::json::Json; use crate::atividades_administrativas_model::{ AtividadesAdministrativas, InsertableAtividadeAdministrativa, }; use crate::schema; use crate::DbConn; #[post( "/atividades_administrativas/<id_professor>", data = "<atividades_administrativas>"...
#![feature(test)] extern crate test; #[cfg(test)] mod tests { fn is_square_number(num: usize) -> bool { (num as f64).sqrt().fract() == 0.0 } fn is_square_number_cast(num: usize) -> bool { let sqrt = (num as f64).sqrt() as usize; (sqrt * sqrt) == num } use rand::prelude::*;...
use super::{Op, Span, SyntaxError}; use crate::index::*; use std::str; define_index_type! { #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub struct Ident(usize); } #[derive(Copy, Clone, PartialEq, Debug)] pub enum Token { EOF, KwLoc, KwProc, KwReg, KwRun, KwIf, ...
use std::mem; use std::fmt::Debug; use std::fmt::Display; use std::fmt::Formatter; use std::fmt; use std::str; use std::slice; use cql_bindgen::CASS_VALUE_TYPE_ASCII; use cql_bindgen::CASS_VALUE_TYPE_VARCHAR; use cql_bindgen::CASS_VALUE_TYPE_TEXT; use cql_bindgen::CASS_OK; use cql_bindgen::cass_value_get_int32; use cq...
test_stdout!(without_exiting_returns_true, "true\n"); // `with_exiting_returns_false` in unit tests
extern crate serde; extern crate serde_json; #[macro_use] extern crate serde_derive; extern crate rand; use rand::{thread_rng, Rng}; use std::error::Error; #[repr(u8)] #[derive(Debug, Clone, Copy)] enum Building { Defense = 0, Attack = 1, Energy = 2, } impl std::fmt::Display for Building { fn fmt(&...
use crate::backend::c; use bitflags::bitflags; /// `struct itimerspec` for use with [`timerfd_gettime`] and /// [`timerfd_settime`]. /// /// [`timerfd_gettime`]: crate::time::timerfd_gettime /// [`timerfd_settime`]: crate::time::timerfd_settime pub type Itimerspec = linux_raw_sys::general::__kernel_itimerspec; bitfla...
mod generic; mod lifetime; mod trait_demo; fn main() { generic::gn(); trait_demo::trait_demo(); lifetime::life(); }
mod send; use crate::{ helpers::{array::get_slice, assertions::ensure_vote_exists, params::get_public_key}, types::{ Ballot, Cipher, PublicKey as SubstratePK, ShufflePayload, ShuffleProof, ShuffleState, Topic, TopicId, Vote, VoteId, VotePhase, Wrapper, }, }; use crate::{ Call, Ciphers, ...
mod args; mod client; mod dlm_error; mod downloader; mod file_link; mod progress_bar_manager; mod retry; mod user_agents; mod utils; use crate::args::{get_args, Arguments}; use crate::client::make_client; use crate::dlm_error::DlmError; use crate::downloader::download_link; use crate::progress_bar_manager::ProgressBar...
pub fn matrix_mul(a: &Vec<i32>,b: &Vec<i32>,l: usize,m: usize,n: usize) -> Vec<i32>{ let r = l * n; let mut c: Vec<i32> = vec![0;r]; for i in 0..r{ for j in 0..m{ c[i] = c[i] + (a[i / n * m + j] * b[(i % n) + j * n]); } } return c; }
mod canvas; mod color; mod coord; mod lang; mod scene; mod traits; use canvas::Canvas; use color::{Color, BLACK}; use coord::{WorldCoordinate, ORIGIN}; use lang::parser::{LightDefinition, Parser, SceneDefinition}; use log::error; use pixels::SurfaceTexture; use scene::object::light::Light; use scene::object::shape::Sp...
use crate::environment::blockchain_interface::BlockchainInterface; use near_vm_logic::mocks::mock_external::MockedExternal; use near_vm_logic::mocks::mock_memory::MockedMemory; use near_vm_logic::types::PromiseResult; use near_vm_logic::{Config, External, MemoryLike, VMContext, VMLogic}; use std::cell::RefCell; use std...
//! A registry of values, available both internally to Way Cooler //! and its clients. //! //! The registry is divided into "categories", which gives the values some //! semblance of structure (e.g window properties are part of the "windows" //! category) while also allowing fine grain permissions for clients //! (e.g ...
use super::Command; use clap::ArgMatches; use log::info; pub fn run(matches: &ArgMatches, commands: &mut Vec<Command>) { info!("Running NEW subcommand"); let command = matches.value_of("command").unwrap().to_owned(); let keywords: Vec<String> = matches .values_of("keywords") .unwrap() ...
use std; use std::collections::HashMap; use csv; use lazy_static::lazy_static; use pbr::ProgressBar; use std::error; use std::error::Error; use std::fmt; use std::fs; use std::fs::File; use std::io::prelude::*; use std::path::Path; use std::path::PathBuf; use std::process::Command; use std::str::FromStr; use x86::cpui...
// Copyright 2020 IOTA Stiftung // // 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 w...
pub mod item; pub mod quest; pub mod entity; pub mod game_local; pub mod game; pub mod gamesys; pub mod player; pub mod multiplayer_game;
// // model.rs // Spose // // Author: Wess (me@wess.io) // Created: 12/08/2020 // // Copywrite (c) 2020 Wess.io // use serde::{Serialize}; use mongodb::bson::{ to_bson, Bson, oid::ObjectId }; pub trait Model : Serialize { fn id(&self) -> Option<ObjectId> { let b = self.to_bson(); let d = b.as_docum...
use futures::TryStreamExt; use sqlx::postgres::{PgPool, PgQueryAs, PgRow}; use sqlx::{Connection, Cursor, Executor, Postgres, Row}; use sqlx_test::new; use std::time::Duration; // TODO: As soon as I tried to deserialize a json value in a function, inferance for this test stopped working. I am at a loss as to how to re...
pub mod time_util; pub mod xml_loader; pub mod print_util; pub mod string_util; pub mod value_util; pub mod bencher; pub mod join_in; pub mod error_util; pub mod array_util;
// This file is part of linux-epoll. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-epoll/master/COPYRIGHT. No part of linux-epoll, including this file, may be copied, modified, propagated, or distri...
use thiserror::Error; use tokio::task::JoinError; use tokio::time::error::Elapsed; #[derive(Error, Debug)] pub enum DlmError { #[error("the input file is empty")] EmptyInputFile, #[error("connection closed")] ConnectionClosed, #[error("connection timeout")] ConnectionTimeout, #[error("respo...
use midi_message::MidiMessage; use color::Color; use color_strip::ColorStrip; use effects::effect::Effect; // http://www.roxlu.com/downloads/scholar/001.fluid.height_field_simulation.pdf pub struct Ripple { u: Vec<f64>, v: Vec<f64>, } impl Ripple { pub fn new(led_count: usize) -> Ripple { Ripple {...
use input_i_scanner::{scan_with, InputIScanner}; fn main() { let stdin = std::io::stdin(); let mut _i_i = InputIScanner::from(stdin.lock()); let (a, b, c) = scan_with!(_i_i, (u32, u32, u32)); for x in a..=b { if x % c == 0 { println!("{}", x); return; } } ...
use std::cell::RefCell; use std::rc::Rc; use nom::character::complete::char as nom_char; use nom::combinator::recognize; use nom::error::Error; use nom::sequence::pair; use nom::IResult; use nom::Parser; type InputType<'a> = &'a str; type NomError<'a> = Error<InputType<'a>>; type DynParser<'a> = dyn FnMut(InputType<'...
//! Utilities for testing `cam_geom` implementations. use super::*; use nalgebra::{ base::{dimension::Dyn, VecStorage}, convert, }; pub(crate) fn generate_uv_raw<R: RealField>( width: usize, height: usize, step: usize, border: usize, ) -> Pixels<R, Dyn, VecStorage<R, Dyn, U2>> { let mut uv_...
// 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::fs::File; use std::string::String; use std::io::prelude::*; use std::char; fn main() { let mut box_ids = String::new(); File::open("./../input.txt") .expect("Unable to read from input.txt") .read_to_string(&mut box_ids) .expect("Unable to feed contents to string"); let mut...
use crate::geom::{Point, Vector}; pub struct Inertia { pub position: Point, pub prev: Point, } impl Inertia { pub fn step() -> f32 { 0.01 } pub fn new(position: Point) -> Inertia { let prev = position; Inertia { position, prev } } pub fn integrate(&mut self) { ...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[cfg(feature = "Media_Capture_Core")] pub mod Core; #[cfg(feature = "Media_Capture_Frames")] pub mod Frames; #[link(name = "windows")] extern "system" {} pub type AdvancedCapturedPhoto = *mut ::core::ffi:...
// 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 super::{InlineObject, InlineObjectTrait}; use crate::{ heap::{ object_heap::HeapObject, symbol_table::impl_ord_with_symbol_table_via_ord, Heap, Int, Tag, }, utils::{impl_debug_display_via_debugdisplay, impl_eq_hash_ord_via_get, DebugDisplay}, }; use derive_more::Deref; use extension_trait::exten...
use core::slice::{Iter, IterMut}; use std::ops::{Index, IndexMut}; #[derive(Debug)] pub struct VkMappedMemory<'a, T> where T: Clone, { data: &'a mut [T], } impl<'a, T: Clone> VkMappedMemory<'a, T> { pub(crate) fn new(data: &'a mut [T]) -> VkMappedMemory<'a, T> { VkMappedMemory { data } } ...
use cortex_m::asm::bkpt; use cortex_m; use nrf51; use boards::nrf51dk::PERIPH; use Kernel; use boards::peripherals::timers::Timer; #[derive(PartialEq, Clone)] pub enum PendingInterrupt { Button1, Button2, Button3, Button4 } pub struct Interrupt { pub pending_interrupt: Option<PendingInterrupt> ...
/// The basic macro for making a union of entities. /// /// This macro is the most generic version. /// You can find more specific versions in `shape`, `material` and `object` modules. /// /// You can read more about the technique [here](https://clay-rs.github.io/knowledge/#objects). #[macro_export] macro_rules! instan...
/* tree!{ sum => { mul => { a, c }, b } }; ****** sum(mul(a, c), b) */ #[derive(Debug)] struct My { a: i32, b: i32 } fn procedure<'res, 'a: 'res, 'b: 'res>( a: &'a My, b: &'b My) -> &'res My { if a.a > b.b { a } else { b } } fn main() { l...
use crate::errors::ServiceError; use actix_web::{client::Client, http::StatusCode}; use failure::Error; use qrcode::QrCode; use redis::{Commands, RedisError}; pub struct QREncoder { username: String, github_url: String, redis_url: String, redis_ttl: usize, } impl QREncoder { pub fn new( us...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Operating mode Register"] pub mtlomr: MTLOMR, _reserved1: [u8; 28usize], #[doc = "0x20 - Interrupt status Register"] pub mtlisr: MTLISR, _reserved2: [u8; 220usize], #[doc = "0x100 - Tx queue operating mode Regis...
/* * __ __ _ _ _ * | \/ | ___ ___ __ _| | (_)_ __ | | __ * | |\/| |/ _ \/ __|/ _` | | | | '_ \| |/ / * | | | | __/\__ \ (_| | |___| | | | | < * |_| |_|\___||___/\__,_|_____|_|_| |_|_|\_\ * * Copyright (c) 2017-2018, The MesaLink Authors. * All rights reserved. * *...
/// ```rust,ignore /// 43. 字符串相乘 /// /// 给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。 /// /// 示例 1: /// /// 输入: num1 = "2", num2 = "3" /// 输出: "6" /// /// 示例 2: /// /// 输入: num1 = "123", num2 = "456" /// 输出: "56088" /// /// 说明: /// /// num1 和 num2 的长度小于110。 /// num1 和 num2 只包含数字 0-9。 /// num1 和 num2...
//! Inlets use std::ffi::c_void; ///Callback method for Float inlet pub type FloatCB<T> = Box<dyn Fn(&T, f64)>; ///Callback method for Int inletk pub type IntCB<T> = Box<dyn Fn(&T, max_sys::t_atom_long)>; /// Inlets for Max objects pub enum MaxInlet<T> { Float(FloatCB<T>), Int(IntCB<T>), Proxy, } /// Inl...
use neqo_future::*; use std::panic::{ catch_unwind, AssertUnwindSafe }; use std::ffi::CStr; use std::thread::LocalKey; use std::cell::RefCell; use async_std::task::JoinHandle; use async_std::task; use futures::{AsyncWriteExt, AsyncReadExt}; type ConnectionInfo = (JoinHandle<Option<u64>>, Connection); pub enum Stre...
extern crate atoi; extern crate bincode; extern crate byteorder; extern crate hex; extern crate openssl; #[macro_use] extern crate serde_derive; #[macro_use] extern crate log; pub enum Command { PING, SET(Vec<u8>), GET(Vec<u8>), NOTSUPPORTED, } pub mod server; pub mod storage;
::windows_sys::core::link ! ( "ole32.dll""system" #[doc = "*Required features: `\"Win32_System_Com_StructuredStorage\"`*"] fn CoGetInstanceFromFile ( pserverinfo : *const super:: COSERVERINFO , pclsid : *const :: windows_sys::core::GUID , punkouter : :: windows_sys::core::IUnknown , dwclsctx : super:: CLSCTX , grfmode ...
use std::io::{Read, Result as IOResult}; use crate::lump_data::{LumpData, LumpType}; use crate::PrimitiveRead; #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] pub struct LeafBrush { pub index: u16 } impl LumpData for LeafBrush { fn lump_type() -> LumpType { LumpType::LeafBrushes } fn lump_type_hdr() ->...
use log::error; use std::env; use std::result::Result; use thiserror::Error; use crate::common; #[derive(Error, Debug)] enum CurrentCommandError { #[error("reading .rpilot file failed. Make sure this project is initialised properly.")] NotInitialized, #[error("the specified profile name does not exists f...
#[test] fn mock_test() { assert!(true); }
use super::Money; use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct LineItem { number: usize, description: String, quantity: usize, unit_price: Money, }
// Copyright 2020, The Tari Project // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following // disclai...
// 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 CSR"] pub type R = crate::R<u32, super::CSR>; #[doc = "Writer for register CSR"] pub type W = crate::W<u32, super::CSR>; #[doc = "Register CSR `reset()`'s with value 0"] impl crate::ResetValue for super::CSR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { ...
// https://leetcode.com/problems/matrix-diagonal-sum/ impl Solution { pub fn diagonal_sum(mat: Vec<Vec<i32>>) -> i32 { let mut diagonal_sum = 0; for i in 0..mat.len() { diagonal_sum += mat[i][i] + mat[mat.len()-i-1][i]; } if (mat.len()%2 == 1) { ...
use nalgebra::Vector3; use crate::{LumpType, LumpData}; use crate::PrimitiveRead; use std::io::{Read, Result as IOResult}; pub struct DispVert { pub vec: Vector3<f32>, pub dist: f32, pub alpha: f32 } impl LumpData for DispVert { fn lump_type() -> LumpType { LumpType::DisplacementVertices } fn lump_typ...
// 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 bitfield::bitfield; use byteorder::{LittleEndian, WriteBytesExt}; use std::io; #[cfg(test)] use byteorder::ReadBytesExt; // IEEE Std 802.11-2016, 9.2...
use crate::hitable::*; use crate::ray::*; use crate::sphere::*; use crate::vec3::*; use rand::Rng; use rand::distributions::{Distribution, Standard}; // One trait to rule them all pub trait Material { fn scatter(&self, r_in: &Ray, rec: &HitRecord, attenuation: &mut Vec3) -> Option<Ray>; } // Use an enum as type of ...
// 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 ...
extern crate proc_macro; use proc_macro::TokenStream; #[proc_macro_derive(Command, attributes(test_attr))] pub fn derive_command_fn(_item: TokenStream) -> TokenStream { "fn command() { let meme = 21; println!(\"I purchased {} watermelons today\", meme); }" .parse() .unwrap() } #[proc_macro_derive(...