text stringlengths 3.09k 13.9k |
|---|
#[derive(Copy, Clone, Debug)]
pub struct Matrix2D {
pub a: f64,
pub b: f64,
pub c: f64,
pub d: f64,
pub e: f64,
pub f: f64,
}
pub enum Matrix2DTransformError {
DeterminantIsZero,
}
impl Matrix2D {
pub fn new() -> Matrix2D {
Matrix2D {
a: 1f64,
b: 0f64,
c: 0f64,
d: 1f64,
... |
use super::{parse_input, Output};
use regex::Regex;
use std::cmp::Ordering;
use std::collections::HashMap;
lazy_static! {
static ref RE: Regex = Regex::new(r"#(\d+)").unwrap();
}
const INPUT: &str = "day4.txt";
#[derive(Debug, Default)]
struct Guard {
last_operation: Operation,
id: Option<usize>,
slep... |
//! Wrapper to handle closing async tasks in a concurrent way.
use std::{
future::Future,
panic,
pin::Pin,
sync::Arc,
task::{Context, Poll},
};
use futures_channel::oneshot::{self, Receiver, Sender};
use futures_util::FutureExt;
use parking_lot::Mutex;
use tokio::task::{JoinError, JoinHandle};
use crate::error;... |
#![no_std]
#![deny(missing_docs)]
#![cfg_attr(test, deny(warnings))]
//! # Random-fast-rng
//!
//! This crate provides a fast **non cryptographic** random number generator that implements the [`Random`](trait.Random.html) trait. <br>
//! Currently it's implemented using the `Pcg32` algorithm, that generates 32 bit of ... |
use super::{
app::{self, APP_NAME},
make_error,
message::{self, Message},
r#type::{Color, ColorChannel, Coord, RawTime, TimeUnit, Vector},
shared_access, Error, Result, Shared,
};
use css_color_parser::Color as CssColor;
use lazy_static::lazy_static;
use rustyline::{
completion::Completer,
c... |
use internal::search::binary_search_function;
use rank::{BitRankSupport, RankSupport};
use space_usage::SpaceUsage;
use bit_vec::BitVec;
use super::{SelectSupport, Select1Support, Select0Support};
/// Performs a select query by binary searching rank queries.
pub struct BinSearchSelect<Rank> {
rank_support: Rank,
}... |
use rand::distributions::WeightedIndex;
use rand::prelude::*;
use rayon::prelude::*;
use solhop_types::{Clause, LBool, Lit, Solution};
use std::fs::File;
use std::io;
/// Magic numbers used by local search.
const C_MAKE: f32 = 0.5;
const C_BREAK: f32 = 3.7;
/// Scoring function type.
pub enum ScoreFnType {
/// Ch... |
use conrod_core::color::Color;
pub const DARK_THEME: Theme = Theme::const_default();
pub const LIGHT_THEME: Theme = Theme {
text_primary: OXFORD_BLUE,
text_secondary: MINT_CREAM,
text_light: MINT_CREAM,
text_dark: OXFORD_BLUE,
background: MINT_CREAM,
panel_dark: INDEPENDANCE,
panel_light:... |
use std::collections::HashMap;
pub fn mct_from_leaf_values(arr: Vec<i32>) -> i32 {
//mct_inner_help(&arr, 0, arr.len()).1
let mut record = HashMap::new();
mct_inner_help(&arr, 0, arr.len(), &mut record).1
}
// return largest element and non-leaf node
// fn mct_inner_help(a: &Vec<i32>, start_ind: usize, len... |
use std::io;
use strum_macros::EnumIter;
#[path = "../../src/toot_and_otto/player.rs"]
mod player;
use player::Player;
#[path = "../../src/connect4/connect4.rs"]
mod connect4;
use connect4::Connect4;
#[path = "../../src/connect4/piece_color.rs"]
mod piece_color;
use piece_color::PieceColor;
#[path = "../../src/conne... |
use {
super::{define, errors::MpegTsError},
bytes::BytesMut,
bytesio::bytes_writer::BytesWriter,
};
#[derive(Debug, Clone)]
pub struct Pes {
pub program_number: u16,
pub pid: u16,
pub stream_id: u8,
pub codec_id: u8,
pub continuity_counter: u8,
pub esinfo: BytesMut,
pub esinfo_l... |
// Copyright 2017 <NAME> (IRCAM)
// 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 wri... |
use std::{borrow::Cow};
use serde::forward_to_deserialize_any;
use super::{
tokenizer::{TokenContent, Tokenizer},
ParserError, ParserErrorKind, Token,
};
impl<'src> serde::Deserializer<'src> for &'_ mut Tokenizer<'src> {
type Error = ParserError;
fn deserialize_any<V>(self, visitor: V) -> Result<V::... |
use ordermap::OrderMap;
use std::hash::Hash;
use parser::Spanning;
use ast::{InputValue, ToInputValue};
/// Serializable value returned from query and field execution.
///
/// Used by the execution engine and resolvers to build up the response
/// structure. Similar to the `Json` type found in the serialize crate.
//... |
extern crate matrix_bot_api;
use matrix_bot_api::ActiveBot;
extern crate fractal_matrix_api;
use fractal_matrix_api::util::{media_url, put_media};
extern crate reqwest;
use url::Url;
// Just used for loading the username, password and homeserverurl from a file.
extern crate config;
// Just used for rolling dice
ext... |
use super::*;
use ::parser;
use ::translate;
use ::translate::symtab;
use ::lexer::mem_reader;
use ::arch::inst::register;
// Test cpu state (registers and stuff) after execution through binary from translate
#[test]
fn test_cpu() {
let mut m = MockMachine {
cpu: Cpu::new(),
bus: MockBus { addr:... |
//! Parsing utilities for postal addresses.
//!
//! # Examples
//!
//! ```
//! use rustpostal::{address, LibModules};
//! use rustpostal::error::RuntimeError;
//!
//! fn main() -> Result<(), RuntimeError> {
//! let postal_module = LibModules::Address;
//! postal_module.setup()?;
//!
//! let address = "St Jo... |
use crate::MLTT;
use actix_web::{get, HttpResponse, Responder};
use r2d2_redis::redis::Commands;
use rbatis::core::db::DBExecResult;
use rbatis::crud::{CRUDMut, CRUD};
use rbatis::crud_table;
use rbatis::executor::RbatisExecutor;
use rbatis::html_sql;
use rbatis::py_sql;
use rbatis::rb_py;
use rbatis::rbatis::Rbatis;
u... |
extern crate pest;
#[macro_use]
extern crate pest_derive;
use pest::Parser;
use regex::Regex;
use std::collections::HashSet;
use std::io::{stdin, Read};
#[derive(Parser)]
#[grammar = "notes.pest"]
struct NotesParser;
#[derive(Debug)]
enum Position {
Uninitialized,
Candidates(HashSet<usize>),
Determined(u... |
use super::{boards, notes, oauth, users};
use actix_cors::Cors;
use actix_session::CookieSession;
use actix_web::{middleware::Logger, App, HttpServer};
use diesel::{
pg::PgConnection,
r2d2::{ConnectionManager, Pool},
};
use oauth2::{basic::BasicClient, AuthUrl, ClientId, ClientSecret, RedirectUrl, TokenUrl};
us... |
// Copyright (c) The XPeer Core Contributors
// SPDX-License-Identifier: Apache-2.0
//! Interface between Mempool and Network layers.
use crate::{
error::NetworkError,
interface::{NetworkNotification, NetworkRequest},
proto::MempoolSyncMsg,
protocols::direct_send::Message,
validator_network::Event... |
//! # Prices Module
//!
//! ## Overview
//!
//! The data from Oracle cannot be used in business, prices module will do some
//! process and feed prices for Minterest. Process include:
//! - specify a fixed price for stable currency;
//! - feed price in USD;
//! - lock/unlock the price data get from oracle.
#![cf... |
// Copyright 2018 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
use std::cell::RefCell;
use std::fmt::Display;
use std::rc::Rc;
type NodeRef<T> = Rc<RefCell<Node<T>>>;
struct BinaryTree<T> {
head: Option<NodeRef<T>>,
}
#[derive(Debug)]
struct Node<T> {
data: T,
left: Option<NodeRef<T>>,
right: Option<NodeRef<T>>,
}
impl<T> BinaryTree<T>
where
T: std::cmp::Pa... |
// Copyright (c) 2018-2021 The MobileCoin Foundation
//! View Enclave Application-side Proxy object.
#![deny(missing_docs)]
extern crate fog_ocall_oram_storage_untrusted;
use std::{path, result::Result as StdResult, sync::Arc};
use fog_types::ETxOutRecord;
use fog_view_enclave_api::UntrustedQueryResponse;
use mc_a... |
use crate::ast::context::{Context, TableArrayContext};
use crate::builtins::Types;
use crate::lexer::Tokens;
use crate::TomlValue;
use std::error::Error;
use std::fmt;
pub mod context;
#[derive(Debug, PartialEq, Eq)]
pub enum HeadOption<T> {
Some(T),
None,
// Table array with the array name
TableArr(S... |
use crate::people::PlayerPositionType;
const SKILL_MIN_VALUE: u8 = 1;
const SKILL_MAX_VALUE: u8 = 20;
#[derive(Debug)]
pub struct PlayerSkills {
pub technical: Technical,
pub mental: Mental,
pub physical: Physical,
}
impl PlayerSkills {
pub fn get_for_position(&self, position: PlayerPositionType) -> ... |
//! A demonstration of using `winit` to provide events and GFX to draw the UI.
//!
//! `winit` is used via the `glutin` crate which also provides an OpenGL context for drawing
//! `conrod_core::render::Primitives` to the screen.
#![allow(unused_variables)]
extern crate conrod_core;
extern crate conrod_example_shared;... |
// Copyright (C) 2020-2021 <NAME>.
use super::{bag, error, game_config, movegen};
use rand::prelude::*;
pub fn use_tiles<II: IntoIterator<Item = u8>>(
rack: &mut Vec<u8>,
tiles_iter: II,
) -> error::Returns<()> {
for tile in tiles_iter {
let pos = rack.iter().rposition(|&t| t == tile).ok_or("bad t... |
mod odbc_api_ext;
mod odbc_connector;
mod config;
mod protocol;
use config::Config;
use odbc_api::{DataType, InputParameter, IntoParameter, RowSetBuffer, handles::{CData, CDataMut, HasDataType, Statement}, parameter::{VarChar, VarCharBox}, sys::{ParamType, SqlDataType}};
use std::sync::Arc;
use tokio::sync::Mutex;
#... |
use astar_solver::AStarSolver;
use maze::Maze;
use maze_creator::MazeCreator;
use pix_engine::prelude::*;
use timer::Timer;
mod astar_solver;
mod cell;
mod maze;
mod maze_creator;
mod timer;
const WIDTH: u32 = 801;
const HEIGHT: u32 = 601;
const SIZE: u32 = 20;
const FOOTER: u32 = 50;
const COLS: u32 = WIDTH / SIZE;
... |
pub mod influxrpc;
pub mod reorg;
pub mod sql;
#[cfg(test)]
mod test {
use std::sync::Arc;
use arrow::compute::SortOptions;
use datafusion::physical_plan::{
metrics::{self, MetricValue},
ExecutionPlan, ExecutionPlanVisitor,
};
use futures::StreamExt;
use schema::{merge::SchemaM... |
use abi_stable::{
abi_stability::{
abi_checking::check_layout_compatibility,
get_static_equivalent::{GetStaticEquivalent_, Unsized},
},
std_types::{RStr, RVec},
type_layout::TypeLayout,
StableAbi,
};
mod unit_type {
use abi_stable::GetStaticEquivalent;
#[derive(GetStaticEqu... |
pub use raft::eraftpb::{Snapshot, SnapshotMetadata, Entry};
pub use raft::eraftpb::{ConfState, HardState};
use raft::storage::RaftState;
use failure::{Fail, Backtrace};
#[derive(Debug, Fail)]
pub enum EntryReadError {
#[fail(display = "The entry was compacted into a snapshot and is not accessible any more!")]
... |
#![cfg(test)]
use std::collections::HashSet;
use serde::de::{Visitor, SeqVisitor, Deserialize, Deserializer, Error, Unexpected};
use serde::de::value::SeqVisitorDeserializer;
use serde_json::{self, Value};
use token::*;
use word::Name;
use std::fmt;
pub struct LexerTest {
pub source: String,
pub operator: boo... |
#![deny(unused_must_use)]
//! Integration test of the reliable broadcast protocol.
mod network;
use std::collections::BTreeMap;
use std::iter::once;
use std::sync::Arc;
use log::info;
use rand::Rng;
use crate::network::{
Adversary, MessageScheduler, MessageWithSender, NodeId, RandomAdversary, SilentAdversary,
... |
use std::str::FromStr;
#[derive(Clone, Debug)]
struct Board {
/// 5 x 5 board stored as 25 consecutive numbers.
/// The bool indicates wether the number has been drawn or not.
/// Get chunks of 5 to get each row
numbers: [(u8, bool); 25],
}
impl Board {
fn mark_num(&mut self, n: u8) {
if l... |
//! Data model for MORF.
//!
use std::convert::TryFrom;
use num_enum::TryFromPrimitive;
use crate::SystemExclusiveData;
use crate::k5000::{UnsignedLevel, SignedLevel};
use crate::k5000::control::VelocityCurve;
pub type VelocityDepth = UnsignedLevel;
pub type EnvelopeTime = UnsignedLevel;
/// Harmonic group.
#[deri... |
//! The main actor loop for Rita, this loop is common to both rita and rita_exit (as is everything
//! in rita common).
//!
//! This loops ties together various actors through messages and is generally the rate limiter on
//! all system functions. Anything that blocks will eventually filter up to block this loop and
//... |
// Copyright 2020-2021, The Tremor Team
//
// 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 agr... |
use std::env::current_dir;
use std::path::PathBuf;
use super::util::get_interactive_confirmation;
use nu_engine::CallExt;
use nu_path::canonicalize_with;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, ShellError, Signature, SyntaxShape};
use crate::... |
use anyhow::{anyhow, Error};
mod hbwrap;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
pub mod ftwrap;
pub mod locator;
pub mod parser;
pub mod rasterizer;
pub mod shaper;
pub mod units;
#[cfg(all(unix, not(target_os = "macos")))]
pub mod fcwrap;
use crate::font::locator::{FontDataHandle, ... |
extern crate libloading as lib;
extern crate patronus_provider;
use self::error::Error;
use patronus_provider as provider;
pub use patronus_provider::AnnotationKind;
use std::borrow::Cow;
use std::env;
use std::ffi::CStr;
use std::ffi::CString;
use std::fs;
use std::os::raw::c_int;
use std::path::Path;
use std::path::... |
// Copyright 2021 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 {
anyhow::{anyhow, bail, Context, Result},
chrono::{Local, TimeZone},
errors::{ffx_bail, ffx_error},
fidl_fuchsia_developer_remotecontr... |
#![deny(warnings)]
use warp::Filter;
use serde::{Deserialize, Serialize};
use futures::future;
use std::str::FromStr;
use tokio_postgres::Error;
use uuid::Uuid;
use std::net::{IpAddr, Ipv6Addr};
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Account {
pub uuid: Uuid,
pub username: String,
pub ... |
// use std::collections::HashMap;
use futures_util::{future, pin_mut, StreamExt};
// use std::env;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio_tungstenite::{connect_async, tungstenite::protocol::Message};
use std::fs::File;
//use std::io::prelude::*;
use std::io::BufReader;
// use serde::{Deserialize, Ser... |
// Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by ... |
//! **petgraph** is a graph data structure library.
//!
//! - [`Graph`](./graph/struct.Graph.html) which is an adjacency list graph with
//! arbitrary associated data.
//!
//! - [`StableGraph`](./stable_graph/struct.StableGraph.html) is similar
//! to `Graph`, but it keeps indices stable across removals.
//!
//! - [`G... |
#[derive(Debug)]
struct Match {
haplo_a: Vec<usize>,
haplo_b: Vec<usize>,
end: usize,
}
/// Find long matches and compute the next positional prefix
/// array and divergence array (Durbin's a_{k+1}[i] and d_{k+1}[i])
/// from the current ones
///
/// # Arguments
///
/// * `pos_prefix_array` - An array slic... |
use super::TaskControlBlock;
use super::__switch;
use super::add_task;
use super::{fetch_task, TaskStatus};
use crate::config::CPU_NUM;
use crate::trap::TrapContext;
use alloc::sync::Arc;
use alloc::vec::Vec;
use core::cell::RefCell;
use lazy_static::*;
use crate::async_rt::run_until_idle;
lazy_static! {
pub stati... |
use super::super::engine::Transaction;
use super::super::schema::Table;
use super::super::types::{Expression, Row, Value};
use super::{Executor, ResultSet};
use crate::error::{Error, Result};
use std::collections::{HashMap, HashSet};
/// An INSERT executor
pub struct Insert {
table: String,
columns: Vec<Strin... |
pub struct CPU {
pub opcode: u16, // operation code;
pub memory: [u8; 4096], // memory..duh;
pub v: [u8; 16], // V registers that allow manipulation of data;
pub i: usize, //
pub pc: usize, // program counter;
pub gfx: [[u8; 64]; 32], // graphics array that maps out pixels on or off;
pub de... |
use crate::syntax::abs::ParamVisibility::*;
use crate::syntax::abs::{AstTerm, Binder};
use crate::syntax::elab::{Def, Term};
use crate::syntax::lexical::Locatable;
use crate::type_check::context::TCError::*;
use crate::type_check::context::{TCError, TCResult, TCState};
/// If something is a type
pub fn is_type(state: ... |
use super::super::drawable::{Drawable, Pixel};
use super::super::transform::Transform;
use super::ImageFile;
use crate::geometry::{Dimensions, Point, Size};
use crate::pixelcolor::raw::RawData;
use crate::pixelcolor::PixelColor;
use core::marker::PhantomData;
use tinytga::{Tga, TgaIterator};
/// TGA format image
///
/... |
use super::{Malvi,Ast,SAst,Result,Bindings,BindingsHandle};
use ::std::rc::Rc;
use crate::im::HashMap;
use crate::im::Vector;
impl Malvi {
fn resolve_sym_impl(&self, env:&Bindings, s:&Ast) -> Option<Ast> {
//eprintln!("resolve_sym {} against bindings {:?}", super::BoundAstRef(s,self),env as *const Binding... |
use std::cmp;
use std::marker::PhantomData;
use std::os::raw::c_char;
use vst3_sys::vst::TChar;
use widestring::U16CString;
#[cfg(all(debug_assertions, feature = "assert_process_allocs"))]
#[global_allocator]
static A: assert_no_alloc::AllocDisabler = assert_no_alloc::AllocDisabler;
/// A Rabin fingerprint based stri... |
//! Blocked iterator
use crate::std::mem::size_of;
use crate::std::marker::PhantomData;
use rawslice::SliceIter;
use rawpointer::ptrdistance;
pub unsafe trait Block {
type Item;
fn capacity() -> usize;
}
macro_rules! impl_pod {
(@array $($e:expr),+) => {
$(
unsafe impl<T> Block for [T; $... |
use std::collections::HashMap;
use std::sync::Arc;
use std::thread::panicking;
use failure::ResultExt;
use opentracingrust::ExtractFormat;
use opentracingrust::Result as OTResult;
use opentracingrust::SpanContext;
use opentracingrust::Tracer;
use serde::Deserialize;
use super::metrics::TASK_ACK_ERRORS;
use super::met... |
// Zinc, the bare metal stack for rust.
// Copyright 2014 <NAME> <<EMAIL>>
//
// 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
//
// Unles... |
// The MIT License (MIT)
//
// Copyright (c) 2013 <NAME> (<EMAIL>)
//
// 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... |
use std::collections::HashMap;
use std::io;
const UNKNOWN_CHARACTER: &str = "........";
const _UNKNOWN_MORSE_CHARACTER: &str = "_";
pub fn encode(message: &str) -> String {
let dictionary = _morse_dictionary();
message
.chars()
.into_iter()
.map(|char| char.to_uppercase().to_string())
... |
//! PeerSpec types
use std::io;
use bounded_vec::BoundedVec;
use sigma_ser::vlq_encode::VlqEncodingError;
use sigma_ser::{ScorexParsingError, ScorexSerializable, ScorexSerializeResult};
use crate::peer_addr::PeerAddr;
use crate::{peer_feature::PeerFeature, protocol_version::ProtocolVersion};
type PeerFeatures = Boun... |
use crate::protocol::cdp::Page;
use crate::browser::tab::point::Point;
#[derive(Debug, Copy, Clone)]
pub struct ElementQuad {
pub top_left: Point,
pub top_right: Point,
pub bottom_left: Point,
pub bottom_right: Point,
}
impl ElementQuad {
pub fn from_raw_points(raw_quad: &[f64]) -> Self {
... |
use{
crate::{*, glue_helper::*},
rayon::prelude::*
};
pub(crate) fn norm_ln_prob(ln_prob: &mut[f64]) -> f64
{
let max = subtract_max(ln_prob);
// calculate actual sum in non log space
let sum = ln_prob.iter()
.fold(0.0, |acc, &val| {
if val.is_finite(){
acc + val... |
use crate::constant::constant::MAX_KEY_LEN;
use crate::derror::message_parse_error::MessageParseError;
use crate::derror::message_send_error::MessageSendError;
use crate::model::command::Command;
use crate::model::Search;
use crate::{Candidate, Item, Pack, TransmitterEvent, Value};
use crossbeam::channel::Sender;
use l... |
// Rust JSON-RPC Library
// Written in 2015 by
// <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 software is distributed without
// any warranty.
//
// You should have re... |
pub mod types;
use crate::diagnostics::Diagnostic;
use types::TokenType as TT;
pub use types::*;
pub struct ScanResult {
pub tokens: Vec<Token>,
pub diagnostics: Vec<Diagnostic>,
}
pub fn scan<'a, T: Into<&'a str>>(input: T) -> ScanResult {
let mut scanner = Scanner::new(input.into());
scanner.scan()... |
// 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
// di... |
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CommissionDataGrp {
/// NoCommissions
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "2639")]
pub commissions: Option<fix_common::RepeatingValues<Commission>>,
}
#[derive(Serial... |
//! In this example for the turingmachine-rs crate a turing machine is created which, when
//! supplied with two numbers `n` and `k` will determine whether `n` is divisable by `k`.
//!
//! Its usage is in the CLI by adding 2 args with numbers:
//! `cargo run --example divisibility -- 9 6`
//!
//! The turing machine sta... |
//! Types and functions used by the http server to manage the event-stream.
use datasize::DataSize;
use futures::{Stream, StreamExt};
use serde::{Deserialize, Serialize};
use tokio::sync::{
broadcast::{self, error::RecvError},
mpsc,
};
use tokio_stream::wrappers::{
errors::BroadcastStreamRecvError, Broadca... |
#![allow(non_snake_case)]
use serde_json;
use std::cmp;
use std::error::Error;
use std::fs::File;
use std::path::Path;
use url::percent_encoding::percent_decode;
use url::Url;
#[derive(Serialize, Deserialize, Debug)]
pub struct Creator {
pub name: String,
pub version: String,
}
#[derive(Serialize, Deserializ... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
decode_key, get_available_port_from, get_random_available_port, load_key, parse_key_val,
ApiQuotaConfig, BaseConfig, ConfigModule, QuotaDuration, StarcoinOpt,
};
use anyhow::{bail, format_err, Result};
use netwo... |
use crate::lua::{LuaHost, PackageReference, SerializableValue};
use crate::object::api;
use crate::object::types::Message;
use crate::world::actor::WorldActor;
use crate::world::state::State as WorldState;
use crate::world::{Id, World, WorldRef};
use rlua;
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Clone)]
pub ... |
use bio_types::strand::Strand;
use derive_more::{Add, AddAssign};
use crate::core::summary::{MismatchesSummary, ROISummary};
use super::ROIBasedStat;
#[derive(Copy, Clone, Default, Add, AddAssign)]
pub struct EditingIndex {
accumulator: MismatchesSummary,
}
impl ROIBasedStat for EditingIndex {
fn process(&m... |
use crate::cache::*;
use crate::config::Config;
use crate::filter::*;
use crate::helpers::*;
use crate::instrumentation::*;
use crate::message::*;
use crate::resolver_manager::ResolverManager;
use std::error::Error;
use std::net::{Ipv4Addr, SocketAddr};
use std::sync::mpsc::Sender;
use std::sync::{Arc, Mutex};
use tok... |
use dialoguer::{Input, Select, Confirm};
use crate::error::Res;
use chrono::{NaiveDate, Local, Datelike};
use crate::currency::Currency;
use crate::invoice::invoice_type::InvoiceType;
use crate::invoice::Invoice;
use crate::invoice::amount::Amount;
use dialoguer::theme::{ColorfulTheme, Theme};
use crate::printer::{Prin... |
use std::io::Read;
use std::sync::Arc;
use crate::error::ColumnQError;
use crate::table::{TableLoadOption, TableOptionParquet, TableSource};
use datafusion::arrow;
use datafusion::arrow::datatypes::Schema;
use datafusion::arrow::record_batch::RecordBatch;
use datafusion::datasource::parquet::ParquetTable;
use datafus... |
use std::borrow::Cow;
use futures::FutureExt;
use schema::{Snowflake, SnowflakeExt};
use smol_str::SmolStr;
use crate::{
ctrl::{auth::Authorization, perm::get_cached_room_permissions, Error, SearchMode},
permission_cache::PermMute,
ServerState,
};
use sdk::models::*;
pub mod embed;
pub mod slash;
pub mo... |
// Copyright 2018 <NAME> <<EMAIL>>
//
// 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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except accordin... |
use std::fmt;
use wasm_bindgen::prelude::*;
use js_sys::Array;
use rand::{thread_rng, Rng};
use rand::seq::SliceRandom;
use rand::distributions::{Distribution, Uniform};
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static A... |
use std::net::SocketAddr;
use naia_shared::{
Connection, ConnectionConfig, EntityType, ManagerType, Manifest, PacketReader, PacketType,
ProtocolType, Ref, Replicate, SequenceNumber, StandardHeader, WorldMutType, WorldRefType,
};
use super::{
command_receiver::CommandReceiver, entity_manager::EntityManager... |
//! Traits to be implemented by structures that can be dumped in the .lp format
//!
use std::cmp::Ordering;
use std::fmt;
use std::fmt::Formatter;
use std::io::prelude::*;
use std::io::Result;
use tempfile::NamedTempFile;
/// Optimization sense
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
pub enum LpObjective {
/... |
extern crate wasm_bindgen;
use sha2::{Digest, Sha256};
use wasm_bindgen::prelude::*;
#[allow(dead_code)]
fn pipe<A, B, C>(fn1: fn(A) -> B, fn2: fn(B) -> C) -> impl Fn(A) -> C {
move |x: A| fn2(fn1(x))
}
/// 函数式的 pipe
fn pipe3<A, B, C, D>(fn1: fn(A) -> B, fn2: fn(B) -> C, fn3: fn(C) -> D) -> impl Fn(A) -> D {
... |
use cadence::{SpyMetricSink, StatsdClient};
use cadence_macros::{statsd_count, statsd_gauge, statsd_histogram, statsd_meter, statsd_set, statsd_time};
use std::io;
use std::sync::{Arc, Mutex, Once};
/// Underlying writer to be used by a `SpyMetricSink`
static mut WRITER: Option<Arc<Mutex<TestWriter>>> = None;
/// Con... |
pub mod render_hmd;
pub mod render_window;
pub mod swapchain;
use std::mem::ManuallyDrop;
use anyhow::{Error, Result};
use ash::vk::{CommandBuffer, Extent2D, Fence, RenderPass, Semaphore};
use openxr::{
FrameState, FrameStream, FrameWaiter, Posef, ReferenceSpaceType, Session, Space, Time, View,
ViewConfigurat... |
use crate::primitives::error;
use crate::util::Result;
#[cfg(feature = "postgres")]
use postgres_types::private::BytesMut;
#[cfg(feature = "postgres")]
use postgres_types::{FromSql, IsNull, ToSql, Type};
use serde::{Deserialize, Serialize};
use snafu::ensure;
#[cfg(feature = "postgres")]
use snafu::Error;
use std::{
... |
/*
Copyright 2020 <盏一 <EMAIL>>
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, software
distribut... |
use crate::{
gui::{filters::Filters, sort_by::SortBy, style::Theme},
package::Package,
};
use derive_deref::{Deref, DerefMut};
use device_query::Keycode;
use directories_next::ProjectDirs;
use lazy_static::{initialize, lazy_static};
use regex::Regex;
use serde::{Deserialize, Serialize};
use std::{
env::curr... |
use super::image::*;
use super::widget::*;
use super::widget_data::*;
use super::basic_widget::*;
use super::flo_fixed_widget::*;
use super::super::gtk_action::*;
use super::super::gtk_thread::*;
use flo_ui;
use flo_ui::*;
use gtk;
use gtk::prelude::*;
use std::rc::*;
use std::cell::*;
///
/// Handles events for 'b... |
#![feature(proc_macro_hygiene)]
// Copyright (c) 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, o... |
use anyhow::Result;
use std::io::BufRead;
const DATA_FILE: &str = "3.txt";
pub fn data<P: AsRef<std::path::Path>>(data_dir: P) -> Result<Vec<u32>> {
let data_file = data_dir.as_ref().join(DATA_FILE);
let data = std::io::BufReader::new(std::fs::File::open(&data_file)?);
data.lines()
.map(|s_res| {
... |
use crate::{
error::{Error, ErrorType},
interpreter::Interpreter,
nodes::{
expr::Expr,
stmt::{ImportType, Stmt},
},
token::{TType, Token},
};
pub struct Resolver {
scopes: Vec<Vec<String>>,
interpreter: Interpreter,
}
impl Resolver {
pub fn new(interpreter: Interpreter)... |
//! Lights, camera, materials, and dimensions!
//!
//! # Coordinate spaces
//! ## Screen space
//! Screen space defined by the image plane of the viewing frustum
//! centered at (0, 0).
//!
//! On the more limiting dimension of width or height, screen space extends from -1 to 1. The
//! larger dimension will extend fr... |
use std::io;
use std::ptr;
use std::mem;
use std::io::Error;
use std::io::ErrorKind;
use std::path::Path;
use std::ffi::CString;
use winapi::um::winnt::HANDLE;
use winapi::um::errhandlingapi as werror;
use winapi::um::winbase::{INFINITE, CREATE_NO_WINDOW, CREATE_SUSPENDED};
use winapi::um::memoryapi as wmem;
use winap... |
use std::io::BufRead;
fn main() {
let mut b: Board = Board {
b: [None, None, None, None, None, None, None, None, None],
rules: WinRule::new(),
input: String::new(),
};
loop {
b.render_board();
b.player_turn();
b.check_for_end();
b.bot_turn();
... |
/*
* Copyright 2018 Intel Corporation
*
* 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... |
#[cfg(target_os = "macos")]
extern crate corelocation_rs;
#[cfg(target_os = "macos")]
use corelocation_rs::Locator;
use super::errors::*;
use super::name_cache::LocationCache;
use super::name_cache::LocationCacher;
use super::Result;
use reqwest::Url;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
#[... |
use std::collections::BTreeMap;
use regex::Regex;
use crate::client::{Scraper, TomatoClientInternal};
use crate::prometheus::{PromMetric, PromMetricType, PromSample};
#[derive(Clone)]
pub struct MemClient {
client: TomatoClientInternal,
}
impl MemClient {
pub fn new(client: TomatoClientInternal) -> MemClien... |
use ctap_hid_fido2;
use ctap_hid_fido2::public_key_credential_descriptor::PublicKeyCredentialDescriptor;
use ctap_hid_fido2::public_key_credential_user_entity::PublicKeyCredentialUserEntity;
use ctap_hid_fido2::{util, Key, Cfg, InfoParam};
extern crate clap;
use clap::{App, Arg};
fn rps(cfg: &Cfg, pin: Option<&str>) {... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.