text stringlengths 8 4.13M |
|---|
fn main() {
for n in 1..101 {
if n % 15 == 0 {
println!("fizzbuzz");
} else if n % 5 == 0 {
println!("buzz");
} else if n % 3 == 0 {
println!("fizz");
} else {
println!("{}", n);
}
}
for n in 1..=100 {
if n % 15 ... |
#[doc = "Register `SQR1` reader"]
pub type R = crate::R<SQR1_SPEC>;
#[doc = "Register `SQR1` writer"]
pub type W = crate::W<SQR1_SPEC>;
#[doc = "Field `SQ25` reader - 25th conversion in regular sequence"]
pub type SQ25_R = crate::FieldReader;
#[doc = "Field `SQ25` writer - 25th conversion in regular sequence"]
pub type... |
use io::hid;
use realtime;
fn wait_for_button_mask(active: u16, pressed: u16, prev_ref: &mut u16) -> u16 {
loop {
let curr = hid::pressed_mask();
let prev = *prev_ref;
*prev_ref = curr;
if (curr ^ pressed) & active == 0 && (curr ^ prev) & active != 0 {
return curr
... |
use crate::ray::*;
use crate::vec3::*;
use rand::rngs::ThreadRng;
use rand::Rng;
#[derive(Debug)]
pub struct Camera {
pub origin: Vec3,
pub horizontal: Vec3,
pub vertical: Vec3,
pub lower_left: Vec3,
pub lens_radius: f64,
pub u: Vec3,
pub v: Vec3,
}
impl Camera {
fn random_in_unit_disk... |
fn main() {
proconio::input! {
n: usize,
}
let ans = n * (n - 1) / 2;
println!("{}", ans);
}
|
// This file was generated
pub mod fs;
pub mod net;
|
use core::ops::Mul;
/// This code is inspired from Dalek's field multiplication for 64-bits backends contained in the
/// file [`src/backend/u64/field.rs`](https://github.com/dalek-cryptography/curve25519-dalek/blob/master/src/backend/u64/field.rs)
use secret_integers::*;
/// A `FieldElement64` represents an element o... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::move_resource::MoveResource;
use anyhow::{format_err, Result};
use num_enum::{IntoPrimitive, TryFromPrimitive};
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
use std::fmt::{self, Formatter};
use std::str::From... |
use async_trait::async_trait;
use std::collections::HashMap;
use crate::errors::Result;
use crate::request::{get, put, Body};
use crate::{Client, QueryMeta, QueryOptions, WriteMeta, WriteOptions};
#[serde(default)]
#[derive(Clone, Default, Eq, PartialEq, Serialize, Deserialize, Debug)]
pub struct SessionID {
pub ... |
//! Module containing basic types representing coordinate systems.
use super::tensors::{ContravariantIndex, CovariantIndex, Matrix, Tensor};
use crate::typenum::consts::U2;
use crate::typenum::uint::Unsigned;
use crate::typenum::Pow;
use generic_array::{ArrayLength, GenericArray};
use std::fmt;
use std::ops::{Index, I... |
use std::env::set_current_dir;
pub fn is_builtin(command: &str) -> bool {
command.eq("history") || command.eq("cd") || command.starts_with('!')
}
pub fn execute_builtin(command: &str, args: &[&str], history: &Vec<String>) {
match command {
"history" => list_history(&history),
"cd" => change_wo... |
pub mod helper;
|
pub fn multiply(numbers: &[i32]) -> i64 {
numbers.iter().fold(1, | prod, i | prod * i64::from(*i))
} |
//! An expression that evaluates a sub-expression, without consuming input.
//!
//! See [`crate::Parser::check`].
use crate::parser::Parser;
use crate::span::Span;
/// The struct returned from [`crate::Parser::check`].
pub struct Check<P>(pub(crate) P);
impl<P> Parser for Check<P>
where
P: Parser,
{
type Val... |
// MIT License
//
// Copyright (c) 2018-2021 Hans-Martin Will
//
// 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... |
#[cfg(test)]
extern crate lib_pixel;
pub mod pixel{
#[derive(Debug, Clone, Copy)]
pub struct Pixel{ //création de la structure
red : u8,
green : u8,
blue : u8
}
impl Pixel{
pub fn new(red : u8, green: u8, blue:u8) -> Self{ //constructeur
Pixel{
red:red,
gre... |
use super::mock::*;
use crate::{Error, NFTsForSale};
use frame_support::{assert_noop, assert_ok, StorageMap};
use frame_system::RawOrigin;
#[test]
fn cannot_list_nft_if_not_owner() {
ExtBuilder::default()
.one_nft_for_alice()
.build()
.execute_with(|| {
assert_noop!(
... |
use std::io::{self, Write};
use std::fs::{File, OpenOptions};
use std::ffi::OsStr;
use std::path::Path;
use std::os::unix::ffi::{OsStrExt, OsStringExt};
pub fn create_unique<P1, P2>(path: &P1, extension: Option<&P2>) -> io::Result<File>
where
P1: AsRef<Path> + ?Sized,
P2: AsRef<Path> + ?Sized,
{
let path = path.as... |
pub fn problem_006() -> usize {
let n = 100;
let sum_of_squares: usize = (1..n + 1).map(|x| x * x).fold(0, |sum, x| sum + x);
let square_of_sum: usize = (1..n + 1).fold(0, |sum, x| sum + x).pow(2);
square_of_sum - sum_of_squares
}
#[cfg(test)]
mod test {
use super::*;
use test::Bencher;
#[... |
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_std::{CanonicalAddr, Decimal, Order, ReadonlyStorage, StdResult, Storage, Uint128};
use cosmwasm_storage::{
bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, Singleton,
};
use spectrum_protocol::common::{
calc_ra... |
use crate::{
gui::{
BuildContext, CustomWidget, EditorUiMessage, EditorUiNode, SceneItemMessage, Ui, UiMessage,
UiNode,
},
load_image,
scene::{
commands::{
graph::{LinkNodesCommand, SetVisibleCommand},
make_delete_selection_command, ChangeSelectionCommand,... |
use shorthand::ShortHand;
#[derive(Copy, Clone, Default)]
struct Number(usize);
#[derive(ShortHand, Default)]
#[shorthand(enable(copy))]
struct Command {
index: Number,
#[shorthand(disable(copy))]
index2: Number,
index3: Number,
}
#[test]
fn test_copy() {
let _: Number = Command::default().index(... |
// chapter 2 "using varibales and types"
fn main() {
// value 5 is bound to a variable "energy"
let energy = 5;
let copy_energy = energy;
println!("your energy is {}", copy_energy);
}
/* output should be:
end of output */
|
use anchor_lang::prelude::*;
declare_id!("Av2WRMKbkw1ircKXbxh9djiBUhJzasHEhXXHkcz3xVUw");
const LIKES_CAPACITY: u8 = 200;
#[program]
pub mod likes {
use super::*;
pub fn create_likes_account(ctx: Context<CreateLikesAccount>) -> ProgramResult {
let mut likes = ctx.accounts.likes.load_init()?;
... |
#![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
extern crate serde_json;
#[macro_use] extern crate rocket_contrib;
#[macro_use] extern crate serde_derive;
extern crate futures;
extern crate tokio_core;
extern crate tokio_process;
//#[cfg(test)] mod tests;
//#[macro_use] extern crate log;
extern ... |
use anyhow::Result;
use nom::{
bytes::complete::{is_not, tag},
character::complete::{digit1, line_ending},
combinator::map,
multi::{many1, separated_list1},
sequence::tuple,
IResult,
};
use std::{fs, str::FromStr};
fn parse_num<T>(input: &str) -> IResult<&str, T>
where
T: FromStr,
<T as... |
//! Types.
use gfx_debug_draw;
use gfx_device_gl;
/// The type of debug renderer.
pub type DebugRenderer =
gfx_debug_draw::DebugRenderer<gfx_device_gl::Resources, gfx_device_gl::Factory>;
|
use std::collections::HashMap;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::PathBuf;
use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
use crate::lineage;
#[derive(Debug, Deserialize)]
struct DiagramAssignment {
urs: String,
model_name: Str... |
use crate::irc::command::Error as CommandError;
use crate::irc::prefix::Error as PrefixError;
use crate::irc::{command::Command, prefix::Prefix};
#[derive(Debug, PartialEq)]
pub enum Error {
PrefixError(PrefixError),
CommandError(CommandError),
}
#[derive(Debug, PartialEq, Clone)]
pub struct Message {
pub... |
pub mod persistent;
|
mod clients;
pub mod prelude;
pub mod requests;
pub mod responses;
use crate::core::Client;
use crate::responses::PopReceipt;
pub use clients::*;
use std::borrow::Cow;
use std::fmt::Debug;
use std::time::Duration;
//********* Request traits
pub trait VisibilityTimeoutSupport {
type O;
fn with_visibility_timeo... |
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use crate::lib::nns_types::account_identifier::AccountIdentifier;
use clap::Clap;
/// Prints the selected identity's AccountIdentifier.
#[derive(Clap)]
pub struct AccountIdOpts {}
pub async fn exec(env: &dyn Environment, _opts: AccountIdOpts... |
pub mod oauth2;
pub mod user;
use std::time::Duration;
use actix_ratelimit::{RateLimiter, RedisStore, RedisStoreActor};
use actix_web::{web, HttpResponse, Responder, ResponseError};
use crate::error::AppError;
fn scope(path: &str) -> actix_web::Scope {
web::scope(path).default_service(web::route().to(|| AppErro... |
#[doc = "Reader of register IDENTITY"]
pub type R = crate::R<u32, super::IDENTITY>;
#[doc = "Reader of field `P`"]
pub type P_R = crate::R<bool, bool>;
#[doc = "Reader of field `NS`"]
pub type NS_R = crate::R<bool, bool>;
#[doc = "Reader of field `PC`"]
pub type PC_R = crate::R<u8, u8>;
#[doc = "Reader of field `MS`"]
... |
use std::dbg;
#[derive(Copy,Clone,PartialEq)]
enum Operation {
Nop,
Jmp,
Acc,
}
#[derive(Copy,Clone)]
struct Instruction {
count: isize,
operation: Operation,
argument: isize,
}
pub struct Program {
acc: Vec<isize>,
instructions: Vec<Instruction>,
}
impl Program {
fn new() -> Prog... |
fn main() {
assert!(false);
}
|
use utils;
use std::collections::HashSet;
use std::char;
fn is_pandigital(n: u64) -> bool{
let s = n.to_string();
let mut ns = HashSet::new();
for d in s.chars(){
if ns.contains(&d) {
return false;
}
ns.insert(d);
}
for i in 1..(s.len()+1) {
// 48 is th... |
#![allow(non_snake_case)]
extern crate log;
extern crate lazy_static;
#[cfg(not(target_os = "windows"))]
extern crate socket2;
use std::net;
use std::time;
use std::thread;
use std::sync::{Arc, Mutex, mpsc};
use crate::utils;
use lazy_static::lazy_static;
#[allow(unused_imports)]
use log::{trace, debug, info, warn,... |
use super::{Expression, JsonValue, visitor::ExpressionVisitor};
#[derive(Debug)]
pub struct ValueExpression {
pub value: JsonValue
}
impl ValueExpression {
pub fn new(value: JsonValue) -> ValueExpression {
ValueExpression {value}
}
}
impl Expression for ValueExpression {
fn accept(&mut self, ... |
#[doc = "Register `DAC_STR2` reader"]
pub type R = crate::R<DAC_STR2_SPEC>;
#[doc = "Register `DAC_STR2` writer"]
pub type W = crate::W<DAC_STR2_SPEC>;
#[doc = "Field `STRSTDATA2` reader - DAC Channel 2 Sawtooth reset value"]
pub type STRSTDATA2_R = crate::FieldReader<u16>;
#[doc = "Field `STRSTDATA2` writer - DAC Chan... |
use std::collections::{HashSet, VecDeque};
fn main() -> std::io::Result<()> {
let input = std::fs::read_to_string("examples/21/input.txt")?;
let mut lists: Vec<IngredientList> = input
.lines()
.map(|line| {
let mut it = line.split("(contains").map(|x| x.trim());
let ingre... |
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*/
#![warn(missing_debug_implementations, missing_docs)]
//! File operations
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use std::{mem, io};
use std::fs::{self, File, OpenOptions};
use std::io::{Read, B... |
use crate::{
grid::{
config::{ColoredConfig, Entity, Position, SpannedConfig},
records::{ExactRecords, Records},
},
settings::CellOption,
};
/// Columns (Vertical) span.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct ColumnSpan {
size: usize,
}
impl ColumnSpan... |
use crate::headers::*;
use crate::AddAsHeader;
use chrono::{DateTime, Utc};
use http::request::Builder;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum IfSourceModifiedSinceCondition {
Modified(DateTime<Utc>),
Unmodified(DateTime<Utc>),
}
impl AddAsHeader for IfSourceModifiedSinceCondition {
fn add_as_h... |
use crate::pb::{
maine::maine_service_client::MaineServiceClient,
ragdoll::ragdoll_internal_service_client::RagdollInternalServiceClient,
};
#[derive(Debug, Clone)]
pub struct Client {
pub regdoll: RagdollInternalServiceClient<tonic::transport::Channel>,
pub maine: MaineServiceClient<tonic::transport::... |
use aoc2019::intcode;
use aoc2019::io::{slurp_stdin, parse_intcode_program};
fn main() {
let data = parse_intcode_program(&slurp_stdin());
let mut input: Vec<intcode::Mem> = vec![1];
let mut output: Vec<intcode::Mem> = Vec::new();
intcode::run_program_splitio(data.clone(), &mut input, &mut output).unw... |
use std::fmt;
use std::fmt::{Formatter, write};
use std::hash::Hash;
use futures::executor::block_on;
use crate::Poll::Pending;
async fn say() {
println!("hi")
}
#[derive(Debug)]
struct Song {
title: String,
}
async fn learn_song() -> Song {
println!("i learned the song Radio");
Song {
titl... |
use ordered_float::OrderedFloat;
#[derive(Debug)]
struct MaStruct {
no_u32: u32,
no_string: String,
float: OrderedFloat<f64>,
}
fn main() {
let s1 = MaStruct {
no_u32: 10,
no_string: "0A".to_string(),
float: OrderedFloat(2.0)
};
let s2 = MaStruct {
no_u32: 5,
... |
// Copyright (c) SimpleStaking and Tezedge Contributors
// SPDX-License-Identifier: MIT
/// Rust implementation of messages required for Rust <-> OCaml FFI communication.
use std::collections::HashMap;
use std::fmt;
use std::fmt::Debug;
use std::mem::size_of;
use derive_builder::Builder;
use failure::Fail;
use lazy_... |
#[doc = "Register `ICSR` reader"]
pub type R = crate::R<ICSR_SPEC>;
#[doc = "Register `ICSR` writer"]
pub type W = crate::W<ICSR_SPEC>;
#[doc = "Field `ALRAWF` reader - ALRAWF"]
pub type ALRAWF_R = crate::BitReader;
#[doc = "Field `ALRBWF` reader - ALRBWF"]
pub type ALRBWF_R = crate::BitReader;
#[doc = "Field `WUTWF` r... |
use futures_lite::stream::StreamExt;
use lapin::{
options::*,
types::{AMQPValue, FieldTable},
Connection, ConnectionProperties, ExchangeKind, Result,
};
use tracing::info;
fn main() -> Result<()> {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "info");
}
tracing... |
mod proc_service;
mod thread_db;
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
pub use thread_db::{TdErr, TdTaStats, TdThrInfo};
use thread_db::{TdThrAgent, TdThrHandle, TdThrState};
use proc_service::ProcHandle;
use dlopen::wrapper::Container;
/// Runs a libthread_db function, returning on e... |
use nom::character::complete::char;
use nom::combinator::map;
use nom::sequence::tuple;
use nom::IResult;
const INPUT: &str = include_str!("../inputs/day_10_input");
fn parse_num_pair(i: &str) -> IResult<&str, (i32, i32)> {
use nom::character::complete::{space0, space1};
Ok(map(
tuple((
c... |
use inkwell::values::{IntValue, PointerValue};
pub struct Environment {
variables: Vec<(String, Variable)>,
}
impl Environment {
pub fn new() -> Environment {
let variables: Vec<(String, Variable)> = Vec::new();
Environment { variables }
}
pub fn get(&self, skey: &String) -> Option<Vari... |
pub mod upgrade;
mod sender;
pub use sender::Sender;
|
use std::{mem, string::ToString};
use failure::{format_err, Error};
const TOKEN_TYPE_REFERENCE_ID: u8 = 0x01;
const TOKEN_TYPE_ATTRIBUTE_REFERENCE_ID: u8 = 0x02;
const TOKEN_TYPE_STRING: u8 = 0x03;
const TOKEN_TYPE_FLOAT: u8 = 0x04;
const TOKEN_TYPE_DIMENSION: u8 = 0x05;
const TOKEN_TYPE_FRACTION: u8 = 0x06;
const TO... |
use crate::geometry::*;
use crate::input::cursor::CursorManager;
use crate::output_manager::OutputManager;
use crate::surface::{Surface, SurfaceEventManager, SurfaceExt};
use crate::window::*;
use crate::window_management_policy::WmPolicyManager;
use crate::window_manager::{WindowLayer, WindowManager, WindowManagerExt}... |
use unsafe_hacspec_examples::ec::{arithmetic, p256, p384, Affine};
use hacspec_dev::prelude::*;
use hacspec_lib::prelude::*;
use rayon::prelude::*;
create_test_vectors!(
TestVector,
algorithm: String,
generatorVersion: String,
numberOfTests: usize,
header: Vec<Value>, // not used
notes: Opt... |
/*
Creates a batch job and task using the data plane APIs
cargo run --package azure_svc_batch --example create_task
*/
use azure_identity::token_credentials::AzureCliCredential;
use azure_svc_batch::models::{JobAddParameter, PoolInformation, TaskAddParameter};
use azure_svc_batch::operations::{job, task};
#[tokio::m... |
use crate::schema::statement_of_accounts;
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
#[derive(GraphQLObject, Queryable, Debug, Serialize, Deserialize)]
pub struct StatementOfAccount {
pub id: i32,
pub description: Option<String>,
pub starting: NaiveDateTime,
pub ending: NaiveDateTi... |
pub mod proxy_info;
pub use crate::proxy_info::{
Anonymity,
ProxyInfo,
ProxyInfoError,
};
pub use isocountry::CountryCode;
use select::{
document::Document,
predicate::{
Attr,
Name,
},
};
use std::time::Duration;
pub type ProxyResult<T> = Result<T, ProxyError>;
#[derive(Debug)... |
pub mod labeling;
pub mod translation;
pub mod axiom_translation;
pub mod class_translation;
pub mod property_translation;
|
use super::super::context::*;
use super::super::error::*;
use super::super::traits::WorkType;
use super::super::utils::*;
use super::super::work::{WorkBox, WorkOutput};
use conveyor::ConveyorError;
use conveyor::*;
use conveyor_http::{Http as WHttp, HttpResponse, HttpResponseReader, Url};
use conveyor_work::http::{Http... |
//! Implements mesh generation for sectors.
//!
//! Each sector is a small rendererable chunk of the voxel world,
//! and is assigned a VAO in the form of a ``Tesselation``.
//! This module provides the logic that generates a list of vertex
//! attributes from a list of voxels.
//!
//! In other words, it makes models f... |
use std::{env, path::Path, process::Command};
pub fn build(manifest_dir: &Path, target_triple: &str, out_dir: &Path) {
println!("cargo:rerun-if-env-changed=CC");
println!("cargo:rerun-if-env-changed=CXX");
println!("cargo:rerun-if-changed=cfltk/CMakeLists.txt");
println!("cargo:rerun-if-changed=cfltk/i... |
pub mod get_report_entries;
pub mod types;
|
use std::io::{Write};
use super::Generator;
use super::ast::{Code};
use super::ast::Statement::{Var, Expr};
use super::ast::Expression::{Call, Name, Str, Attr};
impl<'a, W:Write+'a> Generator<'a, W> {
pub fn add_css(&self, code: Code, css: &str) -> Code {
let stmt = vec![
// var _style = do... |
use super::super::data::DataReader;
use super::super::entry::Entry;
use super::super::env::SeriesEnv;
use super::super::error::Error;
use super::super::file_system::{FileKind, OpenMode};
use std::collections::VecDeque;
use std::sync::Arc;
pub struct SeriesReader {
env: Arc<SeriesEnv>,
}
impl SeriesReader {
pu... |
use crate::ray::Ray;
use crate::vec3::Vec3;
pub struct Camera {
origin: Vec3,
lower_left_corner: Vec3,
horizontal: Vec3,
vertical: Vec3,
}
impl Camera {
pub fn new() -> Self {
Camera {
origin: Vec3::new(0., 0., 0.),
lower_left_corner: Vec3::new(-2., -1., -1.),
... |
#[doc = "Reader of register IC_RX_TL"]
pub type R = crate::R<u32, super::IC_RX_TL>;
#[doc = "Writer for register IC_RX_TL"]
pub type W = crate::W<u32, super::IC_RX_TL>;
#[doc = "Register IC_RX_TL `reset()`'s with value 0"]
impl crate::ResetValue for super::IC_RX_TL {
type Type = u32;
#[inline(always)]
fn re... |
#![no_std]
#![feature(alloc)]
extern crate alloc;
use alloc::collections::BTreeMap;
use alloc::string::String;
use alloc::vec::Vec;
extern crate common;
use common::contract_api::{get_arg, ret, store_function};
fn hello_name(name: &str) -> String {
let mut result = String::from("Hello, ");
result.push_str(na... |
use std::{
collections::HashMap,
sync::{Mutex, RwLock},
};
use apllodb_shared_components::{ApllodbError, ApllodbResult};
use crate::correlation::correlation_name::CorrelationName;
use super::{
node_id::{QueryPlanNodeId, QueryPlanNodeIdGenerator},
node_kind::QueryPlanNodeKind,
QueryPlanNode,
};
#... |
//!
//! # `Data Section`
//!
//! +------------+----------------+-----------+
//! | | | |
//! | #Layouts | Layout #1 | ... |
//! | (2 bytes) | (see `Layout`) | |
//! | | | |
//! +------------+----------------+-----------+
//!... |
use rltk::{Rltk, RGB};
use specs::prelude::*;
use super::{RunState, gamelog::GameLog, GameClock, WantsToSowSeed, Seed,
Position, Renderable, InPlayerInventory, Name, IsSown};
pub struct SeedSowingSystem {}
impl<'a> System<'a> for SeedSowingSystem {
#[allow(clippy::type_complexity)]
type SystemData = (
... |
use crate::commands::WholeStreamCommand;
use crate::context::CommandRegistry;
use crate::data::base::select_fields;
use crate::errors::ShellError;
use crate::prelude::*;
#[derive(Deserialize)]
struct PickArgs {
rest: Vec<Tagged<String>>,
}
pub struct Pick;
impl WholeStreamCommand for Pick {
fn name(&self) ->... |
use std::io::println;
use triangle_routines::triangle_print;
mod triangle_routines;
static NUM_PEGS:int = 15;
static NUM_MOVES:int = 36;
static moves:[[int, ..3], ..NUM_MOVES] = [
[0, 1, 3],
[0, 2, 5],
[1, 3, 6],
[1, 4, 8],
[2, 4, 7],
[2, 5, 9],
[3, 1, 0],
[3, 4, 5],
[3, 6, 10],
[3, 7, 12],
[4,... |
// Copyright 2019 Parity Technologies
//
// 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 nalgebra;
use std::marker::PhantomData;
use std::mem;
use std::ops::{Deref, DerefMut};
use std::thread::{self, ThreadId};
use hibitset::BitSetLike;
use specs::prelude::*;
use specs::storage::{
DenseVecStorage, MaskedStorage, TryDefault, UnprotectedStorage,
};
use specs::world::Index as SpecsIndex;
use specs_de... |
pub fn encode(s : &'static str) -> String {
format!("1{}1", s)
}
#[cfg(test)]
mod tests {
use super::encode;
#[test]
fn should_encode_a_simple_char() {
assert_eq!("1A1", encode("A"));
assert_eq!("1B1", encode("B"));
}
#[test]
fn should_encode_a_simple_sequence() {
... |
// I'm going to make this non-standard GCode by adding in custom commands not in the standard.
// Non-standard commands
// Q1 -> Change quadrants
#[derive(Debug, PartialEq, Clone)]
pub struct Word {
pub letter: char,
pub value: u16
}
#[derive(Debug, PartialEq, Clone)]
pub struct GCode {
pub... |
/*
* Copyright 2020 Cargill Incorporated
*
* 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 a... |
mod cpu;
#[cfg(feature = "cuda")]
mod cuda;
|
//! Doctor Syn a computer algebra system for rust macros.
pub mod error;
pub mod expression;
pub mod name;
pub mod polynomial;
pub mod transformation;
pub mod variablelist;
pub mod visitor;
#[cfg(test)]
mod tests;
pub use expression::{Expression, Parity};
pub use name::Name;
pub use std::convert::{TryFrom, TryInto};... |
extern crate iron;
extern crate persistent;
extern crate router;
extern crate r2d2;
extern crate r2d2_sqlite;
extern crate rusqlite;
extern crate uuid;
use iron::prelude::*;
use iron::status;
use std::io::Read;
pub struct ConnectionPool;
impl iron::typemap::Key for ConnectionPool {
type Value = r2d2::Pool<r2d2_sq... |
use once_cell::sync::OnceCell;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::error::Error;
/// An abstraction for regex patterns.
///
/// * Allows swapping out the regex implementation because it's only in this module.
/// * Makes regexes serializable and deserializable using just the pattern... |
use aoc20::days::day8;
#[test]
fn day8_parse() {
assert_eq!(day8::Instruction::parse("nop +0"),
day8::Instruction::new(String::from("nop"), 0)
);
assert_eq!(day8::Instruction::parse("acc -99"),
day8::Instruction::new(String::from("acc"), -99)
);
assert_eq!(day8::Instruction::parse("... |
use std::iter::Iterator;
use std::vec::Vec;
pub struct BufferedIterator<T, TIter: Iterator<Item = T>> {
itr: TIter,
buf: Vec<T>,
}
impl<T, TIter: Iterator<Item = T>> BufferedIterator<T, TIter> {
pub fn new(itr: TIter) -> BufferedIterator<T, TIter> {
BufferedIterator {
itr,
buf: Vec::new(),
}
}
pub fn ... |
use bonuses;
/// An object which tracks dodge bonus values.
pub struct DodgeBonus {
tracker: bonuses::StackingTracker,
}
impl DodgeBonus {
/// Create an instance of DodgeBonus.
pub fn new() -> DodgeBonus {
DodgeBonus {
tracker: bonuses::StackingTracker::new()
}
}
}
impl bonuses::BonusTracker for DodgeBonu... |
extern crate atty;
extern crate rayon;
extern crate ring;
extern crate serde_json;
extern crate solana;
use atty::{is, Stream};
use solana::mint::{Mint, MintDemo};
use std::io;
use std::process::exit;
fn main() {
let mut input_text = String::new();
if is(Stream::Stdin) {
eprintln!("nothing found on st... |
use crate::DATABASE;
// use rusqlite::NO_PARAMS;
use rusqlite::{Connection, Result};
#[derive(Serialize, Deserialize, Debug)]
pub struct User {
pub id: Option<String>,
pub public_key: String,
pub token: String,
pub platform: String,
}
// Implements user
impl User {
// checks if the user exists
... |
#[cfg(test)]
mod test {
use nom::IResult;
use parser::program;
use std::collections::HashMap;
use ast::{Datatype, TypeInfo, VariableStore};
use test::Bencher;
use std::rc::Rc;
#[test]
fn program_parse_and_execute_integration_test_1() {
let mut map: VariableStore = VariableStore... |
/*
eval.rs: holds the functionality of the evaluator of the Interpreter!
The module "eval" is a submodule of "main" and contains the two functions eval and apply which are
the core of the Interpreter. "eval" is the Interface to the Evaluator and is everything that needs
to be called to evaluate an expression.
*/
// l... |
mod rand_no_trades;
mod real_player_cli;
extern crate lazy_static;
use crate::game::GameState;
use crate::types::*;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use serde_json;
use std::collections::HashMap;
use std::sync::Mutex;
type StrategyConstructor = fn() -> Box<dyn PlayerStrategy>;
lazy_... |
use super::ecdsa::*;
use super::eddsa::*;
use super::error::*;
use super::handles::*;
use super::rsa::*;
use super::signature_op::*;
use super::signature_publickey::*;
use super::WASI_CRYPTO_CTX;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[repr(u16)]
pub enum KeyPairEncoding {
Raw = 1,
PKCS8 = 2,
DER = ... |
use crate::set1::aes;
use crate::utils::random::{coin_flip, random_bytes, random_in_range};
pub fn encryption_oracle<T: AsRef<[u8]>>(input: T) -> (bool, Vec<u8>) {
let key = random_bytes(16);
let padding_size: usize = random_in_range(5, 10);
let mut padded_input = random_bytes(padding_size);
padded_i... |
pub mod boundaries;
pub mod layout;
pub mod pane_resizer;
pub mod panes;
pub mod tab;
pub fn _start_client() {}
|
use std::fs;
use std::collections::HashMap;
use seven::*;
fn part1(bags: &HashMap<String, Bag>, bagname: &String) -> usize {
let mut count: usize = 0;
for (k, v) in bags.iter() {
if k != bagname && v.can_contain(bags, bagname) {
count +=1;
}
}
count
}
fn part2(bags: &HashMap<String... |
#[doc = "Reader of register ADV_ACCADDR_L"]
pub type R = crate::R<u32, super::ADV_ACCADDR_L>;
#[doc = "Writer for register ADV_ACCADDR_L"]
pub type W = crate::W<u32, super::ADV_ACCADDR_L>;
#[doc = "Register ADV_ACCADDR_L `reset()`'s with value 0xbed6"]
impl crate::ResetValue for super::ADV_ACCADDR_L {
type Type = u... |
// ===============================================================================
// Authors: AFRL/RQQA
// Organization: Air Force Research Laboratory, Aerospace Systems Directorate, Power and Control Division
//
// Copyright (c) 2017 Government of the United State of America, as represented by
// the Secretary of th... |
use std::fs;
use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
use crate::dnd::ability_scores::AbilityScores;
use crate::dnd::character::Character;
use crate::dnd::html_formatting::ToHTMLString;
use crate::io::file_utils::random_line_from_file;
use crate::threading::threadpool::ThreadPool;
static NAM... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.