text stringlengths 3.09k 13.9k |
|---|
#![allow(unused)]
/*
Kata (6kyu): Are they the "same"?
Url: https://www.codewars.com/kata/are-they-the-same/train/rust
Given two arrays a and b write a function comp(a, b)
(compSame(a, b) in Clojure) that checks whether the two arrays have
the "same" elements, with the same multiplicities. "Same" ... |
pub use self::platform::{
next,
start,
Task,
};
pub fn wait_result<X, E1, E2, F, G>(mut f: F, mut g: G) -> Result<X, E2>
where
F: FnMut() -> Result<X, E1>,
G: FnMut(E1) -> Option<E2>,
{
loop {
match f() {
Ok(x) => return Ok(x),
Err(e) => match g(e) {
... |
use std::path::PathBuf;
use std::sync::mpsc::Sender;
use std::sync::Arc;
use std::sync::Mutex;
use std::time::{Duration, Instant};
use chashmap::CHashMap;
use snork_core::agents::*;
use snork_core::env::{GameRequest, IndexResponse, MoveResponse, API_VERSION};
use actix_web::{get, post, web, App, HttpResponse, HttpSe... |
use termimage::ops;
use image::GenericImage;
use term_size::dimensions;
use player::*;
use download::Downloader;
use backend::*;
use std::io::{StdoutLock, Write};
use std::path::PathBuf;
const SCALE_FACTOR: f32 = 0.5;
pub struct CommandCenter<'a> {
currents: Vec<BackendSearchResult>,
current: Option<Backend... |
/*
* Copyright 2018 Bitwise IO, 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 agree... |
//! A widget for displaying and mutating a one-line field of text.
use {
Align,
Color,
Colorable,
FontSize,
Borderable,
Positionable,
Range,
Rect,
Scalar,
Sizeable,
Widget,
};
use event;
use input;
use widget;
/// A widget for displaying and mutating a small, one-line field... |
use super::super::AppState;
use super::camera::new_camera_2d;
use super::components::{Jumper, Materials, Player};
use super::{
death_by_height, destroy_bullet_on_contact, kill_on_contact, on_bullet_fired,
on_living_being_dead, on_living_being_hit, BulletFiredEvent, Enemy, GameDirection, LivingBeing,
LivingB... |
use {
std::{
collections::{HashMap},
net::{SocketAddr},
time::{Instant, Duration},
},
crc::{crc32},
header::{Header, PacketClass, SequencedHeader},
worker::{PacketWorker},
Error, MTU_ESTIMATE,
};
pub struct Peer {
protocol_id: u32,
worker: PacketWorker,
co... |
//! Field tests
use quickcheck::{Arbitrary, Gen};
use crate::util;
use super::*;
#[quickcheck]
fn single_capsule_consitency(
moves: Vec<movement::Movement>,
a: util::Colour,
b: util::Colour,
row: util::RowIndex,
mut virs: std::collections::HashMap<util::Position, util::Colour>,
) -> bool {
... |
use libc::FILE;
use std::ffi::c_void;
use std::ffi::CString;
use std::os::raw::c_char;
use std::os::raw::c_double;
use std::os::raw::c_float;
use std::os::raw::c_int;
use std::os::raw::c_long;
#[repr(C)]
pub struct TinyTiffFile {
file: *mut FILE,
last_ifd_offset_field: u32,
last_start_pos: c_long,
last... |
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
use std::cmp;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::time::Instant;
use collections::HashMap;
use crate::server::load_statistics::ThreadLoadPool;
use tikv_util::sys::thread::{self, Pid};
/// A Linux-specific `ThreadLoadStatist... |
extern crate libc;
use std::ffi::CStr;
use std::{ptr, mem, slice};
pub type ChromaprintContext = *mut ::libc::c_void;
pub type ChromaprintAlgorithm = ::libc::c_int;
pub const CHROMAPRINT_ALGORITHM_TEST1: ChromaprintAlgorithm = 0;
pub const CHROMAPRINT_ALGORITHM_TEST2: ChromaprintAlgorithm = 1;
pub const CHROMAPRINT_A... |
// [[file:~/phd/code_phd/simple_shapes/README.org::code:create_zhang_geometry][code:create_zhang_geometry]]
use crate::{tank_2d, circle_2d};
/// Create stack of cylinders as in the benchmark of Zhang
pub fn create_cylinders_zhang(spacing: f32) -> (Vec<f32>, Vec<f32>, Vec<usize>) {
// We follow three steps while cre... |
// Copyright (c) 2014, 2015 <NAME> <<EMAIL>>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// excep... |
use std::convert::Into;
use futures::channel::oneshot;
use std::sync::{Arc, Mutex};
use crate::tower_service::Builder;
use crate::config::{HttpVersion, Config};
use crate::middlewares::Middlewares;
use std::env::set_var;
use crate::{RUST_LOG, LOOPBACK, PORT};
use std::str;
use async_trait::async_trait;
use hyper::ser... |
//! A Rust crate to connect a HD44780 lcd display
//!
//! # Example
//! ```no_run
//! use pi_lcd::*;
//!
//! // create a new lcd
//! let lcd = HD44780::new(11,10,[6,5,4,1],20,4);
//!
//! // send a String to the lcd at row 0
//! lcd.send_string("Hello World".to_string(),0);
//! ```
extern crate cupi;
extern crate regex... |
/*
Copyright 2017-2018 <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 writing, software
dis... |
use super::{
aucaptureoffsets::AUCaptureOffsets, auprocess::AUProcess, game_settings::GameSettings,
process::Process,
};
const ENABLE_UNCONTROLLABLE_PARAMS: bool = false;
struct Offsets {
game_options_offset: u32,
game_settings_relative_address: [u32; 2],
map: u32,
player_speed: u32,
crewm... |
extern crate prng;
extern crate rng;
extern crate time;
extern crate mat4;
extern crate gl_context;
extern crate glutin;
extern crate gl;
use std::f32::consts::PI;
use glutin::GlContext;
use gl::types::*;
use gl_context::{
Context, TextureKind, TextureFormat, TextureWrap, FilterMode,
BufferTarget, DrawMode, ... |
use std::collections::HashMap;
use std::fs;
use std::path::{Path, PathBuf};
use chrono::Local;
use structopt::StructOpt;
use anyhow::{anyhow, bail, Context, Result};
use noter::configs::{Configuration, NoteVariant};
use noter::{NoteWriter, StringWriter};
#[derive(StructOpt, Debug)]
#[structopt(name = "noter")]
struc... |
// Copyright (c) 2021 Open Information Security Foundation
//
// 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,
... |
use std::{thread, time};
use std::fs::read_dir;
use std::io::Write;
use std::process::{Command, Stdio};
use std::sync::{mpsc, Arc, Mutex};
use std::sync::mpsc::{Receiver, Sender};
use std::thread::{JoinHandle};
use std::ops::{Deref, DerefMut};
use crate::State::{Watching, InSync};
#[derive(Debug)]
enum State {
InS... |
//! The web form API for interacting with shaft.
use actix_http::httpmessage::HttpMessage;
use actix_web::web::ServiceConfig;
use actix_web::{error, web, Error, HttpRequest, HttpResponse};
use chrono;
use hyper::header::{LOCATION, SET_COOKIE};
use itertools::Itertools;
use serde_json::json;
use crate::db;
use crate::... |
/// Implementation of story and story event triggers. As well as all source text
use crate::AppState;
use crate::prelude::*;
use bevy::prelude::*;
use bevy::utils::Duration;
use bevy_console::PrintConsoleLine;
use bevy_console::{reply, AddConsoleCommand, ConsoleCommand, ConsoleConfiguration, ConsolePlugin};
use crate... |
use std::cmp::Ordering;
use std::ops::{Index, IndexMut};
use std::time::Instant;
use log::{debug, trace};
use rand::seq::SliceRandom;
use crate::Game;
const DURATION: u128 = 995;
const THRESHOLD: u32 = 3;
const EXPLORE: f64 = 1.414;
/// Run MCTS to select a turn.
pub fn run<G: Game>(game: &G) -> G::Turn {
// Re... |
mod config;
mod group;
mod light;
mod resourcelink;
mod rule;
mod scene;
mod schedule;
mod sensor;
mod value;
use std::{fmt, net::IpAddr};
use structopt::StructOpt;
pub fn exec() {
let args = Args::from_args();
match args.subcommand {
Subcommand::Discover => discover(),
Subcommand::Register(v)... |
use std::fs::{self, File, OpenOptions};
use std::io::{self, BufWriter, Write};
use std::path::{Path, PathBuf};
use std::sync::mpsc;
use std::thread;
use std::time::{Duration, Instant};
use std::u64;
extern crate libflate;
use libflate::gzip::Encoder as GzipEncoder;
pub struct FileAppender {
path: PathBuf,
f... |
use core::convert::TryInto;
const IMAGE_FILE_MACHINE_I386: u16 = 0x14c;
const IMAGE_FILE_MACHINE_AMD64: u16 = 0x8664;
// Represents a supported machine of the PE file that we support as a parser
#[derive(Debug)]
enum PeMachine {
Unknown,
AMD64,
I386
}
// Infomation about the PE file we parsed and infoma... |
// Contain and utilize the bus logic
use crate::hal::{timer::Timer, usart::Usart, i2c::I2c};
use crate::driver::i2c;
const ALT_BEGIN: u8 = 0x01;
const MAG_BEGIN: u8 = 0x02;
const GYRO_BEGIN: u8 = 0x03;
const TERM_CHAR: u8 = 0x0D;
const ALT_FAILED: [u8; 3] = [0, 0, TERM_CHAR];
const MAG_FAILED: [u8; 3] ... |
//! Module to process standalone WordStar control characters
use crate::uni_chars;
use crate::ws_chars;
use std::char;
// PRIVATE HELPER FUNCTIONS
/// Returns `Some(replacement)` if the given character is a standalone WordStar
/// control character that can be mapped to replacement text, otherwise `None`
///
/// Two... |
use regex::Match;
use regex::Regex;
use lazy_static::lazy_static;
use crate::parser::dateparse::DateParser;
use crate::parser::Event;
#[cfg(feature = "debug-json")]
use super::EventDebug;
const NEXT_ROUND_REGEX: &str = "Next (Session|Round): ";
const PREV_ROUND_REGEX: &str = "Previous (Session|Round)\\(s\\): ";
con... |
#![deny(unsafe_code)]
#![no_main]
#![no_std]
//! Example for using the BME680 sensor with an RTIC application.
//!
//! ## STM32F411RE - Nucleo 64
//!
//! Connect the BME680 sensor to the I2C port #1 using pins PB8/PB9.
//!
//! ## STM32F723E - DISCOVERY
//!
//! Connect the BME680 to the STM32F723E DISCOVERY board via t... |
//! Redundant Instruction Elimination
//!
//! 1. Computes the set of available instructions for each block (forward must analysis)
//! 2. Iterates through each block and removes all instructions which are already available
//!
//! This optimization requires that the program is in SSA form.
//! This optimization is limi... |
use crate::{color::Color, mesh::Mesh, utils::default, vertex::Vertex};
#[derive(Debug)]
struct Lookup<T>
where
T: PartialEq,
{
store: Vec<T>,
ref_counts: Vec<u32>,
pub buffer: wgpu::Buffer,
pub changed: bool,
}
type LookupIndex = usize;
impl<T> Lookup<T>
where
T: PartialEq,
{
pub fn new(device: &wgpu::Device,... |
use std::{cmp, fs, net::SocketAddr, path::PathBuf};
use anyhow::{anyhow, Context, Result};
use bytes::Bytes;
use futures::{AsyncReadExt, AsyncWriteExt, StreamExt};
use http::{Response, StatusCode};
use structopt::{self, StructOpt};
use tracing::error;
use quinn_h3::{
self,
server::{Builder as ServerBuilder, C... |
// Asset order lock script
//
// An Asset order lock script using 43 bytes cell data
//
// This asset order lock script has three scenarios:
//
// 1. The placing order operation will generate cells, which contain sudt type script and
// data conforming to certain rules.
//
// Cell data includes six fields:
// - sudt am... |
use crate::*;
const YOCTO_MULTIPLIER: f32 = 0.000000000000000000000001;
/// Price per 1 byte of storage from mainnet config after `1.18.0` release and protocol version `42`.
/// It's 10 times lower than the genesis price.
pub(crate) const STORAGE_PRICE_PER_BYTE: Balance = 10_000_000_000_000_000_000;
pub(crate) fn u... |
//! A logger that prints all messages with a readable output format.
#[cfg(feature = "chrono")]
use chrono::Local;
#[cfg(feature = "colored")]
use colored::*;
use log::{Level, LevelFilter, Log, Metadata, Record, SetLoggerError};
use std::collections::HashMap;
pub struct SimpleLogger {
/// The default logging leve... |
//
// model.rs
// Copyright (C) 2021 gmg137 <g<EMAIL> live.<EMAIL>>
// snap7-rs is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
// http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVI... |
pub use flat_bytes_derive::flat_enum;
pub use flat_bytes_derive::Flat;
pub trait Flat: Sized {
fn serialize(&self) -> Vec<u8>;
fn deserialize_with_size(data: &[u8]) -> Option<(Self, usize)>;
fn deserialize(data: &[u8]) -> Option<Self> {
Self::deserialize_with_size(data).map(|(r, _)| r)
}
}
mac... |
use crate::*;
use std::convert::TryFrom;
use std::fmt;
use std::mem::{self, MaybeUninit};
use wasmer_derive::ValueType;
use wasmer_types::ValueType;
pub type __wasi_subclockflags_t = u16;
pub const __WASI_SUBSCRIPTION_CLOCK_ABSTIME: u16 = 1 << 0;
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
#[repr(C)]
pub ... |
#![feature(proc_macro, generators)]
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate serde_derive;
extern crate docopt;
extern crate futures_await as futures;
extern crate glob;
extern crate nalgebra as na;
extern crate rand;
extern crate serde;
extern crate tokio_core;
extern crate sc2;
use std::f3... |
use std::convert::TryInto;
use std::io::Write;
use std::path::PathBuf;
use sharded_lmdb::{ShardedLmdb, DEFAULT_LEASE_TIME};
use store::Store;
use tempfile::TempDir;
use testutil::data::TestData;
use testutil::relative_paths;
use workunit_store::{RunningWorkunit, WorkunitStore};
use crate::{
CommandRunner as Command... |
use parking_lot::RwLock;
use ssz_derive::{Decode, Encode};
use std::collections::HashMap;
use std::iter::FromIterator;
use types::{BeaconBlock, EthSpec, Hash256, Slot};
#[derive(Debug, PartialEq)]
pub enum Error {
MismatchingLengths { roots_len: usize, slots_len: usize },
}
/// Maintains a list of `BeaconChain` h... |
#![allow(non_camel_case_types)]
use crate::ctx::WasiCtx;
use crate::memory::*;
use crate::sys::hostcalls_impl;
use crate::{wasm32, Error, Result};
use log::trace;
use std::convert::TryFrom;
pub(crate) fn args_get(
wasi_ctx: &WasiCtx,
memory: &mut [u8],
argv_ptr: wasm32::uintptr_t,
argv_buf: wasm32::uin... |
//! implements Google's Jump Consistent Hash
//! From the paper "A Fast, Minimal Memory, Consistent Hash Algorithm" by <NAME>, <NAME> (2014).
//! [Paper](http://arxiv.org/abs/1406.2294)
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
/// hashes an `&str` to a `u32` which is in the range ... |
pub mod linting;
pub mod metadata;
pub mod operations;
use std::{fs::File, io::BufReader, path::Path};
use indexmap::IndexMap;
use openapiv3::{OpenAPI, ReferenceOr, RequestBody, Response, StatusCode};
use serde_json::Value;
use crate::AppError;
pub(crate) fn spec_from_file<P: AsRef<Path>>(path: P) -> Result<OpenAP... |
use crate::platform::{CALLBACKS, RPC};
use crate::webview::WV;
use crate::Result;
use std::{
collections::hash_map::DefaultHasher,
ffi::{c_void, CStr, CString},
hash::{Hash, Hasher},
os::raw::c_char,
ptr::null,
};
use cocoa::appkit::{NSView, NSViewHeightSizable, NSViewWidthSizable};
use cocoa::bas... |
use std::{
ffi::{CStr, CString},
sync::Arc,
};
use crate::protocol::{Argument, Interface};
use crate::types::server::{GlobalInfo, InvalidId};
use super::{
client::{Client, ClientStore},
ClientId, GlobalHandler, GlobalId, ObjectId,
};
/*
GlobalId.id is the global protocol name (starting at 1), hen... |
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use super::blocksync::BlockSyncResponse;
use super::hello::HelloMessage;
use super::rpc::{RPCEvent, RPCRequest, RPCResponse};
use super::{ForestBehaviour, ForestBehaviourEvent, Libp2pConfig};
use async_std::stream;
use async_std::sync::{ch... |
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
anyhow::{Context, Error},
fidl_fuchsia_bluetooth_sys::{AccessMarker, AccessProxy},
fuchsia_bluetooth::{
expectation::asynchronous... |
//! Convert a serialized event to an event Trigger
//!
use std::any::Any;
use std::sync::Arc;
use dioxus_core::{ElementId, EventPriority, UserEvent};
use dioxus_html::on::*;
#[derive(serde::Serialize, serde::Deserialize)]
struct ImEvent {
event: String,
mounted_dom_id: u64,
// scope: u64,
contents: s... |
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... |
#![recursion_limit = "192"]
extern crate proc_macro;
use std::iter;
use std::mem;
use std::str::FromStr;
use proc_macro2::{Ident, Span, TokenStream};
use quote::{quote, ToTokens};
use syn::{
parse_macro_input, AttrStyle, Attribute, Data, DeriveInput, Expr, Fields, Index, Meta,
NestedMeta, Type, TypeGenerics,... |
// MIT License
//
// Copyright (c) 2021-2022 <NAME> <<EMAIL>>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, cop... |
use crate::chunked_vector::{
load_variable_list_from_db, load_vector_from_db, BlockRoots, HistoricalRoots, RandaoMixes,
StateRoots,
};
use crate::{Error, Store};
use ssz_derive::{Decode, Encode};
use std::convert::TryInto;
use types::*;
/// Lightweight variant of the `BeaconState` that is stored in the databas... |
use std::collections::BTreeMap;
#[derive(Debug)]
pub(crate) struct Passport<'a>(BTreeMap<&'a str, &'a str>);
const REQUIRED_FIELDS: [&str; 7] = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"];
impl<'a> Passport<'a> {
pub(crate) fn new(raw_data: &'a str) -> Self {
let mut map = BTreeMap::new();
... |
use std::io::Cursor;
use std::io::Error as IoError;
use log::trace;
use bytes::BufMut;
use bytes::Bytes;
use bytes::BytesMut;
use tokio_util::codec::Decoder;
use tokio_util::codec::Encoder;
use crate::core::Decoder as FluvioDecoder;
/// Implement Kafka codec as in https://kafka.apache.org/protocol#The_Messages_ListO... |
// Copyright (C) 2019 Twitter, 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::ffi::{OsStr, OsString};
use std::iter::FromIterator;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::vec::Vec;
use sha1::{Sha1, Digest};
use structopt::StructOpt;
use crate::errors::CargoPlayError;
#[derive(Debug, Clone)]
pub enum RustEdition {
E2015,
E2018,
E2021,
}
impl FromStr fo... |
use std::fs::File;
use std::io::prelude::*;
use crate::config::{Config, Delimiter};
use crate::util;
use crate::CliError;
use crate::CliResult;
use hlua::{AnyLuaValue, Lua, LuaError, LuaTable};
use indicatif::{ProgressBar, ProgressDrawTarget};
use serde::Deserialize;
static USAGE: &str = r#"
Create a new column, filt... |
//! Safe dropping of deep trees that otherwise could cause stack overflow.
//!
//! Does not require any allocation and reuses existing space of a tree to
//! enable working back up a tree branch, instead of the stack.
//!
//! Is `no_std` and so can be used in constrained environments (e.g. without
//! heap allocation).... |
use core::marker::PhantomData;
use core::mem;
use core::pin::Pin;
use futures_core::future::Future;
use futures_core::stream::Stream;
use futures_core::task::{Context, Poll};
use futures_sink::Sink;
use pin_utils::{unsafe_pinned, unsafe_unpinned};
/// Sink for the [`with`](super::SinkExt::with) method.
#[derive(Debug)... |
/*
* Copyright 2018 <NAME>, 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... |
use clap::{crate_description, crate_name, crate_version, value_t, App, Arg};
use serde::Deserialize;
use std::{
collections::HashSet,
env,
ffi::OsString,
fs::{create_dir_all, File},
io::{self, BufReader, Read},
path::{Path, PathBuf},
sync::Arc,
};
// Configuration structure for serializatio... |
#![allow(dead_code)]
#[derive(Debug, Clone, Copy)]
pub struct Split<'a> {
parser: &'a [u8],
separator: u8,
ignore_last_empty: bool,
}
#[derive(Debug, Clone, Copy)]
pub struct SplitBytes<'a> {
parser: &'a [u8],
separator: &'a [u8],
ignore_last_empty: bool,
}
pub trait Parser<'a> {
fn consu... |
/*!
* Definitions for the Hawkes process log-likelihood function.
*/
use ndarray::prelude::*;
use ndarray_parallel::prelude::*;
use crate::temporal::hawkes::ExpHawkes;
use crate::temporal::DeterministicIntensity;
pub struct HawkesExpParams {
lbda0: f64,
alpha: f64,
beta: f64
}
/// Log-likelihood of t... |
// -*- mode: rust; -*-
//
// This file is part of groupzk.
// Copyright (c) 2018 Signal Foundation
// See LICENSE for licensing information.
//
// Authors:
// - <NAME> <<EMAIL>>
//! An implementation of CMZ'13 MAC_GGM based anonymous credentials for Signal.
#[cfg(all(not(feature = "std"), feature = "alloc"))]
use all... |
//!
//! The semantic analyzer contract value element.
//!
#[cfg(test)]
mod tests;
use std::cell::RefCell;
use std::fmt;
use std::rc::Rc;
use zinc_lexical::Location;
use zinc_syntax::Identifier;
use crate::semantic::element::access::dot::contract_field::ContractField as ContractFieldAccess;
use crate::semantic::elem... |
use std::fs::{File,self};
use std::io::{Read,Write};
use std::path::{Path,PathBuf};
use std::slice;
use std::collections::BTreeMap;
use winapi::WORD;
use regex::Regex;
use super::RcRoot;
pub struct RcFile;
impl RcFile {
fn decode(&self, buf: Vec<u8>) -> String {
//println!("BOM:{:?}", &buf[0..2]);... |
use crate::endpoint::Endpoint;
use crate::jws::encode_kid_mac;
use acme_common::crypto::KeyPair;
use acme_common::error::Error;
use serde::{Deserialize, Serialize};
use serde_json::value::Value;
use std::str::FromStr;
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Account {
pub contact: Vec<Str... |
//! FFI helper functions, traits and types to communicate with `sentry-native`.
#[cfg(windows)]
use std::os::windows::ffi::OsStrExt;
#[cfg(doc)]
use std::process::abort;
use std::{
ffi::{CStr, CString},
os::raw::c_char,
panic::{self, AssertUnwindSafe},
path::PathBuf,
process,
};
#[cfg(not(windows)... |
use nalgebra_glm as glm;
use num_traits::{Float, Zero};
use crate::raytracing::{AABB, Triangle};
use crate::raytracing::bvh::{hull::Hull, node::Node};
use crate::raytracing::bvh::node::{NodeIndex, NodeType};
const BINS_PER_LAYER: usize = 5;
const MAX_PRIMITIVES_PER_LEAF: usize = 5;
type Triangles = Vec<Triangle>;
en... |
use super::lib::*;
extern crate regex;
use self::regex::Regex;
extern crate petgraph;
use self::petgraph::graph::{DiGraph, Graph, NodeIndex};
use self::petgraph::graphmap::DiGraphMap;
use self::petgraph::visit::EdgeRef;
lazy_static! {
static ref RE_TO: Regex = Regex::new(r"(?P<to_bag>\w+ \w+) bags contain").unwra... |
/*
* Copyright (c) 2017-2018 Boucher, Antoni <<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, copy, mod... |
use std::convert::TryInto;
use crate::{constraints::*, events::WidgetEvent, InteractiveState, Result};
use glam::{Mat4, Vec2};
use glfw::Action;
use hecs::{Entity, World};
use hecs_hierarchy::Hierarchy;
use hecs_schedule::{GenericWorld, Read, Write};
use ivy_base::{Events, Position2D, Size2D, Visible};
use ivy_graphic... |
#![windows_subsystem = "windows"]
mod amoled_image;
use amoled_image::AmoledImageConverter;
use std::path::PathBuf;
use iced::{
button, slider, text_input, window, Align, Button, Column, Container, Element,
HorizontalAlignment, Length, Row, Sandbox, Settings, Slider, Text, TextInput,
};
use rfd::FileDialog;... |
use super::{api, backend, models};
use rocket::fairing::AdHoc;
use rocket::http::{Cookie, CookieJar, SameSite};
use rocket::request::Form;
use rocket::response::Redirect;
use rocket_contrib::json::Json;
use rocket_contrib::serve::StaticFiles;
use rocket_contrib::templates::Template;
use rocket_oauth2::{OAuth2, TokenRes... |
use numlib::traits::{ FromPrimitive };
use piston_window::*;
use std::path::Path;
use std::str;
use iobus::{ IoDevice };
pub const CRT_ROWS: u32 = 25;
pub const CRT_COLS: u32 = 80;
pub struct CGA {
ram: [u8; 0x8000],
window: PistonWindow
}
impl CGA {
pub fn new() -> CGA {
let mut cga = CGA {
... |
//! Proposal Vote Record Account
use borsh::maybestd::io::Write;
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use solana_program::{
account_info::AccountInfo,
borsh::try_from_slice_unchecked,
clock::{Slot, UnixTimestamp},
instruction::{AccountMeta, Instruction},
program_error::Prog... |
#![forbid(unsafe_code)]
#![forbid(missing_docs)]
#![warn(clippy::all, clippy::pedantic)]
/*!
# Proton Call
Run any Windows program through [Valve's Proton](https://github.com/ValveSoftware/Proton).
## Usage:
Defaults to the latest version of Proton.
```
proton-call -r foo.exe
```
Defaults to the latest version of ... |
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use kvproto::encryptionpb::EncryptedContent;
use tikv_util::box_err;
use super::metadata::*;
use crate::{crypter::*, AesGcmCrypter, Error, Iv, Result};
/// An in-memory backend, it saves master key in memory.
#[derive(Debug)]
pub(crate) struct MemAes... |
// Copyright 2020 The Vega Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
use boxer::{ValueBox, ValueBoxPointer};
use compositor::compositor::CompositorContext;
use compositor::layers::layer::Layer;
use compositor::rasterizers::picture_rasterizer::PictureToRasterize;
use compositor::shadow_cache::Shadow;
use skia_safe::image_filters::drop_shadow_only;
use skia_safe::paint::Style;
use skia_sa... |
//! The calibration stage. The fuzzer measures the average exec time and the bitmap size.
use crate::{
bolts::current_time,
corpus::{Corpus, PowerScheduleTestcaseMetaData},
executors::{Executor, HasObservers},
fuzzer::Evaluator,
inputs::Input,
observers::{MapObserver, ObserversTuple},
stage... |
#![feature(decl_macro)] // `macro`
use std::{env, path::Path};
use structopt::StructOpt;
use thiserror::Error;
mod driverinterface;
mod selection;
mod subprocess;
mod targets;
mod utils;
#[tokio::main]
async fn main() {
env_logger::from_env(env_logger::Env::default().default_filter_or("r3_test_runner=info"))
... |
use crate::backlog;
use crate::prelude::*;
use noria::channel;
/// A StreamUpdate reflects the addition or deletion of a row from a reader node.
#[derive(Clone, Debug, PartialEq)]
pub enum StreamUpdate {
/// Indicates the addition of a new row
AddRow(Vec<DataType>),
/// Indicates the removal of an existing... |
mod ast;
mod cli;
mod config;
mod diff;
mod formatting;
mod parse;
use anyhow::Result;
use ast::{AstVector, AstVectorData};
use cli::{list_supported_languages, set_term_colors, Args};
use config::{Config, ConfigReadError};
use console::Term;
use formatting::{DisplayParameters, DocumentDiffData};
use log::{debug, error... |
use crate::vec3::{Vec3d, Point3d};
use crate::hittable::{Hittable, HitRecord};
use crate::ray::Ray;
use crate::acceleration::aabb::AABB;
use crate::util::Angle;
pub struct Translate<T>
where
T: Hittable + Send + Sync {
offset: Vec3d,
hittable: T
}
impl<T: Hittable + Send + Sync> Translate<T> {
pub fn ... |
use crate::{project::PackageExt as _, shell::Shell};
use anyhow::ensure;
use az::SaturatingAs as _;
use camino::{Utf8Path, Utf8PathBuf};
use cargo_metadata as cm;
use human_size::{Byte, Size};
use liquid::object;
use maplit::btreemap;
use snowchains_core::{
judge::CommandExpression,
testsuite::{PartialBatchTest... |
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use syn::{parse::{Parse, ParseStream}, punctuated::Punctuated, spanned::Spanned};
pub struct Table {
name: syn::Ident,
fields: Punctuated<Field, syn::Token![,]>,
insert: Option<syn::Block>,
requires: Option<syn::ExprArray>,
}
struct Fi... |
/*!
updater helps running brupop on existing EKS cluster and clean up all
resources once completing integration test
!*/
use lazy_static::lazy_static;
use snafu::{ensure, ResultExt};
use std::process::Command;
use tokio::time::Duration;
use tokio_retry::{
strategy::{jitter, ExponentialBackoff},
Retry,
};... |
// Copyright 2020-2021 The Datafuse Authors.
//
// SPDX-License-Identifier: Apache-2.0.
use std::sync::Arc;
use common_datavalues::DataSchema;
use common_datavalues::DataValue;
use common_exception::Result;
use common_planners::AggregatorPartialPlan;
use common_planners::EmptyPlan;
use common_planners::Expression;
us... |
use num_rational::Ratio;
use psutil::cpu;
use tui::buffer::Buffer;
use tui::layout::Rect;
use tui::symbols::Marker;
use tui::widgets::{Axis, Chart, Dataset, GraphType, Widget};
use crate::colorscheme::Colorscheme;
use crate::update::UpdatableWidget;
use crate::widgets::block;
const HORIZONTAL_SCALE_DELTA: u64 = 25;
... |
use core::panic;
use albedo_math::{clamp, AABB};
use glam::Vec3;
use crate::accel::{BVHBuilder, BVHNode, BVH};
use crate::mesh::Mesh;
#[derive(Default, Copy, Clone)]
struct SAHBin {
aabb: AABB,
primitives_count: u32,
right_cost: f32,
}
// @todo: allow to change bin size with const generics?
pub struct SA... |
//! The `wasmer.Instance` Python object to build WebAssembly instances.
//!
//! The `Instance` class has the following declaration:
//!
//! * The constructor reads bytes from its first parameter, and it
//! expects those bytes to represent a valid WebAssembly module,
//! * The `exports` getter, to get exported functi... |
use {
crate::{
activitypub::Clean,
attempt_fetch,
database::{Actor as DbActor, InsertActor, InsertExt, InsertObject, Object as DbObject},
error::Error,
impl_from, impl_into, impl_is_owned_by, map_err,
state::ArcState,
util::HTTP_CLIENT,
},
reqwest::Int... |
use crate::ReflectDeriveData;
use proc_macro::TokenStream;
use proc_macro2::Span;
use quote::quote;
use syn::{Field, Generics, Ident, Index, Lit, LitInt, LitStr, Member, Path};
/// Implements `FromReflect` for the given struct
pub(crate) fn impl_struct(derive_data: &ReflectDeriveData) -> TokenStream {
impl_struct_... |
use std::{fs::File, io::Read};
use pest::error::Error;
use pest::iterators::{Pair, Pairs};
use pest::Parser;
use pest_derive::*;
use crate::gast::constant::Constant;
use crate::gast::list::List;
use crate::gast::symbol::{Location, Symbol};
use crate::{error::CompilerError, utils::escape_str};
use crate::gast::*;
#[d... |
extern crate bytes;
extern crate futures;
extern crate tokio_core;
extern crate tokio_io;
extern crate tokio_serial;
extern crate tokio_signal;
mod andselect;
mod sample;
use std::{env, io, str};
use tokio_core::reactor::Core;
use tokio_io::codec::{Decoder, Encoder, FramedRead};
use tokio_io::AsyncRead;
use bytes::B... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.