text stringlengths 3.09k 13.9k |
|---|
use authorization::AuthorizationHeaderFactory;
use Bytes;
use write::{OutputFileWriter, OutputChunkWriter};
use client::GetResponse;
use hyper::client::Client;
use hyper::error::Error;
use hyper::header::{ByteRangeSpec, Headers, Range};
use hyper::net::HttpsConnector;
use hyper_native_tls::NativeTlsClient;
use pbr::{Mu... |
//! Unofficial library to use the Stych email flow in Rust
//!
//! # Usage
//!
//! ```no_run
//! use stytch::Stytch;
//!
//! // Store credentials
//! let stytch = Stytch::new(
//! "project_id",
//! "secret",
//! "redirect_for_login",
//! "redirect_for_signup"
//! );
//!
//! // Create new user
//! let us... |
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "std")]
extern crate core;
#[cfg(feature = "alloc")]
extern crate alloc;
use arrayref::array_ref;
use ockam_core::vault::{
AsymmetricVault, Hasher, PublicKey, SecretType, SecretVault, Signer, SymmetricVault, Verifier,
};
use ockam_core::{compat::vec::Vec... |
extern crate pcap;
extern crate hyper;
extern crate rustc_serialize;
use pcap::{Device, Capture};
use std::sync::mpsc::{channel, Sender, Receiver};
use packet::{PingPacket, PacketContainer};
use std::thread;
use hyper::Client;
use std::collections::VecDeque;
use rustc_serialize::{json, Encodable};
use Runnable;
use std... |
//! This crate provides an abstraction of a [bang-bang controller](https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control)
//! along with a simple reference implementation. Suitable for regular applications using the standard
//! library and embedded applications using [`#![no_std]`](https://doc.rust-lang.org/referenc... |
use std::borrow::Cow;
use inflections::Inflect;
use svd::{Access, Cluster, Register};
use syn::Ident;
use quote::Tokens;
use either::Either;
use errors::*;
pub const BITS_PER_BYTE: u32 = 8;
/// List of chars that some vendors use in their peripheral/field names but
/// that are not valid in Rust ident
const BLACKLI... |
use libc::*;
use *;
#[repr(C)]
#[derive(Copy, Clone)]
pub enum point_conversion_form_t {
POINT_CONVERSION_COMPRESSED = 2,
POINT_CONVERSION_UNCOMPRESSED = 4,
POINT_CONVERSION_HYBRID = 6,
}
pub enum EC_METHOD {}
pub enum EC_GROUP {}
pub enum EC_POINT {}
pub const OPENSSL_EC_NAMED_CURVE: c_int = 1;
extern... |
use makepad_render::*;
use makepad_widget::*;
use crate::searchindex::*;
use crate::appstorage::*;
use crate::mprstokenizer::*;
use crate::livemacro::*;
#[derive(Clone)]
pub struct RustEditor {
pub view: View,
pub live_macros_view: LiveMacrosView,
pub splitter: Splitter,
pub text_editor: TextEditor,
}
... |
use crate::{Vertex, Graph};
use crate::error::{GraphError, ErrorKind};
use crate::algorithms::{VisitorDFS, VisitorDFSAction, dfs_with_visitor};
struct CustomVisitor {
orders: Vec<usize>,
visited: Vec<bool>
}
impl <T> VisitorDFS<T> for CustomVisitor {
fn exit_from_vertex_event(&mut self, vertex: &Vertex<T>)... |
// External Dependencies ------------------------------------------------------
use std::cmp;
use std::io::Error;
use std::net::SocketAddr;
use std::collections::{BinaryHeap, HashSet};
use cobalt::{
Config,
Connection,
ConnectionID,
ConnectionMap,
MessageKind,
Handler as CobaltHandler,
Serve... |
//! # Day 2: Password Philosophy
//!
//! Your flight departs in a few days from the coastal airport; the easiest way
//! down to the coast from here is via toboggan.
//!
//! The shopkeeper at the North Pole Toboggan Rental Shop is having a bad day.
//! "Something's wrong with our computers; we can't log in!" You ask if... |
use ndarray::{ArrayView2, ArrayView1, Array1};
use rand;
use rand::Rng;
// use rand::distributions::Uniform;
use average::Variance;
// use ndarray::parallel::prelude::*;
use serde::{Serialize, Deserialize};
use crate::utils::numerics::{D, NonNan};
use crate::estimator::Estimator;
use crate::utils::array::*;
/// Split ... |
use std::io::Cursor;
use std::ops::Sub;
use std::path::PathBuf;
use std::str::FromStr;
use std::thread;
use std::time::Duration;
use bitcoin::secp256k1;
use bitcoin::{Address, Transaction};
use bitcoincore_rpc::Client;
use bitcoincore_rpc::{Auth, RpcApi};
use clightningrpc::responses::NetworkAddress;
use clightningrpc... |
use crate::app::App;
use crate::game::{DrawBaselayer, State, Transition};
use crate::helpers::nice_map_name;
use crate::render::DrawArea;
use ezgui::{
hotkey, Btn, Color, Composite, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, ScreenPt, Text,
Widget,
};
use geom::{Distance, Polygon, Pt2D};
use map_model::Ci... |
use cfg_expr::{
error::Reason,
expr::{Predicate as P, TargetPredicate as TP},
targets::*,
Expression, ParseError,
};
macro_rules! test_validate {
(ok [$($text:expr => [$($expected:expr),*$(,)?]),+$(,)?]) => {
$(
let val_expr = Expression::parse($text).unwrap();
let m... |
//! Smooth screen-space line rendering.
//!
//! Heavily inspired by:
//! https://mattdesl.svbtle.com/drawing-lines-is-hard
//!
//! More specifically:
//! https://github.com/mattdesl/webgl-lines/blob/master/projected/vert.glsl
//!
//! I've integrated the anti-aliasing technique from:
//! https://blog.mapbox.... |
use std::collections::HashMap;
use std::io::{self, Read};
use std::fs::File;
use interpreter;
use value::Value;
use function::Function;
use tokenize;
pub struct Engine {
//so that no empty hashmap has to be generated on every interpreted line (-> local vars)
static_empty_map: HashMap<String, Value>,
vars:... |
use crate::co;
use crate::kernel::decl::{LANGID, WinResult, WString};
use crate::version::decl::{GetFileVersionInfo, VarQueryValue, VS_FIXEDFILEINFO};
/// Retrieves data from an embedded resource, which can be read from an
/// executable file or a DLL.
///
/// # Examples
///
/// Reading version information:
... |
use thiserror::Error;
use crate::operations::CollectionUpdateOperations;
use segment::types::{PointIdType, ScoredPoint, SegmentConfig, VectorElementType, HasIdCondition};
use std::result;
use crate::operations::types::{Record, CollectionInfo, UpdateResult, UpdateStatus, SearchRequest, RecommendRequest};
use std::sync::... |
/// MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between
/// ICS20 enabled chains. See ICS Spec here:
/// https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgTransfer {
/// the port on which t... |
// Common types used across API
use chrono::{NaiveDate, NaiveDateTime};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::validators;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct Game {
pub id: u64,
pub titl... |
/*
* Copyright 2019 The Starlark in Rust Authors.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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/lic... |
use bigdecimal::BigDecimal;
use chrono::prelude::DateTime;
use chrono::Utc;
use serde::{Deserialize, Serialize};
use std::fmt;
use std::time::{Duration, UNIX_EPOCH};
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub enum Value {
UnsignedInteger(u8),
SignedInteger(i64),
Float(f32),
Double(f64),
... |
use super::{Allocator, AllocatorError};
use crate::{mem::AddressRange, prelude::*};
#[repr(C)]
#[derive(Copy, Clone)]
union NextOrChecksum {
next: *mut BlockHeader,
checksum: usize,
}
#[repr(C)]
pub struct BlockHeader {
size: usize,
next_or_checksum: NextOrChecksum,
}
const HEADER_SIZE: usize = size_... |
use lockfree::queue::Queue;
use owned_alloc::OwnedAlloc;
use std::{
cell::Cell,
fmt,
ptr::{null_mut, NonNull},
sync::{
atomic::{AtomicPtr, AtomicUsize, Ordering::*},
Arc,
},
thread,
};
pub fn spawn<F, T>(task: F) -> JoinHandle<T>
where
F: FnOnce() -> T + Send + 'static,
... |
use crate::field::FieldRef;
use crate::query::{Presence, Query};
use crate::token::TokenSet;
use crate::vector::Vector;
use std::cmp::Ordering;
use std::collections::{HashMap, HashSet};
#[derive(Eq, PartialEq, Clone)]
pub struct InvertedIndex {
pub index: u64,
pub documents: HashMap<String, HashSet<String>>, ... |
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use libra_config::config::{PeerNetworkId, UpstreamConfig};
use std::{
collections::{BTreeSet, HashMap, HashSet},
sync::Mutex,
};
/// stores only peers that receive txns from this node
pub(crate) type PeerInfo = HashMap<PeerNet... |
use glm::Mat4;
use crate::gl;
use crate::video::color::*;
use crate::video::*;
use crate::*;
pub struct SpriteBatcher {
gl: gl::Gl,
program: Program,
projection_uniform: Option<Uniform>,
vbo: ArrayBuffer,
vao: VertexArray,
vertices: Vec<Vertex>,
capacity: usize,
texture: TextureAtlas,
... |
use core::iter::FusedIterator;
#[derive(Clone, Debug)]
pub(crate) struct AttributePairs<'a> {
string: &'a str,
index: usize,
}
impl<'a> AttributePairs<'a> {
pub const fn new(string: &'a str) -> Self { Self { string, index: 0 } }
}
impl<'a> Iterator for AttributePairs<'a> {
type Item = (&'a str, &'a s... |
// Magical Bitcoin Library
// Written in 2020 by
// <NAME> <<EMAIL>>
//
// Copyright (c) 2020 Magical Bitcoin
//
// 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, in... |
use cmake::Config;
use std::env;
use std::ffi::OsString;
use std::path::PathBuf;
#[cfg(debug_assertions)]
fn get_bin_dir() -> (&'static str, &'static str) {
match env::var("CARGO_CFG_TARGET_OS").unwrap().as_str() {
"linux" => ("linux", "bin/linux.clang/debug"),
"windows" => ("windows", "bin/win.x86... |
use std::collections::HashMap;
use std::ops::{Index, IndexMut, RangeInclusive, Add};
use std::fmt;
/*
Provides infinite hypercube operations (get w/default, set, ranges) and
debug formatting for hypercubes of enums with no associated data.
To use, just set up the enum as described in the grid module.
*/
type Grid<T> ... |
use super::Sample;
use std::f64::consts::PI;
use nannou::rand::random;
// We could later turn WavetableIndex into a generational index if we'd want
pub type WavetableIndex = usize;
pub struct Wavetable {
buffer: Vec<Sample>, // Box<[Sample; 131072]>,
// Store the size as an f64 to find fractional indexes wit... |
mod preset;
mod preset_small;
mod preset_medium;
mod preset_large;
use morsels_common::MorselsLanguageConfig;
use crate::fieldinfo::FieldsConfig;
use crate::loader::Loader;
use crate::loader::csv::CsvLoader;
use crate::loader::html::HtmlLoader;
use crate::loader::json::JsonLoader;
use crate::loader::txt::TxtLoader;
... |
use std::fmt;
use kailua_env::{Span, Spanned, WithLoc};
use kailua_diag::{self, Report, Reporter};
use kailua_syntax::Name;
use kailua_types::ty::{TypeContext, ClassSystemId, ClassId, Class, Display, DisplayState};
use kailua_types::ty::{Slot, SpannedSlotSeq, Key, T, Nil};
use message as m;
/// Defines the various cha... |
use crate::{
semantic_analysis::{
ast_node::TypedExpression,
declaration::{EnforceTypeArguments, Monomorphize, MonomorphizeHelper},
},
type_engine::*,
CallPath, CompileResult, Ident, TypeArgument, TypeInfo, TypedDeclaration,
TypedFunctionDeclaration,
};
use super::{module::Module, r... |
use std::mem;
use wrap::*;
use common::math::Transform;
use collision::{Manifold, WorldManifold};
use dynamics::body::FixtureHandle;
use dynamics::fixture::Fixture;
use dynamics::world::BodyHandle;
use user_data::RawUserData;
#[repr(C)]
#[doc(hidden)]
pub struct ContactEdge {
pub other: *mut ffi::Body,
pub con... |
// Copyright <NAME> 2021.
// Distributed under the MIT License.
// See accompanying file License.txt, or online at
// https://opensource.org/licenses/MIT
#![cfg_attr(not(doctest), doc = include_str!("../Readme.md"))]
use std::collections::HashMap;
use std::io::Cursor;
use image::io::Reader as ImageReader;
use image:... |
use std::time::SystemTimeError;
use bytes::{
Buf,
Bytes,
BytesMut,
};
use prost::Message;
use crate::{
graplinc::common::v1beta1::{
SystemTime,
Uuid,
},
protobufs::graplinc::grapl::pipeline::v1beta1::{
Envelope as EnvelopeProto,
Metadata as MetadataProto,
... |
// This file is part of simple-http-server. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/simple-http-server/master/COPYRIGHT. No part of simple-http-server, including this file, may be copied, modified, ... |
use crate::field_new;
use crate::{
biginteger::BigInteger256,
curves::{
models::{ModelParameters, TEModelParameters},
twisted_edwards_extended::{GroupAffine, GroupProjective},
},
fields::jubjub::{fq::Fq, fr::Fr},
};
use std::str::FromStr;
#[cfg(test)]
mod tests;
pub type JubJubAffine =... |
use crate::error::Error;
use crate::rmps::encode as rencode;
use crate::rmps::Deserializer;
use crate::time_pack::TimePack;
use rmp::encode;
use serde::Deserialize;
use std::collections::VecDeque;
use std::time::SystemTime;
pub trait Take<T> {
fn take(&mut self, buf: &mut Vec<T>);
}
impl<T> Take<T> for VecDeque<T... |
//! Handles interfacing with the database.
use chrono::Utc;
use rocket::{
request::{self, FromRequest, Request},
Outcome, Rocket,
};
use rocket_contrib::{
database,
databases::mongodb::{
self, bson,
coll::{
options::{FindOneAndUpdateOptions, FindOptions},
results... |
//! File chunking and hashing utilities.
use std::collections::BTreeMap;
use std::fmt::Write;
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
use crate::model::{FolderEntry, FolderEntryKind};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ChunkInfo {
/// the length of thi... |
use line_reader::read_file_to_lines;
use NumPad::*;
pub(crate) fn day02_part1() -> String {
bathroom_code(read_file_to_lines("input/day02.txt"), NumPadType::Simple)
}
pub(crate) fn day02_part2() -> String {
bathroom_code(read_file_to_lines("input/day02.txt"), NumPadType::Complex)
}
enum NumPadType {
Simp... |
// Copyright (c) 2018 <NAME>
// [This program is licensed under the "MIT License"]
// Please see the file LICENSE in the source
// distribution of this software for license terms.
use super::Cartridge;
use std::fs::File;
use std::fs::OpenOptions;
use std::io::prelude::*;
use std::io::SeekFrom;
// This code was made u... |
// Copyright 2016 PingCAP, 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 i... |
use std::marker::PhantomData;
use nbt::Blob;
use serde::{de::Visitor, Deserialize, Serialize};
use crate::{
packets::types::{LengthPrefixedVec, Nbt},
serde::varint::VarInt,
};
/// A crafting recipe.
#[derive(Serialize, Deserialize)]
pub struct Recipe<'a> {
/// The recipe id.
id: String,
/// The t... |
//! Provides a utility for sorting tickets and fields.
use std::collections::{HashMap, HashSet};
use crate::{Ticket, TicketFieldRule};
/// Finds the field ordering for a set of tickets and a set of unordered field rules.
//
/// Assumes there is exactly one valid field ordering and at least one valid ticket.
pub stru... |
//! A module for interpolating pixels.
// from rust
use std::cmp;
// from external crate
// from local crate
use error::RasterResult;
use Image;
use Color;
/// An enum for the various modes that can be used for interpolation.
#[derive(Debug)]
pub enum InterpolationMode {
Bilinear,
Bicubic,
Nearest,
}
... |
#[macro_use]
extern crate log;
extern crate rand;
extern crate web_logger;
#[macro_use]
extern crate yew;
use yew::prelude::*;
pub const HEIGHT: usize = 30;
pub const WIDTH: usize = 40;
#[derive(Debug)]
pub struct Cell {
mined: bool,
exposed: bool,
flagged: bool,
mine_count: usize,
}
pub type Board ... |
//src/web/map.rs: Map related REST endpoints.
//Author: <NAME>
//Copyright (c) 2020 LAPS Group
//Distributed under the zlib licence, see LICENCE.
use crate::{types::BackendError, util::create_redis_key};
use rocket::{http::ContentType, Response, State};
use rocket_contrib::{json, json::JsonValue};
use std::io::Cursor;... |
//! [Problem 18](https://projecteuler.net/problem=18)([JP](http://www.odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2018))
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::iter::repeat;
pub const TRIANGLE: &[&[usize]] = &[
&[75],
&[95, 64],
&[17, 47, 82],
&[18,... |
// 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.
use {
crate::model::*,
cm_rust::{ComponentDecl, ExposeDecl, UseDecl},
directory_broker::RoutingFn,
failure::format_err,
fidl::endpoints... |
mod rt_util;
mod tree_node;
use crate::rt_util::*;
use lazy_static::lazy_static;
use lrlex::lrlex_mod;
use lrpar::lrpar_mod;
use regex::Regex;
use std::fs;
use std::io::{self, BufRead, ErrorKind, Write};
// Using `lrlex_mod!` brings the lexer for `calc.l` into scope. By default the
// module name will be `calc_l` (i.... |
use chrono::NaiveDate;
use reqwest::blocking::{Client, Response};
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::thread::sleep;
use std::time::Duration;
use crate::tagger::matcher::Matcher;
use crate::tagger::{Explicitness, ITunesID, MusicPlatform, TaggerConfig, Track, TrackMatcherST};
pub struc... |
// Copyright (c) 2016 <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distri... |
use super::{MapBuilder, Map,
TileType, Position, spawner, SHOW_MAPGEN_VISUALIZER,
remove_unreachable_areas_returning_most_distant, generate_voronoi_spawn_regions};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use std::collections::HashMap;
#[derive(PartialEq, Copy, Clone)]
pub enum DistanceAlgorit... |
// This file is part of Sulis, a turn based RPG written in Rust.
// Copyright 2018 <NAME>
//
// Sulis is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your opt... |
// Copyright 2021 The Grin Developers
//
// 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 agree... |
use std::fmt;
use std::iter::Iterator;
use std::ops::{Add, Mul, Sub};
#[derive(Debug, Copy, Clone)]
pub struct Color {
r: u8,
g: u8,
b: u8,
next: NextColor,
}
#[derive(Debug, Copy, Clone)]
pub enum NextColor {
Red,
Green,
Blue,
Done,
}
impl Iterator for Color {
type Item = u8;
... |
use std::fmt;
use libeir_diagnostics::SourceSpan;
use crate::lexer::{AtomToken, LexicalToken, SymbolToken, Token};
use super::Result;
use super::directives;
use super::token_reader::{ReadFrom, TokenReader};
/// Macro directive
#[derive(Debug, Clone)]
pub enum Directive {
Module(directives::Module),
Include... |
use {
crate::ErrorCode,
anchor_lang::{
prelude::{msg, AccountInfo, ProgramError, ProgramResult, Pubkey, Rent, SolanaSysvar},
solana_program::{
program::{invoke, invoke_signed},
program_pack::{IsInitialized, Pack},
system_instruction,
},
},
std:... |
//! This is a pretty direct port of the [sparkline demo in the tui crate][demo].
//!
//! [demo]: https://github.com/fdehau/tui-rs/blob/3f62ce9c199bb0048996bbdeb236d6e5522ec9e0/examples/sparkline.rs
use console_error_panic_hook::set_once as set_panic_hook;
use crossterm::{execute, terminal::EnterAlternateScreen};
use r... |
extern crate basic_otp;
extern crate structopt;
#[macro_use]
extern crate clap;
extern crate toml;
#[macro_use]
extern crate serde_derive;
extern crate app_dirs;
extern crate data_encoding;
use std::path::PathBuf;
use app_dirs::*;
use basic_otp::totp_offset;
use data_encoding::BASE32;
use structopt::StructOpt;
use s... |
use arg_mappings::*;
use clap::{Arg, App, AppSettings, SubCommand};
use cmd_executer::*;
use invocation_error::*;
use itertools::Itertools;
use em_refactor_lib_types::{*, defs::*};
mod arg_mappings;
mod cmd_executer;
mod invocation_error;
fn app<'a, 'b>() -> App<'a, 'b> {
App::new("Refactoring tool")
.versio... |
use crate::entity::error::Error;
use crate::entity::hidden::Hidden;
use crate::entity::request::{SetupRequest, UpdateSiteRequest};
use crate::entity::response::{AppNeedUpdateResponse, SiteBriefResponse, SiteFullResponse};
use crate::entity::site::Site;
use crate::entity::user::User;
use crate::service::app_state::AppSt... |
use std::slice::Iter;
pub const STANDARD_DECK_SIZE: u8 = 52;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Color {
Red,
Black,
}
impl Color {
pub fn other(&self) -> Color {
match *self {
Color::Red => Color::Black,
Color::Black => Color::Red,
}
}
}
#[derive(Debug, Copy, Clo... |
//! A sound API that allows playing clips at given volumes
//!
//! On the desktop, currently all sounds are loaded into memory, but streaming sounds may be
//! introduced in the future. On the web, it can be different from browser to browser
use {
Result,
error::QuicksilverError,
futures::{Future, future},... |
//! Brainfuck REPL Interpreter
//!
//! The REPL interpreter allows you to input a Brainfuck program from the command line and see it
//! execute on the fly.
//!
//! This module also contains the context of the virtual machine used to execute Brainfuck code.
use std;
use std::str::FromStr;
use std::io::{Write};
use ... |
use std::fs::File;
use std::io;
use std::path::{Path, PathBuf};
use fern::colors::ColoredLevelConfig;
use gumdrop::Options;
use redscript::bundle::ScriptBundle;
use redscript::definition::AnyDefinition;
use redscript::error::Error;
use redscript_compiler::source_map::{Files, SourceFilter};
use redscript_compiler::unit... |
use super::owned::UseStateOwned;
use std::{
cell::{Ref, RefMut},
fmt::{Debug, Display},
rc::Rc,
};
pub struct UseState<'a, T: 'static>(pub(crate) &'a UseStateOwned<T>);
impl<T> Copy for UseState<'_, T> {}
impl<'a, T: 'static> Clone for UseState<'a, T> {
fn clone(&self) -> Self {
UseState(self... |
extern crate yansi;
extern crate whoami;
extern crate dirs;
extern crate crossterm;
#[macro_use]
extern crate lazy_static;
#[cfg( windows )]
extern crate winapi;
#[macro_use]
extern crate clap;
mod peek;
mod parsing;
mod shell;
mod kernel;
mod empty;
use std::env::{ current_dir as env_current_dir };
use std::io::{... |
use std::sync::Arc;
use crate::{Id, IdSequence, Item, Metric};
const CHUNK_SIZE: usize = 4096;
use tokio::sync::mpsc::{
unbounded_channel, UnboundedReceiver as Receiver, UnboundedSender as Sender,
};
#[derive(Clone)]
pub struct Metrics {
// chunks只扩容,不做其他变更。
chunks: Vec<*const Item>,
register: Sende... |
use std::{mem, ptr};
use {Errno, Error, Result};
use libc::{c_void, c_long, siginfo_t};
use ::unistd::Pid;
pub mod ptrace {
use libc::c_int;
pub type PtraceRequest = c_int;
pub const PTRACE_TRACEME: PtraceRequest = 0;
pub const PTRACE_PEEKTEXT: PtraceRequest = 1;
pub const PTRACE_PEEKDATA:... |
use bytes::{Buf, BufMut, Bytes, BytesMut};
use futures::{TryStreamExt, stream::{Stream, StreamExt}};
use std::task::{Context, Poll};
use crate::ebml::FromEbml;
use crate::error::WebmetroError;
pub struct EbmlStreamingParser<S> {
stream: S,
buffer: BytesMut,
buffer_size_limit: Option<usize>,
borrowed: ... |
// Copyright 2021 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any late... |
// Copyright 2021 <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
//
// Unless required by applicable law or agreed t... |
use std::{cell::RefCell, rc::Rc};
use std::ops::Deref;
use crate::ppu::NESPpu;
use super::mapper::Mapper;
pub trait MemoryRead {
fn read(&self, addr: u16) -> u8; /* A side-effect less read */
fn read_mut(&mut self, addr: u16) -> u8; /* A read with side-effects */
// Convenience function... |
#![recursion_limit = "128"]
//! Provides the `#[numeric_newtype]` proc_macro_attribute to implement `std::ops::*` traits.
//!
//! # Examples
//!
//! ```edition2018
//! use derive_more::{Add, AddAssign, Display, From, Sub, SubAssign};
//! use numeric_newtype_derive::numeric_newtype;
//!
//! macro_rules! test {
//! ... |
use crate::bw::game::Game;
use crate::bw::unit::Unit;
use crate::{ffi, FromRaw};
use cxx::memory::UniquePtrTarget;
use cxx::UniquePtr;
use once_cell::sync::Lazy;
use std::cell::RefCell;
use std::collections::VecDeque;
use std::marker::PhantomData;
use std::ops::Deref;
use std::pin::Pin;
use std::ptr::null_mut;
use std:... |
use std::collections::HashMap;
use std::iter::FromIterator;
type TParsed = Vec<TParsedSub>;
type TParsedSub = Instruction;
pub fn day(input: String) -> (u64, u64) {
let parsed_input = parse(&input);
(part_1(&parsed_input), part_2(&parsed_input))
}
fn part_1(input: &TParsed) -> u64 {
let mut current_mask ... |
extern crate cfg_if;
extern crate console_error_panic_hook;
extern crate wasm_bindgen;
use cfg_if::cfg_if;
use real_hora::core::ann_index::ANNIndex;
use real_hora::core::metrics;
use std::panic;
use wasm_bindgen::prelude::*;
cfg_if! {
if #[cfg(feature = "wee_alloc")] {
extern crate wee_alloc;
#[glo... |
use alloc::vec;
use alloc::vec::Vec;
use core::convert::TryInto;
use core::ptr;
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use core::time::Duration;
use log::{error, info, trace};
use spin::Mutex;
use x86::bits64::paging::{PAddr, VAddr, BASE_PAGE_SIZE};
use lineup::rwlock::{RwLock, RwLockIntent};
us... |
// Copyright (c) 2015-2019 <NAME>.) <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 ... |
use slog::Logger;
use specs;
use specs::{Read, Write, WriteStorage};
use super::{
CellDweller, CellDwellerMessage, RecvMessageQueue, RemoveBlockMessage, SendMessage,
SendMessageQueue,
};
use crate::globe::Globe;
use crate::grid::PosInOwningRoot;
use crate::net::{Destination, EntityIds, NodeResource, Transport}... |
use clap::Parser;
#[derive(Parser)]
#[clap(version, author)]
struct DoCoreOpts {
/// DO Core instruction
#[clap(short, long)]
insn: String,
}
#[derive(Debug)]
struct Instruction {
opcode: OpCode,
op0: u8,
op1: u8,
}
#[derive(Debug)]
enum Error {
InvalidOpCode(u8),
Op0OutOfRange,
O... |
// Copyright (c) 2012, <NAME> <<EMAIL>>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISC... |
use std::io::Read;
pub const HEAPSIZE: usize = 30000;
pub const CODESIZE: usize = HEAPSIZE;
pub const STACKSIZE: usize = 30000;
#[derive(Copy, Clone)]
pub enum Instruction {
Backward(u8),
Forward(u8),
Subtract(u8),
Add(u8),
Land,
Jump,
Write,
Read,
Nop,
}
impl Instruction {
#[... |
use crate::boards::idx_coord::BoardCoord;
use crate::boards::{board_cols, board_rows};
use crate::constants::colors::{
DARK_GRAY, DARK_GREEN, FAINT_BLUE, FAINT_RED, LIGHT_BLUE, LIGHT_GRAY, RED, WHITE,
};
use crate::system::letter_mesh::make_letter_mesh;
use crate::system::math::{pt, Offset, OffsetTuple, Point};
use... |
use rayon::prelude::*;
use crate::*;
use crate::ecelgamal::*;
fn divide_up(a: usize, b: usize) -> usize {
(a / b) + (if a % b == 0 { 0 } else { 1 })
}
pub fn reply_size(dimension: u8, packing: u8, elem_size: usize) -> usize {
let mut target_size = elem_size;
for _ in 0..dimension {
target_size = C... |
use std::fs::File;
use std::io::prelude::*;
use std::io::Result;
use dsl::*;
use dsl::Constraint::*;
pub trait LpFileFormat {
fn to_lp_file_format(&self) -> String;
fn write_lp(&self, file_model: &str) -> Result<()> {
let mut buffer = File::create(file_model)?;
buffer.write(self.to_lp_file_for... |
use errno::{set_errno, Errno};
use std::{marker::PhantomData, mem::size_of, os::raw::c_void};
use crate::map_batch::*;
use crate::map_common as mc;
use crate::map_common::{MapLike, MapValue};
use crate::object::XDPLoadedObject;
use crate::result::XDPResult;
use crate::{KeyValue, MapType, XDPError};
/// Used for worki... |
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at yo... |
use aoc_runner_derive::{aoc, aoc_generator};
use lazy_static::lazy_static;
//use petgraph::dot::Dot;
use petgraph::graph::{Graph, NodeIndex};
use petgraph::Direction;
use regex::Regex;
use std::collections::HashMap;
use std::collections::HashSet;
// The regex to extract from input
lazy_static! {
static ref LINEPAR... |
use std::convert::TryFrom;
use std::mem::swap;
/// Non-empty vector.
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
pub struct Vec1<T> {
head: T,
tail: Vec<T>,
}
impl<T> From<T> for Vec1<T> {
fn from(head: T) -> Self {
Self::new(head, Default::default())
}
}
impl<T> TryFrom<Vec<T>> f... |
// Track generic associated constants (constants in generic contexts that depend
// on generic type parameters) here: https://github.com/rust-lang/rfcs/pull/1657
//
// The implementation relying on "gen_assoc_consts" has been removed due to
// maintainability concerns
#[cfg(all(
not(feature = "gen_assoc_consts"),
... |
// # Pointers (old)
//
// ~96~ 80 bytes .bss
//
// # -Os
//
// init
// a(bl=16000000, now=16000249)
// b(bl=24000000, now=24000248)
// a(bl=32000000, now=32000249)
// b(bl=48000000, now=48000282)
// a(bl=48000000, now=48001731)
// a(bl=64000000, now=64000249)
// b(bl=72000000, now=72000248)
// a(bl=80000000, now=800002... |
extern crate crypto;
use log::log_file::LogFile;
use self::crypto::symmetriccipher::SymmetricCipherError;
pub struct Interpreter {
pub logfile: LogFile
}
impl<'a> Interpreter {
pub fn new(path: &'a str) -> Interpreter {
let logfile = LogFile::open(path);
Interpreter { logfile }
}... |
use std::cmp::min;
use std::io;
use std::io::prelude::*;
use std::time::Instant;
use zmu_cortex_m::semihosting::{SemihostingCommand, SemihostingResponse, SysExceptionReason};
const TT_HANDLE_STDIN: u32 = 1;
const TT_HANDLE_STDOUT: u32 = 2;
const TT_HANDLE_STDERR: u32 = 3;
const SEMIHOST_FEATURES_HANDLE: u32 = 4;
/*
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.