text stringlengths 8 4.13M |
|---|
use itertools::Itertools;
use raster::Color;
use std::collections::HashMap;
use std::convert::Infallible;
use std::str::FromStr;
fn get_attribute(attributes: &HashMap<&str, &str>, key: &str) -> Option<String> {
attributes
.get(&key)
.and_then(|x| -> Option<String> { Some(x.to_string()) })
}
#[deri... |
/// An enum to represent all characters in the Grantha block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Grantha {
/// \u{11300}: '๐'
SignCombiningAnusvaraAbove,
/// \u{11301}: '๐'
SignCandrabindu,
/// \u{11302}: '๐'
SignAnusvara,
/// \u{11303}: '๐'
SignVisarga,
... |
use crate::treeer::core::StateAccessor;
/// This is for tags which be self contained.
pub trait SelfContainedTag: StateAccessor {}
|
//!
//! Measurement to be Stored
//!
use crate::Value;
use crate::Precision;
use crate::Utc;
use crate::DateTime;
use std::collections::BTreeMap;
/// The smallest unit of recording. Multiple of these Measurements are fit in a [Record](struct.Record.html), which in
/// turn is submitted to InfluxDB.
#[derive(Debug, ... |
extern crate iron;
extern crate mount;
extern crate router;
extern crate staticfile;
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;
use iron::status;
use iron::{Iron, Request, Response, IronResult};
use iron::mime::Mime;
use mount::Mount;
use router::Router;
use staticfile::Stat... |
use clap::{App, ArgMatches, SubCommand};
use std::process;
use database::DB;
pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> {
SubCommand::with_name("search")
.about("Search bookmark")
.arg_from_usage("<KEYWORD>... 'Search bookmarks with keywords in title or URL'")
.arg_from_usage("-t --ta... |
use aes::cipher::generic_array::GenericArray;
use aes::cipher::{BlockCipher, NewBlockCipher};
use aes::Aes128;
use std::io::BufWriter;
use byteorder::{BigEndian, WriteBytesExt};
use crate::error::Error;
pub const LABEL_SRTP_ENCRYPTION: u8 = 0x00;
pub const LABEL_SRTP_AUTHENTICATION_TAG: u8 = 0x01;
pub const LABEL_S... |
use std::fmt;
#[derive(Debug, PartialEq, Clone, Copy)]
/// The color type used to represent this image
pub enum ColorType {
/// Grayscale, with one color channel
Grayscale,
/// RGB, with three color channels
RGB,
/// Indexed, with one byte per pixel representing one of up to 256 colors in the image... |
use tokio::io::AsyncReadExt;
use tokio::io::AsyncWriteExt;
use std::os::unix::io::AsRawFd;
use std::io;
use std::os::unix::io::RawFd;
use std::os::unix::prelude::IntoRawFd;
use tokio::process::Command;
fn dup(fd: RawFd) -> io::Result<RawFd> {
let r = unsafe {
libc::dup(fd)
};
if r == -1 {
... |
use nom::types::CompleteStr;
use nom::IResult;
use std::error::Error;
named!(parse_sig<CompleteStr, CompleteStr>,
do_parse!(
take_until_and_consume!(r#""signature","#) >>
f: take_until!("(") >>
delimited!( tag!("("), take_until!(")"), tag!(")"))>>
(f)
)
);
fn definition<'a>(
... |
#![allow(non_snake_case, non_camel_case_types)]
use libc::{c_char, c_int, c_uchar, c_uint, c_void};
use crate::channel::ssh_channel;
use crate::fd_set;
use crate::pki::ssh_key;
use crate::{socket_t, timeval};
pub type ssh_server_known_e = c_int;
pub const SSH_SERVER_KNOWN_SSH_SERVER_ERROR: ssh_server_known_e = -1;
... |
#[doc = "Reader of register SM_EXECCTRL"]
pub type R = crate::R<u32, super::SM_EXECCTRL>;
#[doc = "Writer for register SM_EXECCTRL"]
pub type W = crate::W<u32, super::SM_EXECCTRL>;
#[doc = "Register SM_EXECCTRL `reset()`'s with value 0x0001_f000"]
impl crate::ResetValue for super::SM_EXECCTRL {
type Type = u32;
... |
use megam_api::util::accounts::Account;
use megam_api::util::accounts::Success;
use hamcrest::assert_that;
#[test]
fn create() {
let mut p = Account{first_name: format!("{}", "rr"), last_name: format!("{}", ""), phone: format!("{}", ""), email: format!("{}", "b@test.com"), api_key: format!("{}", "testapikey"), pas... |
use super::SigningPublicKey;
use crate::dev::*;
use derive_more::{Add, AddAssign, AsRef, From, Into};
use smallvec::SmallVec;
use std::{
cmp::Ordering,
time::{Duration, Instant},
};
/// Represents a path from the root to a node.
/// This path is generally part of a spanning tree, except possibly the last hop
/... |
pub mod coordinates;
|
use crate::args::Args;
use crate::bash::is_literal_bash_string;
use crate::path_clean::PathClean;
use crate::trace::Trace;
use itertools::{chain, Itertools};
use nix::unistd::{access, AccessFlags};
use once_cell::sync::Lazy;
use std::collections::{BTreeMap, HashSet};
use std::env::current_dir;
use std::ffi::{OsStr, OsS... |
use response::page::Pages;
#[derive(Deserialize)]
pub struct Links {
pub pages: Option<Pages>,
}
|
use std::io::prelude::*;
use std::sync::Mutex;
use std::{io, fmt};
use std::ffi::OsStr;
use std::fs::{self, File};
use std::path::PathBuf;
#[cfg(any(target_os = "redox", rustdoc))]
use std::{
io::BufWriter,
};
use smallvec::SmallVec;
use log::{Metadata, Record};
/// An output that will be logged to. The two majo... |
pub const CACHEMAGIC_NEW: &[u8; 17usize] = b"glibc-ld.so.cache";
pub const CACHE_VERSION: &[u8; 3usize] = b"1.1";
//pub const CACHEMAGIC_VERSION_NEW: &'static [u8; 20usize] = b"glibc-ld.so.cache1.1";
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct FileEntryNew {
pub flags: i32,
pub key: u32,
pub value:... |
extern crate proc_macro;
use proc_macro::TokenStream;
use syn::{ parse_macro_input, DeriveInput, Meta, Lit, NestedMeta, LitStr, Type };
use quote::quote;
use proc_macro2::{Ident, Span};
#[proc_macro_derive(Fetch, attributes(api))]
pub fn derive_show(item: TokenStream) -> TokenStream {
// parse the whole token tree... |
use std::path::Path;
use anyhow::{anyhow, Context, Result};
use base64::Engine;
use ordered_float::NotNan;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use super::metadata::AppleDesktop;
/// Property List for the time based wallpaper.
#[derive(Deserialize, Serialize, PartialEq, Eq, Debug)]
pub struct P... |
fn main() {
let arr: [i32; 4] = [10, 20, 30, 40];
println!("array is {:?}", arr);
println!("array size is :{}", arr.len());
for index in 0..4 {
println!("index is: {} & value is : {}", index, arr[index]);
}
} |
use WinVersion;
use super::Cache;
pub fn sanity_check_features(cache: &mut Cache) {
use std::collections::BTreeSet;
let mut weird_vers = BTreeSet::new();
cache.iter_features(|path, line, &ref feat| {
use features::Partitions;
/*
What we're looking for are any features that might... |
use std::{
sync::atomic::{self, AtomicU32, AtomicU64},
time::SystemTime,
};
use chashmap::CHashMap;
use crc::crc32;
use fal::{time::Timespec, Filesystem as _};
pub mod block_group;
pub mod disk;
pub mod extents;
pub mod htree;
pub mod inode;
pub mod journal;
pub mod superblock;
pub mod xattr;
pub use inode::... |
fn connect() {
println!("This is the client side");
} |
// This file is part of rdma-core. 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/rdma-core/master/COPYRIGHT. No part of rdma-core, including this file, may be copied, modified, propagated, or distributed ... |
#![allow(dead_code, unused_imports, unused_variables)]
use std::collections::*;
const COUNT: usize = 513401;
fn main() {
println!("Part 1: {}", part1());
println!("Part 2: {}", part2());
}
fn part1() -> String {
let mut recipes = vec![3, 7];
let mut first = 0;
let mut second = 1;
while reci... |
// Copyright (C) 2021 Subspace Labs, Inc.
// SPDX-License-Identifier: GPL-3.0-or-later
// 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 Software Foundation, either version 3 of the License, or
// (at your option)... |
use crate::custom_types::array::Array;
use crate::custom_types::bytes::LangBytes;
use crate::custom_types::dict::Dict;
use crate::custom_types::enumerate::Enumerate;
use crate::custom_types::exceptions::{
arithmetic_error, assertion_error, io_error, not_implemented, null_error, value_error,
};
use crate::custom_typ... |
use actix_web::http::StatusCode;
use actix_web::HttpResponse;
use failure::Fail;
// use octo_budget_lib::auth_token::UserId;
use diesel::result::Error as DieselError;
use serde::{Serialize, Serializer};
#[derive(Fail, Debug, Clone, Copy, PartialEq)]
pub enum ValidationError {
#[fail(display = "Unable to log in wit... |
/// The value of the Scale bits in a SIB byte
#[repr(u8)]
#[derive(Copy,Clone,Debug,PartialEq,Eq)]
pub enum Scale {
Val1 = 0,
Val2 = 64,
Val4 = 128,
Val8 = 192
}
impl Into<u8> for Scale {
#[inline(always)]
fn into(self) -> u8 {
use std::mem;
unsafe{ mem::transmute(self) }
}
}
impl Scale {
/// ... |
// This file is part of Substrate.
// Copyright (C) 2020-2021 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
//
// ht... |
extern crate clap;
#[macro_use]
extern crate lazy_static;
extern crate env_logger;
extern crate hyper;
#[macro_use]
extern crate log;
extern crate rustc_serialize;
mod models;
use clap::{Arg, App, SubCommand};
use hyper::Url;
use hyper::client::Client;
use hyper::status::StatusCode;
use hyper::client::response::Respo... |
#[derive(Debug)]
struct student<'a> {
name: &'a str,
}
fn main() {
let n1_student_01 = String::from("AreebSiddiqui");
let student_01 = n1_student_01.split('.')
.next()
.expect("Could not find '.'");
let my_n_student_01 = student {name: student_01};
println!("{:#?}",my_n_student_01);
}
... |
// #[macro_use]
// extern crate lazy_static;
use base64::encode as base64_encode;
use num_enum::{IntoPrimitive, TryFromPrimitive, TryFromPrimitiveError};
use serde_json::Value;
use std::collections::HashMap;
use std::convert::{From, TryFrom, TryInto};
use std::error::Error;
use std::fmt;
use std::time::{SystemTime, U... |
pub mod op_def;
pub mod attr_value;
pub mod types;
pub mod tensor_shape;
pub mod tensor;
pub mod resource_handle;
|
#[macro_use]
extern crate stdweb;
extern crate rand;
use rand::Rng;
static FOOD_PLACES: [&str; 16] = [
"Bar Burrito",
// "Bento Ya",
"Dough",
"Herbivore Kitchen",
"Hula",
"Let us eat",
// "Maki and Ramen",
"Mama's",
"Pizza Express",
"Pumpkin Brown",
"Redbox",
"Sรถderberg... |
#[doc = "Register `RCC_TZCR` reader"]
pub type R = crate::R<RCC_TZCR_SPEC>;
#[doc = "Register `RCC_TZCR` writer"]
pub type W = crate::W<RCC_TZCR_SPEC>;
#[doc = "Field `TZEN` reader - TZEN"]
pub type TZEN_R = crate::BitReader;
#[doc = "Field `TZEN` writer - TZEN"]
pub type TZEN_W<'a, REG, const O: u8> = crate::BitWriter... |
pub fn run() {
println!("\n====3.16 MATCH====");
let country_code = 44;
// TODO: Try to use another country codes
// let country_code = 55;
// let country_code = 2000;
let country = match country_code {
44 => "UK",
46 => "Sweeden",
7 => "Russia",
1..=1000 => "unk... |
use crate::*;
pub struct PartitionedDisk<D: Disk> {
raw_disk: D,
layout: DiskLayout,
}
impl<D: Disk> core::ops::Deref for PartitionedDisk<D> {
type Target = D;
fn deref(&self) -> &Self::Target {
&self.raw_disk
}
}
impl<D: Disk> PartitionedDisk<D> {
pub fn new(raw_disk: D) -> Result<Se... |
use amethyst::{
input::{InputHandler, StringBindings},
derive::SystemDesc,
ecs::{Read, System, SystemData},
};
#[derive(SystemDesc)]
pub struct InputSystem;
impl <'s> System<'s> for InputSystem {
type SystemData = Read<'s, InputHandler<StringBindings>>;
fn run(&mut self, input: Self:: SystemData... |
use crate::{
neighbour_table::{nlas::NeighbourTableNla, NeighbourTableBuffer, NeighbourTableHeader},
traits::{Emitable, Parseable},
DecodeError,
};
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct NeighbourTableMessage {
pub header: NeighbourTableHeader,
pub nlas: Vec<NeighbourTableNla>,
}
impl E... |
use serde::Deserialize;
use serde::Serialize;
use crate::common::deserialize_as_u64_from_number_or_string;
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NetworkFeeStats {
#[serde(rename = "1")]
pub core: CoreFeeStats,
#[serde(rename = "2"... |
/*
* Slack Web API
*
* One way to interact with the Slack platform is its HTTP RPC-based Web API, a collection of methods requiring OAuth 2.0-based user, bot, or workspace tokens blessed with related OAuth scopes.
*
* The version of the OpenAPI document: 1.7.0
*
* Generated by: https://openapi-generator.tech
*... |
#[doc = "Register `MMCRGUFCR` reader"]
pub type R = crate::R<MMCRGUFCR_SPEC>;
#[doc = "Field `RGUFC` reader - Received good unicast frames counter"]
pub type RGUFC_R = crate::FieldReader<u32>;
impl R {
#[doc = "Bits 0:31 - Received good unicast frames counter"]
#[inline(always)]
pub fn rgufc(&self) -> RGUFC... |
#![feature(slice_rotate)]
type Knot = Vec<Increment>;
type Length = usize;
type Increment = usize;
type Skip = usize;
type Index = usize;
type DenseHash = String;
fn main() {
let input = "46,41,212,83,1,255,157,65,139,52,39,254,2,86,0,204";
// Answer # 1
let lengths_numeric = lengths_numeric(input);
... |
extern crate proc_macro;
extern crate syn;
#[macro_use]
extern crate quote;
use proc_macro::TokenStream;
mod deserialize;
mod helpers;
mod serialize;
#[proc_macro_derive(Deserialize)]
pub fn deserialize_macro_derive(input: TokenStream) -> TokenStream {
deserialize::deserialize_macro_derive(input)
}
#[proc_macro_... |
use cocoa::base::id;
use std::mem;
use std::ops::{Deref, DerefMut};
use {CommandEncoder, StoreAction, RenderCommandEncoder};
#[derive(Debug)]
pub struct ParallelRenderCommandEncoder(id);
unsafe impl Send for ParallelRenderCommandEncoder {}
impl Deref for ParallelRenderCommandEncoder {
type Target = CommandEncode... |
#[doc = "Reader of register DDRPHYC_ODTCR"]
pub type R = crate::R<u32, super::DDRPHYC_ODTCR>;
#[doc = "Writer for register DDRPHYC_ODTCR"]
pub type W = crate::W<u32, super::DDRPHYC_ODTCR>;
#[doc = "Register DDRPHYC_ODTCR `reset()`'s with value 0x8421_0000"]
impl crate::ResetValue for super::DDRPHYC_ODTCR {
type Typ... |
use crate::fontinfo::*;
use crate::utils::adjust_offset;
use fonttools::cmap;
use fonttools::font;
use fonttools::font::Font;
use fonttools::font::Table;
use fonttools::glyf;
use fonttools::head::head;
use fonttools::hhea;
use fonttools::hmtx;
use fonttools::maxp::maxp;
use fonttools::name::{name, NameRecord, NameRecor... |
use quick_xml::{XmlReader, XmlWriter, Element, Event};
use quick_xml::error::Error as XmlError;
use fromxml::FromXml;
use toxml::{ToXml, XmlWriterExt};
use error::Error;
/// A representation of the `<image>` element.
#[derive(Debug, Default, Clone, PartialEq)]
pub struct Image {
/// The URL of the channel image.
... |
#![no_std]
use num_traits::int::PrimInt;
#[inline(always)]
pub fn is_bitflag_set<T: PrimInt>(source: T, flag: T) -> bool {
source & flag == flag
}
#[inline(always)]
pub fn set_bitflag<T: PrimInt>(source: &mut T, flag: T) {
*source = *source | flag
}
#[inline(always)]
pub fn unset_bitflag(source: &mut u8, fl... |
#[derive(Debug, PartialEq)]
pub enum Faction {
Blue,
Red,
}
impl Default for Faction {
fn default() -> Self {
Faction::Blue
}
}
|
//! Indexed collection of values.
//!
//! # Remarks
//!
//! With the ``prelude`` module, we can easily convert a tuple of ``IntoIterator``s
//! into ``Heatmap`` for ease of use. The same can be achieved with the
//! ``new`` method.
//!
//! # Examples
//!
//! Quick plot.
//! ```no_run
//! # use itertools::iproduct;
//! ... |
use ::opcodes::{AddressingMode, OpCode};
#[derive(Eq, PartialEq, Debug, Clone, Copy)]
pub enum ImmediateBase {
Base10,
Base16,
}
#[derive(Clone, Debug, PartialEq )]
pub enum LexerToken {
Ident(String),
Assignment,
Address(String),
OpenParenthesis,
CloseParenthesis,
Comma,
Period,
... |
use crate::error::ApiError;
use crate::todos::{ Todo, TodoInit };
use actix_web::{ delete, get, post, put, web, HttpResponse, Responder };
use tera::{ Tera, Context };
use serde_json::json;
#[get("/")]
async fn find_all() -> Result<HttpResponse, ApiError> {
let todos = Todo::find_all()?;
Ok(HttpResponse::Ok().... |
use crate::iconv::Iconv;
use crate::iconv::IconvError;
use crate::locale_ffi::{__locale_struct, freelocale, newlocale, uselocale, LC_ALL_MASK, };
use std::ffi::CString;
use std::ptr;
/// Transliterates text in the same thread where it is called.
/// Be aware this calls the unsafe ffi function uselocale from C.
/// If ... |
#[macro_use] extern crate nickel;
use nickel::{Nickel, HttpRouter, StaticFilesHandler, FaviconHandler};
use std::collections::HashMap;
// Needed For Post
extern crate hyper;
use std::io::Read;
use hyper::Client;
use hyper::header::Connection;
// Needed For Post
fn main() {
//Implement A Server
let mut serve... |
//! Texture resource handling.
use std::error::Error;
use std::fmt::{self, Display, Formatter};
use futures::{Async, Future, Poll};
use gfx::format::SurfaceType;
use imagefmt::ColFmt;
use rayon::ThreadPool;
use renderer::{Error as RendererError, Texture, TextureBuilder};
use assets::{Asset, AssetFuture, AssetPtr, As... |
#[doc = "Reader of register PERIPH_ID_7"]
pub type R = crate::R<u32, super::PERIPH_ID_7>;
#[doc = "Reader of field `PERIPH_ID_7`"]
pub type PERIPH_ID_7_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:7 - not used"]
#[inline(always)]
pub fn periph_id_7(&self) -> PERIPH_ID_7_R {
PERIPH_ID_7_R::new((sel... |
extern crate rocket;
use rocket::http::RawStr;
#[get("/msg/<msg>")]
fn handler(msg: &RawStr) -> String {
msg.as_str().to_string()
}
impl MsgController for Controller {
fn handlers() {
vec![
handler,
handler
]
}
} |
pub mod linksdb;
|
extern crate rusty_machine as rm;
use rm::learning::optim::Optimizable;
use rm::linalg::Matrix;
use rm::learning::optim::grad_desc::GradientDesc;
use rm::learning::optim::OptimAlgorithm;
// f(x,y)=((x,y)-(cx,cy))^2
struct XSqModel2D {
c: (f64, f64),
}
impl Optimizable for XSqModel2D {
type Inputs = Matrix<(f... |
// 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 super::validate;
pub struct Step {
pub actions: Vec<validate::Action>,
//metrics: Vec<metrics::Metric>, Ignore for now - will be in a future C... |
pub use macro_generator::*;
pub use core::Cake;
|
// use quicli::prelude::*;
// use quicli::prelude::structopt::StructOpt;
// use super::*;
// use quicli::prelude::structopt::*;
// use structopt::*;
use std::path::{PathBuf};
#[derive(StructOpt, Debug)]
struct IOArg {
#[structopt(help = "input file of hex-string/binary data (or reading from stdin if not given)")... |
#![allow(non_camel_case_types)]
pub struct u16_l(u16);
pub struct u32_l(u32);
pub struct u64_l(u64);
pub struct u16_b(u16);
pub struct u32_b(u32);
pub struct u64_b(u64);
pub struct i16_l(i16);
pub struct i32_l(i32);
pub struct i64_l(i64);
pub struct i16_b(i16);
pub struct i32_b(i32);
pub struct i64_b(i64);
use std::f... |
use amethyst::{
assets::{PrefabData, ProgressCounter},
derive::PrefabData,
ecs::Entity,
Error,
};
use serde::{Deserialize, Serialize};
use crate::components::map::MapCoords;
use crate::components::npc::{Named, Movement};
#[derive(Debug, Deserialize, Serialize, PrefabData)]
#[serde(deny_unknown_fields)... |
pub mod path_fixer;
pub fn is_slice_equal_permutation<T: PartialEq>(a: &[T], b: &[T]) -> bool {
if a.is_empty() && !b.is_empty() {
false
} else {
// TODO: Find a way to do this faster.
for source in a.iter() {
let mut found = false;
for other in b.iter() {
... |
#[doc = "Register `RSR` reader"]
pub type R = crate::R<RSR_SPEC>;
#[doc = "Register `RSR` writer"]
pub type W = crate::W<RSR_SPEC>;
#[doc = "Field `RMVF` reader - remove reset flag Set and reset by software to reset the value of the reset flags."]
pub type RMVF_R = crate::BitReader<RMVF_A>;
#[doc = "remove reset flag S... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub mod servers {
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub async fn g... |
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead, BufReader};
type BingoIndex = HashMap<usize, (usize, usize)>;
type BingoBoard = [[(usize, bool); 5]; 5];
fn main() {
let filename = "input/input.txt";
let (drawn_numbers, boards) = parse_input_file(filename);
println!("drawn_numbers... |
use super::sanitizer::{should_rebase_url, Sanitizer, SlashPath};
use crate::renderer::RawMessageWriter;
use aho_corasick::AhoCorasick;
use emojis::Emoji;
use memchr::{memchr_iter, Memchr};
use pulldown_cmark::{
Alignment, CodeBlockKind, CowStr, Event, HeadingLevel, LinkType, MathDisplay, Options, Parser,
Tag,
}... |
use {
crate::{
client::{self, RequestType},
entities::*,
Client,
},
std::error::Error,
};
/// Get information about a specific artist
pub async fn get(client: &Client, id: i64) -> Result<Artist, Box<dyn Error>> {
Ok(client::perform_request::<GeneralMessage>(
RequestType:... |
use std::sync::{RwLock, Arc};
use std::collections::HashMap;
use crate::view::View;
use crate::message::{PrePrepare, Prepare, Commit};
use libp2p::PeerId;
pub struct State {
current_view: Arc<RwLock<View>>,
pre_prepares: HashMap<PrePrepareKey, PrePrepare>,
prepares: HashMap<PrepareKey, HashMap<PeerId, Prep... |
// Generated from mat.rs.tera template. Edit the template, not the generated file.
use crate::{
coresimd::*, f32::math, swizzles::*, DMat4, EulerRot, Mat3, Mat3A, Quat, Vec3, Vec3A, Vec4,
};
#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::iter::{Product, Sum};
use core::ops::{Add, AddAssign, Mul, MulAs... |
/*
Copyright 2019-2023 Didier Plaindoux
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... |
use std::fmt;
trait HasArea {
fn get_area(&self) -> i32;
}
struct Rectangle {
width: i32,
height: i32,
}
impl HasArea for Rectangle {
fn get_area(&self) -> i32 {
self.width * self.height
}
}
impl fmt::Display for Rectangle {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
... |
// https://adventofcode.com/2017/day/8
use std::io::{BufRead, BufReader};
use std::fs::File;
use std::collections::HashMap;
fn check_cnd(split: &Vec<&str>, registers: &mut HashMap<String, i32>) -> bool {
let lhs = registers.entry(split[4].to_string()).or_insert(0);
let rhs = split[6].parse::<i32>().unwrap();
... |
use std::io;
use std::fs;
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete::digit1;
use nom::combinator::map;
use nom::sequence::preceded;
use nom::IResult;
type Deck = Vec<u32>;
#[derive(Debug)]
enum Instruction {
DealIntoNew,
Cut(isize),
DealWithIncr(usize),
}
fn deal_i... |
use bevy::{
prelude::*, //default bevy
input::{keyboard::KeyCode, Input},
};
use crate::{
systems::life::LIFE_FORM_SIZE,
DEFAULT_UNIVERSE_SIZE,
};
pub fn setup(mut commands: Commands) {
commands.spawn_bundle(Camera3dBundle {
projection: PerspectiveProjection {
near: 0.1,
... |
// Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied,
// modified, or di... |
/*!
```rudra-poc
[target]
crate = "rocket"
version = "0.4.4"
[[target.peer]]
crate = "rocket_codegen"
version = "0.4.4"
[[target.peer]]
crate = "rocket_http"
version = "0.4.4"
[test]
cargo_toolchain = "nightly"
[report]
issue_url = "https://github.com/SergioBenitez/Rocket/issues/1312"
issue_date = 2020-05-27
rustse... |
use std::error::Error;
use std::fmt::{Display, Formatter};
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum BeanstalkdError {
ConnectionError,
UnknownStatusError(String),
RequestError,
}
impl Error for BeanstalkdError {
fn description(&self) -> &str {
match self {
BeanstalkdError::C... |
//! Loadable shader settings.
use crate::Shader;
use arctk::{
err::Error,
img::Gradient,
math::Pos3,
ord::{Link, Set, X, Y, Z},
};
use arctk_attr::input;
/// Colouring settings builder.
#[input]
pub struct ShaderLinker {
/// Sun position used for lighting calculations [m].
sun_pos: [f64; 3],
... |
// Copyright 2016 Google Inc. All Rights Reserved.
//
// Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
use bincode::SizeLimit;
use bincode::serde as bincode;
use byteorder::{BigEndian, WriteByte... |
use crate::{alphabet::Alphabet, dfa::DFA};
use core::marker::PhantomData;
use valis_ds::set::Set;
pub struct DFADisplay<'d, D, A>(pub &'d D, PhantomData<A>);
impl<'d, D, A> From<&'d D> for DFADisplay<'d, D, A>
where
D: DFA<A>,
A: Alphabet,
{
fn from(src: &'d D) -> Self {
DFADisplay(src, PhantomDat... |
use std::collections::HashMap;
use std::sync::{Arc, RwLock};
type Key = String;
type Val = Vec<u8>;
type Map = HashMap<Key, Val>;
pub type Cache = Arc<RwLock<Box<Map>>>;
#[derive(Debug)]
pub struct FileCache {
pub cache: Cache,
}
impl FileCache {
pub fn new() -> FileCache {
FileCache {
c... |
/// An enum to represent all characters in the Kannada block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Kannada {
/// \u{c80}: 'เฒ'
SignSpacingCandrabindu,
/// \u{c81}: 'เฒ'
SignCandrabindu,
/// \u{c82}: 'เฒ'
SignAnusvara,
/// \u{c83}: 'เฒ'
SignVisarga,
/// \u{c84}: 'เฒ... |
/// Replaces `*t` with `f` applied to the original `*t`,
pub fn replace_with<T, F: FnOnce(T) -> T>(t: &mut T, f: F) {
let raw = t as *mut T;
unsafe{
std::ptr::write(raw, f(std::ptr::read(raw)));
}
} |
#![allow(dead_code, unused_imports)]
use std::fs::File;
use std::io;
use std::io::Write;
use std::ops::Div;
use rand::{random, Rng, SeedableRng};
use rayon::prelude::*;
use crate::camera::{Camera, Viewport};
use crate::hittable::{HitRecord, Hittable};
use crate::image::Image;
use crate::material::Material;
use crate... |
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use crate::lib::identity::identity_utils::call_sender;
use crate::lib::operations::canister::deploy_canisters;
use crate::lib::provider::create_agent_environment;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::util::clap::valida... |
use proc_macro::TokenStream;
mod paths;
mod utils;
mod impl_check;
mod impl_command;
mod impl_hook;
use impl_check::impl_check;
use impl_command::impl_command;
use impl_hook::impl_hook;
#[proc_macro_attribute]
pub fn command(attr: TokenStream, input: TokenStream) -> TokenStream {
match impl_command(attr.into(),... |
use crate::{
tokenizers::FullPathForChars,
field_paths::{FieldPaths,FieldPath},
};
#[allow(unused_imports)]
use core_extensions::SelfOps;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote_spanned;
use syn::{
parse::{self,Parse,ParseStream},
punctuated::Punctuated,
Ident,Token,
};
... |
extern crate piston_window;
mod draw;
mod paddle;
mod game;
mod block;
mod ball;
mod rectangle;
use piston_window::*;
use piston_window::types::Color;
use game::Game;
const BACK_COLOR: Color = [0.5,0.5,0.5,1.0];
fn main() {
let (width, height) = (400.0, 400.0);
let mut window: PistonWindow = WindowSetting... |
use crate::inv::{Inventory, Release, BUCKET, REGION};
use crate::vrs::Version;
use anyhow::{anyhow, Error};
use chrono::{DateTime, Utc};
use regex::Regex;
use serde::Deserialize;
use std::convert::TryFrom;
use url::Url;
/// Content Node in the XML document returned by Amazon S3 for a public bucket.
#[derive(Debug, Des... |
//! The `BonsaiDb` Server.
#![forbid(unsafe_code)]
#![warn(
clippy::cargo,
missing_docs,
// clippy::missing_docs_in_private_items,
clippy::nursery,
clippy::pedantic,
future_incompatible,
rust_2018_idioms,
)]
#![cfg_attr(doc, deny(rustdoc::all))]
#![allow(
clippy::missing_errors_doc, // ... |
// Problem 19 - Counting Sundays
//
// You are given the following information, but you may prefer to do some research
// for yourself.
//
// - 1 Jan 1900 was a Monday.
//
// - Thirty days has September,
// April, June and November.
// All the rest have thirty-one,
// Saving February alone,
//... |
use super::RingBuffer;
pub struct ResizedRingBuffer {
// ๅจresizeไนๅ๏ผไธ่ฝ็ซๅณ้ๆพringbuffer๏ผๅ ไธบๆๅฏ่ฝ่ฟๆๅค้จๅผ็จใ
// ้่ฆๅจๆๆ็processed็ๅญ่้ฝ่ขซackไนๅ๏ผ้่ฟreset_read๏ผๆ่ฝ้ๆพ
max_processed: usize,
old: Vec<RingBuffer>,
inner: RingBuffer,
}
use std::ops::{Deref, DerefMut};
impl Deref for ResizedRingBuffer {
type Target = Rin... |
fn is_valid_part_01(input: &str) -> bool {
let data: Vec<&str> = input
.split_whitespace()
.collect();
let range: Vec<usize> = data[0]
.split('-')
.map(|s| s.parse().unwrap())
.collect();
let character = &data[1][0..1];
let count = data[2]
.chars()
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.