text stringlengths 3.09k 13.9k |
|---|
#![no_main]
#![no_std]
extern crate cortex_m;
extern crate cortex_m_rt;
extern crate panic_abort;
extern crate stm32f042_hal as hal;
use cortex_m_rt::{entry, exception};
use hal::gpio::gpioa::{PA11, PA8};
use hal::gpio::gpiob::{PB0, PB1, PB4, PB5, PB6, PB7};
use hal::gpio::gpiof::{PF0, PF1};
use hal::gpio::{Output,... |
use indicatif::ProgressIterator;
use rayon::prelude::*;
use std::fmt;
use std::fs::File;
use std::io;
use std::io::BufRead;
use std::str;
use std::time::Instant;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
struct Word {
word: [u8; 5],
}
impl fmt::Display for Word {
fn fmt(&self, f: &mut fmt... |
use std::net::SocketAddr;
use std::{io::ErrorKind, sync::Arc};
use anyhow::anyhow;
use anyhow::Result;
use bytes::Bytes;
use futures::SinkExt;
use tracing::{debug, error};
use common::{
generate_uuid, AgentMessagePayloadTypeValue, MessageFramedGenerateResult, MessageFramedGenerator, MessageFramedRead, MessageF... |
//! An interface for dealing with the kinds of parallel computations involved in
//! `bellperson`.
use std::env;
use crossbeam_channel::{bounded, Receiver};
use lazy_static::lazy_static;
use yastl::Pool;
lazy_static! {
static ref NUM_CPUS: usize = read_num_cpus();
pub static ref THREAD_POOL: Pool = Pool::new... |
//! This example shows how to use the stencil buffer to implement a glowing effect when moving the cursor on the
//! triangle.
use crate::{
shared::{Semantics, Vertex, VertexColor, VertexPosition},
Example, InputAction, LoopFeedback, PlatformServices,
};
use luminance::UniformInterface;
use luminance_front::{
co... |
// Copyright 2020-2021 the Deno authors. All rights reserved. MIT license.
use crate::ast_parser::get_default_ts_config;
use crate::ast_parser::AstParser;
use crate::ast_parser::SwcDiagnostic;
use crate::context::Context;
use crate::control_flow::ControlFlow;
use crate::diagnostic::LintDiagnostic;
use crate::ignore_dir... |
#[cfg(all(test, not(target_os = "emscripten")))]
mod tests;
use crate::cell::UnsafeCell;
use crate::marker::PhantomPinned;
use crate::ops::Deref;
use crate::panic::{RefUnwindSafe, UnwindSafe};
use crate::pin::Pin;
use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed};
use crate::sys::locks as sys;
/// A re-entran... |
//! Easy-to-use java class file reader.
//!
//! # Example
//!
//! ```
//! use java_rs::ClassFile;
//!
//! # let bytes = include_bytes!("../Main.class");
//! let class_file = ClassFile::from_bytes(bytes).unwrap();
//!
//! println!("class name: {}\n super class name: {}", class_file.this_class(), class_file.super_class()... |
use std::sync::Arc;
use wasm_bindgen_futures::JsFuture;
use web_sys::console;
use web_sys::WebGlRenderingContext;
use web_sys::WebGlProgram;
use web_sys::WebGlUniformLocation;
use crate::error::GfxError;
use crate::memory::Memory;
use crate::shader::Shader;
use crate::types::MAX_CHAR;
pub struct Uniform {
nam... |
pub mod day_14 {
use std::collections::HashMap;
pub struct Data {
start: char,
end: char,
rules: HashMap<(char, char), char>,
}
pub(crate) fn parse(s: &str) -> (Data, HashMap<(char, char), u64>) {
let mut lines = s.split('\n');
let start = lines.next().unwrap()... |
use std::borrow::Borrow;
use std::collections::BTreeMap;
use indexmap::map::IndexMap as HashMap;
use indexmap::set::IndexSet as HashSet;
use json_deserializer::{Number, Value};
use crate::datatypes::*;
use crate::error::Result;
const ITEM_NAME: &str = "item";
/// Infers [`DataType`] from [`Value`].
pub fn infer(jso... |
pub mod output;
mod builder;
mod state;
pub use builder::TimerBuilder;
pub use output::Output;
pub use state::TimerState;
use std::thread::sleep;
use std::time::{Duration, Instant};
use crate::error::{ClimerError, ClimerResult};
use crate::settings::timer::*;
use crate::time::Time;
#[derive(Clone)]
pub struct Time... |
mod commands;
mod db;
mod dialogue;
mod utils;
use crate::db::RedisConnection;
use crate::dialogue::Dialogue;
use crate::utils::format_log_chat;
use std::sync::Arc;
use teloxide::prelude::*;
// TODO: get rid of using tokio's Mutex https://tokio.rs/tokio/tutorial/channels
use tokio::sync::Mutex;
#[tokio::main]
async f... |
#![warn(clippy::pedantic)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::needless_pass_by_value)]
use cosmwasm_std::{
to_binary, Api, Binary, Env, Extern, HandleResponse, InitResponse, Querier, StdError,
StdResult, Storage,
};
use crate::msg::{Credentials, HandleMsg, InitMsg, QueryMsg};
use crate::st... |
use super::scores::*;
use super::stopwords::STOPWORDS;
use super::structs::*;
use crate::searcher::*;
use crate::IndexFromFile;
use std::cmp::Ordering;
use std::collections::HashMap;
const EXCERPT_BUFFER: usize = 8;
const EXCERPTS_PER_RESULT: usize = 5;
const DISPLAYED_RESULTS_COUNT: usize = 10;
#[derive(Clone, Debug... |
use rlua::Context;
use rust_decimal::Decimal;
use core::{data_type::DataType, charter::{Constraint, ToleranceType}, lua::eval};
use crate::{model::{record::Record, schema::{Column, GridSchema}}, error::MatcherError, lua};
pub fn passes(
constraint: &Constraint,
records: &[&Record],
schema: &GridSchema,
... |
// Copyright 2020 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied,
// modified, or di... |
// Copyright 2020 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 {
assert_matches::assert_matches,
fidl_fuchsia_update_installer::{
InstallerMarker, InstallerProxy, InstallerRequest, InstallerRequestS... |
#[macro_use]
extern crate erlang_nif_sys;
use erlang_nif_sys::*;
use std::{mem, ptr};
use std::cmp::min;
use std::sync::atomic::{AtomicIsize, Ordering};
static mut RUSTMAP_TYPE: *const ErlNifResourceType = 0 as *const ErlNifResourceType;
static mut DTOR_COUNTER: Option<AtomicIsize> = None;
nif_init!("mynifmod", [
... |
use std::convert::TryInto;
use near_sdk::{
borsh::{self, BorshDeserialize, BorshSerialize},
collections::LookupMap,
ext_contract, near_bindgen,
setup_alloc, log, BorshStorageKey,
env, Promise, AccountId,
json_types::{ValidAccountId, U64, U128},
};
setup_alloc!();
pub type TokenId = String;
pu... |
use std::convert::TryFrom;
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::collections::{LookupMap};
use near_sdk::json_types::{U128, ValidAccountId};
use near_sdk::serde::{Deserialize, Serialize};
use near_sdk::{env, ext_contract, near_bindgen, AccountId, Gas, Balance, PanicOnDefault, Prom... |
use crate::object::*;
use crate::edge::*;
use crate::commander::*;
use crate::structure::*;
use std::io;
use postgres::{Error};
use itertools::Itertools;
pub struct CLI {
commander: Commander
}
impl CLI {
pub fn new(commander: Commander) -> CLI {
CLI {commander}
}
pub fn start(&mut self) -> ... |
use p256::PublicKey;
use crate::dh::DhKeyPair;
use alloc::vec::Vec;
use serde::{Serialize, Deserialize};
use crate::aead::encrypt;
use aes_gcm_siv::{Key, Nonce, Aes256GcmSiv};
use aes_gcm_siv::aead::{NewAead, AeadInPlace};
#[cfg(test)]
use crate::dh::gen_key_pair;
use alloc::string::{ToString, String};
use core::str::... |
use async_std::fs::File;
use async_std::prelude::*;
use async_std::stream::Stream;
use async_std::task::Context;
use futures::channel::mpsc::UnboundedReceiver as Receiver;
use std::collections::HashMap;
use std::pin::Pin;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
use std::sync::mpsc as sync_mps... |
use crate::{
player::{Player, PlayerDisplayState, PlayerId, PlayerInputCommand, PlayerSnapshot},
settings,
settings::RealField,
};
use bevy::prelude::*;
use crystalorb_bevy_networking_turbulence::crystalorb::{
command::Command,
fixed_timestepper::Stepper,
world::{DisplayState, World},
};
use nph... |
use bot::{
constants::{
API_DOCS_BOT_ID, API_DOCS_CHANNEL, ISSUE_BUTTON_EMOJI, ISSUE_MANAGEMENT_USERS,
REMOVE_BUTTON_EMOJI,
},
github::create_issues,
types::TwHttpClient,
};
use dotenv::dotenv;
use futures::stream::StreamExt;
use std::{env, error::Error, sync::Arc};
use twilight_gateway:... |
use crate::conf::GLOBAL_CONF;
use crate::conn::writer::Writer;
use crate::replica::replica::ReplicaMeta;
use crate::resp::Message;
use crate::server::{EventsConsumer, Server};
use crate::{now_secs, CstError, now_mil};
use nix::sys::wait::{waitpid, WaitPidFlag, WaitStatus};
use nix::unistd::Pid;
use tokio::fs::OpenOptio... |
//! Line regions for fixed boundary condition
//!
//! Data Layout
//! ------------
//!
//! - Open: `x_i = (i+1)L / (N+1)`
//! - Closed: `x_i = iL / (N-1)`, with fixed values `x_0 = x_L`, `x_{N-1} = x_R`
//!
//! These are used for implementing `Manifold` trait.
//!
//! ```ignore
//! xxx---------xxx Line<A, P3, Open>(N=... |
use log::*;
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
use crate::ir::*;
use crate::util::{ToSanitizedPascalCase, ToSanitizedSnakeCase, ToSanitizedUpperCase};
#[derive(Debug, Serialize, Deserialize)]
pub struct Sanitize {}
impl Sanitize {
pub fn run(&self, ir: &mut IR) -> anyh... |
use stakker::{ret, task::Task, task::TaskTrait, Core, Ret};
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
/// Spawn a `Future` and pass the final result to the given `Ret`
///
/// This call does not support the `std::task::Waker` mechanism which
/// might ... |
// Copyright (c) 2020 ESRLabs
//
// 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 agre... |
//! The trait wiring analyzer pass connects trait methods to their implementations.
//!
//! This pass also fills type parameter placeholder types (TPPTs) with method definition stubs
//! from their trait bounds.
use crate::analyzer::GlobalVisitor;
use crate::ast::TypeDef;
use crate::context::CompilerContext;
use crate... |
use num::BigUint;
use zksync_eth_signer::EthereumSigner;
use zksync_types::{
helpers::{closest_packable_fee_amount, is_fee_amount_packable},
tx::PackedEthSignature,
Address, Nonce, Token, TokenLike, TxFeeTypes, ZkSyncTx,
};
use crate::{
error::ClientError, operations::SyncTransactionHandle, provider::P... |
//! Day 12:
//! Another straightforward problem today. As usual, for these easier problems parsing
//! the data is expensive. Since the trig is only by 90 degrees, it is faster to just
//! directly handle the rotation matrix effects in part 2.
use crate::prelude::*;
// ------------------------------------------------... |
/***********************************************************************************************************************
* Copyright (c) 2019 by the authors
*
* Author: <NAME> <<EMAIL>>
* License: Apache License 2.0 / MIT
*********************************************************************************************... |
use std::thread;
use std::net::SocketAddr;
use std::net::ToSocketAddrs;
use std::collections::HashMap;
use std::sync::mpsc;
use std::sync::Arc;
use std::sync::Mutex;
use std::io;
use tokio_core::reactor;
use tokio_core::net::TcpListener;
use futures;
use futures::stream;
use futures::Stream;
use futures::Future;
use ... |
use parse::combinator::{identifier, many0, opt, separated_list, separated_nonempty_list, symbol};
use parse::id_gen::IdGen;
use parse::tpe::class;
use parse::tree::{
Annotated, AnnotatedParam, AnnotatedValue, AnnotatedValueArray, ClassType, EnclosingType,
MarkerAnnotated, NormalAnnotated, SingleAnnotated,
};
us... |
use crate::config::CONFIG;
use crate::resource::Resource;
use multimap::MultiMap;
use sophia::graph::{inmem::sync::FastGraph, *};
use sophia::iri::IriBox;
use sophia::ns::Namespace;
use sophia::parser::turtle;
use sophia::prefix::{PrefixBox, PrefixMap};
use sophia::term::Term;
use sophia::triple::stream::TripleSource;
... |
/// Transaction state management
use crate::common::errors::Error;
use crate::system::config::ConfigMt;
use crate::common::defs::ObjectId;
use crate::common::defs::Sequence;
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::Condvar;
use std::collections::HashSet;
use std::collections::HashMap;
use std::time::D... |
use std::{collections::HashMap, ffi::CString, ptr};
use gl::types::{GLint, GLchar};
use glam::{Vec4, Vec3, Mat4};
use super::resource_loader;
// "class fields"
pub struct ShaderProgram {
program_id: u32,
vertex_shader_id: u32,
fragment_shader_id: u32,
// the original java code should have been using h... |
//! This file defines `LPBoost` based on the paper
//! "Boosting algorithms for Maximizing the Soft Margin"
//! by Warmuth et al.
//!
use crate::{Data, Sample};
use crate::{Classifier, CombinedClassifier};
use crate::BaseLearner;
use crate::Booster;
use grb::prelude::*;
/// Struct `LPBoost` has one parameter.
/// ... |
//!
use std::path::Path;
/// The amount of retries to do during various aspects of the directory creation.
#[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq)]
pub struct Retries {
/// How many times the whole directory can be created in the light of racy interference.
/// This count combats racy situ... |
extern crate debugger;
extern crate guifuzz;
pub mod mesofile;
use std::path::Path;
use std::process::Command;
use std::collections::{HashMap};
use std::sync::{Arc, Mutex};
use std::fs::File;
use std::io::Write;
use std::time::{Instant, Duration};
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, H... |
//! Naive RSA implementation. Do not use.
use num::{Zero, One};
use num::bigint::BigUint;
// Adapted from https://github.com/jsanders/rust-rsa
fn mod_exp(base: &BigUint, exponent: &BigUint, modulus: &BigUint) -> BigUint {
let (zero, one): (BigUint, BigUint) = (Zero::zero(), One::one());
let mut result = one.... |
use super::geometry::{Direction, Vector2};
use super::hero::*;
use super::uniq::*;
use rand::prelude::*;
use std::fmt;
use serde::{Deserialize, Serialize};
/// Каждая клетка, которая может быть размещена на карте, должна быть внесена в данное перечисление
///
/// Через перечисление должна быть возможноть получить все ... |
///! There are two types of broadcast mechanisms.
///!
///! A simple broadcast mechanism just relays (sender, timestamp, message) triples,
///! possibly implementing rate limiting.
///!
///! A validating broadcast mechanism
///! * relays (sender, message) pairs,
///! * notifies the peers about timeout events (i.e.,... |
use super::*;
use gfx;
gfx_defines! {
pipeline pipe {
u_format: gfx::Global<i32> = "u_format",
s_y: gfx::TextureSampler<f32> = "s_y",
s_u: gfx::TextureSampler<f32> = "s_u",
s_v: gfx::TextureSampler<f32> = "s_v",
rt_color: gfx::RenderTarget<ColorFormat> = "rt_color",
}
}
... |
use advent::helpers;
use anyhow::{Context, Result};
use petgraph::graphmap::DiGraphMap;
use petgraph::visit::{Dfs, DfsPostOrder, Reversed, Walker};
use std::collections::HashMap;
type NodeName<'a> = &'a str;
type BagGraph<'a> = DiGraphMap<NodeName<'a>, u32>;
type BagCount = u32;
type NodeBagCounter<'a> = HashMap<NodeN... |
use chrono::Utc;
use dotenv::dotenv;
use env_logger;
use futures::Future;
use log;
use mongodb::coll::options::{FindOptions, UpdateOptions};
use mongodb::db::ThreadedDatabase;
use mongodb::{bson, doc, Bson};
use mongodb::{Client, ThreadedClient};
use regex::Regex;
use serde::Deserialize;
use std::env;
use tgbot::{
... |
use tract_core::context::Context;
use tract_core::model::ModelDsl;
use tract_core::ops::nn::ConvUnary;
use tract_core::ops::prelude::*;
use tract_core::optim::OptimizerPass;
use tract_core::*;
#[derive(Debug)]
pub struct TensorflowContext;
impl TensorflowContext {}
impl Context for TensorflowContext {
fn optimiz... |
extern crate fixedbitset;
use fixedbitset::FixedBitSet;
#[derive(Default)]
pub struct Graph {
cell_dimensions: (f32, f32),
even_line_buffer_active: bool,
even_rect_buffer_active: bool,
line_buffer_0: Vec<f32>,
line_buffer_1: Vec<f32>,
rect_buffer_0: Vec<f32>,
rect_buffer_1: Vec<f32>,
}
im... |
#![forbid(unsafe_code)]
#![warn(unused_results)]
#![cfg_attr(feature = "cargo-clippy", warn(empty_line_after_outer_attr))]
#![cfg_attr(feature = "cargo-clippy", warn(filter_map))]
#![cfg_attr(feature = "cargo-clippy", warn(if_not_else))]
#![cfg_attr(feature = "cargo-clippy", warn(mut_mut))]
#![cfg_attr(feature = "cargo... |
//! Traits for I/O.
//!
//! This module provides traits for reading embeddings
//! (`ReadEmbeddings`), memory mapping embeddings (`MmapEmbeddings`),
//! and writing embeddings (`WriteEmbeddings`).
use std::fs::File;
use std::io::{BufReader, Read, Seek, Write};
use failure::Error;
/// Read finalfusion embeddings.
///... |
use crate::encoders::{AudioEncoder, VideoEncoder};
use futures::future::BoxFuture;
use futures::stream::FuturesUnordered;
use futures::{FutureExt, StreamExt};
use gstreamer::bus::BusStream;
use gstreamer::prelude::*;
use gstreamer::{MessageView, Pipeline, State};
use mmids_core::workflows::MediaNotificationContent;
use... |
/*
build.rs
Copyright (c) 2019-2022 <NAME> All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the righ... |
//! WebSocket stream connection.
use chrono::prelude::*;
use futures::future::{self, Future, Loop};
use futures::prelude::*;
use websocket::{ClientBuilder, OwnedMessage, WebSocketError};
use websocket::async::TcpStream;
use websocket::client::async::{Client as WebSocketClient, TlsStream};
use market::{Events, Event, ... |
#![cfg_attr(not(test), no_std)]
#[cfg_attr(feature = "std", derive(Debug))]
#[cfg_attr(feature = "defmt_format", derive(defmt::Format))]
#[derive(serde::Serialize, serde::Deserialize, PartialEq, Default, Clone, Copy)]
pub struct AirQuality {
pub co2_concentration: f32,
pub temperature: f32,
pub humidity: f... |
use std::mem::swap;
use parking_lot::RwLock;
use {Error, Interned, NodeHandle, NodeMut, Result, Value, Vnodes};
#[derive(Derivative)]
#[derivative(Default(bound = ""))]
pub struct InternedMap<T> {
keys: Vec<u64>,
values: Vec<T>,
}
impl<T> InternedMap<T> {
pub fn new() -> Self {
Default::default(... |
// Copyright 2021 <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 writi... |
use std::{borrow::Cow, sync::Arc};
use gooey_core::{
figures::{Displayable, Figure, Point, Rect, Rectlike, Round, Size, Vector},
styles::{Alignment, ColorPair, FallbackComponent, Style, VerticalAlignment},
Scaled,
};
use gooey_renderer::{Renderer, TextMetrics};
/// A [`Text`](crate::Text) that has been me... |
use std::fs;
use std::collections::HashSet;
use std::io::Result;
use itertools::Itertools;
#[derive(Debug,Default,Clone)]
struct Item {
name: String,
sub_name: String,
missing: Vec<Item>,
}
impl PartialEq for Item {
fn eq(&self, other: &Self) -> bool {
if self.name != other.name { return false; }
if s... |
use std::{
io::{BufRead, BufReader, Read},
mem,
};
use thiserror::Error;
mod command;
mod script;
pub use script::{Command, Script};
#[derive(Debug, Clone)]
pub struct File {
lines: Vec<Vec<u8>>,
}
#[derive(Debug, Clone)]
enum Line<'a> {
Add(Vec<&'a Vec<Vec<u8>>>),
Delete,
Keep,
Replace(... |
use std::collections::HashSet;
use crate::config::command::MainCommand;
use crate::config::volumes::{PersistentInfo, Volume};
use crate::launcher::{Context, storage_dir};
fn _check_volumes<'x, I>(ctx: &Context, iter: I, result: &mut Vec<&'x String>)
where I: IntoIterator<Item=&'x Volume>
{
for vol in iter.i... |
use tuix::*;
use tuix::widgets::*;
fn calculate_winner(squares: &[GameData; 9]) -> GameData {
const LINES: [[usize; 3]; 8] = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[2, 4, 6],
];
for i in 0..LINES.len() ... |
//! Producer and consumer configuration.
//!
//! ## C library configuration
//!
//! The Rust library will forward all the configuration to the C library. The
//! most frequently used parameters are listed here.
//!
//! ### Frequently used parameters
//!
//! For producer-specific and consumer-specific parameters check t... |
// Copyright 2017 TiKV Project Authors. Licensed under Apache-2.0.
use std::sync::{mpsc::channel, Arc};
use std::thread;
use std::time::Duration;
use fail;
use grpcio::*;
use kvproto::kvrpcpb::{self, Context, Op, PrewriteRequest, RawPutRequest};
use kvproto::tikvpb_grpc::TikvClient;
use test_raftstore::{must_get_equ... |
use crate::types::{
Animation, File, InlineKeyboardMarkup, InputFile, Message, MessageEntity, User,
};
use crate::{bot::Bot, error::Result};
use serde::Serialize;
use serde_json;
#[must_use = "SendAnimation does nothing until you `send` it"]
#[derive(Serialize)]
pub struct SendAnimation<'a> {
#[serde(skip)]
... |
#[macro_use]
extern crate thiserror;
fn main() -> webview2_nuget::Result<()> {
// Uncomment this if it needs to update webview2 dependency
// let package_root = webview2_nuget::install()?;
// webview2_nuget::update_windows(package_root)?;
windows::build!(
Microsoft::Web::WebView2::Core::*,
... |
//! A command is the parsed representation of what the user types
//! in the input. It's independant of the state of the application
//! (verbs arent checked at this point)
use regex::Regex;
use termion::event::Key;
#[derive(Debug)]
pub struct Command {
pub raw: String, // what's visible in the input
... |
use crate::{db, fetch, State};
use chrono::prelude::*;
use chrono::{DateTime, Datelike, NaiveDate, Utc};
use std::cmp::Ordering;
use std::collections::{BTreeMap, HashMap};
use tide::http::mime;
use tide::{Body, Request, Response, Result};
use tracing::{info, info_span, warn_span};
pub type CurrentMarkets = HashMap<Str... |
#![allow(unstable)]
extern crate cql_ffi;
use std::slice;
use cql_ffi::*;
#[derive(Show)]
struct Basic {
bln:cass_bool_t,
flt:cass_float_t,
dbl:cass_double_t,
i32:cass_int32_t,
i64:cass_int64_t,
}
fn print_error(future:&mut CassFuture) {unsafe{
let message = cass_future_error_message(future... |
use super::utils::repo;
use crate::error::Result;
use git2::{Commit, Error, Oid};
use scopetime::scope_time;
use unicode_truncate::UnicodeTruncateStr;
/// identifies a single commit
#[derive(
Debug, Copy, Clone, PartialEq, Eq, Hash, Ord, PartialOrd,
)]
pub struct CommitId(Oid);
impl CommitId {
/// create new ... |
use specs::prelude::*;
use super::{Pools, SufferDamage, Player, Name, gamelog::GameLog, RunState, Position, Map,
InBackpack, Equipped, LootTable, Attributes, particle_system::ParticleBuilder};
use crate::gamesystem::{player_hp_at_level, mana_at_level};
pub struct DamageSystem {}
impl<'a> System<'a> for DamageSyst... |
use std::cmp::min;
use rand::SeedableRng as _;
use serenade::objective;
use serenade::config::AppConfig;
use std::io::{stdout, Write};
use indicatif::ProgressBar;
extern crate csv;
use csv::Writer;
pub fn convert_string_to_vec_i32(s: String) -> Vec<i32> {
return s
.replace(&['[', ']'][..], "")
.c... |
// Copyright 2019 Parity Technologies (UK) Ltd.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, mer... |
// Copyright © 2019 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
//! [Virtual Function I/O (VFIO) API](https://www.kernel.org/doc/Documentation/vfio.txt)
//!
//! Many modern system now provide DMA and interrupt remapping facilities to help ensure I/O
//! devices behave within the boundar... |
// Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// Copyright © 2019 Intel Corporation. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
//! Provides allocation and releasing strategy for IDs.
//!
//! This module implements an allocation strategies for all resource ... |
//! High-level CA interface.
use std::convert::TryFrom;
use std::sync::Arc;
use crate::dim::*;
use crate::ndtree::{NdTree, NodeRefTrait};
use crate::num::{BigInt, BigUint, Zero};
use crate::sim::rule::{DummyRule, NdRule};
use crate::sim::{hashlife, AsSimulate, Simulate};
/// 1D cellular automaton.
pub type Automaton... |
use crate::helpers::{
app_paths::{app_dir, tauri_dir},
config::{get as get_config, reload as reload_config},
manifest::rewrite_manifest,
Logger, TauriScript,
};
use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use shared_child::SharedChild;
use std::{
env::{set_current_dir, set_var},
ffi::Os... |
#[cfg(test)]
mod spec_tests;
use super::Memory;
use apu::{Apu, ApuContract};
use cpu::Interrupt;
use input::{Input, InputBase};
use ppu::{Ppu, PpuImpl};
use rom::NesRom;
use screen::NesScreen;
#[cfg(feature = "debugger")]
use seahash;
use std::io::Write;
use std::rc::Rc;
macro_rules! dma_tick {
( $mem : expr ) =... |
// https://devzone.nordicsemi.com/guides/short-range-guides/b/bluetooth-low-energy/posts/ble-characteristics-a-beginners-tutorial
// http://www.blesstags.eu/2018/08/services-characteristics-descriptors.html
// https://github.com/espressif/esp-idf/blob/master/examples/bluetooth/nimble/throughput_app/blecent_throughput/m... |
// This file is part of Substrate.
// Copyright (C) 2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// 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://... |
use crypto_market_type::MarketType;
use crate::{MessageType, Order, OrderBookMsg, TradeMsg, TradeSide};
use serde::{Deserialize, Serialize};
use serde_json::{Result, Value};
use std::collections::HashMap;
const EXCHANGE_NAME: &str = "kraken";
// https://docs.kraken.com/websockets/#message-trade
#[derive(Serialize, ... |
fn sort_cyclic_shifts(s: &[char]) -> Vec<usize> {
let n = s.len();
const ALPHABET: usize = 256;
let mut cnt = vec![0; n.max(ALPHABET)];
for &ch in s {
cnt[ch as usize] += 1;
}
for i in 1..ALPHABET {
cnt[i] += cnt[i - 1];
}
let mut p = vec![!0; n];
// p[i] := the index... |
use crate::client_transport::ClientTransport;
use crate::log;
use crate::parsers;
use crate::shared_config::SharedConfig;
use crate::upstream_proxy::UpstreamProxy;
use crate::init_error::InitError;
use std::clone::Clone;
use std::collections::HashMap;
use std::env;
use std::path;
/// This object is a handle to allow ... |
use enum_iterator::IntoEnumIterator;
use std::collections::HashSet;
use std::str::FromStr;
use helpers::input_lines;
const INPUT: &str = include_str!("../input.txt");
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
struct Point {
x: i64,
y: i64,
}
impl std::ops::Add for Point {
type Output = Self;
... |
#![allow(dead_code)]
use std::collections::HashMap;
struct DeterministicDice {
_current: u64,
_roll_count: u64,
}
trait Dice {
fn next(&mut self) -> u64;
fn roll_count(&self) -> u64;
}
impl DeterministicDice {
fn new() -> Self {
DeterministicDice {
_current: 0,
_ro... |
//! Private methods of the client.
use chrono::{DateTime, NaiveDate, Utc};
use getset::{CopyGetters, Getters, Setters};
use serde::{Deserialize, Deserializer, Serialize};
use uuid::Uuid;
use crate::amount::Amount;
mod auth;
mod exchange;
mod transactions;
mod user;
/// User information structure.
#[derive(Debug, Cl... |
use crate::msgs::codec::{Codec, Reader};
use crate::msgs::base::Payload;
use crate::msgs::alert::AlertMessagePayload;
use crate::msgs::ccs::ChangeCipherSpecPayload;
use crate::msgs::handshake::HandshakeMessagePayload;
use crate::msgs::enums::{ContentType, ProtocolVersion};
use crate::msgs::enums::{AlertLevel, AlertDes... |
use term::{self, StderrTerminal};
use super::errors::*;
use super::spec;
type Terminal = StderrTerminal;
pub trait Render {
fn render(&self, &mut Box<Terminal>) -> Result<()>;
}
impl Render for spec::Diagnostic {
fn render(&self, t: &mut Box<Terminal>) -> Result<()> {
self.level.set_attr(false, t)?... |
/*
* Copyright 2020, Offchain Labs, Inc. All rights reserved.
*/
//!Provides utilities used in the `postlink_compile` function
use super::ImportedFunc;
use crate::compile::CompileError;
use crate::mavm::{AVMOpcode, CodePt, Instruction, Label, Opcode, Value};
use crate::uint256::Uint256;
use std::collections::{HashM... |
use anyhow::Context as _;
use native_tls::{Certificate, TlsConnector};
use postgres_native_tls::MakeTlsConnector;
use std::sync::{Arc, Mutex};
use tokio::sync::{OwnedSemaphorePermit, Semaphore};
use tokio_postgres::Client as DbClient;
pub mod notifications;
pub mod rustc_commits;
const CERT_URL: &str = "https://s3.am... |
use std::f64::INFINITY;
use serde::{Deserialize, Serialize};
use super::AsModel;
use super::ModelMessage;
use crate::input_modeling::random_variable::BooleanRandomVariable;
use crate::simulator::Services;
use crate::utils::error::SimulationError;
use crate::utils::{populate_history_port, populate_snapshot_port};
///... |
use super::client::{IncomingEvent, JanusClient, PollResult, SessionId};
use crate::{
db::{agent_connection, janus_backend, ConnectionPool},
util::spawn_blocking,
};
use anyhow::anyhow;
use diesel::Connection;
use std::{
collections::{hash_map::Entry, HashMap},
sync::{
atomic::{AtomicBool, Orderi... |
// Copyright 2021 Open Information Security Foundation
//
// MIT License.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
//... |
use regex::Regex;
use std::{
collections::{HashMap, HashSet},
fs,
ops::Range,
};
type Ticket = Vec<usize>;
#[derive(Debug, Clone, PartialEq)]
struct Ranges {
range1: Range<usize>,
range2: Range<usize>,
}
#[derive(Debug)]
struct Note {
fields: HashMap<String, Ranges>,
ticket: Ticket,
n... |
// 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.
//! Common utilities used by directory related tests.
//!
//! Most assertions are macros as they need to call async functions themselves. As a typical tes... |
// Code liberally borrowed from here
// https://github.com/navierr/coloriz
use std::ops;
use std::u32;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Rgb {
/// Red
pub r: u8,
/// Green
pub g: u8,
/// Blue
pub b: u8,
}
impl Rgb {
/// Creates a new [Rgb] color
#[inline]
pub c... |
/**
* [218] The Skyline Problem
*
* A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return the skyline formed by these buildings collectively.
* The geometric information of each build... |
use crate::u32_sum_all_nibs;
#[cfg(test)]
use proptest::{
arbitrary::{any, Arbitrary},
strategy::{BoxedStrategy, Strategy},
};
use std::{
cmp, fmt,
hash::{Hash, Hasher},
ops,
};
/// A compressed representation of a multiset (a set with potential duplicates
/// of the same item), that can store up t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.