text stringlengths 8 4.13M |
|---|
#[test]
fn iterators_filter_map_test() {
use std::str::FromStr;
let mut results = Vec::new();
let text = "aloha 3.14 notanumber 2t 6.18 15";
for number in text
.split_whitespace()
.filter_map(|w| f64::from_str(w).ok())
{
results.push(number);
}
assert_eq!(results, [3... |
//! <https://github.com/EOSIO/eosio.cdt/blob/4985359a30da1f883418b7133593f835927b8046/libraries/eosiolib/core/eosio/symbol.hpp#L234-L337>
use super::SymbolCode;
use crate::bytes::{NumBytes, Read, Write};
use core::fmt;
use eosio_numstr::{symbol_from_code, symbol_to_code, symbol_to_precision};
/// Stores information a... |
// 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 ... |
#[cfg(test)]
mod tests {
use lib;
/// Returns the array to work with for tests purposes
///
/// Returns:
///
/// tests purpose array
fn get_array() -> Vec<f32> {
return vec![
9.0,
3.0,
3.0,
4.0,
5.0,
4.9,
... |
#[doc = "Reader of register TEST"]
pub type R = crate::R<u8, super::TEST>;
#[doc = "Writer for register TEST"]
pub type W = crate::W<u8, super::TEST>;
#[doc = "Register TEST `reset()`'s with value 0"]
impl crate::ResetValue for super::TEST {
type Type = u8;
#[inline(always)]
fn reset_value() -> Self::Type {... |
use std::cmp::max;
use std::collections::HashMap;
use std::ffi::CString;
use std::fmt::{
Debug,
Formatter,
};
use std::hash::{
Hash,
Hasher,
};
use std::mem::MaybeUninit;
use std::sync::{
Arc,
Mutex,
};
use ash::vk::{
self,
BufferDeviceAddressInfo,
Handle,
SharingMode,
};
use sm... |
// 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::{font::Font, widgets::Color};
use nannou::{geom::rect::Rect, prelude::Vector3, text::Scale, wgpu::Texture, Draw};
use utopia_core::CommonPrimitive;
use utopia_decorations::{
primitives::{border::BorderPrimitive, quad::QuadPrimitive},
widgets::scale::ScaledPrimitive,
};
use utopia_image::primitive::Im... |
/*
* Copyright 2020 Fluence Labs Limited
*
* 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 a... |
pub mod physics;
mod spatial_grid;
pub use physics::PhysicsPipeline;
pub use spatial_grid::*;
|
//! Trivial type-map implementation
//!
//! Implementation uses type erased values with type as index.
//! Due to limitation of `TypeId` only types without non-static references are supported. (in future it can be changed)
//!
//! ## Hash implementation
//!
//! The map uses simplified `Hasher` that relies on fact that ... |
#![crate_name = "uu_logname"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Benoit Benedetti <benoit.benedetti@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/* last synced with: logname (GNU coreuti... |
#[macro_use]
mod syntax_kind;
mod grammar;
mod lexer;
pub use syntax_kind::SyntaxKind;
#[cfg(test)]
mod tests {
use super::*;
use std::fmt;
fn multi_assert<T>(assertions: &[(T, T)])
where
T: fmt::Debug + PartialEq,
{
for assertion in assertions {
assert_eq!(assertion.0... |
/*
* This code is totally unsafe.
* It relies on the gc thread getting enough cpu time that it never lags
* too far behind the app thread. If this assumption fails, undefined behaviour
* results.
*/
#![feature(alloc)]
use std::boxed;
use std::mem::transmute;
use std::sync::Arc;
use std::sync::atomic::{AtomicIsiz... |
use crate::base::Mat;
use crate::base::Vector;
use crate::base::Layer;
pub struct MaxPooling {
pub input: Mat,
pub output: Mat,
pub input_width: usize,
pub input_height: usize,
pub pool_size: usize,
pub strides: usize,
pub padding: usize,
pub max_index: Mat,
}
impl MaxPooling {
pub... |
use std::convert::TryInto;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_std::{Addr, Coin, Order, StdResult, Storage, Uint128};
use cw0::Expiration;
use cw_storage_plus::{Bound, I64Key, Item, Map, U128Key};
use crate::msg::{Params, PlanContent};
/// (plan-id, subscriber-address)
pub ty... |
use std::io::{Read, Result as IOResult};
use crate::PrimitiveRead;
pub struct Header {
pub id: i32,
pub version: i32,
pub checksum: i32,
pub lods_count: i32,
pub lod_vertexes_count: [i32; 8],
pub fixups_count: i32,
pub fixup_table_start: i32,
pub vertex_data_start: i32,
pub tangent_data_start: i32
}... |
/*
* Runtime.rs
*
* Contains re-implemented parts of Rust's libstd that are needed here, for
* convenience or because the compiler needs some of them to use some features
* of the language.
*
* Contains some parts copied from Rust's official libstd. See
* http://github.com/mozilla/rust/
*/
use self::libc::*;
... |
#[doc = "Reader of register TPLOG6"]
pub type R = crate::R<u32, super::TPLOG6>;
#[doc = "Reader of field `TIME`"]
pub type TIME_R = crate::R<u32, u32>;
impl R {
#[doc = "Bits 0:31 - Tamper Log Calendar Information"]
#[inline(always)]
pub fn time(&self) -> TIME_R {
TIME_R::new((self.bits & 0xffff_fff... |
use mpi::collective::Root;
use mpi::traits::Communicator;
use sdl2::event::Event;
use sdl2::pixels::Color;
use crate::calculation::mpi_eng::common::*;
use crate::calculation::mpi_eng::procedure::*;
use crate::global::*;
pub fn main() {
if WORLD.rank() == ROOT {
root_routine()
} else {
sub_rout... |
/// Extend `std::io::Write` with wincon styling
///
/// Generally, you will want to use [`Console`][crate::Console] instead
pub trait WinconStream {
/// Change the foreground/background
///
/// A common pitfall is to forget to flush writes to
/// stdout before setting new text attributes.
fn set_col... |
mod database;
use crate::database::{DatabaseQueries, UserModel};
use crate::database::{CollectibleModel, DatabaseHelper, };
use anyhow::{bail, Error};
use anyhow::Result;
use serde_derive::Deserialize;
use serenity::client::{Context, EventHandler};
use serenity::model::channel::{Attachment, Message, Reaction};
use ser... |
use bindings::emscripten::*;
use bindings::gl;
use common::color::*;
pub struct WebGLContext {}
impl WebGLContext {
pub fn new() -> Self {
use std::mem::uninitialized;
let ems_context_handle = unsafe {
let mut attribs = uninitialized();
emscripten_webgl_init_context_attributes(&mut attribs);
attribs.a... |
use crate::Result;
use crossterm::{queue, style::*, terminal::*};
use std::{cell::RefCell, fmt::Display, rc::Rc, sync::OnceLock};
static NO_COLOR: OnceLock<bool> = OnceLock::new();
fn no_color() -> bool {
*NO_COLOR.get_or_init(|| std::env::var("NO_COLOR").is_ok())
}
#[derive(Debug, Clone)]
pub struct Raw<W> {
... |
use async_graphql::*;
#[tokio::test]
pub async fn test_derived_field_object() {
use serde::{Deserialize, Serialize};
struct Query;
#[derive(Serialize, Deserialize)]
struct ValueDerived(String);
scalar!(ValueDerived);
impl From<i32> for ValueDerived {
fn from(value: i32) -> Self {
... |
use std::collections::HashMap;
use proc_macro2::{Ident, TokenStream};
use syn::{parse2, DataEnum, GenericParam, Generics, TypeParam, Variant, Visibility};
use crate::token_builder::{
access_field, extend_ts, generics_arg_by_mutating_type_params, ident, join_ts, pattern_match, safe_field_ident, ts,
TokenBuilde... |
use std::collections::{HashMap, VecDeque};
use crate::{
error::LuxError, expr::Expr, function::Function, interpreter::Interpreter, stmt::Stmt,
token::Token,
};
pub struct Resolver<'a> {
scopes: VecDeque<HashMap<String, bool>>,
interpreter: &'a mut Interpreter,
current_function: FunctionType,
}
ty... |
use std::collections::HashMap;
// Following enums/structs & their methods should be fairly
// self-explanitory
enum Operation {
Increment(isize),
Decrement(isize),
}
impl Operation {
fn apply(&self, val: &mut isize) -> isize {
use Operation::*;
match *self {
Increment(i) => {
... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct NV_MEMORY_RANGE {
pub BaseAddress: *mut ::core::ffi::c_void,
pub Length: usize,
}
impl NV_MEMORY_... |
//!
//! Trait(s) specific to code generation objects within this crate.
//!
pub mod attributes;
pub mod docs;
pub mod fields;
pub mod generics;
pub mod trait_bounds;
pub use attributes::*;
pub use docs::*;
pub use fields::*;
pub use generics::*;
pub use trait_bounds::*;
/// Trait implemented for elements representin... |
use serde::Deserialize;
#[derive(Deserialize)]
pub struct Register {
pub username: String,
pub country: String,
}
|
extern crate gl;
use crate::core::{pass, pipeline, tech};
use crate::gl::{shader, uniform};
use std::collections::HashMap;
use std::vec::Vec;
pub struct TechniqueContainer {
pub map: HashMap<Techniques, Technique>,
}
impl TechniqueContainer {
pub fn new() -> TechniqueContainer {
TechniqueContainer {
... |
use std::io::Read;
fn read<T: std::str::FromStr>() -> T {
let token: String = std::io::stdin()
.bytes()
.map(|c| c.ok().unwrap() as char)
.skip_while(|c| c.is_whitespace())
.take_while(|c| !c.is_whitespace())
.collect();
token.parse().ok().unwrap()
}
fn main() {
let... |
use crate::{
combinators::if_all, loading::systems, modes::ModeExt, AppBuilderExt, GameStage, GlobalMode,
ModeEvent,
};
use game_lib::bevy::{ecs as bevy_ecs, prelude::*};
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, SystemLabel)]
pub struct LoadingPlugin;
impl Plugin for LoadingPlugin {
fn build(&sel... |
extern crate clap;
extern crate tar_api;
extern crate flate2;
use clap::{App, Arg, SubCommand, value_t};
use std::path::{Path, PathBuf};
use std::process::exit;
fn main() {
let matches = &App::new("tar_api")
.subcommand(
SubCommand::with_name("tar")
)
.subcommand(
SubCommand::with_name("unta... |
#![feature(plugin)]
#![plugin(phf_macros)]
#![feature(test)]
extern crate test;
#[macro_use]
extern crate lazy_static;
extern crate phf;
// 数量少的话, match/find最遭的情况依然比map好
//
// Hash的 O(1), 匹配时间仅取决于当前字符串/bytes的长度(Hash一次).
//
// match/if-else 的 O(n), 取决于匹配次数(直到匹配成功或全部失败), 另外还有目标字符串/bytes长度.
//
// 参见b模块, if-else的最糟糕情况 O(... |
use std::sync::Arc;
use actix_web::web;
use crate::graphql::Schema;
use deadpool_postgres::Pool;
use serde::{Deserialize, Serialize};
use tokio_pg_mapper_derive::PostgresMapper;
#[derive(Serialize, Deserialize, PostgresMapper)]
#[pg_mapper(table = "todo_list")]
pub struct Level {
pub id: i32,
pub creator: String,
... |
use wasm_bindgen::prelude::*;
use bincode;
use objects::PacketId;
use objects::Request;
use objects::Answer;
use objects::RequestAction;
fn vec_to_id(buf: Vec<u32>) -> PacketId {
[buf[0], buf[1], buf[2], buf[3]]
}
#[wasm_bindgen]
pub fn request_to_buf(id: Vec<u32>, msg: JsValue) -> Option<Vec<u8>> {
let msg: ... |
use std::fmt::{Result, Display, Formatter};
#[derive(Default, Eq, Ord, Copy, Clone, Debug, PartialEq, PartialOrd, Hash)]
pub struct Rank(u8);
impl Rank {
pub fn from_bits(bits: u8) -> Self {
debug_assert!(bits < 8);
Rank(bits)
}
pub fn parse(input: char) -> Self {
debug_assert!((in... |
use chrono::prelude::*;
use std::error::Error;
use std::fs::OpenOptions;
use std::io::prelude::*;
use std::{thread, time};
pub struct Config {
pub duration_in_millis: u32,
pub log_path: String,
}
impl Config {
pub fn new(args: &[String]) -> Result<Config, &'static str> {
if args.len() < 3 {
... |
extern crate sdl2;
extern crate rand;
mod maze;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use sdl2::rect::Rect;
use maze::Direction;
use maze::GameState;
pub fn main() {
let mut map = make_new_game();
let width = 10*map.cols;
let height = 10*map.rows;
println!... |
use crate::*;
use std::cmp::Ordering;
use std::fmt;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, Default)]
pub struct ExScore(i32);
impl ExScore {
pub fn from_score(score: i32) -> ExScore {
ExScore(score)
}
pub fn ex_score(&self) -> i32 {
self.0
}
}
impl fmt::D... |
use iron::typemap::Key;
#[derive(Debug)]
pub struct ConfigMisc {
pub jwt_secret: String,
pub jwt_time_variation: i64
}
impl Key for ConfigMisc {
type Value = ConfigMisc;
}
|
extern crate multipart;
extern crate nickel;
use std::io::{self, Write};
use nickel::{Action, HttpRouter, MiddlewareResult, Nickel, Request, Response};
use nickel::status::StatusCode;
use multipart::server::nickel::MultipartBody;
use multipart::server::{Entries, SaveResult};
use multipart::mock::StdoutTee;
... |
use futures::{channel::mpsc, Future};
use std::pin::Pin;
use std::task::Poll;
pub(crate) type ExecutorFuture =
Pin<Box<dyn Future<Output = Result<(), Box<dyn std::error::Error>>> + 'static>>;
pub struct Executor<I, T> {
pub handle: fn(I) -> ExecutorFuture,
pub future: Option<ExecutorFuture>,
pub tx: O... |
/// Set the length of the vec when the `SetLenOnDrop` value goes out of scope.
///
/// Copied from https://github.com/rust-lang/rust/pull/36355
pub struct SetLenOnDrop<'a> {
len: &'a mut usize,
local_len: usize,
}
impl<'a> SetLenOnDrop<'a> {
#[inline]
pub fn new(len: &'a mut usize) -> Self {
Se... |
use std::fs;
use permutohedron::LexicalPermutation;
mod intcode;
use intcode::IntcodeComputer;
fn generate_permutations(mut list: Vec<i128>) -> Vec<Vec<i128>> {
let mut permutations = Vec::new();
loop {
permutations.push(list.to_vec());
if !list.next_permutation() {
break;
... |
#![doc = include_str!("../README.md")]
#![recursion_limit = "1024"]
// NOTICE: Unfortunately this macro MUST be defined here, in the crate's root module, because Rust
// doesn't allow to export `macro_rules!` macros from a `proc-macro` crate type currently,
// and so we cannot move the definition into ... |
use boards::board::Board;
use boards::nrf51dk::{Nrf51dk};
use Semaphore;
use Kernel;
pub fn task1(maybe_sem: Option<Semaphore>) {
if let Some(sem) = maybe_sem {
//print("semaphore from 1");
let board: Nrf51dk = Nrf51dk::new();
match sem {
Semaphore::Button1 => {
... |
use crate::parsing::Id;
use crate::query::{BuiltInMacro, QueryConstFn, QueryError, Used};
use runestick::{CompileMeta, Item, Span};
use std::sync::Arc;
/// Query interface for the interpreter.
pub(crate) trait IrQuery {
/// Query for the given meta.
fn query_meta(
&mut self,
span: Span,
... |
#[cfg(all(not(target_arch = "wasm32"), test))]
mod test;
use anyhow::*;
use num_bigint::BigInt;
use liblumen_alloc::erts::exception::{self, *};
use liblumen_alloc::erts::process::trace::Trace;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::*;
/// `-/1` prefix operator.
#[native_... |
#[doc = "Reader of register INI5_READ_QOS"]
pub type R = crate::R<u32, super::INI5_READ_QOS>;
#[doc = "Writer for register INI5_READ_QOS"]
pub type W = crate::W<u32, super::INI5_READ_QOS>;
#[doc = "Register INI5_READ_QOS `reset()`'s with value 0x04"]
impl crate::ResetValue for super::INI5_READ_QOS {
type Type = u32... |
//! Some color utilities that are useful for implementing color transforms,
//! anaglyph modes, etc.
use std::ops::Add;
/// Represents a color
pub struct Color {
r: u8,
g: u8,
b: u8,
}
impl From<(f32, f32, f32)> for Color {
/// Convert a tuple of RGB in the [0, 1] range into a color
fn from((r, g... |
// 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.
//!
//! Generation of canonicalized SMILES for molecules
//! Use GIVP orbits directly, assume that GIVP or... |
use crate::{DocBase, VarType};
const TIME_DESC: &'static str = r#"
Function time returns UNIX time of current bar for the specified resolution and session or NaN if time point is out-of-session.
"#;
const TIME_EXAMPLE: &'static str = r#"
```pine
study("Time", overlay=true)
// Try this on chart AAPL,1
timeinrange(res,... |
#![cfg_attr(feature = "pedantic", warn(clippy::pedantic))]
#![warn(clippy::use_self)]
#![warn(clippy::map_flatten)]
#![warn(clippy::map_unwrap_or)]
#![warn(deprecated_in_future)]
#![warn(future_incompatible)]
#![warn(noop_method_call)]
#![warn(unreachable_pub)]
#![warn(missing_debug_implementations)]
#![warn(rust_2018_... |
#[derive(Clone, Debug)]
pub enum Platform {
PosixX8664,
PosixX8664Spectest,
PosixX8664Wasi,
CKBVMAssemblyScript,
CKBVMSpectest,
Unknown,
}
// A Config specifies the global config for a build.
#[derive(Clone, Debug)]
pub struct Config {
// Path of cc, usually the result of "$ which gcc".
... |
use crate::BLOCK_224_256_LEN as BLOCK_LEN;
use crate::PAD_AND_LENGTH_224_256_LEN as PAD_AND_LENGTH_LEN;
use crate::STATE_224_256_LEN as STATE_LEN;
use crate::WORD_224_256_LEN as WORD_LEN;
use crate::{inner_full_pad, inner_pad, process_block_224_256, zero_block};
use crate::{Error, Hash, Sha2};
/// Digest length in byt... |
//! Substrate utils
fn main() {
substrate_build_script_utils::generate_cargo_keys();
substrate_build_script_utils::rerun_if_git_head_changed();
}
|
// 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 crate::common::{KeyAttributes, KeyRequestType, KeyType, KmsKey};
use crate::crypto_provider::{AsymmetricProviderKey, CryptoProvider};
use fidl_fuchsia_... |
//! This module contains a set of performance debugging tools, akin to telemetry.
//!
//! To assist in the optimization of the program the following tools are provided.
//! The macros `timeit!` and `DEBUG_timeit!` should be used when timing a block of code.
//! `timeit!` is a macro that will print the elapsed time and... |
use incrementalmerkletree::Hashable;
use super::pedersen_hash_root;
use rand::{Rng,SeedableRng,StdRng};
impl Hashable for PedersenDigest {
fn combine(left: &Self, right: &Self) -> PedersenDigest {
PedersenDigest(pedersen_hash_root(left.0.clone(), right.0.clone()))
}
fn blank() -> PedersenDigest {
... |
use std::path::PathBuf;
use deck_core::OutputId;
use crate::local::dir::{DirFuture, Directory, ReadPath, WritePath};
#[derive(Debug)]
pub struct OutputsDir;
impl Directory for OutputsDir {
type Id = OutputId;
type Input = PathBuf;
type Output = PathBuf;
const NAME: &'static str = "outputs";
fn... |
// Copyright 2016 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 ... |
/*
Copyright ⓒ 2017 contributors.
Licensed under the MIT license (see LICENSE or <http://opensource.org
/licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of
<http://www.apache.org/licenses/LICENSE-2.0>), at your option. All
files in the project carrying such notice may not be copied, modified,
or distribu... |
// Copyright 2021 rust-ipfs-api Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except accord... |
#![allow(unused_imports)]
#![allow(dead_code)]
extern crate chrono;
#[macro_use]
extern crate log;
extern crate pretty_env_logger;
extern crate uinput;
extern crate uinput_sys;
#[macro_use]
extern crate maplit;
use std::{fs::File, io::{self}, process};
use std::collections::HashMap;
use std::env;
use std::fs::OpenOpti... |
use core::fmt::{self, Debug, Display};
use Fail;
without_std! {
/// An error with context around it.
///
/// The context is intended to be a human-readable, user-facing explanation for the
/// error that has occurred. The underlying error is not assumed to be end-user-relevant
/// information.
... |
# ! [ doc = "Basic-timers" ]
# [ doc = r" Register block" ]
# [ repr ( C ) ]
pub struct BTim {
# [ doc = "0x00 - control register 1" ]
pub cr1: Cr1,
# [ doc = "0x04 - control register 2" ]
pub cr2: Cr2,
_reserved0: [u8; 4usize],
# [ doc = "0x0c - DMA/Interrupt enable register" ]
pub dier: Di... |
//! Copyright 2017 Robert L Snyder, Ithaca, NY <zoltatech@gmail.com> <robscary@gmail.com>
//!
//! 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/licens... |
mod config;
mod error;
#[macro_use]
extern crate lazy_static;
use anyhow::Result;
use config::config;
pub use error::Error;
use serde_json::{Map, Value};
use std::collections::HashMap;
pub async fn verify(code: String) -> Result<GoogleProfile, Error> {
let body = make_token_request_body(code);
let obj = toke... |
//! Rewards module.
use std::convert::{Infallible, TryFrom, TryInto};
use num_traits::Zero;
use once_cell::sync::Lazy;
use thiserror::Error;
use crate::{
context::Context,
core::consensus::beacon,
error,
module::{self, Module as _, Parameters as _},
modules, storage,
types::address::{Address, ... |
//! Structure management components and systems
use bevy::prelude::*;
use crate::core::Position;
#[derive(Default, Debug, Clone)]
pub struct Structure {
max_hp: u16,
hp: u16,
attackable: bool,
ar: u8,
}
impl Structure {
pub fn player_base() -> Structure {
Structure {
max_hp: ... |
use std::mem;
pub struct List<T> {
head: Link<T>,
}
type Link<T> = Option<Box<Node<T>>>;
struct Node<T> {
elem: T, //i32,
next: Link<T>,
}
//There are three common methods which can create iterators from a collection:
//iter(), which iterates over &T.
//iter_mut(), which iterates over &mut T.
... |
#![cfg_attr(not(feature = "std"), no_std)]
use ink_lang as ink;
pub use self::nfticket::NfticketTrait;
pub use nftmart_contract::*;
#[ink::contract(env = CustomEnvironment)]
mod nfticket {
use super::*;
use primitives::{Meeting, NFTicketError};
use ink_prelude::string::String;
#[ink(storage)]
pu... |
extern crate dns_parser;
#[macro_use] extern crate log;
extern crate net2;
extern crate mio;
extern crate rotor;
extern crate libc;
extern crate rand;
extern crate multimap;
extern crate nix;
extern crate byteorder;
mod fsm;
use fsm::{AddressFamily, FSM, Command, DEFAULT_TTL};
mod services;
use services::{ServicesInn... |
mod body;
mod errors;
mod request;
mod response;
mod relay;
mod utils;
pub use body::*;
pub use errors::*;
pub use request::*;
pub use response::*;
pub use relay::*;
pub use utils::*;
|
/// ```rust,ignore
/// 1137. 第 N 个泰波那契数
///
/// 泰波那契序列 Tn 定义如下:
///
/// T0 = 0, T1 = 1, T2 = 1, 且在 n >= 0 的条件下 Tn+3 = Tn + Tn+1 + Tn+2
///
/// 给你整数 n,请返回第 n 个泰波那契数 Tn 的值。
///
///
///
/// 示例 1:
///
/// 输入:n = 4
/// 输出:4
/// 解释:
/// T_3 = 0 + 1 + 1 = 2
/// T_4 = 1 + 1 + 2 = 4
///
/// 示例 2:
///
/// 输入:n = 25
/// 输出:138953... |
//! Provides functionality for extracting data from CSV files,
//! along with additional functionality for manipulation and cleansing of extracted data.
//!
//! This module's functions takes, processes and returns Vectors of Strings or f64(floats).
//! This means there is no restriction on manipulation and visability o... |
use futures_core::future::BoxFuture;
use crate::cursor::HasCursor;
use crate::database::Database;
use crate::describe::Describe;
/// A type that contains or can provide a database connection to use for executing queries
/// against the database.
///
/// No guarantees are provided that successive queries run on the sa... |
#[path = "lib/erlang.rs"]
pub mod erlang;
#[path = "lib/maps.rs"]
pub mod maps;
test_stderr_substrings!(
backtrace,
vec![
"native_implemented/otp/tests/internal/lib/backtrace/init.erl:9, in init:bad_reverse/1",
"native_implemented/otp/tests/internal/lib/backtrace/init.erl:11, in init:bad_revers... |
use crate::DlmError;
use async_channel::{Receiver, Sender};
use chrono::Local;
use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};
use std::cmp::{min, Ordering};
const PENDING: &str = "pending";
pub struct ProgressBarManager {
main_pb: ProgressBar,
file_pb_count: usize,
pub tx:... |
pub mod lib{
use std::io::{Write, Read, ErrorKind};
use std::process::exit;
use std::fs::OpenOptions;
// The Read trait implements read_to_end and read_to_string functions which
// read from a buffer until EOF is reached, but for applications like output
// piped to stdout there is no EOF, so the functions ... |
use chrono::NaiveDate;
use chrono::NaiveDateTime;
use diesel;
use diesel::expression::dsl;
use diesel::prelude::*;
use diesel::sql_types;
use models::*;
use schema::{artists, event_artists, events, organization_users, organizations, venues};
use utils::errors::DatabaseError;
use utils::errors::ErrorCode;
use utils::err... |
use crate::io::Buf;
use crate::postgres::database::Postgres;
use byteorder::NetworkEndian;
#[derive(Debug)]
pub struct BackendKeyData {
/// The process ID of this database.
pub process_id: u32,
/// The secret key of this database.
pub secret_key: u32,
}
impl BackendKeyData {
pub(crate) fn read(mu... |
// 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 anchor_lang::prelude::*;
#[program]
pub mod yta_token {
use super::*;
pub fn initialize(ctx: Context<Initialize>) -> ProgramResult {
let yta_token = &mut ctx.accounts.yta_account;
yta_token.amount=0;
yta_token.authority = *ctx.accounts.authority.key;
Ok(())
}
pub fn ... |
use crate::interface::RedeemStakeBatchReceipt;
use crate::{
domain,
interface::{BatchId, TimestampedStakeBalance, YoctoNear},
};
use near_sdk::serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(crate = "near_sdk::serde")]
pub struct RedeemStakeBatch {
pub id: BatchId,
... |
use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::{self, Read};
use std::process;
use regex::{Captures, Regex};
const PROG_NAME: &str = "ser";
fn usage() {
println!("USAGE: {} [-h, --help] [FILE]", PROG_NAME);
}
fn exit_err(output: &str) -> ! {
eprintln!("{}", output);
process... |
#[doc = "Reader of register PCI2C"]
pub type R = crate::R<u32, super::PCI2C>;
#[doc = "Writer for register PCI2C"]
pub type W = crate::W<u32, super::PCI2C>;
#[doc = "Register PCI2C `reset()`'s with value 0"]
impl crate::ResetValue for super::PCI2C {
type Type = u32;
#[inline(always)]
fn reset_value() -> Sel... |
use crate::error::Error;
use std::{io::Read, str, u16};
use tokio::io::AsyncReadExt;
/*
* By "atom", I mean an individual part of a minecraft packet, such as an int, varint, or string.
*/
/*
* The other methods here are non-async since we'll read a full packet at a time
* before parsing it, but we need to async re... |
#![allow(non_snake_case)]
use wallets_macro::{DlCR, DlDefault, DlStruct};
use wallets_types::{EthChain, EthChainToken, EthChainTokenAuth, EthChainTokenDefault, EthChainTokenNonAuth,EthChainTokenShared};
use crate::kits::{CArray, CBool,CR, CStruct,to_str,to_c_char,Assignment};
use crate::types::{CChainShared, CTokenSh... |
use futures::stream::Fuse;
use futures::{Async, Poll, Stream};
/// A simple extension to the futures::Stream allowing to take elements in
/// batches of a given maximum size.
pub trait BatchStream {
/// Create a stream of batches of stream items. Each batch will contain
/// at most max_batch_size elements.
... |
use super::*;
pub use std::collections::BTreeSet;
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord)]
pub struct TypeDef {
pub row: Row,
pub generics: Vec<ElementType>,
}
impl From<Row> for TypeDef {
fn from(row: Row) -> Self {
Self { row, generics: Vec::new() }
}
}
impl TypeDef {
pub fn wit... |
use druid::kurbo::{Affine, Shape, TranslateScale};
use druid::widget::prelude::*;
use druid::{Color, Data, KeyOrValue};
use crate::data::GlyphDetail;
use crate::theme;
/// A widget that draws a glyph.
pub struct GlyphPainter {
color: KeyOrValue<Color>,
placeholder_color: KeyOrValue<Color>,
draw_frame: boo... |
use rustc::mir;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::layout::{self, Align, LayoutOf, TyLayout};
use rustc_data_structures::indexed_vec::Idx;
use rustc::mir::interpret::{GlobalId, Value, Scalar, EvalResult, Pointer, ScalarMaybeUndef};
use super::{EvalContext, Machine, ValTy};
use interpret::memory::HasMemo... |
extern crate log;
extern crate rand;
use go::Vertex;
use go::PASS;
use go::GoGame;
use go::Stone;
use go::stone;
use go::VIRT_LEN;
use rand::Rng;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::cmp;
use std::collections;
use std::cell;
use std::ops::Index;
mod zobrist;
use self::zobrist::BoardHasher;
use sel... |
use std::path::PathBuf;
use std::env;
use std::fs::DirBuilder;
use std::error::Error;
use std::fmt;
use std::io;
use std::io::prelude::*;
#[derive(Debug)]
pub enum ValidationError {
UserAbort,
TargetIsADir,
EnvError(io::Error),
BuildDirErr(io::Error),
}
impl Error for ValidationError {
fn descript... |
use crate::reader::Arg;
use crate::reader::Operation;
use crate::autodiff::autodiff::{OUTPUT_NAMES, AutoDiff};
use quote::{quote, format_ident};
use proc_macro2::TokenStream;
use syn::Ident;
use std::collections::HashMap;
pub struct Solver {
autodiff: AutoDiff,
curr_var: u32,
}
impl Solver {
pub fn new() ... |
use super::{Deserialize, Serialize};
use std::fmt;
#[derive(Serialize, Deserialize)]
pub struct Checksum256 {
pub value: [u8; 32],
}
impl Checksum256 {
pub fn to_string(&self) -> String {
let mut hex_string = String::from("");
for v in &self.value {
let hex = format!("{:02x}", v);
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.