text stringlengths 3.09k 13.9k |
|---|
mod gen_network;
use actix_rt::System;
use bus::{Bus, BusActor};
use chain::ChainActor;
use config::{get_random_available_port, NodeConfig};
use consensus::dev::DevConsensus;
use crypto::{hash::PlainCryptoHash, keygen::KeyGen};
use futures_timer::Delay;
use gen_network::gen_network;
use libp2p::multiaddr::Multiaddr;
u... |
//! Types related to chats.
use serde::Deserialize;
mod action;
mod id;
mod invite_link;
mod kind;
mod location;
pub mod member;
mod permissions;
mod photo;
pub use {
action::Action, id::Id, invite_link::InviteLink, kind::Kind,
location::Location, member::Member, permissions::Permissions, photo::Photo,
};
/... |
// Copyright 2018 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
// Rust Monero Library
// Written in 2019 by
// h4sh3d <<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... |
extern crate kafka_delta_ingest;
use kafka_delta_ingest::KafkaJsonToDelta;
use log::debug;
use rdkafka::{
admin::{AdminClient, AdminOptions, NewTopic, TopicReplication},
producer::FutureProducer,
producer::FutureRecord,
util::Timeout,
ClientConfig,
};
use serde_json::json;
use std::{collections::Ha... |
//! Library used in solving Project Euler problems needing `BigInt` or `BigUint`.
//!
//!
//! # Example
//!
//! ```
//! use euler_library::big as eu_big;
//!
//! let big_number_string = eu_big::factorial(31).to_string();
//! assert_eq!(big_number_string.to_string(), "8222838654177922817725562880000000");
//! ```
ext... |
//! Holds connection related data types.
mod closereason;
mod r#type;
pub use self::closereason::*;
pub use self::r#type::*;
use std::collections::HashMap;
use std::convert::TryInto;
use std::future::Future;
use std::io;
use std::sync::Arc;
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
use tokio::net:... |
use crate::block::{Block, Header};
use crate::crypto::hash::{H256,H160, Hashable};
use std::collections::HashMap;
use ring::signature::{self,Ed25519KeyPair, Signature, KeyPair, VerificationAlgorithm, EdDSAParameters};
use crate::crypto::key_pair;
use super::*;
pub struct Blockchain{
// use hashmap to save the blo... |
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use hash_hasher::{HashBuildHasher, HashedSet};
use wasm_bindgen::prelude::*;
use crate::game::{D15Game, Move, PlayerState, Point, Color};
mod game;
fn calculate_hash<T: Hash>(t: &T) -> u64 {
let mut s = DefaultHasher::new();
t.ha... |
use std::collections::HashMap;
type Point = (i32, i32);
type Memory = HashMap<Point, u32>;
type ValueFn = dyn Fn(&u32, &Point, &Memory) -> u32;
#[derive(Debug, PartialEq, Eq)]
enum Direction {
North,
East,
South,
West,
}
const PUZZLE_INPUT: u32 = 368_078;
fn main() {
let distance = find_memory_l... |
use ethereum_types::U256;
use proof::impls::replace_index;
use proof::node::Node;
use proof::tree_arithmetic::zeroed::subtree_index_to_general;
use proof::types::VariableList;
use proof::{hash_children, Error, MerkleTreeOverlay, PathElement, Proof, SerializedProof};
use typenum::U8;
// S's merkle tree
//
// ro... |
// Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//! Worker-local state for storage timely instances.
use std::any::Any;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
u... |
use crate::app::components::display_add_css_provider;
use crate::app::loader::ImageLoader;
use crate::app::models::SongModel;
use crate::app::Worker;
use gio::MenuModel;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::CompositeTemplate;
mod imp {
use super::*;
const SONG_CLASS: &str = "song--pl... |
use std::ops;
use crate::{Cons, Value};
/// A type that can be used to index into a `lexpr::Value`.
///
/// The [`get`] method of `Value` accept any type that implements
/// `Index`, as does the [square-bracket indexing operator]. This
/// trait is implemented for strings and `Value`, both of which can be
/// used to... |
// Copyright 2020-2022 <NAME>
// SPDX-License-Identifier: Apache-2.0
use log::LevelFilter;
use serde::Deserialize;
use std::borrow::Cow;
/// Default value for the target width.
const DEFAULT_TARGET_WIDTH: usize = 42;
/// Default value for the level width.
const DEFAULT_LEVEL_WIDTH: usize = 5;
/// Default name for an... |
use std::fmt;
use std::marker::PhantomData;
use std::mem::ManuallyDrop;
use std::ops::Deref;
#[cfg(any(unix, target_env = "sgx"))]
use std::os::unix::io::{AsRawFd, FromRawFd};
#[cfg(windows)]
use std::os::windows::io::{AsRawSocket, FromRawSocket};
use crate::Socket;
/// A reference to a [`Socket`] that can be used to... |
use crate::queryplanner::hll::Hll;
use crate::CubeError;
use arrow::array::{Array, BinaryArray, UInt64Builder};
use arrow::datatypes::DataType;
use datafusion::error::DataFusionError;
use datafusion::physical_plan::functions::Signature;
use datafusion::physical_plan::udaf::AggregateUDF;
use datafusion::physical_plan::u... |
/*
Copyright 2021, 2022 Volt Contributors
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 o... |
// Copyright Materialize, Inc. 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 the Apache License... |
use ggez::audio::SoundSource;
use ggez::graphics::{Rect, Text};
use ggez::input::keyboard::{is_key_pressed, KeyCode};
use ggez::Context;
use rand::Rng;
use crate::assets::*;
use crate::function;
/// Define the width of the game window
pub const SCREEN_WIDTH: f32 = 600.;
/// Define the height of the game window
pub con... |
/* ************************************************************************ **
** This file is part of rsp2, and is licensed under EITHER the MIT license **
** or the Apache 2.0 license, at your option. **
** **
** ... |
use std::sync::atomic::{AtomicU32, AtomicUsize, Ordering};
use std::sync::Arc;
use crate::analysis::Analyser;
use crate::context::{AudioContextRegistration, BaseAudioContext};
use crate::render::{AudioParamValues, AudioProcessor, AudioRenderQuantum, RenderScope};
use super::{AudioNode, ChannelConfig, ChannelConfigOpt... |
// Copyright 2020 Google Inc. All Rights Reserved.
//
// 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... |
//! This is an experimental Javascript lexer, parser and compiler written in Rust. Currently, it
//! has support for some of the language.
//!
//! # Crate Features
//! - **serde** - Enables serialization and deserialization of the AST (Abstract Syntax Tree).
//! - **console** - Enables `boa`s WHATWG `console` object ... |
/// Modular Square Roots-based Verifiable Delay Function (VDF) implementation.
pub mod vdf_mod_sqrt {
use rug::Integer;
/// Verifies that delay function from given `seed` was calculated and produced a `witness`
pub fn verify(modulus: &Integer, seed: &Integer, num_steps: u64, witness: &Integer) -> bool {
... |
use std::convert::TryInto;
use crate::*;
use rustc_target::abi::LayoutOf;
use rustc_target::spec::abi::Abi;
impl<'mir, 'tcx> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> {
fn pthread_create(
&mut self... |
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018, the Perspective Authors.
//
// This file is part of the Perspective library, distributed under the terms
// of the Apache License 2.0. The full license can be found in the LICENSE
// file.
use crate::*;
use std... |
use crate::read_lines;
use std::fmt;
pub fn part1() -> i32 {
let lines = read_lines("./data/day18.txt");
let mut num = SFNumber::from_str(&lines[0]);
for i in 1..lines.len() {
num.add_by(SFNumber::from_str(&lines[i]));
num.reduce();
//println!("{}", num);
}
//println!("{}", ... |
#[macro_use]
extern crate log;
use std::path::{Path, Component};
use clap::{App, Arg};
use failure::Error;
use log::LevelFilter;
use simplelog::{TermLogger, Config, SimpleLogger};
use git2::{Repository, DiffOptions, Commit, Oid};
use std::collections::HashMap;
use std::str::FromStr;
use std::fmt::Display;
type Resul... |
use math::Vector2;
use platform::{common::WindowId, Window};
use crate::*;
/// A simple 2D sprite based renderer.
///
/// A renderer can be created for a Window and holds a reference to the window, which will
/// keep the window alive as long as the renderer is alive.
///
/// # Example
///
/// ```no_run
/// use riddl... |
use lycaon::booster::Booster;
use lycaon::booster::LPBoost;
// use lycaon::base_learner::DStump;
use lycaon::read_csv;
use std::time::Instant;
use std::fs::OpenOptions;
use std::io::Write;
pub mod sparse_ltf;
use sparse_ltf::*;
fn main() {
{
let mut file = OpenOptions::new()
.write(true)
... |
use serde::{Deserialize, Serialize};
use crate::types::{ChatPermissions, ChatPhoto, Message};
/// This object represents a chat.
///
/// [The official docs](https://core.telegram.org/bots/api#chat).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Chat ... |
use anyhow::{bail, Context, Error};
use cargo_about::{licenses, Krates};
use handlebars::Handlebars;
use serde::Serialize;
use std::{collections::BTreeMap, path::PathBuf};
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
pub struct Args {
/// The confidence threshold required for license files
/// to be p... |
use std::sync::{Arc, Mutex};
use futures::{
future,
sync::mpsc,
Async, Future, Poll, Stream
};
use trust_dns_proto::{
error::ProtoResult,
rr::{Name, RData, RecordType},
xfer::{ DnsRequestOptions, RetryDnsHandle,},
};
#[cfg(feature = "dnssec")]
use trust_dns_proto::SecureDnsHandle;
use config::... |
module!(pt1: parse, pt2: parse);
use crate::mat2::Mat2;
use crate::vec2::Vec2us;
use crate::HashSet;
use num::integer::Integer;
use std::convert::Into;
type Vec2 = crate::vec2::Vec2i;
struct CloserToCenterIter {
pos: Vec2,
offset: Vec2,
}
impl Iterator for CloserToCenterIter {
type Item = Vec2;
fn ne... |
use std::cmp;
use std::collections::BinaryHeap;
use std::num::FpCategory;
use std::vec;
/// A collection of scored values, sorted in descending order by score.
#[derive(Clone, Debug, Default)]
pub struct SearchResults<T>(Vec<Scored<T>>);
impl<T> SearchResults<T> {
/// Create an empty collection of scored values.
... |
use super::highlighters::get_spinner;
use inflector::Inflector;
use yew::prelude::*;
use yew_prism::Prism;
use yew_styles::layouts::{
container::{Container, Direction, Wrap},
item::{Item, ItemLayout},
};
use yew_styles::spinner::{Spinner, SpinnerType};
use yew_styles::styles::{get_palette, get_size, Palette, Si... |
use crate::for_tupled_reprs::{
classify::{
Classify, HasSameKindNumber, Tuple0, Tuple1, Tuple2, Tuple3, Tuple4, Tuple5, Tuple6,
Tuple7, Tuple8,
},
False, True,
};
#[allow(unused_imports)]
use crate::for_tupled_reprs::classify::{
Chars1, Chars2, Chars3, Chars4, Chars5, Chars6, Chars7, Ch... |
use rand::seq::SliceRandom;
use url::Url;
use ic_canister_client::{Agent, Sender};
use ic_interfaces::registry::RegistryTransportRecord;
use ic_registry_transport::{
deserialize_atomic_mutate_response, deserialize_get_changes_since_response,
deserialize_get_value_response, serialize_atomic_mutate_request,
... |
use crate::{AnyConnection, SessionKeys, H256};
use serde_json::{json, Value};
use sp_core::storage::{StorageChangeSet, StorageData};
use substrate_api_client::StorageKey;
fn json_req(method: &str, params: Value, id: u32) -> Value {
json!({
"method": method,
"params": params,
"jsonrpc": "2.0... |
use async_trait::async_trait;
use futures::{
future, stream, Future as StdFuture, FutureExt, Stream as StdStream, StreamExt, TryFutureExt,
};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{pin::Pin, time::Duration};
/// A type alias for `Future` that may return `crate::error::Error`
pub type ... |
//! Global configurations
//! Units: centimeter
//!
//! Materials:
//! - Top boards: African Mohogany
//! - Top support boards: African Mohogany
//! - Side support boards: Canary Wood
//! - Leg boards: Cherry
//! - Tenon pins: Padauk
pub const VISUAL_OVERRUN: f32 = 0.1;
/// Distance between leg center to leg center a... |
use super::get_contents;
pub fn main() {
println!("Day-17 part 1: {}", part_one());
println!("Day-17 part 2: {}", part_two());
}
fn part_one() -> i32 {
let contents = get_contents("src/days/day_17/input.txt");
let target = get_target_from_input(contents);
let max_v = get_max_y_v(target);
calc_... |
// 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 crate::config::{from_reader, BoardConfig, ProductConfig};
use crate::vfs::RealFilesystemProvider;
use anyhow::{Context, Result};
use assembly_base_pack... |
use crate::Table;
use nu_protocol::{value::StringExt, Primitive, TaggedDictBuilder, UntaggedValue, Value};
use nu_source::Tag;
use scraper::{Html, Selector as ScraperSelector};
pub struct Selector {
pub query: String,
pub tag: Tag,
pub as_html: bool,
pub attribute: String,
pub as_table: Value,
... |
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in... |
pub mod gcra;
pub mod leaky_bucket;
pub use self::gcra::*;
pub use self::leaky_bucket::*;
use crate::{instant, InconsistentCapacity, NegativeMultiDecision};
use crate::lib::*;
/// The default rate limiting algorithm in this crate: The ["leaky
/// bucket"](leaky_bucket/struct.LeakyBucket.html).
///
/// The leaky buc... |
//! Module with [`rt::Setup`].
//!
//! [`rt::Setup`]: Setup
use std::num::NonZeroUsize;
use std::path::Path;
use std::{env, io, thread};
use log::{debug, warn};
use crate::actor_ref::ActorGroup;
use crate::rt::coordinator::Coordinator;
use crate::rt::{worker, Error, Runtime, Worker, MAX_THREADS};
use crate::trace;
... |
use std::collections::HashMap;
use std::sync::mpsc::Receiver;
use std::sync::Arc;
use log::{debug, error, trace};
use waithandle::WaitHandleListener;
use crate::builds::{Build, BuildStatus};
use crate::engine::{EngineEvent, EngineState, EngineThreadMessage};
use crate::filters::FilterResult;
use crate::providers::obs... |
//! Module defining registry of models which are loading asynchronously.
use crate::prelude::*;
use crate::notification::Publisher;
use flo_stream::Subscriber;
// =============
// === Error ===
// =============
/// An error indicating that another task of loading item results in error.
///
/// Unfortunately we ca... |
use super::BTree;
use core::ptr::NonNull;
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[repr(C)]
struct SizeFirstPtrSecond {
size: usize,
ptr: NonNull<u8>,
}
pub struct VirtualMemoryAllocator {
best_fit_tree: BTree<SizeFirstPtrSecond, ()>,
merge_tree: BTree<NonNull<u8>, usize>,
}
im... |
use crate::{unit::*, values as val, Color, St, StyleValues, UpdateStyleValues};
use derive_rich::Rich;
use savory::prelude::DeclarativeConfig;
/// ```
/// use savory_style::{values as val, Style, Color, unit::em};
/// use palette::rgb::Rgb;
///
/// Style::default()
/// // for single shadow
/// .and_box_shadow(... |
// 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 anyhow::{format_err, Error};
use fidl_fuchsia_auth::Status::{self as TokenManagerStatus, *};
use fidl_fuchsia_identity_account::Error as AccountApiErro... |
// Copyright 2019 <NAME>.
// Licensed under the MIT license (http://opensource.org/licenses/MIT)
// This file may not be copied, modified, or distributed
// except according to those terms.
//! A trait system for Bayesian statistical modelling.
use std::cmp::Eq;
use std::collections::HashMap;
use std::hash::Hash;
use... |
//! Traits to abstract over firebird client implementations
use num_enum::TryFromPrimitive;
use std::str::FromStr;
use crate::*;
///A wrapper trait compatible with the niceties provided by the main rsfbclient crate
pub trait FirebirdClient
where
Self: FirebirdClientDbOps,
Self: FirebirdClientSqlOps<DbHandle ... |
use num;
pub type Rgb<T = f32> = [T; 3];
pub type Rgba<T = f32> = [T; 4];
pub trait ToRgb<T: num::Float> {
fn to_rgb(&self) -> Rgb<T>;
fn to_rgba(&self) -> Rgba<T> {
let rgb = self.to_rgb();
[rgb[0], rgb[1], rgb[2], T::one()]
}
}
pub trait FromRgb<T: num::Float>: Sized {
fn from_rgb(c: &Rgb<T>) -> Self;
f... |
use crate::db::loaders::ContinentEntity;
use crate::db::{DatabaseEntity, PlayerGenerator, PositionType, StaffGenerator};
use core::club::academy::ClubAcademy;
use core::context::{NaiveTime, Timelike};
use core::continent::Continent;
use core::league::{DayMonthPeriod, League, LeagueSettings, LeagueTable};
use core::shar... |
extern crate clap;
extern crate regex;
use std::io::prelude::*;
use std::fs::File;
use regex::Regex;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
enum Pixel {
On,
Off,
}
impl Pixel {
#[inline(always)]
fn is_on(&self) -> bool {
match *self {
Pixel::On => true,
Pixel::O... |
//! Image usage, format, kind, extent, creation-info and wrappers.
pub mod format;
mod usage;
pub use self::format::Format;
pub use self::usage::*;
use memory::MemoryBlock;
use relevant::Relevant;
use escape::Escape;
use SharingMode;
/// Image dimensionality
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Ki... |
// Copyright 2018-2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
// Author: <NAME> <<EMAIL>>
use crate::{constants, Error, Result};
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4, ToSocketAddrs},
str::FromStr,
};
use url::Url;
impl From<url::ParseError> for Error {
fn from(e: url::... |
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_std::{Addr, Coin, Order, StdError, StdResult, Storage};
use cw_storage_plus::Map;
use cosmwasm_storage::{singleton, singleton_read, ReadonlySingleton, Singleton};
use cw20::{Balance, Cw20CoinVerified};
#[derive(Serialize, Deserialize, Clone,... |
//! Special handling for note expressions, because VST3 makes this a lot more complicated than it
//! needs to be. We only support the predefined expressions.
use vst3_sys::vst::{NoteExpressionValueEvent, NoteOnEvent};
use crate::midi::NoteEvent;
type MidiNote = u8;
type MidiChannel = u8;
type NoteId = i32;
/// The... |
use clap::{App, Arg, ArgMatches};
use std::collections::HashMap;
use std::{error, fmt, result};
use thud_game::agent::{self, Agent};
pub mod mcts;
pub const FLAG_PLAYER_1_AGENT: &'static str = "player_1_agent";
pub const FLAG_PLAYER_2_AGENT: &'static str = "player_2_agent";
#[derive(Debug)]
pub enum Error {
/// No... |
/* SPDX-License-Identifier: (Apache-2.0 OR MIT OR Zlib) */
/* Copyright © 2021 <NAME> */
use {
alloc::sync::{Arc, Weak},
core::{
cell::Cell,
fmt,
mem::{self, size_of},
ptr,
sync::atomic::{AtomicPtr, AtomicUsize, Ordering},
},
};
use super::{WatchArg, WatchedMeta};
... |
use yaxpeax_arch::{Arch, AddressBase, AddressDisplay, Decoder, LengthedInstruction, ShowContextual, YaxColors};
use analyses::control_flow::{BasicBlock, ControlFlowGraph, Determinant};
use std::collections::HashMap;
use arch::InstructionSpan;
use arch::FunctionQuery;
use memory::{MemoryRepr, MemoryRange};
use num_trait... |
use std::{
collections::HashMap,
path::Path,
path::PathBuf,
sync::{Arc, Mutex},
thread,
time::Duration,
};
use message_io::node::NodeHandler;
use notify::{watcher, DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher};
use super::{CarrierEvent, EventSupression, WatcherEvent};
use crate::... |
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::{
def_id::DefId, intravisit, itemlikevisit::ItemLikeVisitor, Block, BodyId, HirId, ItemKind,
};
use rustc_middle::ty::{Ty, TyCtxt, TyKind};
use rustc_span::Span;
/// Maps `HirId` of a type to `BodyId` of related impls.
/// Free-standing (top level) functions... |
/// UART driver for PIC32
extern crate vcell;
use core::fmt::Write;
use nb;
use vcell::VolatileCell;
#[repr(C)]
struct RegisterBlock {
mode: VolatileCell<u32>,
modeclr: VolatileCell<u32>,
modeset: VolatileCell<u32>,
modeinv: VolatileCell<u32>,
sta: VolatileCell<u32>,
staclr: VolatileCell<u32>,... |
use std::time::{Duration, SystemTime};
use formaters::*;
use std::collections::HashMap;
use chrono::{NaiveDate, Datelike, Local};
extern crate search;
extern crate formaters;
extern crate chrono;
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;
#[derive(Serialize, Deserialize, Debu... |
use std::convert::TryFrom;
use std::fs;
use std::path::{Path, PathBuf};
use anyhow::Error;
use fs_extra::dir::CopyOptions;
use git2::{Oid, Repository};
use git2::build::RepoBuilder;
use crate::context::Context;
use crate::manifest::{CheckoutParams, Git};
use crate::stdoutln;
/// Git prefix.
pub const PREFIX: &str = ... |
use async_std::net::{SocketAddr, SocketAddrV4, SocketAddrV6, TcpStream, ToSocketAddrs, UdpSocket};
use async_trait::async_trait;
use socket2::{Domain, Protocol, Socket, Type};
use std::io;
use std::option::Option::Some;
use std::prelude::v1::Result::Ok;
pub const STREAM_BUF_SIZE: usize = 32 * 1024;
pub const DATAGRAM... |
use super::vga_buffer;
use crate::{warn, println};
use crate::util::Flag;
use alloc::{boxed::Box, string::String};
use conquer_once::spin::OnceCell;
use core::{
fmt::{Arguments, Error, Write},
pin::Pin,
task::{Context, Poll},
};
use crossbeam_queue::ArrayQueue;
use futures_util::{stream::Stream, stream::Str... |
use cosmwasm_vm::BackendError;
use crate::memory::UnmanagedVector;
/// This enum gives names to the status codes returned from Go callbacks to Rust.
/// The Go code will return one of these variants when returning.
///
/// 0 means no error, all the other cases are some sort of error.
///
/// cbindgen:prefix-with-name... |
#[derive(Debug, Clone)]
pub struct Config {
pub(crate) accel_fs_sel: AccelFullScaleSelect,
pub(crate) gyro_fs_sel: GyroFullScaleSelect,
pub(crate) fifo_sample_rate: FifoSampleRate,
pub(crate) gyro_fchoice: u8,
pub(crate) gyro_dlpf_cfg: GyroDlpfCfg,
pub(crate) accel_fchoice: u8,
pub(crate) ac... |
use anyhow::{bail, Context, Result};
use sscanf::scanf;
fn add_bound_10(a: u32, b: u32) -> u32 {
(a + b - 1) % 10 + 1
}
struct Loaded {
val: u32,
counter: usize,
}
impl Loaded {
fn new() -> Loaded {
Loaded { val: 1, counter: 0 }
}
fn roll(&mut self) -> u32 {
let out = self.va... |
use crate::contest::Contest;
use cost_model::{wei_to_grt, CostError, CostModel};
use fraction::BigFraction;
use num_bigint::{BigInt, BigUint};
use num_format::{Locale, ToFormattedString as _};
use rayon::prelude::*;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
use tree_buf::prelude:... |
use bevy::prelude::*;
use bevy_rapier2d::prelude::*;
use data::client_db::save_player;
use protocol::data::player_data::{PlayerData, PlayerListData};
use crate::engine::plugin::network_plugin::{SynEntity, PLAYER};
pub struct PlayerPlugin;
impl Plugin for PlayerPlugin {
fn build(&self, app: &mut AppBuilder) {
... |
//! Segger J-Link interface.
use super::{
begin_log_output, gdb_script_command, gdb_script_continue, gdb_script_wait, run_gdb_client,
run_gdb_server, rustc_substitute_path, setup_serial_endpoint,
};
use crate::{
cli::{ProbeFlashCmd, ProbeGdbCmd, ProbeLogCmd, ProbeResetCmd},
log,
templates::Registry... |
use std::io;
use std::io::prelude::*;
use std::net::Shutdown;
use std::net::TcpStream;
use std::net::ToSocketAddrs;
use std::sync::Mutex;
const FEND: u8 = 0xC0;
const FESC: u8 = 0xDB;
const TFEND: u8 = 0xDC;
const TFESC: u8 = 0xDD;
pub(crate) struct TcpKissInterface {
// Interior mutability is desirable so that w... |
use crate::{ChanProtoSender, MailBox, ProtoSender};
use std::future::Future;
use std::sync::Arc;
use tokio::net::{TcpListener, TcpStream};
use tokio::sync::{
broadcast,
mpsc::{self, error::TrySendError},
Semaphore,
};
use tokio::time::{self, Duration};
extern crate llog;
use crate::{Connection, ProtoMsgTy... |
use std::{collections::HashMap, convert::Infallible, net::SocketAddr, sync::Arc};
use axum::{extract, extract::Extension, response::Html, Router};
use bonsaidb::{core::connection::AsyncConnection, local::AsyncDatabase};
use chrono::{Duration, Utc};
use http::StatusCode;
use serde::{Deserialize, Serialize};
use tera::{... |
use crate::{
command::{Command, CommandSystem, Context},
utils::snapshot::SnapshotLocal,
};
use anyhow::{anyhow, Error, Result};
use chrono::{SecondsFormat, Utc};
use std::{
path::{Path, PathBuf},
str::FromStr,
};
use uuid::Uuid;
#[cfg(test)]
mod tests;
pub trait BtrfsCommands {
/// Get subvolumes
... |
#![feature(asm)]
use std::{ffi::c_void, mem, ptr::{null_mut}};
const PAGE_SIZE: usize = 1024 * 1024;
#[derive(Clone, Debug)]
enum Op{
Put,
Get,
IncVal,
DecVal,
IncPtr,
DecPtr,
Loop (Box<Vec<Op>>),
}
fn main() {
let program: Box<[u8]> = compile(">+++++++++[<++++++++>-]<.>+++++++[<++++... |
//! This module provides **very** dumb implementation of text word wraspping.
//!
//! I wanted to use `textwrap` crate, but it requires the whole string up-front which I don't have.
//! So, I've written _this_. The code seems to work, but it doesn't do anything with lots of egde cases,
//! this may result in weird resu... |
use crate::{create_binding, create_details, Error, create_calls};
use serde::{Deserialize, Serialize};
create_calls! {
FolderApi where
Endpoint = "1.0/folder",
Details: Details,
Type: Folder,
Create: CreateFolder,
Update: UpdateFolder,
Error: Error,
Identifi... |
extern crate proc_macro;
use proc_macro::TokenStream;
use proc_macro2::Span;
use quote::{format_ident, quote};
use syn::{parse, spanned::Spanned, Block, FnArg, Ident, Item, ItemMod, Path, ReturnType, Type};
#[proc_macro_attribute]
pub fn tests(args: TokenStream, input: TokenStream) -> TokenStream {
match tests_im... |
//! Demonstrates a DMA-based UART transfer and receive
//!
//! The example waits for a UART character, then echos that
//! character back to the user with a header. Each received
//! character causes the LED to toggle. Received bytes and
//! replies are logged over USB.
//!
//! Pinout:
//! - Pin 14: UART2_TX
//! - Pin ... |
use crate::clipboard;
use crate::env_vars;
use crate::extractor;
use crate::writer;
use crate::finder::structures::{Opts as FinderOpts, SuggestionType};
use crate::finder::Finder;
use crate::shell::{BashSpawnError, IS_FISH};
use crate::structures::cheat::{Suggestion, VariableMap};
use crate::structures::config::Action... |
use distill::loader::handle::{AssetHandle, Handle};
use legion::{Resources, World};
use rafx::assets::distill_impl::AssetResource;
use rafx::assets::AssetManager;
use rafx::rafx_visibility::VisibleBounds;
use rafx::visibility::{CullModel, ObjectId, VisibilityRegion};
use rafx_plugins::components::{MeshComponent, Transf... |
use std::collections::HashMap;
use std::error::Error;
use bytes::{Bytes, BytesMut};
use edgedb_protocol::encoding::{Input, Output};
use edgedb_protocol::features::ProtocolVersion;
use edgedb_protocol::client_message::{ClientMessage, ClientHandshake};
use edgedb_protocol::client_message::{ExecuteScript, Execute};
use ... |
use std::{collections::HashMap, fs};
#[derive(Debug, Default)]
struct Signal {
signal_patterns: Vec<String>,
ouput: Vec<String>,
}
fn main() {
println!("Part 1 result: {}", part1(get_data("input.txt")));
println!("Part 2 result: {}", part2(get_data("input.txt")));
}
fn part1(signals: Vec<Signal>) -> ... |
use serde_json::Value;
enum IndexingState {
LookingForLeftParenthesis,
Accumulating(usize),
Starting,
}
/// Updates a json Value at the specified path.
pub fn update_nested_value<V>(target: &mut Value, path: &[&str], value: V)
where
V: Into<String>,
{
let map = match target {
Value::Object... |
#![allow(clippy::cast_possible_truncation)]
use lsp_async_stub::{rpc::Error, util::Mapper, Context, Params};
use lsp_types::{FoldingRange, FoldingRangeKind, FoldingRangeParams};
use taplo::{
dom::node::DomNode,
rowan::TextRange,
syntax::{
SyntaxElement,
SyntaxKind::{
ARRAY, COMM... |
use crate::contracts::{ContractId, IdentifyableContract};
use bitcoin_hashes::sha256::Hash as Sha256;
use bitcoin_hashes::Hash as BitcoinHash;
use bitcoin_hashes::{borrow_slice_impl, hash_newtype, hex_fmt_impl, index_impl, serde_impl};
use minimint_api::encoding::{Decodable, DecodeError, Encodable};
use minimint_api::O... |
use seed::prelude::*;
use seed::{fetch, Method, Request};
use serde::{Serialize, Deserialize};
use serde_json::json;
use futures::Future;
use seed::dom_types::MessageMapper;
use wasm_bindgen::JsCast;
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct Token {
id: u32,
identityId: u32,
token... |
use std::io::{prelude::*, Cursor, SeekFrom};
use std::str::FromStr;
use failure::{format_err, Error};
use ips::Patch;
use neutopia::{self, rom, verify::Region, Neutopia};
use radix_fmt::radix_36;
use rand::{self, prelude::*};
use rand_core::SeedableRng;
use rand_pcg::Pcg32;
mod patches;
mod state;
pub use state::Che... |
// Pedersen Decentralized Verifiable secret sharing
use amcl_wrapper::group_elem::GroupElement;
use amcl_wrapper::group_elem_g1::G1;
use amcl_wrapper::field_elem::{FieldElement, FieldElementVector};
use std::collections::HashMap;
use crate::pedersen_vss::PedersenVSS;
// Pedersen Decentralized Verifiable secret shari... |
use std::collections::HashMap;
const BIRTH_COOLDOWN: i32 = 2;
const BIRTH_CYCLE: i32 = 7;
const BIRTH_CYCLE_STEP: usize = 7;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LanternFish {
day_born: i32,
}
impl LanternFish {
pub fn from_days_until_spawn(days_until_spawn: i32) -> LanternFish... |
/// Async server-side trees
use std::{ops, fmt, mem};
use dbus::tree::{Factory, Tree, MethodType, DataType, MTFn, Method, MethodInfo, MethodErr};
use dbus::{Member, Message, Connection};
use std::marker::PhantomData;
use std::cell::RefCell;
use futures::{IntoFuture, Future, Poll, Stream, Async};
use std::ffi::CString;... |
use dsf_core::components::Pos;
use dsf_core::levels::LevelSave;
use dsf_core::resources::{Tile, TileDefinition, TileDefinitions, TileMap, WorldBounds};
use std::collections::{HashMap, HashSet};
/// The representation of a level in the level editor.
#[derive(Debug, Default, Clone)]
pub struct LevelEdit {
pub tile_m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.