text
stringlengths
3.09k
13.9k
use more_asserts::assert_gt; use std::{env, process}; use std::convert::TryInto; use wasi_tests::open_scratch_directory; unsafe fn test_file_pread_pwrite(dir_fd: wasi::Fd) { // Create a file in the scratch directory. let file_fd = wasi::path_open( dir_fd, 0, "file", wasi::OFLAGS...
//! TLS configuration for [Sender](crate::Sender) //! //! Provides common configuration for TLS connection to Zabbix Server and Zabbix Proxy. //! Implementations are private submodules of this module (e.g. `rustls`, `openssl`). //! //! To configure encrypted communication with Zabbix, a [TlsConfig] struct is created, u...
use super::*; /// get node-ids by brute-force #[allow(dead_code)] pub fn get_closest_point_stupid(node: Node, nodes: &[Node]) -> usize { let mut tmp_minimum = std::f32::MAX; let mut tmp_closeset = INVALID_NODE; for (i, n) in nodes.iter().enumerate() { let dist = calc_distance(node, *n); if ...
use crate::graph::Graph; use bit_set::BitSet; use bimap::BiMap; pub struct Preprocessor{} impl Preprocessor { /// Removes all leaves *v* of *g* as long as the neighbor of *v* is adjacent to another leaf. /// Returns the shrunken graph *h* (a copy, *g* itself is not directly modified) and an isomorphism betwee...
// Load OS-specific modules use std::{env, ffi::OsStr, ffi::OsString, fs, os::unix::ffi::OsStrExt, path::Path, path::PathBuf, process::Command}; pub fn get_data_file_path(data_file: &str) -> PathBuf { let data_path: String = String::from("/opt/W...
// Copyright 2022 <NAME>. // // 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 writ...
use std::io::{BufRead, Write}; use std::path::PathBuf; use std::result::Result; use std::str; use chrono::DateTime; use chrono::Local; use chrono::NaiveDate; use structopt::StructOpt; use crate::error::TTError; use crate::utils::FileProxy; use self::subcommands::add::AddOpt; use self::subcommands::report::ReportOpt;...
#![allow(proc_macro_derive_resolution_fallback, unused_attributes)] use std::{fs::File, io::Write, sync::Arc, time::Duration}; use chat_params::ChatParams; use error::{ActionExtractorError, InitError, PollerError}; use params_extractor::{ExtractingResult, ParamsExtractor}; use shared::{ http_client::{HttpClient, ...
use std::{ collections::HashMap, fs::File, io::Write, mem, path::PathBuf, sync::{ atomic::{AtomicU64, Ordering}, Arc, }, thread::sleep, time::{Duration, Instant}, }; use iota::iota; use rustc_hash::FxHashMap; use crate::utils::stop_soon; iota! { // Over...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Watchdog Load"] pub load: LOAD, #[doc = "0x04 - Watchdog Value"] pub value: VALUE, #[doc = "0x08 - Watchdog Control"] pub ctl: CTL, #[doc = "0x0c - Watchdog Interrupt Clear"] pub icr: ICR, #[doc = "0x10 ...
#[derive(Clone, PartialEq, ::prost::Message)] pub struct Int32Stats {} #[derive(Clone, PartialEq, ::prost::Message)] pub struct Int64Stats {} #[derive(Clone, PartialEq, ::prost::Message)] pub struct Float64Stats {} #[derive(Clone, PartialEq, ::prost::Message)] pub struct StringStats {} #[derive(Clone, PartialEq, ::pros...
use crate::tagvalue::SerializeField; use crate::Buffer; const LEN_IN_BYTES: usize = 8; /// Concrete value for [`DataType::LocalMktDate`](crate::DataType::LocalMktDate) /// and [`DataType::UTCDateOnly`](crate::DataType::UtcDateOnly) fields. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct DtfDate { year: u3...
use proc_macro::TokenStream; use quote::quote; use syn::{parse_macro_input, DeriveInput}; mod utils; use utils::*; /// Derive macro for the Builder Design Pattern. /// /// # Examples /// /// ```rust /// # use derive_builder::Builder; /// /// # fn main() { /// #[derive(Builder)] /// pub struct Command { /// executa...
// 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::sync::Arc; use anyhow::{format_err, Error}; use fidl::endpoints::{create_proxy, ClientEnd, RequestStream}; use fidl_fuchsia_ui_app::ViewProviderM...
use std::path::{Path, PathBuf}; /// Parses the next value in the given string. `value` is left at the next value. Parsed value is returned. pub fn parse_next_value(string: &mut &str) -> Option<String> { let bytes = string.as_bytes(); let mut offset = 0; while offset < bytes.len() { if bytes[offset...
use super::common::{b, s, LastBlock, SIGMA}; use crate::cryptoutil::{read_u32v_le, read_u64v_le}; macro_rules! G { ($conmod:ident, $r:expr, $i:expr, $a:expr, $b:expr, $c:expr, $d:expr, $m:expr) => { $a = $a.wrapping_add($b).wrapping_add($m[SIGMA[$r][2 * $i + 0]]); $d = ($d ^ $a).rotate_right($conmo...
mod auth; mod manager; #[macro_use] extern crate magic_crypt; #[macro_use] extern crate prettytable; use ansi_term::Color::{Green, Purple, Red, Yellow}; use dirs::home_dir; use manager::Item; use prettytable::Table; use rpassword; use serde_json; use std::collections::HashMap; use std::{env, fs}; type DB = HashMap<St...
use frame_support::{ construct_runtime, dispatch::DispatchResult, dispatch::Weight, parameter_types, sp_io, traits::{GenesisBuild, SortedMembers}, PalletId, }; use frame_system::{EnsureRoot, EnsureSignedBy}; use orml_traits::XcmTransfer; use sp_core::H256; use sp_runtime::{ testing::Header,...
//! # Boiler - Multi-language Code Preprocessor & Module Loader //! It's like webpack for everything! It grabs a file with the name //! specified in whatever is being boiled's 'recipe' section. //! Checks the same folder for a .boil, then the global folder for a .boil. //! Copyright (c) 2017 <NAME> extern crate regex;...
use std::{pin::Pin, sync::Arc, task::Context}; use anyhow::Error; use graph::{ blockchain::{ block_stream::{ BlockStream, BlockStreamEvent, BlockWithTriggers, ScanTriggersError, TriggersAdapter, }, Block, BlockHash, Blockchain, DataSource, IngestorAdapter as IngestorAdapterTrait...
// wengwengweng use dirty::*; use gfx::shapes; use input::Key; use math::noise::*; struct Game { tex: gfx::Texture, noise_type: NoiseType, seed: u8, } #[derive(Clone, Copy, PartialEq, Debug)] enum NoiseType { Perlin, OpenSimplex, SuperSimplex, Fbm, Billow, Worley, RidgedMulti, Turbulence, } impl NoiseTy...
use rand::{RngCore, Rng}; use crate::generator::types::{VisibleWorld, Feature}; use nalgebra::{Vector3}; use crate::generator::calculate_prefabs_spawn_bounds::{calculate_prefabs_spawn_bounds}; /// Randomizes a shift with which all the entities belonging to this feature will be spawned. This /// function makes sure tha...
use autograd::{Variable, VariableArgs, VarAccess}; use tensor::{NumLimits, Tensor}; use std::slice::{Iter, IterMut}; use torch; use itertools::zip; type Var64List = Vec<Variable<f64>>; type Layer = fn(&Var64List) -> Var64List; type PartialLayer = FnMut(&Var64List) -> Tensor<f64>; pub fn contiguous(v: &Var64List) -> ...
use bytesize::ByteSize; use futures::{future, FutureExt}; use http::request::Parts; use hyper::{header, upgrade::Upgraded, Body, Method}; use regex::Regex; use reqwest::Client; use tokio::{ io, net::{lookup_host, TcpStream}, task, time, }; use std::{net::SocketAddr, time::Duration}; use super::exception::...
use crate::wxa::img::{post_img_data, Pos, WH}; use crate::{error::SdkError::InvalidParams, wechat::WxApiRequestBuilder, SdkResult}; use serde::{Deserialize, Serialize}; pub use crate::wxa::img::ImgData; #[derive(Debug, Serialize, Deserialize)] pub struct Id { pub id: String, } #[derive(Debug, Serialize, Deserial...
//! This crate provides a parser/formatter for the [HTTP version //! field](https://tools.ietf.org/html/rfc7230#section-2.6) found in the //! request/response [start line](https://tools.ietf.org/html/rfc7230#section-3.1). //! //! ## Example //! //! ```rust //! use uhttp_version::HttpVersion; //! use std::io::Write; //!...
use std::fmt; use super::{Selection, Shortcut}; #[rustfmt::skip] #[derive(Debug, PartialEq, Clone)] pub enum Element { // 0 1 2 3 4 5 6 7 8 9 H, He, Li, Be, B, C, N, O, F, // 0 Ne, Na, Mg, Al, Si, P, S, Cl, Ar, K, // 1 Ca, Sc, Ti, V, Cr, Mn, Fe, Co, Ni, Cu, // 2 Zn, Ga...
//! The Color module might be the only portable structure here. These are //! defined over and over in game code. //! //! This struct has 4 values: r,g,b,a components describing a color. //! You can create a new color from ```Color::new(color: &str)``` where ```color``` //! is a string in one of the following form...
use cast::{u64, u8}; use codemap::CodeMap; use codemap_diagnostic::{ColorConfig, Diagnostic, Emitter, Level, SpanLabel, SpanStyle}; use serde::Deserialize; use serde_taml::de::{from_taml_str, EncodeError}; use std::{borrow::Cow, io::stdout, iter}; use taml::diagnostics::{DiagnosticLabel, DiagnosticLabelPriority, Diagno...
use std::path::{PathBuf, Path}; use std::fs::{self, File}; use std::io; use std::env; use std::net::Ipv4Addr; use dirs; use serde::{Serialize, Deserialize}; use prettytable::{Table, Row, Cell}; use crate::server::Server; #[derive(Debug, Serialize, Deserialize)] pub struct Manager { pub servers: Vec<Server>, ...
use nom::{ branch::alt, bytes::complete::{tag, tag_no_case}, character::complete::*, combinator::*, multi::*, sequence::*, IResult, }; use std::str::FromStr; use nom_locate::{position, LocatedSpanEx}; use crate::grammer::*; pub type Span<'a> = LocatedSpanEx<&'a str, &'a str>; fn register(i: Span) -> IResult...
// Copyright 2018-2019 Mozilla // // 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, sof...
use ages_ice_archive::{Group, IceArchive, IceGroupIter}; use std::error::Error; use std::fs::File; use std::path::{Path, PathBuf}; use anyhow::Context; use structopt::StructOpt; #[derive(Debug, StructOpt)] #[structopt(name = "agesdeice", about = "Tool for unpacking PSO2 ICE archives.")] struct Args { #[structopt...
fn muttest1() { let v1 = 1; // immutable なので破壊的操作ができない // v1 += 10; // immutable binding なので再束縛できない // v1 = 2; println!("muutest1 {:?}", v1); // let はできる let v1 = 2; println!("muutest1 {:?}", v1); } fn muttest2() { { let mut v1 = 1; let p1 = &1; println!("muutest2 *p1...
//! Module for defining the allocator interface and its traits. //! //! This type actually has a top-level trait (`Allocator`), but most of its //! functionality is still split up into traits. //! pub use self::phantom::PhantomAllocator; use std::marker::PhantomData; use derivative::Derivative; use crate::{ err...
// Copyright 2022 <NAME> // SPDX-License-Identifier: Apache-2.0 use std::fmt::Debug; use async_trait::async_trait; use chronicle::{ db::model::stardust::block::BlockId, runtime::{Actor, ActorContext, ActorError, Addr, HandleEvent, Report, SpawnActor}, }; use inx::{client::InxClient, proto::NoParams, tonic::Ch...
#![feature(map_first_last)] use rayon::prelude::*; use crate::utils; use std::collections::BTreeSet; use std::collections::{LinkedList, VecDeque}; use std::iter::FromIterator; use std::time::SystemTime; use std::cmp::{max, min}; use std::thread; type Cup = u32; // type Cups = LinkedList<Cup>; type Cups = Vec<Cup>; /...
use crate::api::theme::HtmlTheme; use crate::api::HtmlContext; use crate::template::Template; use crate::theme::Theme; use handlebars::{Context, Handlebars, Helper, HelperDef, Output, RenderError}; use pulldown_cmark::{html, Event, Parser}; use regex::{Captures, Regex}; use serde::Serialize; use std::cmp::Ordering; us...
use rt; use memory; use memory::kernel::PhysAddr; use core::mem; use core::slice; use core::str; const ATAG_NONE: u32 = 0x00000000; const ATAG_CORE: u32 = 0x54410001; const ATAG_MEM: u32 = 0x54410002; const ATAG_VIDEOTEXT: u32 = 0x54410003; const ATAG_RAMDISK: u32 = 0x54410004; const ATAG_INITRD2: ...
use crate::image::Image; use crate::lerp::Lerp; pub trait Interpolation<T: Lerp> { fn interpolate(&self, image: &Image<T>, x: f64, y: f64) -> T; } pub trait AudioInterpolation<T> { fn interpolate(&self, audio_slice: &[T], x: f64) -> T; } pub struct NearestNeighbor; impl<T: Lerp> Interpolation<T> for Nearest...
//! Scrabble AI implementation. use crate::{ ai::movegen::GeneratedPlay, game::{board::Board, play::Play, rack::Rack, Game, GameStatus}, util::{self, fsm::Fsm}, }; use rand::Rng; pub mod lookup; pub mod movegen; /// The weighting of the proportional length difference in the score. const LEN_WEIGHT: f32 =...
//! Interface to the Power control (PWR) peripheral //! //! See STM32L0x2 reference manual, chapter 6. use cortex_m::{ asm, peripheral::SCB, }; use crate::{ pac, rcc::{ ClockSrc, PLLSource, Rcc, }, }; /// Entry point to the PWR API pub struct PWR(pac::PWR); impl PWR { ...
use twitchchat::{Writer, commands::PrivMsg, commands::Join}; use std::time::{Duration, Instant}; use std::collections::HashMap; use std::error::*; use serde::{Serialize, Deserialize}; use std::fs::{self, File}; use std::io::prelude::*; use regex::Regex; use reqwest; use log::*; /// Data structure for representing when...
// Note: for StreamSocket, the client uses a server socket, the server uses a client socket. // This is because of certificate management. The server needs to trust a client and its certificate mod quic; mod tcp; mod udp; use super::*; use crate::{data::*, *}; use bytes::{ buf::{BufExt, BufMutExt}, Bytes, Byt...
// Copyright (c) The diem-devtools Contributors // SPDX-License-Identifier: MIT OR Apache-2.0 //! Support for partitioning test runs across several machines. //! //! At the moment this only supports a simple hash-based sharding. In the future it could potentially //! be made smarter: e.g. using data to pick different ...
use std::collections::HashMap; use std::fs::{create_dir, File}; use std::io; use std::io::{Read, Write}; use std::net::{TcpListener, TcpStream}; use std::path::{Path, PathBuf}; use std::process::{Child, Command, Stdio}; use std::thread::sleep; use std::time::Duration; use tempfile::{tempdir, TempDir}; fn get_unused_po...
use std::fmt; use std::fs::File; use std::io; use std::path::Path; use std::time; use csv; use failure::ResultExt; use fst; use memmap::Mmap; use crate::error::{Error, ErrorKind, Result}; /// The TSV file in the IMDb dataset that defines the canonical set of titles /// available to us. Each record contains basic inf...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - master control register"] pub mcr: crate::Reg<mcr::MCR_SPEC>, #[doc = "0x04 - master status register"] pub msr: crate::Reg<msr::MSR_SPEC>, #[doc = "0x08 - transmit status register"] pub tsr: crate::Reg<tsr::TSR_SPEC...
use std::rc::Rc; use crate::ast::Atom; use crate::ast::AtomCache; use crate::ast::Exp; pub fn modulate(list: &Exp) -> String { let mut buffer = String::new(); modulate_mut(list, &mut buffer); buffer } fn modulate_mut(list: &Exp, buffer: &mut String) { if let Exp::Atom(Atom::Nil) = list { buff...
use charlie_buffalo as cb; const LOG_FILE_PATH: &str = "logs.msgpack"; #[allow(unreachable_code)] fn main() { std::fs::write(LOG_FILE_PATH, "").unwrap(); let logger = cb::concurrent_logger_from(cb::Logger::new( cb::new_dispatcher(Box::from(dispatcher)), cb::new_dropper(Box::from(dropper)) )); let logger_for...
use convert_case::{Case, Casing}; use gekko_metadata::{parse_hex_metadata, ModuleMetadataExt}; use proc_macro::TokenTree; use proc_macro2::TokenStream; use quote::{format_ident, quote}; use std::collections::HashMap; use std::fs::read_to_string; #[proc_macro_attribute] pub fn parse_from_hex_file( args: proc_macro:...
use crate::common::{ bnfcore::is_token_char, errorparse::SipParseError, hostport::HostPort, nom_wrappers::{from_utf8_nom, take_quoted_string, take_sws, take_while_trim_sws}, take_sws_token, }; use alloc::collections::btree_map::{BTreeMap, Keys}; use nom::{bytes::complete::take_while, multi::many0}; ...
/* origin: FreeBSD /usr/src/lib/msun/src/e_log2.c */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunSoft, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freel...
use std::sync::Arc; use cursive::{ traits::Finder, view::{Selector, ViewWrapper}, views::{HideableView, LinearLayout, NamedView, PaddedView, TextView}, Vec2, View, }; use indexmap::IndexSet; use log::debug; use smol_str::SmolStr; use super::tag_view::TagView; use crate::{model::MessageGroup, util::Dir...
use ff::{BitIterator, PrimeField, PrimeFieldRepr}; use fil_sapling_crypto::pedersen_hash; use paired::bls12_381::{Bls12, Fr}; use rand::Rng; use crate::crypto; use crate::error; use crate::fr32::{bytes_into_fr, fr_into_bytes}; use crate::hasher::pedersen::{PedersenDomain, PedersenFunction, PedersenHasher}; use crate::...
// Copyright (C) 2020 <NAME> <<EMAIL>> // This file is subject to the terms and conditions defined in // file 'LICENSE', which is part of this source code package. use anyhow::{anyhow, Result}; use std::collections::BTreeMap; use std::collections::BTreeSet; use std::io::{stdin, BufRead}; // Ingredient, Allergen: inte...
use crate::{ driver::Driver, events::{Event, EventContext, EventData, EventHandler, TrackEvent}, input::Input, tracks::{self, Track, TrackHandle, TrackResult}, }; use async_trait::async_trait; use parking_lot::Mutex; use std::{collections::VecDeque, sync::Arc}; use tracing::{info, warn}; #[derive(Defau...
// LNP Node: node running lightning network protocol and generalized lightning // channels. // Written in 2020 by // Dr. <NAME> <<EMAIL>> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This ...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - EVTIMER Low Register"] pub evtimerl: EVTIMERL, #[doc = "0x04 - EVTIMER High Register"] pub evtimerh: EVTIMERH, #[doc = "0x08 - Local Capture Low Register for CPUn"] pub capturen_l: CAPTUREN_L, #[doc = "0x0c - Lo...
use serde::Deserialize; use async_std::task; use std::env; use std::time::{Duration, SystemTime}; use webhook::Webhook; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { // Only initializes if `SENTRY_DSN` env var is set with a valid DSN. let _guard = sentry::init(sentry::ClientOptions...
use pool::{self, Pool, Lifecycle, MAX_FUTURES}; use task::Task; use std::sync::Arc; use std::sync::atomic::Ordering::{AcqRel, Acquire}; use tokio_executor::{self, SpawnError}; use futures::{future, Future}; /// Submit futures to the associated thread pool for execution. /// /// A `Sender` instance is a handle to a s...
use std::env; use std::ffi::OsString; use std::path::PathBuf; use std::process::Command; use BaseDirs; use UserDirs; use ProjectDirs; use unix; pub fn base_dirs() -> Option<BaseDirs> { if let Some(home_dir) = unix::home_dir() { let cache_dir = env::var_os("XDG_CACHE_HOME") .and_then(is_absolute_pat...
use anyhow::Error; use chrono::{DateTime, NaiveDateTime, Utc}; use serde::{Deserialize, Serialize}; use stack_string::StackString; use std::{ collections::{BTreeMap, BTreeSet}, convert::{TryFrom, TryInto}, fmt, }; use tokio::process::Command; #[derive(Default, Clone)] pub struct SystemdInstance { servi...
//! Mid-level text composition interface. use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use std::{marker, mem}; use crate::{ colour, error, font, metrics, render, resource::{self, Map}, }; /// A formatted text renderer. /// /// This type serves both as a builder for laying out...
use std::collections::HashMap; use std::sync::{Arc, RwLock}; // pyo3 modules use crate::types::PyFunction; use pyo3::prelude::*; use pyo3::types::PyAny; use actix_web::http::Method; use dashmap::DashMap; use matchit::Node; /// Contains the thread safe hashmaps of different routes pub struct Router { get_routes: ...
use aoc_runner_derive::{aoc, aoc_generator}; use regex::Regex; use std::ops::RangeInclusive; #[aoc_generator(day21)] pub fn input_generator(input: &str) -> (u8, u8) { let re1 = Regex::new("Player 1 starting position: ([0-9]+)").unwrap(); let re2 = Regex::new("Player 2 starting position: ([0-9]+)").unwrap(); ...
//! This module implements secrets in the form of protected memory. use crate::errors::InvalidPrivateKey; use ethcontract_common::hash; use secp256k1::key::ONE_KEY; use secp256k1::{Message, PublicKey, Secp256k1, SecretKey}; use std::fmt::{self, Debug, Formatter}; use std::ops::Deref; use std::str::FromStr; use web3::s...
// Copyright (c) Aptos // SPDX-License-Identifier: Apache-2.0 use crate::persistent_liveness_storage::PersistentLivenessStorage; use aptos_crypto::ed25519::Ed25519Signature; use aptos_logger::prelude::info; use aptos_metrics::monitor; use aptos_types::{ epoch_change::EpochChangeProof, ledger_info::{LedgerInfo,...