text stringlengths 8 4.13M |
|---|
extern crate hyper;
extern crate libsnatch;
use hyper::client::Client;
use libsnatch::client::GetResponse;
#[test]
fn check_server_response() {
let hyper_client = Client::new();
let host = "hypem.com".to_string();
let url: String = "http://".to_string() + &host;
// Get informations from arguments
... |
use crate::{
id::Id,
index::Entry,
objects::{Object, Storable},
};
use bytes::{BufMut, Bytes, BytesMut};
use indexmap::IndexMap;
use std::{ffi::OsStr, fmt};
#[derive(Debug)]
pub enum Node {
Tree(Tree),
Entry(Entry),
}
#[derive(Debug)]
pub struct Tree {
pub nodes: IndexMap<String, Node>,
pu... |
use crate::{
Bounds, BoxConstraints, Cid, Component, Font, FontSize, LayoutGlyph, Renderer, Size,
TextLayout, UiDerive, UiLayout,
};
pub struct Glyphs<'a> {
size: FontSize,
font: Option<Font>,
layout: Option<&'a TextLayout>,
}
pub struct GlyphsState {
size: FontSize,
font: Option<Font>,
... |
//! [YubiKey] PIV: [Personal Identity Verification][PIV] support for
//! [Yubico] devices using the Personal Computer/Smart Card ([PC/SC])
//! interface as provided by the [`pcsc` crate].
//!
//! **PIV** is a [NIST] standard for both *signing* and *encryption*
//! using SmartCards and SmartCard-based hardware tokens li... |
#[path = "adt_huffman.rs"]
mod adt_huffman;
use adt_huffman::Tree;
use std::fs;
use std::io::{Read, Write};
pub fn decompress(mut file: fs::File) -> std::io::Result<()> {
let (trash, preorder) = get_header(&mut file).unwrap();
let huff_tree = build_tree(&preorder, &mut 0);
let mut new = fs::File::create("... |
#![deny(missing_docs)]
//! **noodles-bgzf** handles the reading and writing of BGZF (blocked gzip file).
//!
//! While the gzip format is typically a single stream, a BGZF is the concatentation of many gzip
//! streams. Each stream is called a block, with its uncompressed data size being constrained to
//! less than 6... |
use crate::expert::{Anchor, Engine};
use im::ordmap::DiffItem;
use im::OrdMap;
pub type Dict<K, V> = OrdMap<K, V>;
impl<E: Engine, K: Ord + Clone + PartialEq + 'static, V: Clone + PartialEq + 'static>
Anchor<Dict<K, V>, E>
{
// TODO MERGE FN
pub fn inner_filter<F: FnMut(&K, &V) -> bool + 'static>(&self, m... |
use std::path::Path;
use wgpu::{BindGroupLayout, BindingResource, BufferUsage, Device};
use crate::texture::Texture;
use super::{Instance, InstanceRaw, Material, Mesh, ModelVertex};
type ModelResult = Result<(Model, Vec<wgpu::CommandBuffer>), failure::Error>;
/// Describes the 3D objects to be rendered.
/// Each obj... |
use std::iter;
use crate::language::Language;
use crate::row::Row;
use crate::term_color::Color;
#[derive(Clone, Copy, PartialEq)]
pub enum Highlight {
Normal,
Number,
String,
Comment,
Keyword,
Type,
Char,
Statement,
Match,
}
impl Highlight {
pub fn color(self) -> Color {
... |
// Copyright 2017 ETH Zurich. All rights reserved.
//
// 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
//... |
use crate::core::Vector;
use crate::platform_types::size_t;
use crate::traits::OpenCVType;
use crate::{extern_arg_send, extern_container_send, extern_receive, extern_send};
/// This trait is implemented by any type that can be stored inside `Vector`.
///
/// It is mostly used internally, feasibility of implementing it... |
#![crate_name = "uu_arch"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Smigle00 <smigle00@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate libc;
#[macro_use]
extern crate uucore;
use s... |
/// This module contains the code necessary to transform
/// an AST fresh from the parser into a form that can
/// be executed.
use crate::ast::*;
use crate::program::*;
use std::collections::HashMap;
use std::rc::Rc;
use topological_sort::TopologicalSort;
pub mod fragment_builder;
use crate::run::RuntimeEnv;
use frag... |
#![allow(dead_code)]
use std::io;
use std::ops::{Deref, DerefMut};
use bytes::BytesMut;
use sqlx_rt::{AsyncRead, AsyncReadExt, AsyncWrite};
use crate::error::Error;
use crate::io::write_and_flush::WriteAndFlush;
use crate::io::{decode::Decode, encode::Encode};
use std::io::Cursor;
pub struct BufStream<S>
where
... |
use std::collections::HashMap;
use crate::utils::string_from_file;
pub fn run() {
let input = string_from_file("src/14input");
println!("{}", solve(input));
}
pub fn solve(input: String) -> u64 {
let mut mask_one = 0b0u64;
let mut floating: Vec<usize> = vec![];
let mut memory: HashMap<u64, u64> ... |
// This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program 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 Softwa... |
//Copyright 2020 EinsteinDB Project Authors & WHTCORPS Inc. Licensed under Apache-2.0.
use engine_lmdb::raw::{CompactOptions, WriBlock, DB};
use edb::{Causet_DEFAULT, Causet_DAGGER};
use test_violetabftstore::*;
fn init_db_with_sst_files(db: &DB, level: i32, n: u8) {
let mut opts = CompactOptions::new();
opts... |
use std::process::exit;
fn main() {
let ret = spoon_q::cli::main(std::env::args());
exit(ret);
}
|
use nix::sys::wait::waitpid;
use nix::unistd::{fork, ForkResult};
use std::{thread, time};
fn main() {
let seconds = 2;
// Value literals and pointers
let mut value = 99;
let mut number: &i32;
number = &-1;
// Fork the process and panic if forking fails
let result = unsafe{fork()}.expect("... |
use gio::{Settings, SettingsExt};
use std::path::PathBuf;
pub fn change_wallpaper_gnome(file: &str){
let pb = PathBuf::from(file);
if !pb.exists(){
return
}
let wp = String::from("file://") + file;
let bg_settings = Settings::new("org.gnome.desktop.background");
let _ = bg_settin... |
use shipyard::prelude::*;
#[system(Test)]
fn test() {}
fn main() {}
|
#[macro_use]
extern crate log;
extern crate log4rs;
extern crate crypto;
extern crate rand;
extern crate time;
mod aes;
mod blowfish;
mod ctest;
fn main() {
log4rs::init_file("log.yaml", Default::default()).unwrap();
ctest::test_instance();
}
|
// #![deny(missing_docs)]
#![doc(html_root_url = "https://docs.rs/ct-utils/0.0.1")]
//! Crate containing compile time utilities.
//!
//!
extern crate typenum;
#[cfg(test)]
#[macro_use]
extern crate lazy_static;
// #[macro_use]
// pub mod ct_if;
/* Macro containing modules gutter */
pub mod ct_cons;
// pub mod ct_ar... |
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
extern crate nanoid;
use std::io;
use std::path::Path;
use rocket::Data;
use rocket::response::NamedFile;
use nanoid::nanoid;
#[get("/")]
fn usage() -> String {
format!("Usage: ")
}
#[post("/", data = "<data>")]
fn post_file(data: Data... |
mod s0007;
|
#[macro_use]
extern crate lazy_static;
use std::io::prelude::*;
use std::collections::HashMap;
use std::io::BufReader;
use std::fs::File;
lazy_static! {
static ref EXPECTED_FREQUENCIES: HashMap<char, f32> = {
[('a', 0.08167),
('b', 0.01492),
('c', 0.02782),
('d', 0.04253),
... |
// Lumol, an extensible molecular simulation engine
// Copyright (C) Lumol's contributors — BSD license
//! Core types and definitions for lumol.
#![warn(missing_docs, trivial_casts, unused_import_braces, variant_size_differences)]
#![warn(unused_qualifications, unused_results, rust_2018_idioms)]
// Clippy configurat... |
use ate::prelude::*;
use clap::Parser;
/// Removes a particular user from a role within a group
#[derive(Parser)]
pub struct GroupRemoveUser {
/// Name of the group that the user will be removed from
#[clap(index = 1)]
pub group: String,
/// Role within the group that the user will be removed from, mus... |
use http::request::Request;
use http::response::{Response, StatusCode};
use crate::controller::{Controller, RequestController};
type HandleFunction = fn(request: &Request) -> Response;
pub struct FakeController {
handle: Option<HandleFunction>,
}
impl FakeController {
pub fn new() -> Self {
Self {
... |
use std::collections::LinkedList;
use std::str;
// SS -> S $
// S -> A S d | B S | eps
// A -> a | c
// B -> a | b
// First(SS) = {a, b, c, eps}
// First(S) = {a, b, c, eps}
// Follow(S) = {d, $}
// First(A) = {a, c}
// First(B) = {a, b}
#[derive(Clone, Debug)]
#[allow(non_camel_case_types)]
enum Label {
Succ,
... |
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct CompatibilitiesClassActiveItem {
/// Do not create compatibility, only assess if creation is possible.
#[serde(rename = "assess")]
pub assess: Option<bool>,
/// The first class in the desired compatibili... |
// Copyright 2019 Conflux Foundation. All rights reserved.
// Conflux is free software and distributed under GNU General Public License.
// See http://www.gnu.org/licenses/
/// Set this flag to true to enable storing children merkles for
/// possibly faster merkle root computation.
const ENABLE_CHILDREN_MERKLES: bool ... |
use crate::dynamics::RawJointSet;
use crate::math::{RawRotation, RawVector};
use na::Unit;
use rapier::dynamics::{BallJoint, FixedJoint, JointParams, PrismaticJoint, SpringModel};
use rapier::math::Isometry;
#[cfg(feature = "dim2")]
use rapier::math::Rotation;
use wasm_bindgen::prelude::*;
#[cfg(feature = "dim3")]
use ... |
extern crate simplify;
#[macro_use]
extern crate criterion;
mod benchmarks;
criterion_main! {
benchmarks::simplify::benches,
}
|
/*#[derive(Debug)]
pub enum DocumentEntry {
Text(String),
Foreground(String),
Clear
}*/
use crate::parser::{Flag, Flags};
#[derive(Debug,PartialEq)]
pub enum DocumentEntry {
Clear(Flags),
Text(Flags),
Foreground(Flags)
}
#[derive(Debug)]
pub enum DocumentError {
UnrecognizedCommand(Strin... |
extern crate nom;
use std::collections::{BinaryHeap, VecDeque};
#[derive(Clone)]
struct Boss {
hp: u32,
damage: u32,
}
struct Player {
hp: u32,
armor: u32,
mana: u32,
}
struct Spell {
id: &'static str,
cost: u32,
effect: Effect
}
impl Eq for Spell { }
impl PartialEq for Spell {
... |
use imgui::*;
use std::process;
use crate::html;
use crate::navigation;
use crate::structs::{FileMenuState, State, WebpageType};
pub fn show_app_main_menu_bar<'a>(ui: &Ui<'a>, state: &mut State, dimensions: (u32, u32)) {
if let Some(menu_bar) = ui.begin_main_menu_bar() {
if let Some(menu) = ui.be... |
/// Vaccine applied to agent. First and second doses are treated as different
/// vaccines.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum Vaccine {
None,
CoronaVac1,
CoronaVac2,
Oxford1,
Oxford2,
Pfzer1,
Pfzer2,
Sputnik1,
Sputnik2,
JnJ,
}
impl Default for Vaccine {
f... |
use core::{
future::Future,
pin::Pin,
task::{Context, Poll}
};
use super::{timer_queue_push, get_time_ms};
use crate::task::waker::TimerWaker;
/// Future that allows a task to yield without busy waiting.
pub struct Sleep {
time_ms: u64
}
impl Sleep {
/// Creates a new sleep future that sleeps for ... |
//! Encoding of receipts.
mod call;
mod deploy;
mod error;
mod spawn;
mod touched_accounts;
pub(crate) mod logs;
use svm_types::{CallReceipt, DeployReceipt, Receipt, SpawnReceipt};
use crate::{Codec, ParseError, ReadExt};
impl Codec for Receipt {
type Error = ParseError;
fn encode(&self, w: &mut impl crat... |
use std::io::*;
use std::collections::VecDeque;
use util::Scanner;
fn main() {
std::thread::Builder::new()
.stack_size(1048576)
.spawn(solve)
.unwrap()
.join()
.unwrap();
}
fn solve() {
let cin = stdin();
let cin = cin.lock();
let mut sc = Scanner::new(cin);
... |
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[derive(Debug)]
pub struct TeamSize(pub i64, pub i64);
#[derive(Serialize, Deserialize, Debug)]
pub struct Match {
pub size: TeamSize,
}
// private
#[derive(Seria... |
pub mod mruby;
|
use rand::distributions::IndependentSample;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::net::{IpAddr, Ipv4Addr, SocketAddrV4};
use crate::errors::{AddAnyPortError, AddPortError, GetExternalIpError, RemovePortError, RequestError};
use futures::future;
use futures::Future;
use rand;
use crate::soap;
use tokio_... |
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use clock::ChainEpoch;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::convert::TryInto;
use std::ops::Deref;
#[derive(PartialEq, Eq, Copy, Clone, Debug, Default)]
pub struct OptionalEpoch(pub Option<ChainEpoch>);
... |
use crate::featurez::syntax::{SyntaxNode, SyntaxToken};
use crate::featurez::TokenKind;
use std::fmt::{Display, Error, Formatter};
#[derive(Debug, Clone)]
pub enum SyntaxElement {
Node(SyntaxNode),
Token(SyntaxToken),
}
impl SyntaxElement {
pub fn is_node(&self) -> bool {
match self {
... |
use crate::payload::*;
#[derive(Debug, Clone)]
pub struct Packet {
pub sequence_number: u32,
pub nack_number: u32,
pub packet_type: PacketType,
pub payload: Payload,
pub checksum: u8,
}
#[derive(Clone, Debug, PartialEq)]
pub enum PacketType {
Acknowlodge,
NotAcklodge,
Data,
}
impl Pack... |
use shipyard::prelude::*;
#[system(Test)]
fn run(_: Unique<Entities>) {}
fn main() {}
|
// Copyright (c) 2021 Intel Corporation
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// plese use `cargo test -- --nocapture --test-threads=1` to see result.
use rand::RngCore;
#[test]
fn test_rust_rand() {
println!("test_rust_rand");
let mut buffer = [0u64; 4];
for _i in 0..4 {
for b in buffer.it... |
use super::todo_item::*;
pub struct TodoList {
pub tasks: Vec<TodoItem>,
}
impl TodoList {
pub fn new() -> TodoList {
return TodoList { tasks: vec![] };
}
pub fn add(&mut self, todo: TodoItem) {
self.tasks.push(todo);
}
pub fn remove(&mut self, index: usize) {
self.ta... |
#[doc = "Register `PAIN` reader"]
pub struct R(crate::R<PAIN_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<PAIN_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<PAIN_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R<PAIN_SP... |
#![cfg_attr(not(feature = "std"), no_std)]
pub use self::sub::Subcontract;
use ink_lang as ink;
#[ink::contract]
mod sub {
#[ink(storage)]
pub struct Subcontract {
value: u32,
}
impl Subcontract {
#[ink(constructor)]
pub fn new(init_value: u32) -> Self {
Self { val... |
use bevy_utilities::bevy::prelude::*;
pub struct CameraRotationState {
camera: Entity,
}
impl CameraRotationState {
pub fn new(camera: Entity) -> Self {
Self { camera }
}
}
pub fn camera_rotation_system(
state: Res<CameraRotationState>,
time: Res<Time>,
mut transforms: Query<&mut Tran... |
// Copyright 2018 Mozilla
//
// 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... |
use std::fmt::Debug;
use async_trait::async_trait;
#[derive(Debug)]
pub enum RunError {
Other(String),
}
impl<T: std::error::Error> From<T> for RunError {
fn from(e: T) -> Self {
RunError::Other(e.to_string())
}
}
pub type RunResult<R> = Result<R, RunError>;
#[async_trait]
pub trait AsyncTestSu... |
use log::*;
#[cfg(feature="pyo3")]
mod py_ffi;
pub mod bone;
pub mod tex;
pub mod mot;
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
|
use crate::{HashM, HashS};
use crate::imp::structs::ref_value::RefValue;
use std::collections::hash_map::Iter;
#[derive(Debug, PartialEq, Clone)]
pub struct RefDefObj {
refs: Box<RefDefMap>,
/// Enum とRefの二通りの定義の仕方があり、Enumの場合は Ref のうち一つだけ値があり、ほかは全部nullにしなきゃいけない。
/// プログラムからはmatch でアクセス出来る。値があるRefをキャストしてゲッ... |
use arrayref::array_ref;
use dungeon::{bsp, draw, roomscorridors};
use clap::{Arg, Command};
use rand::distributions::Alphanumeric;
use rand::prelude::*;
use sha2::{Digest, Sha256};
use draw::draw;
use bsp::BspLevel;
use roomscorridors::RoomsCorridors;
fn create_hash(text: &str) -> String {
let mut hasher = Sha... |
use actix_web::{web, Scope};
use serde::{Deserialize, Serialize};
mod actions;
mod controller;
pub fn register(scope: Scope) -> Scope {
let mut permission_scope =
web::scope("permissions").wrap(crate::middleware::auth::Authentication);
// Debug routes
if cfg!(debug_assertions) {}
permission_... |
use std::fs::Metadata;
#[cfg(unix)]
use std::os::unix::fs::MetadataExt;
#[cfg(windows)]
use std::os::windows::fs::MetadataExt;
pub fn get_mode(meta: &Metadata) -> String {
#[cfg(unix)]
{
format_mode(meta.mode())
}
#[cfg(windows)]
{
format_mode(meta.file_attributes())
}
}
pub f... |
#![feature(test)]
extern crate test;
use test::{black_box, Bencher};
use std::ops::Range;
use numpy::{PyArray1, PyArray2, PyArray3};
use pyo3::{PyAny, Python, ToPyObject};
#[bench]
fn extract_success(bencher: &mut Bencher) {
Python::with_gil(|py| {
let any: &PyAny = PyArray2::<f64>::zeros(py, (10, 10), ... |
use std::fs;
fn main() {
solve_59();
}
fn solve_59() {
let file_path = "files/p059_cipher.txt";
let contents = fs::read_to_string(file_path).expect("Should have been able to read the file");
for c1 in 97..=122 {
for c2 in 97..=122 {
for c3 in 97..=122 {
let key: [u... |
use super::atan;
use super::fabs;
const PI: f64 = 3.1415926535897931160E+00; /* 0x400921FB, 0x54442D18 */
const PI_LO: f64 = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
#[inline]
pub fn atan2(y: f64, x: f64) -> f64 {
if x.is_nan() || y.is_nan() {
return x + y;
}
let mut ix = (x.to_bits... |
/* -----------------------------------------------------------------------------------
* src/color.rs - A basic structure for colors.
* beetle - Pull-based GUI framework.
* Copyright © 2020 not_a_seagull
*
* This project is licensed under either the Apache 2.0 license or the MIT license, at
* your option. For mor... |
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::fs::File;
use std::io::{BufRead,BufReader,Read,stdin};
use std::env;
fn main(){
start_to_end("a","d");
start_to_end("a","b");
start_to_end("a","c");
}
fn start_to_end(start_alph: &str, end_alph: &str){
... |
use std::collections::HashMap;
use actix_files::NamedFile;
use actix_web::{error, http, web, HttpRequest, HttpResponse, Responder, Result as ActixResult};
use handlebars::Handlebars;
use percent_encoding::percent_decode;
use serde::Deserialize;
use serde_json::json;
use url::Url;
use crate::disk_stat::{humanize_byte_... |
#![allow(non_upper_case_globals)]
extern crate searchspot;
extern crate rs_es;
extern crate chrono;
extern crate params;
extern crate serde_json;
#[macro_use]
extern crate lazy_static;
extern crate urlencoded;
extern crate url;
use helpers::{make_client, refresh_index, parse_query};
use searchspot::resources::{Talen... |
use config::{Config, ConfigError, File};
use serde::{Deserialize, Serialize};
// use serde_json::value::Value;
// use serde::de::DeserializeOwned;
// extern crate serde_value;
pub const CONFIG_FILE_PATH: &str = "./static/rules/rules.json";
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GameStats {
pub ... |
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
//! cargo run --example build_alias_output --release
use iota_client::{
block::{
address::Address,
output::{
feature::{IssuerFeature, MetadataFeature, SenderFeature},
unlock_condition::{
... |
//Copyright 2020 EinsteinDB Project Authors & WHTCORPS Inc. Licensed under Apache-2.0.
#![causet_attr(test, feature(test))]
#![feature(core_intrinsics)]
#![feature(ptr_offset_from)]
#![feature(min_specialization)]
#[macro_use]
extern crate static_assertions;
#[macro_use]
extern crate failure;
#[causet(test)]
extern c... |
/// Cmdlet information for indexing
pub struct Cmdlet {
/// Module the cmdlet came from
pub module: String,
/// Module version for the cmdlet
pub module_version: String,
/// Full name of the cmdlet, eg. Get-Something
pub name: String,
/// Help URL for the cmdlet
pub url: String,
... |
mod fib1;
mod fib2;
mod binsearch;
mod quicksort;
mod c_hello;
mod readfile;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let example: &str;
if args.len() < 2 {
example = "";
} else {
example = args[1].as_str();
}
match example {
"fib1" => f... |
use crate::stream::Stream;
use core::alloc::Layout;
use core::mem;
#[inline(always)]
pub fn allocate(trace_stream: u8, layout: Layout) {
#[inline(never)]
fn trace(trace_stream: u8, layout: Layout) {
let buffer: [usize; 2] = [0_usize.to_be(), layout.size()];
let buffer: [u8; mem::size_of::<[usiz... |
#[macro_use]
extern crate clap;
extern crate glob;
extern crate separator;
extern crate unicode_width;
mod table;
mod file_info;
mod table_format;
use clap::App;
use glob::glob_with;
use std::path::Path;
use glob::MatchOptions;
use file_info::FileInfo;
use table_format::TableFormat;
fn main() {
let yaml = load_y... |
use std::error;
use std::fmt;
/// ErrorKind defines the type of errors that are available
#[derive(Debug)]
pub enum ErrorKind {
DbError
}
/// Error defines the error structure
#[derive(Debug)]
pub struct Error {
kind: ErrorKind,
message: String
}
impl Error {
/// Create a database error variable
... |
//! Architecture dependent functionality.
/// Machine word.
pub(crate) use arch_impl::word::Word;
/// Signed machine word.
pub(crate) use arch_impl::word::SignedWord;
/// Double machine word.
pub(crate) use arch_impl::word::DoubleWord;
/// fn add_with_carry(a: Word, b: Word, carry: bool) -> (Word, bool)
///
/// Add... |
use std::collections::HashMap;
use url::{Url};
use serde::{Deserialize};
type Header<'a> = HashMap<&'a str, &'a str>;
pub struct HttpClient<'a> {
headers: Box<Header<'a>>,
base_url: &'a str
}
pub type Params<'a> = Vec<(&'a str, String)>;
impl<'a> HttpClient<'a> {
pub fn new(headers: Box<Header<'a>>, bas... |
#[macro_use] extern crate num_derive;
use memmap::Mmap;
use stable_deref_trait::StableDeref;
use owning_ref::OwningHandle;
use elsa::FrozenVec;
use std::cell::RefCell;
use std::collections::HashMap;
use std::error::Error;
use std::io;
use std::fmt;
use std::fs::File;
use std::ops::Deref;
use std::path::Path;
mod core... |
use std::io::{Read, BufReader, BufRead};
use std::ops::{GeneratorState, Generator};
use failure::Error;
fn numgen(
mut num: u64,
factor: u64,
modulo: u64,
check_factor: u64,
) -> impl Generator<Yield = u64, Return = !> {
move || loop {
num = (num * factor) % modulo;
if num % check... |
use crate::point::{Point};
use std::collections::HashSet;
type V = i128;
pub type Segment = (Point<V>, Point<V>);
pub fn segment_intersection((a, b): &Segment, (c, d): &Segment) -> Vec<Point<V>> {
let oa = c.cross2(&d, &a);
let ob = c.cross2(&d, &b);
let oc = a.cross2(&b, &c);
let od = a.cross2(&b, &d)... |
use regex::Regex;
use serenity::model::channel::Message;
pub fn get_gift_code(message: &Message) -> Option<String> {
lazy_static! {
static ref GIFT_PATTERN: Regex = Regex::new(
"(discord.com/gifts/|discordapp.com/gifts/|discord.gift/)[ ]*([a-zA-Z0-9]{16,24})"
)
.unwrap();
}
... |
use std::fmt::{self, Debug, Formatter};
use nimiq_hash::Blake2bHash;
use nimiq_mmr::mmr::proof::RangeProof;
use nimiq_transaction::extended_transaction::ExtendedTransaction;
use serde::{Deserialize, Serialize};
/// The chunk size used in our protocol.
/// TODO: Update number.
pub const CHUNK_SIZE: usize = 1024;
#[de... |
use std::collections::BTreeMap;
use crate::imp::structs::my_json::Value;
#[derive(Debug)]
pub struct JsonFile{
pub file_name_without_ext : String,
pub json : String,
}
#[derive(Debug)]
pub struct JsonDir(pub BTreeMap<String, Value>);
impl JsonDir{
pub fn to_string(&self) -> String{
let mut resul... |
pub use super::*;
use crate::ton_api::IntoBoxed;
/*
Implementation details for RoundAttemptState
*/
#[derive(Clone)]
pub(crate) struct RoundAttemptStateImpl {
pool: SessionPool, //pool of the object
hash: HashType, //hash of the attempt
sequence_number: u... |
use common;
use token;
use sourcefile;
use assembler::handler as handler_assembler;
#[test]
fn no_params() {
assert("test_code/roo/handler/no_params.roo", "test_code/java/handler/no_params.java");
}
#[test]
fn some_params() {
assert("test_code/roo/handler/SomeParams.roo", "test_code/java/handler/some_params.... |
pub trait Shaped {
fn shape() -> (usize, usize);
}
pub trait OuterProduct {
type Output;
fn outer(self, other: Self) -> Self::Output;
}
pub trait SquareMatrix {
type N;
fn trace(&self) -> Self::N;
type V;
fn diag(v: Self::V) -> Self;
fn transpose(&self) -> Self;
fn det(... |
mod lib;
pub mod load_decode_image;
pub mod load_image;
pub mod load_image_by_url;
|
use euclidean::Coordinates;
pub type CorrespondingPoints = Vec<Option<Coordinates<f32>>>; |
use std::iter::{FusedIterator, TrustedLen};
pub fn replicate<T>(count: usize, value: T) -> Replicate<T> {
Replicate {
value: match count {
0 => None,
_ => Some(value),
},
count,
}
}
pub struct Replicate<T> {
value: Option<T>,
count: usize,
}
/// A `Repl... |
//! Safe counterparts of WinAPI functions
//!
pub mod bstr;
|
mod lib;
#[macro_use]
mod mac;
#[derive(Debug)]
struct Test {
x: i8,
y: i8
}
fn main() {
let mut message = 50;
println!("Hello, world! => {}", message);
println!("named placeholder => {holder}", holder="Wow!");
message = lib::test(message);
println!("change variables value => {}", mess... |
use crate::common::*;
pub(crate) trait Print {
fn print(&self, stream: &mut OutputStream) -> io::Result<()>;
fn println(&self, stream: &mut OutputStream) -> io::Result<()> {
self.print(stream)?;
writeln!(stream)?;
Ok(())
}
}
|
use std::{
collections::HashMap,
convert::{TryFrom, TryInto},
str::FromStr,
time::Duration,
};
use rusoto_core::{
credential::{AwsCredentials, StaticProvider},
region::ParseRegionError,
HttpClient, Region,
};
use rusoto_s3::{
util::PreSignedRequest, CommonPrefix, ListObjectsV2Request, Object, Owner, S3... |
#![feature(try_trait)]
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicab... |
use std::io::{stdin, stdout};
use anyhow::Result;
use clap::{value_t, App, Arg, SubCommand};
use crate::prodbench::ProdbenchInputs;
mod hash_fns;
mod merkleproofs;
mod prodbench;
mod stacked;
mod window_post;
mod winning_post;
fn main() -> Result<()> {
fil_logger::init();
let stacked_cmd = SubCommand::with... |
// This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// 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.a... |
// Copyright 2020, The Android Open Source Project
//
// 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... |
use std::path::Path;
use base64;
use rocket;
use super::{cache, errors::Result, oauth, orm, queue, storage};
#[cfg(not(debug_assertions))]
pub fn version() -> String {
format!("{}({})", env!("GIT_HEAD"), env!("BUILD_TIME"))
}
#[cfg(debug_assertions)]
pub fn version() -> String {
env!("CARGO_PKG_VERSION").to... |
use std::fs;
fn unique(value: String) -> String {
let mut unique_string = String::new();
for item in value.chars() {
if !unique_string.contains(item) {
unique_string.push(item);
}
}
return unique_string;
}
fn answers_they_agree_on(group: &str) -> String {
let mut agree... |
use liquid_core::Expression;
use liquid_core::Result;
use liquid_core::Runtime;
use liquid_core::{
Display_filter, Filter, FilterParameters, FilterReflection, FromFilterParameters, ParseFilter,
};
use liquid_core::{Value, ValueView};
#[derive(Debug, FilterParameters)]
struct TestPositionalFilterParameters {
#[... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.