text stringlengths 3.09k 13.9k |
|---|
//! Everything related to the [`SharedVertexMesh`].
use std::{array, fmt};
use crate::{
prelude::*,
handle::hsize,
map::DenseMap,
mesh::SplitEdgeWithFacesResult,
traits::marker::{False, TriFaces},
traits::adj::HandleIterFamily,
};
/// One of the simplest and the most used data structure for ... |
use config::Config;
use glfw::{Action, Context, Glfw, Key, SwapInterval, WindowHint, CursorMode};
use std::convert::TryFrom;
use std::sync::mpsc::Receiver;
pub struct Window {
pub width: u32,
pub height: u32,
pub title: String,
pub glfw: Glfw,
pub glfw_window: glfw::Window,
pub glfw_events: Rec... |
use bytes::BufMut;
use futures::{TryFutureExt, TryStreamExt};
use serde::{Deserialize, Serialize};
use std::{convert::Infallible, env, fs::File, io::prelude::*};
use uuid::Uuid;
use warp::{
http::StatusCode,
multipart::{FormData, Part},
Filter, Rejection, Reply,
};
#[derive(Debug, Deserialize, Serialize, C... |
use glob::glob;
use note_rusty::cloze::ClozeChunk;
use note_rusty::render_cards::render_markdown;
use note_rusty::review_cards::{get_reviews, parse_cards};
use note_rusty::Card;
use percent_encoding::percent_decode;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::io::Write;
use std::process::C... |
use std::collections::HashMap;
use crate::{
utils::*,
commands::*,
};
use serenity::{
prelude::SerenityError,
async_trait,
client::Context,
builder::{
CreateEmbed,
CreateButton,
},
futures::StreamExt,
model::{
prelude::application_command::ApplicationCommandIn... |
use crate::bhv::{Bounded, AABB};
use crate::hittable::{Hit, Hittable};
use crate::vec::{Point3, Ray, Vec3};
#[derive(Clone, Copy)]
pub enum Axis {
X,
Y,
Z,
}
pub fn index(a: Axis) -> usize {
match a {
Axis::X => 0,
Axis::Y => 1,
Axis::Z => 2,
}
}
pub struct Translate<T: Hi... |
// -*- mode: rust; -*-
//
// This file is part of twopac.
// Copyright © 2019 Galois, Inc.
// See LICENSE for licensing information.
use crate::{errors::TwopacError, Fancy, FancyInput, FancyReveal, Garbler as Gb, Wire};
// use ocelot::ot::Sender as OtSender;
use ocelot::ot::pvw::{Sender as PVWSender, CRS};
use rand::{... |
//! # 65. 有效数字
//!
//! 难度 困难
//!
//! 验证给定的字符串是否可以解释为十进制数字。
//!
//! 例如:
//!
//! - `"0"` => `true`
//! - `" 0.1 "` => `true`
//! - `"abc"` => `false`
//! - `"1 a"` => `false`
//! - `"2e10"` => `true`
//! - `" -90e3 "` => `true`
//! - `" 1e"` => `false`
//! - `"e3"` => `false`
//! - `" 6e-1"` => `true`
//! - `" 99e2.5 "... |
mod core;
mod geometry;
use rand::Rng;
use std::f32;
use std::rc::Rc;
fn color(r: &mut geometry::Ray, world: &core::Hitable, depth: i32) -> geometry::Vec3 {
let mut rec = core::HitRecord::new();
if world.hit(r, 0.001, f32::INFINITY, &mut rec) == true {
let mut scattered = geometry::Ray::new(
... |
use std::cmp;
use std::fs::File;
use std::io::{self, BufRead};
#[derive(Debug)]
struct Target {
x_min: i64,
x_max: i64,
y_min: i64,
y_max: i64,
}
fn parse_target(data: &String) -> Target {
let instruction_str = data["target area: ".len()..].to_string();
let mut splits = instruction_str.split(", ");
// x... |
// extern
use anyhow::{Context, Result};
use hyper::header::{HeaderValue, CONTENT_TYPE};
use hyper::{Body, Method, Request, Response, StatusCode};
use log::{error, info, trace};
use multer::Multipart;
use nanoid::nanoid;
use rusqlite::{params, Connection};
use url::form_urlencoded;
// std
use std::collections::HashMap... |
use image::Primitive;
use image::Rgb;
use std::primitive::f64;
/// Color represented using the red-yellow-blue subtractive color model.
pub struct Ryb<T: Primitive>(pub [T; 3]);
pub const BLACK: Ryb<f64> = Ryb([1.0, 1.0, 1.0]);
pub const BLUE: Ryb<f64> = Ryb([0.0, 0.0, 1.0]);
pub const CYAN: Ryb<f64> = Ryb([0.0, 0.5,... |
use std::{collections::HashMap, env, fmt};
use semver::VersionReq;
use serde::{Deserialize, Serialize};
use crate::{
ci_string::CiString, error::ForemanError, fs, paths::ForemanPaths, tool_provider::Provider,
};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ToolSpec {
... |
use std::cell::RefCell;
use std::fmt;
use std::rc::Rc;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use web_sys::console;
fn window() -> web_sys::Window {
web_sys::window().expect("no global `window` exists")
}
fn request_animation_frame(f: &Closure<dyn FnMut(f64) -> ()>) {
window()
.request_animat... |
use std::fmt::Debug;
use std::fmt::Display;
use std::hash::Hash;
use bitflags::bitflags;
use failure::Fallible;
bitflags! {
/// Properties verified by the Semiring.
pub struct SemiringProperties: u32 {
/// For all a, b, c: Times(c, Plus(a, b)) = Plus(Times(c, a), Times(c, b)).
const LEFT_SEMI... |
mod bindings_cache;
use std::fmt::{self, Debug};
use std::marker::PhantomData;
use std::ops::Deref;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use parking_lot::RwLock;
use crate::actions::ActionKind;
use crate::bindings::Bindings;
use crate::state::InputState;
use crate::Event;
use self::bin... |
use crate::{
event::{MisbehaviorKind, PeerManagerEvent},
peer_manager::PeerManagerHandle,
};
use futures::channel::mpsc::UnboundedSender;
use log::{error, warn};
use tentacle::{
bytes::{Bytes, BytesMut},
multiaddr::{Multiaddr, Protocol},
utils::is_reachable,
SessionId,
};
use std::{
collec... |
use std::env::var;
use crate::metric::Namespace;
use crate::protocol::{NetworkProtocol, Protocol, Compression};
use crate::MetricalError;
use std::net::IpAddr;
use crate::configuration::{ConfigurationBuilder, Configuration};
use crate::collector::BufferedCollector;
use crate::shared::set_boxed_collector;
static FLUSH_... |
// use server;
use user::*;
use mail::*;
use interpreter::Interpreter;
use types::Type;
use environment::Environment;
#[derive(Debug, Clone)]
pub struct CondBlock {
pub cond: Option<Type>,
pub block: Vec<Instruction>,
pub elseblock: Option<Box<CondBlock>>
}
impl CondBlock {
pub fn append_block(&mut self, condbloc... |
use std::{
collections::HashMap,
sync::Arc,
time::{Duration, SystemTime},
};
use anyhow::{anyhow, Context, Result};
use async_std::{
channel::{unbounded, Receiver, Sender},
net::TcpStream,
prelude::*,
stream::{interval, Interval},
sync::RwLock,
};
use azerust_game::{
accounts::Accou... |
use crate::check::constrain::constraint::builder::ConstrBuilder;
use crate::check::constrain::generate::call::gen_call;
use crate::check::constrain::generate::class::gen_class;
use crate::check::constrain::generate::collection::gen_coll;
use crate::check::constrain::generate::control_flow::gen_flow;
use crate::check::c... |
use crate::card::Card;
use crate::math::*;
use crate::player::*;
use crate::utils::pick_card;
/// Plays a full round by dealing the cards and
/// calling [play_turn] for each of the players.
pub fn play_round(
player_hands: &mut Vec<(Vec<Card>, Option<Vec<Card>>)>,
dealer_hand: &mut Vec<Card>,
pack: &mut V... |
use crate::{
connector::{
transport::{
ButtplugConnectorTransport,
ButtplugConnectorTransportSpecificError,
ButtplugTransportIncomingMessage,
},
ButtplugConnectorError,
ButtplugConnectorResultFuture,
},
core::messages::serializer::ButtplugSerializedMessage,
};
use futures::future... |
// Things that make you go "hmm"
use lalrpop_util;
#[allow(dead_code)]
mod rules;
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Rule {
pub pat: Match,
pub render: Rendering,
}
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub enum Match {
/// loop <prev> <dirs> <curr> <dirs> <next>
Loop(Cha... |
use std::fmt;
use std::path::PathBuf;
use serde::Deserialize;
use serde::Serialize;
use quick_junit::*;
/// The structure that describe Carbon Crush input
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CarbonCrushResult {
pub consumption: String,... |
use super::{custom_float, CustomFloat, Time};
use super::vector::Vector;
#[derive(Clone, Debug)]
pub struct Particle {
pub id: usize,
pub x: Vector,
pub v: Vector,
pub r: CustomFloat,
pub m: CustomFloat,
}
/// Computes solutions to the quadratic formula:
/// ( -b +/- sqrt(b^2 - 4ac) ) / 2a
/// The smaller s... |
extern crate csv;
use std::io;
use std::env;
use std::fs::File;
use std::cmp::{Ord, Ordering};
use std::path::Path;
use std::fmt::{Debug, Formatter, Error as FmtError};
use std::io::{BufWriter, Write};
use std::error::Error;
use std::collections::HashMap;
use std::net::Ipv4Addr;
#[derive(Copy, Clone, Debug, PartialE... |
extern crate reqwest;
extern crate serde;
extern crate serde_json;
use std::io;
use std::io::Write;
use std::convert::TryInto;
use serde::{Serialize, Serializer};
use serde_json::json;
use rand::Rng;
const SPECIES: &str = "charmander";
const POKE_API: &str = "https://pokeapi.co/api/v2";
const GAME_S... |
use crate::data::MaybeSerializableData;
use crate::geometry::contact_generator::{
ContactGenerationContext, PrimitiveContactGenerationContext,
};
use crate::geometry::{Collider, ContactManifold, ShapeType, Trimesh};
use crate::ncollide::bounding_volume::{BoundingVolume, AABB};
#[cfg(feature = "serde-serialize")]
us... |
use std::fs;
use crate::wiifs;
pub mod read {
pub struct ReadInfo {
current_node: u32,
string_table: Option<String>
}
#[allow(dead_code)]
impl ReadInfo {
pub fn new() -> ReadInfo {
ReadInfo {
current_node: 1,
string_table: ... |
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
use std::ops::{Deref, DerefMut};
use std::rc::Rc;
use actix_http::encoding::Decoder;
use actix_http::error::{
ErrorBadRequest, ErrorInternalServerError, ErrorPayloadTooLarge, ErrorUnsupportedMediaType,
};
use actix_http::http::header::CONTENT_LENGTH;
... |
//! F-BLEAU is a tool for estimating the leakage of a system about its secrets
//! in a black-box manner (i.e., by only looking at examples of secret inputs
//! and respective outputs). It considers a generic system as a black-box,
//! taking secret inputs and returning outputs accordingly, and it measures
//! how much... |
#[macro_use]
extern crate log;
pub use ash;
pub use vk_mem;
use ash::vk;
mod alignment;
use alignment::Align;
pub mod util;
pub mod cleanup;
pub use cleanup::VkResource;
pub use cleanup::VkResourceDropSink;
pub mod pool;
pub use pool::VkDescriptorPoolAllocator;
pub use pool::VkPoolAllocator;
pub use pool::VkPoolR... |
/*!
## Yandex service integration and OAuth2 provider
See Yandex OAuth2 docs at https://tech.yandex.ru/oauth/doc/dg/reference/auto-code-client-docpage/.
*/
use auth::oauth2::IsOAuth2Provider;
use base::{serde_extra::is_default, wrappers::DisplayIter, BoxFuture, TimeStamp};
use futures::Future;
use http::{
client... |
//! Handles the CLI's configuration files and credentials.
mod credentials;
mod projects_config;
mod tmc_config;
pub use self::credentials::Credentials;
pub use self::projects_config::{CourseConfig, ProjectsConfig, ProjectsDirExercise};
pub use self::tmc_config::{ConfigValue, TmcConfig};
use crate::{data::LocalExerci... |
/*! Bit Management
The `Bits` trait defines constants and free functions suitable for managing bit
storage of a primitive, and is the constraint for the storage type of a
`BitVec`.
!*/
use std::{
cmp::Eq,
convert::From,
default::Default,
fmt::{
Binary,
Debug,
Display,
LowerHex,
UpperHex,
},
ops::{
N... |
//! Procedural macro support crate for the `topo` crate.
#![deny(missing_docs)]
extern crate proc_macro;
use {
proc_macro::TokenStream,
proc_macro_error::{abort, entry_point},
syn::{
export::TokenStream2, parse::Parser, punctuated::Punctuated, spanned::Spanned, FnArg,
Local, PatType, Stmt,... |
use std::collections::HashMap;
use sdl2::{ self, Sdl, AudioSubsystem };
use sdl2::mixer::{InitFlag, AUDIO_S16LSB, DEFAULT_CHANNELS, Sdl2MixerContext, Chunk, Channel};
use serde::{ Serialize, Deserialize };
use rust_engine_3d::utilities::system::{ newRcRefCell, RcRefCell };
use crate::application::project_application... |
use std::borrow::Cow;
use proc_macro2::TokenStream;
use quote::{ToTokens, TokenStreamExt};
use syn;
/// Field for the builder struct, implementing `quote::ToTokens`.
///
/// # Examples
///
/// Will expand to something like the following (depending on settings):
///
/// ```rust,ignore
/// # extern crate proc_macro2;
/... |
use alloc::string::String;
use crate::read::{ReadError, ReadRef, Result};
use crate::{pe, LittleEndian as LE, U16};
/// The `.rsrc` section of a PE file.
#[derive(Debug, Clone, Copy)]
pub struct ResourceDirectory<'data> {
data: &'data [u8],
}
impl<'data> ResourceDirectory<'data> {
/// Construct from the data... |
use crate::driver::MotorConfig;
use crate::holonomic_controller::HolonomicWheelCommand;
use super::BodyConfig;
use super::Clampable;
use super::HamiltonDriver;
use anyhow::Error;
use anyhow::Result;
use async_trait::async_trait;
use bytes::{BufMut, BytesMut};
use futures::SinkExt;
use lss_driver::LedColor;
use std::st... |
use {
crate::{parser::parser, repo::Repo, util},
serde::{de, Deserialize, Deserializer, Serialize, Serializer},
std::{
fmt,
path::{Path, PathBuf},
},
};
/// |TRC-TAG.1::SYNTAX.1::IMPL.1|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Id {
parts: Vec<(Strin... |
use std::alloc::*;
use std::ptr::NonNull;
use std::slice::from_raw_parts;
use alloc_wg::vec::Vec;
use super::*;
pub type ArgsBox<T> = alloc_wg::boxed::Box<T, hsa_rt::mem::region::RegionAlloc>;
/// Use this to invoc in a loop without allocating every iteration
/// AND without running amuck of Rust's borrow checker.... |
use serde::{Deserialize, Serialize};
use serde_json::ser::to_string;
// use sodiumoxide::utils::{memzero, mlock};
pub use crate::errors::*;
pub use crate::crypto2::create_session_keys_hex;
pub use crate::crypto2::open_box;
pub use crate::crypto2::open_secret_box;
pub use crate::crypto2::open_secret_box as open_secre... |
//! Configuration tools: formats for declaring and recording data
use chrono::{DateTime, offset::Utc};
use serde::{Serialize, Deserialize};
use std::path::PathBuf;
use std::time::Duration;
/// Experiment run specification for both declaring and recording runs in text files.
/// We use JSON as the file format. The for... |
#![cfg_attr(feature = "cargo-clippy", deny(clippy::all))]
#![cfg_attr(feature = "cargo-clippy", deny(clippy::pedantic))]
use {
clap::clap_app,
failure::Error,
futures::{future, Future},
gotham::{
self,
middleware::session::{
Backend, NewBackend, NewSessionMiddleware, Session... |
use crate::geo::{MBR, Point};
use crate::alias::AliasTable;
use crate::util;
use std::rc::Rc;
use rand::distributions::{Uniform, Distribution};
const KDTREE_THRESHOLD: usize = 256;
// Should maintain balance up to roughly 1/20
// const KDTREE_MED_SAMPLE: usize = 200;
struct KDTreeNode {
bounding_box: MBR,
chi... |
use crate::{
constants,
error,
vprintln,
path,
metadata::*
};
use sciimg::cahvor::Cahvor;
use std::fs::File;
use std::io::Read;
use serde::{
Deserialize,
Serialize
};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Extended {
#[serde(alias = "mastAz")]
pub mast_az:... |
use serde::{Serialize, Deserialize};
use serde_json;
use aws_lambda_events::event::apigw;
use crate::result::AuthResult;
pub static POLICY_VERSION: &str = "2012-10-17"; // override if necessary
pub struct ApiGatewayCustomAuthorizerPolicyBuilder {
pub region: String,
pub aws_account_id: String,
pub rest_a... |
use crate::error::{ParquetError, Result};
use parquet_format::ConvertedType;
#[derive(Clone, Debug, PartialEq)]
pub enum PrimitiveConvertedType {
Utf8,
/// an enum is converted into a binary field
Enum,
/// A decimal value.
///
/// This may be used to annotate binary or fixed primitive types. T... |
/*
* Copyright (c) 2021 gematik GmbH
*
* 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... |
pub mod animation;
pub mod paths;
use super::z::*;
use crate::gui::utils::*;
use animation::AnimatedObject;
use mogwai::prelude::*;
use paddle::*;
pub use paddlers_shared_lib::specification_types::*;
/// Manager of all sprites.
/// Cannot easily be in a component because Image is thread local.
pub struct Sprites {
... |
// Copyright 2017 <NAME>.
//
// 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 according to thos... |
enum S {
Atom(String),
Cons(String, Vec<S>),
}
impl std::fmt::Display for S {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
S::Atom(i) => write!(f, "{}", i),
S::Cons(head, rest) => {
write!(f, "({}", head)?;
... |
//! This module contains a Rust implementation of the graph designed by Ivo. All
//! graphs can be loaded and saved from/to JSON.
use petgraph::stable_graph::{NodeIndex, StableDiGraph, StableUnGraph};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HouseGraph {
pub ... |
// use crate::config::Config;
use crate::error::Error;
use csv::StringRecord;
use regex::Regex;
use serde_json::{Map, Value};
/// Reads the issues template .csv file and converts it to a JSON object
/// ```
/// use jiragen::csv_to_json;
/// use csv::StringRecord;
/// use serde_json::json;
///
/// // string conversion
... |
use crate::Locales;
use crate::Template;
use std::rc::Rc;
use sycamore::prelude::GenericNode;
use sycamore::rx::use_context;
use sycamore_router::{Route, RoutePath, Segment};
/// A representation of routes in a Perseus app. This is used internally to match routes. Because this can't be passed directly to
/// the `Rout... |
use crate::file_manip::*;
use crate::platform_specific::*;
use crate::util::*;
use log::*;
#[derive(Debug)]
pub struct HarvestedFile {
pub extension: Option<String>,
pub file_name: Option<String>,
pub path: Option<String>
}
impl HarvestedFile {
pub fn to_string(self: &Self) -> String {
r... |
use std::cmp::Ordering;
use std::collections::{BTreeSet, HashMap, HashSet};
use clap::Arg;
use once_cell::sync::OnceCell;
use serde::Deserialize;
use crate::repository_list::{get_works, Language, Repository, RepositoryLanguage, RepositoryRelatedRepositories, RepositoryTechnologyStacks, TechnologyStack, Works};
mod r... |
use bevy::input::mouse::MouseMotion;
use bevy::prelude::*;
use crate::audio::play_sound;
use crate::bullets::*;
use crate::cooldown::*;
use crate::velocity::*;
use crate::GameState;
pub struct CameraInput;
pub struct PlayerInput;
#[derive(Default)]
pub struct MouseState {
mouse_motion_event_reader: EventReader<... |
mod empty;
pub use empty::*;
pub use bytemuck;
use bytemuck::{cast_slice, Pod};
use core::alloc::{Layout, LayoutError};
use std::{marker::PhantomData, ops::Range};
// TODO: this could easily be proc-macro derived
/// An ordered set of attributes, where each attribute is some POD type that can be referenced as bytes... |
#![warn(clippy::all, clippy::pedantic)]
//! `try-continue` provides one method, [`try_continue`](`TryContinue::try_continue`),
//! which allows you to work with iterators of type `Result<T, _>`, as if they were
//! simply iterators of type `T`. this is is implemented for all iterators providing
//! a `Result`. This is... |
#![allow(non_snake_case, non_camel_case_types)]
use libc::{c_char, c_int, c_void};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ssh_key_struct {
_unused: [u8; 0],
}
pub type ssh_key = *mut ssh_key_struct;
pub type ssh_kex_types_e = c_int;
pub const KEX_TYPES_SSH_KEX: ssh_kex_types_e = 0;
pub const KEX_T... |
//! A rough shell implementation for debugging.
use crate::console::{input_queue, Input};
use crate::devices;
use crate::fs::{fat, VirtIOBlockVolume};
use crate::interrupts::{ticks, TIMER_FREQ};
use crate::phys_memory::frame_manager;
use alloc::string::String;
use core::fmt;
static CLEAR: &str = "\x1b[H\x1b[2J";
stat... |
use gl::types::{GLenum, GLuint, GLchar, GLint, GLsizei};
use crate::TextureRegion;
pub type Index = u16;
pub const GL_INDEX_TYPE: GLenum = gl::UNSIGNED_SHORT;
#[derive(Debug, Clone)]
pub struct Vertex {
pub position: [f32; 2],
pub tex_coord: [f32; 2],
pub foreground_color: [f32; 3],
pub background_co... |
use super::*;
use crate::storage::{BitIndexMaps, FileLoad, FileStore, IdMapFiles};
use crate::structure::util::sorted_iterator;
use crate::structure::*;
use std::convert::TryInto;
use std::io;
#[derive(Clone)]
pub struct IdMap {
pub id_wtree: Option<WaveletTree>,
}
impl Default for IdMap {
fn default() -> Sel... |
//! Manager of all USB serial communication
use crate::hal::usb::UsbBus;
use crate::pac;
use pac::interrupt;
use core::sync::atomic;
use cortex_m::peripheral::NVIC;
use usb_device::{class_prelude::UsbBusAllocator, prelude::*};
use usbd_serial::{SerialPort, USB_CLASS_CDC};
/// Our global singleton for USB serial comm... |
use crate::{FunctionData, Instruction, Location, Label, Value, Map, FlowGraph};
pub struct MemoryToSsaPass;
fn rewrite_memory_to_ssa(function: &mut FunctionData, pointer: Value, start_label: Label,
flow_incoming: &FlowGraph, undef: Value) {
let mut load_aliases = Vec::new();
let mut d... |
use std::cmp::max;
use std::fmt;
use crate::common::position::{CaretPos, Position};
#[derive(PartialEq, Debug, Clone)]
pub struct Lex {
pub pos: Position,
pub token: Token
}
impl Lex {
pub fn new(pos: &CaretPos, token: Token) -> Self {
let start = pos.clone();
let end = if let Token::St... |
use std::{convert::TryFrom as _, env, fs, future::Future, path::Path, str::FromStr as _};
use hyper::http::uri::PathAndQuery;
use tracing::trace;
use crate::credentials::{Credentials, Error, Metadata, Result, ServiceAccount, User};
pub(super) fn from_api_key(key: String) -> Result<Credentials> {
let part = PathA... |
//! Text layout logic.
// ---- START CLIPPY CONFIG
#![cfg_attr(all(not(test), feature="clippy"), warn(result_unwrap_used))]
#![cfg_attr(feature="clippy", warn(unseparated_literal_suffix))]
#![cfg_attr(feature="clippy", warn(wrong_pub_self_convention))]
// Enable clippy if our Cargo.toml file asked us to do so.
#![cf... |
use std::collections::HashMap;
use std::net::SocketAddr;
use std::path::{Path, PathBuf};
use chrono::Duration;
use serde::Deserialize;
use structopt::StructOpt;
use thiserror::Error;
use tracing::*;
use ::config::Config;
use crate::{NodeInfo, NodeList};
use actix_raft::SnapshotPolicy;
#[derive(Error, Debug)]
pub enum... |
use markdown;
use rustc::hir;
use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LintArray};
use syntax_pos::Span;
use syntax::ast;
use syntax::attr;
use ispell::{SpellLauncher, SpellChecker};
use markdown::{Block, Span as MdSpan};
use helpers::to_text_block;
declare_lint!(SPELLING_ERROR, Warn, "War... |
use std::io;
const N: usize = 300;
const HASH_MUL: usize = 31; // TODO - change
type Largenum = [u8; N];
fn read(stdin: &io::Stdin, buffer: &mut String) {
buffer.truncate(0);
stdin.read_line(buffer).ok().unwrap();
}
struct RabinKarp {
hash: usize,
mul: usize,
len: usize,
mul_end: usize,
}
st... |
// This file is part of the SORA network and Polkaswap app.
// Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved.
// SPDX-License-Identifier: BSD-4-Clause
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
... |
pub mod jam;
use jam::*;
use std::collections::HashMap;
use std::fs;
use std::env;
use std::{path::PathBuf, process::exit};
use yaml_rust::{Yaml, YamlLoader};
pub fn new_site(_n: String) {
//TODO
println!("Creating new site");
}
pub fn new_post(_n: String) {
//TODO
println!("Creating new post");
}
... |
use std::ops::Neg;
use super::point::Point;
use crate::math::cmp::ApproxEq;
/// A line, held in normalized standard form.
#[derive(Clone, Copy, PartialEq)]
pub struct Line {
pub a: f32,
pub b: f32,
pub c: f32,
}
impl Line {
/// Creates a new line from standard from and stores it in normalized
///... |
use crate::EscrowTrait;
use codec::{Decode, Encode};
use frame_support::{
dispatch::{DispatchError, DispatchResult},
traits::{Currency, ExistenceRequirement},
};
use primitive_types::H256;
use sp_std::{convert::TryInto, prelude::*, vec::Vec};
use system;
#[derive(Debug, Default, PartialEq, Eq, Encode, Decode, ... |
use crate::{
block::{SifBlock, SifBlockRef},
dom,
};
use sifc_bytecode::{
instr::Instr,
opc::{JmpOpKind, Op},
};
use std::{cell::RefCell, collections::HashSet, rc::Rc};
#[derive(Debug, Clone)]
pub struct CFG {
pub num_nodes: usize,
/// Nodes contains each node in the CFG in a list in any order.... |
use crate::socket::Socket;
pub trait Pin: std::convert::Into<String> {}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Gpio {
DIO0_N,
DIO0_P,
DIO1_N,
DIO1_P,
DIO2_N,
DIO2_P,
DIO3_N,
DIO3_P,
DIO4_N,
DIO4_P,
DIO5_N,
DIO5_P,
DIO6_N,
DIO6_P,
DIO7_N,
DIO7_... |
use std;
use std::rc::Rc;
use bytes::Bytes;
use futures::future::*;
use futures::*;
use h2;
use http;
use hyper;
use hyper::server::{Http, Request, Response, Service};
use regex;
use tokio_core::net::TcpListener;
use tokio_core::reactor::Handle;
use tokio_io::{AsyncRead, AsyncWrite};
use url;
use HyperService;
use er... |
use tokio::time;
use crate::{Configuration, Socket};
use pppoe::error::Error;
use std::{self, io, num, future};
use std::os::unix::io::RawFd;
pub struct Session {
socket: Socket,
config: Configuration,
}
impl Session {
pub fn new(config: Configuration, interface_name: &str) -> io::Result<Self> {
... |
use crate::{square::Square};
pub const FILE_A: u8 = 0;
pub const FILE_B: u8 = 1;
pub const FILE_C: u8 = 2;
pub const FILE_D: u8 = 3;
pub const FILE_E: u8 = 4;
pub const FILE_F: u8 = 5;
pub const FILE_G: u8 = 6;
pub const FILE_H: u8 = 7;
pub const RANK_1: u8 = 0;
pub const RANK_2: u8 = 1;
pub const RANK_3: u8 = 2;
pub... |
//! Contains [Hash](struct@Hash) and implementations
use crate::error::{Error, SignerError, VerifierError};
use crate::{Block, Result, DEFAULT_GENESIS};
use openssl::pkey::{HasPublic, PKey, PKeyRef, Private};
use openssl::{sha::Sha256, sign::Signer, sign::Verifier};
/// Hash for a block allowing full blockchain usage... |
mod in_memory;
mod on_disk;
use std::{
pin::Pin,
task::{Context, Poll},
};
use futures::{task::noop_waker, Sink, Stream};
use quickcheck::{QuickCheck, TestResult};
use tokio::runtime::Runtime;
use super::common::Variant;
use crate::test::{
common::{Action, Message},
model::{in_memory::InMemory, on_di... |
//! A collection of classes used to represent and verify capabilities in the
//! [`Capabilities`](crate::blog::auth::Capabilities) struct.
use serde::{Deserialize, Serialize};
use std::str;
use blog_db::models::*;
/// Used to indicate that a type represents a capabilities level. A Custom variant is listed for
/// an... |
use ggez::{
graphics::{self, Rect},
Context,
};
#[cfg(feature = "debug")]
use ggez::graphics::{Color, Mesh};
use crate::game::{coords::Coords, direction::Direction};
use super::{
consts,
segment::{Growable, Renderable},
Renderer,
};
/// Curved segment of a snake, 0-90 degrees of a ring.
///
#[de... |
use crate::builder::Builder;
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
use rustc_codegen_ssa::mir::operand::OperandRef;
use rustc_codegen_ssa::traits::{BaseTypeMethods, BuilderMethods, ConstMethods, DerivedTypeMethods};
use rustc::ty::layout::{Align, HasDataLayout, HasTyCtxt, L... |
use crate::job::{JobLocked, JobType};
use chrono::Utc;
use std::sync::{Arc, RwLock};
use tokio::task::JoinHandle;
use uuid::Uuid;
/// The JobScheduler contains and executes the scheduled jobs.
pub struct JobsSchedulerLocked(Arc<RwLock<JobScheduler>>);
impl Clone for JobsSchedulerLocked {
fn clone(&self) -> Self {... |
// 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.
//! Raster compact representation.
//!
//! Raster segments are stored in a compact representation that can only be iterated on and has no
//! random access... |
use super::*;
impl TableBuilder for PostgresQueryBuilder {
fn prepare_column_def(&self, column_def: &ColumnDef, sql: &mut SqlWriter) {
column_def.name.prepare(sql, self.quote());
self.prepare_column_type_check_auto_increment(column_def, sql);
for column_spec in column_def.spec.iter() {
... |
use epub_builder::{EpubBuilder, EpubContent, ReferenceType, ZipLibrary};
use image::*;
use crate::reader::*;
use regex::Regex;
use std::collections::*;
use std::path::Path;
pub struct EpubWriter<'a> {
pub title: String,
pub author: String,
pub cover_path: &'a Path,
pub page_content: Vec<String>,
pu... |
use arrayvec::ArrayVec;
use super::{ascii, DataEncodingError, EncodingContext};
pub(crate) const UNLATCH: u8 = 0b011111;
#[cfg(test)]
use alloc::vec;
#[inline]
pub(crate) fn is_encodable(ch: u8) -> bool {
matches!(ch, 32..=94)
}
/// Encode 1 to 4 characters using EDIFACT and write it to the context.
fn write4<... |
// 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 writ... |
use bitcoin::hashes::sha256d::Hash as Sha256dHash;
use rayon::prelude::*;
use std::collections::{BTreeSet, HashMap};
use std::sync::{Arc, RwLock, RwLockReadGuard};
use std::time::{Duration, Instant};
use crate::chain::{OutPoint, Transaction, TxOut};
use crate::daemon::Daemon;
use crate::errors::*;
use crate::new_inde... |
use clarity::{address::Address as EthAddress, utils::bytes_to_hex_str};
use clarity::{PrivateKey as EthPrivateKey, Uint256};
use cosmos_gravity::query::{get_latest_logic_calls, get_logic_call_signatures};
use ethereum_gravity::message_signatures::encode_logic_call_confirm_hashed;
use ethereum_gravity::one_eth;
use ethe... |
// Copyright 2018 Developers of the Rand project.
//
// 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, or distributed
/... |
use super::*;
use crate::{logging, Error, Result};
use std::fs::File;
use std::io::{ErrorKind, Read, Seek, SeekFrom};
use std::sync::Mutex;
static OFFSET_NOT_FOUND: isize = -1;
#[derive(Debug)]
pub struct FilePosition {
pub metric_filename: PathBuf,
pub idx_filename: PathBuf,
pub cur_offset_in_idx: SeekFr... |
//! Instrumentation Trace Macrocell
//!
//! *NOTE* Not available on Armv6-M and Armv8-M Baseline.
use core::cell::UnsafeCell;
use core::ptr;
use volatile_register::{RO, RW, WO};
use crate::peripheral::ITM;
use bitfield::bitfield;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Register block
#[r... |
use anyhow::Context as AnyhowContext;
use anyhow::{anyhow, Result};
use std::fmt;
const COL_WIDTH: usize = 21;
const PROJECT_HEADER: &str = "Name";
const REMAINING_TASK_HEADER: &str = "Remaining";
const AVG_AGE_HEADER: &str = "Avg age";
const COMPLETE_HEADER: &str = "Complete";
use chrono::{Datelike, Duration, Local,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.