text stringlengths 8 4.13M |
|---|
use rand::Rng;
use std::cmp::{max, min};
use std::fmt;
// const DICE_CHARS: [char; 6] = ['⚀', '⚁', '⚂', '⚃', '⚄', '⚅'];
const DICE_CHARS: [char; 6] = ['1', '2', '3', '4', '5', '6'];
#[derive(Debug, PartialEq)]
pub struct Dice {
first: u8,
second: u8,
}
impl Dice {
pub fn make(first: u8, second: u8) -> Di... |
pub mod test_new_filestream;
pub mod test_write;
pub mod test_rw;
pub mod test_read; |
/// A runtime module template with necessary imports
/// Feel free to remove or edit this file as needed.
/// If you change the name of this file, make sure to update its references in runtime/src/lib.rs
/// If you remove this file, you can remove those references
/// For more guidance on Substrate modules, see the ... |
use crate::datastructure::basic::BasicDataStructure;
use crate::postprocessors::gamma::Gamma;
use crate::raytracer::jmstrace::JMSTracer;
use crate::renderer::RendererBuilder;
use crate::scene::scene::SceneBuilder;
use crate::setup::Setup;
use crate::shader::vmcshader::VMcShader;
use crate::util::camera::Camera;
use cra... |
use super::component_prelude::*;
pub struct Loader {
pub loading_distance: Vector,
}
impl Loader {
pub fn new(loading_distance: Vector) -> Self {
Self { loading_distance }
}
}
impl Component for Loader {
type Storage = VecStorage<Self>;
}
|
use crate::{FieldType, MessageType, MatchFieldTypeFn};
fn match_field_accelerometer_data(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::Uint16,
2 => FieldType::Uint16,
3 => FieldType::Uint16,
4 => FieldType::Uint16,
5 => FieldType::Float32... |
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::sugg::Sugg;
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::{def, Expr, ExprKind, PrimTy, QPath, TyKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::Ty;
use... |
use super::*;
use proptest::strategy::Strategy;
mod with_local_pid;
#[test]
fn without_pid_or_port_errors_badarg() {
run!(
|arc_process| {
(
Just(arc_process.clone()),
strategy::term::atom(),
strategy::term(arc_process.clone())
... |
use std::fs;
use std::path::{Path, PathBuf};
use morgan_kvstore::test::gen;
use morgan_kvstore::{Config, Key, KvStore};
const KB: usize = 1024;
const HALF_KB: usize = 512;
#[test]
fn test_put_get() {
let path = setup("test_put_get");
let cfg = Config {
max_mem: 64 * KB,
max_tables: 5,
... |
use std::io;
fn main() {
println!("nth Fibonacci!");
println!("Enter n:");
let mut n = String::new();
io::stdin().read_line(&mut n).expect("Failed to read n");
let n: i32 = loop {
let n: i32 = match n.trim().parse() {
Ok(num) => num,
Err(_) => {
p... |
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct Hook {
pub (crate) _type: String,
pub (crate) method: String,
pub (crate) url: String
} |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtCore/qprocess.h
// dst-file: /src/core/qprocess.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <=... |
pub mod stream_reader;
pub mod stream_writer;
pub enum EndianType {
LittleEndian,
BigEndian,
}
fn swap_i16(i: &i16) -> i16 {
let ff: i16 = 0xff;
(i & ff) << 8 | ((i >> 8) & ff)
}
fn swap_i32(i: &i32) -> i32 {
let ff: i32 = 0xffff;
let v = *i as i16;
let c = (i >> 0x10) as i16;
let d1... |
// Copyright 2023 Datafuse Labs.
//
// 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 ... |
//!
//!
//! Create a single or collection of generics/trait bounds for functions and other
//! objects.
//!
use serde::{Deserialize, Serialize};
use tera::{Context, Tera};
use crate::internal;
use crate::traits::SrcCode;
/// Represent a single trait bound
///
/// Example
/// -------
/// ```
/// use proffer::*;
///
/... |
use crate::alloc;
use alloc::{Alloc, AllocErr};
use std::alloc::{self as system_alloc, Layout};
#[derive(Debug)]
pub struct BPFAllocator {
allocated: usize,
size: usize,
}
impl BPFAllocator {
pub fn new(heap: Vec<u8>) -> Self {
Self {
allocated: 0,
size: heap.len(),
... |
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::RIS {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... |
use assert_cmd::prelude::*; // Add methods on commands
use predicates::prelude::*; // Used for writing assertions
use std::process::Command;
const BIN: &str = "musign";
// secp256k1_ecdsa_signature_serialize_der
// secp256k1_ecdsa_signature_parse_compact
#[test]
fn help_subcommand() -> Result<(), Box<dyn std::error:... |
use std::{fmt::Debug, ops::Mul, rc::Rc};
use cxx::UniquePtr;
use crate::{sys, Term};
#[derive(Clone)]
pub struct Variable {
var: Rc<UniquePtr<sys::Variable>>,
}
impl Variable {
pub fn new(name: &str) -> Self {
cxx::let_cxx_string!(name = name);
Self {
var: Rc::new(unsafe { sys::... |
use super::android::{
back, content_options_positons, draw, get_ime, input, set_ime, sleep, tap, Xpath,
};
use super::config::Rules;
use super::db::*;
pub struct Daily {
ime: String,
daily_delay: u64,
daily_forever: bool,
rules: Rules,
db: DB,
bank: Bank,
has_bank: bool,
submit_posi... |
use std::fmt;
use std::ops;
use std::mem;
use std::slice;
use approx;
use num;
use angle::{FromAngle, Angle, IntoAngle, Deg};
use angle;
use channel::{PosNormalBoundedChannel, AngularChannel, ChannelFormatCast, ChannelCast,
PosNormalChannelScalar, AngularChannelScalar, ColorChannel};
use alpha::Alpha;
use... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtGui/qwindow.h
// dst-file: /src/gui/qwindow.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <= mai... |
use challenges::random_bytes;
use cipher::{ctr::AES_128_CTR, Cipher};
fn main() {
println!("🔓 Challenge 26");
let key = Key::new();
bitflipping_attack(&key);
}
fn bitflipping_attack(key: &Key) {
let input = random_bytes(2 + 16);
let mut ct = key.encryption_oracle(&input);
let xor_diff = xor::... |
use bevy::{prelude::*,};
use game_entities::*;
//not sure the usefulness of a core but will see later. Might come in use when I think of all systems working together.
pub mod stages {
pub const INIT: &'static str = "init";
pub const POST_INIT: &'static str = "post_init";
pub const PRE_UPDATE: &'static s... |
pub use VkShaderStageFlags::*;
#[repr(u32)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum VkShaderStageFlags {
VK_SHADER_STAGE_VERTEX_BIT = 0x0000_0001,
VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 0x0000_0002,
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 0x0000_0004,
VK_SHADER_STAGE_GEOMETRY_BI... |
use hashbrown::HashSet;
fn parse_element(el: &str) -> i32 {
el.parse().unwrap()
}
pub fn part1(input: &[&str]) -> i32 {
input.iter().map(|el| parse_element(el)).sum()
}
pub fn part2_functional(input: &[&str]) -> i32 {
let mut seen = HashSet::new();
seen.insert(0);
let err: Result<_, i32> = input.... |
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct Image {
pub id: i32,
pub file_name: String
}
|
use pest::error::Error;
use pest::Parser;
use pest::iterators::Pair;
use std::str::FromStr;
#[derive(Debug, Clone)]
/// A representation of a simple mathematical expresion. It is produce by the Expresion grammatical
/// rule witch can be find at the parser documentation [`parser`](fn.parser.html).
pub enum Expresion ... |
// Declare the EOSIO externs to read action data and print to the console.
extern "C" {
pub fn read_action_data(msg: *mut CVoid, len: u32) -> u32;
pub fn prints_l(cstr: *const u8, len: u32);
pub fn printn(name: u64);
}
#[repr(u8)]
pub enum CVoid {
// Two dummy variants so the #[repr] attribute can be u... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct AccessKeyDisplayDismissedEventArgs(pub ::windo... |
use std::default::Default;
use std::sync::atomic::{AtomicPtr, AtomicIsize, Ordering};
use std::{fmt, ptr};
use super::item::Item;
// TODO: try to relax the ordering, on a per call basis.
const DEFAULT_ORDERING: Ordering = Ordering::SeqCst;
/// The size of a single [`Segment`]. 32 is chosen somewhat arbitrarily.
///
... |
fn main() {
let d = Data { value: 4 };
println!("{}", d.times());
println!("{}", d.plus(3));
println!("{}", d.plus2());
}
struct Data {
value: i32
}
impl Data {
fn times(&self) -> i32 {
self.value * 2
}
fn plus(&self, v: i32) -> i32 {
self.value + v
}
}
impl Data {
fn plus2(&self) -> i32 {
self.pl... |
use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;
use serde::Deserialize;
use serde_tokenstream::from_tokenstream;
use std::fmt::Formatter;
use std::sync::atomic::{AtomicBool, Ordering};
use syn::Error;
use syn::{spanned::Spanned, FnArg, ItemFn, Pat, PatIdent, PatType, ReturnType, Signature, Type};
#[deri... |
use super::{utils::sort_by_cost_weight_ratio, Item, Problem, Solution, SolverTrait};
#[derive(Debug, Clone)]
pub struct GreedySolver();
impl SolverTrait for GreedySolver {
fn construction(&self, problem: &Problem) -> Solution {
let (items, mappings) = sort_by_cost_weight_ratio(&problem.items, problem.max_... |
// auto generated, do not modify.
// created: Wed Jan 20 00:44:03 2016
// src-file: /QtNetwork/qsslcertificate.h
// dst-file: /src/network/qsslcertificate.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main ... |
use super::Topic;
use super::FirstUpper;
pub struct Elementary;
struct StructWithState {
a: u32,
b: String
}
impl StructWithState {
fn my_method(&self, my_string: &str) -> i32 {
println!("a was {}, parameter was {}", self.a, my_string);
43
}
}
impl Topic for Elementary {
fn ... |
// auto generated, do not modify.
// created: Wed Jan 20 00:44:03 2016
// src-file: /QtQuick/qsgtextureprovider.h
// dst-file: /src/quick/qsgtextureprovider.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// mai... |
#![feature(conservative_impl_trait)]
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::hash::Hash;
/// An Unordered `MultiSet`.
#[derive(Debug, Clone, PartialEq)]
pub struct Bag<T: Eq + Hash>(HashMap<T, usize>);
impl<T: Eq + Hash> Default for Bag<T> {
fn default()... |
use std::env;
use std::fs;
use std::time;
use bg_core::dice::Dice;
use bg_core::game::Match;
use bg_core::movegen::{generate_o_moves, generate_x_moves};
use bg_core::position::Position;
use bg_core::rollout;
use bg_parser::parse_match;
use rand::Rng;
fn load_match(filename: &str) -> Match {
let contents = fs::r... |
pub use crate::ugid::{Gid, Uid};
|
pub mod std;
|
pub trait InspectErr<E> {
fn my_inspect_err<F>(self, f: F) -> Self
where
F: Fn(&E);
}
impl<T, E> InspectErr<E> for Result<T, E> {
fn my_inspect_err<F>(self, f: F) -> Self
where
F: Fn(&E),
{
self.map_err(|e| {f(&e); e})
}
}
|
#[doc = "Reader of register RXESC"]
pub type R = crate::R<u32, super::RXESC>;
#[doc = "Writer for register RXESC"]
pub type W = crate::W<u32, super::RXESC>;
#[doc = "Register RXESC `reset()`'s with value 0"]
impl crate::ResetValue for super::RXESC {
type Type = u32;
#[inline(always)]
fn reset_value() -> Sel... |
use super::UserInput;
use async_trait::async_trait;
use cursive::traits::*;
use cursive::views::Dialog;
use std::collections::HashSet;
use std::io::{Error, ErrorKind, Result};
use std::ops::Deref;
pub struct UIBackend<'a> {
shell_trust: &'a super::ShellTrust,
}
impl<'a> UIBackend<'a> {
pub fn new(shell_trust:... |
#[cfg(feature = "bytemuck")]
pub mod bytemuck;
#[cfg(feature = "mint")]
pub mod mint;
|
//!
//! Import data and WAL from a PostgreSQL data directory and WAL segments into
//! zenith Timeline.
//!
use log::*;
use postgres_ffi::nonrelfile_utils::clogpage_precedes;
use postgres_ffi::nonrelfile_utils::slru_may_delete_clogsegment;
use std::cmp::min;
use std::fs;
use std::fs::File;
use std::io::Read;
use std::p... |
use std::fs::File;
use std::io::prelude::*;
use std::env;
use std::io::{self,BufReader};
mod Import_File;
fn main() -> io::Result<()> {
//let path = env::current_dir()?;
//et path = String::from("12");
//let num:u8 = path.parse().unwrap();
//println!("{}", num);
let f = File::open("2460219.TX... |
use crate::{
core::{
math::{
vec3::Vec3,
vec2::Vec2
},
pool::{Pool, Handle},
},
resource::fbx::{
find_and_borrow_node,
find_node,
FbxContainer,
FbxComponent,
FbxNode,
FbxReference,
string_to_reference,
... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// 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 ... |
use crate::hash_cons::Consed;
use std::ops::Deref;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Symbol(Consed<String>);
impl Deref for Symbol {
type Target = String;
fn deref(&self) -> &String {
&self.0
}
}
impl From<Consed<String>> for Symbol {
fn from(sym: Consed<String>) -> Symbol {
... |
use aoc;
use std::collections::HashMap;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
fn main() -> Result<(), Box<dyn Error>> {
let arg = aoc::get_cmdline_arg()?;
let mut plants: HashMap<String, bool> = HashMap::new();
let mut lines = BufReader::new(File::open(... |
// ctrl-dが押されるまで文字列を読み続け,行ごとに反転して返す
use std::io::Read;
use std::str;
fn reserve_each_line(text: &str) -> String {
text.split_terminator("\n")
.flat_map(|line| line.chars().rev().chain(Some('\n')))
.collect()
}
fn main() {
let mut scan = std::io::stdin();
let mut buf = Vec::new();
scan... |
//! Provides types / enums / structs for defining parser combinators
mod heredoc;
mod interpolable;
mod metadata;
mod nom_prelude;
mod segment;
mod tracked_location;
pub use crate::ast::{
Identifier, IdentifierKind, Interpolated, Literal, Node, Parameter, Program, WhenClause,
};
pub use heredoc::{HeredocIndentati... |
//! Telamon's demo.
//!
//! To run the demo:
//! ```
//! cargo run --example=matmul --features=cuda --release
//! ```
//! To display the candidates evaluated, use `RUST_LOG=telamon::explorer::warn`.
use telamon::device::Context;
use telamon::{codegen, explorer, helper, ir, search_space};
use telamon_cuda as cuda;
// ... |
pub struct Solution;
impl Solution {
pub fn search_insert(nums: Vec<i32>, target: i32) -> i32 {
let n = nums.len();
if n == 0 {
return 0;
}
if target <= nums[0] {
return 0;
}
if nums[n - 1] < target {
return n as i32;
}
... |
// Copyright 2018 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 {
fidl::{endpoints::RequestStream, Error as FidlError},
fidl_fuchsia_bluetooth_snoop::{
PacketType, SnoopMarker, SnoopPacket, SnoopProx... |
use ansi_term::Colour;
use hackscanner_lib::*;
pub fn print_summary(min_severity: Severity, summary: &Summary) {
println!("[SUMMARY]");
println!(
"Detected {} violations with severity '{}' or higher",
summary.ratings_above(min_severity),
min_severity.description().to_lowercase()
);
... |
use crate::scraper::BASE_BOE_URL;
use scraper::{Html, Selector};
use shylock_data::concepts::BoeConcept;
use std::collections::HashMap;
fn parse_html_table(
page: &str,
data_selector: &Selector,
) -> Result<HashMap<BoeConcept, String>, Box<dyn std::error::Error>> {
let mut result: HashMap<BoeConcept, Strin... |
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::HB16CFG3 {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R,... |
use std::convert::Infallible;
use std::net::SocketAddr;
use std::sync::Arc;
use std::time::Instant;
use log::{info, warn};
use snork::agents::*;
use snork::env::{GameRequest, IndexResponse, API_VERSION};
use clap::Parser;
use warp::Filter;
pub const PACKAGE_VERSION: &str = env!("CARGO_PKG_VERSION");
pub const AUTHOR... |
#[derive(Debug)]
enum Mode {
Position,
Immediate,
Relative,
}
#[derive(Debug)]
enum Type {
Parameter,
Address,
}
#[derive(Debug)]
enum Instruction {
Add(i64, i64, usize),
Multiply(i64, i64, usize),
Input(usize),
Output(i64),
JumpIfTrue(i64, i64),
JumpIfFalse(i64, i64),
... |
#![feature(test)]
#![feature(iterator_fold_self)]
#![feature(min_const_generics)]
#![feature(is_sorted)]
extern crate hashbrown;
extern crate test;
extern crate utils;
#[allow(dead_code)]
mod day_25;
// mod day_9;
// mod day_8;
// mod day_7;
// mod day_6;
// mod day_5;
// mod day_4;
// mod day_3;
// mod day_2;
// mod ... |
// Copyright (c) 2017 Anatoly Ikorsky
//
// 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. All files in the project carrying such notice may not be copied,
// m... |
use crate::dir_entry::*;
use crate::rule::Rule;
use crate::rule::RulePath;
use crate::rule::RuleTrait;
pub struct Matcher {}
impl Matcher {
/// Check if the entry's path matches the given rule
pub fn match_entry_path<C, P: RuleTrait<C>, D: DirEntryTrait>(rule: &P, entry: &D) -> bool {
let path_as_stri... |
mod day01;
mod day02;
mod day03;
mod day04;
mod day05;
fn main() {
println!("---- Listing solutions ---- ");
//day01::solve();
//day02::solve();
//day03::solve();
day04::solve();
//day05::solve();
}
|
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use itertools::Itertools;
use whiteread::parse_line;
fn main() {
let n: usize = parse_line().unwrap();
let mut hshs: Vec<(u64, u64)> = vec![];
for _ in 0..n {
let hs = parse_line().unwrap();
hshs.push(hs);
}
let mu... |
use solana_program::{
msg,
program_error::ProgramError,
program_pack::{IsInitialized, Pack, Sealed},
pubkey::Pubkey,
};
use solana_gravity_contract::gravity::state::PartialStorage;
use spl_token::state::Mint;
use gravity_misc::model::{AbstractRecordHandler, RecordHandler};
use gravity_misc::validation... |
extern crate cmake;
use std::env;
use std::path::PathBuf;
const ENV_LLVM_CORE_INCLUDE: &'static str = "DEP_FIREFLY_LLVM_CORE_INCLUDE";
const ENV_LLVM_PREFIX: &'static str = "DEP_FIREFLY_LLVM_CORE_PREFIX";
const ENV_LLVM_LINK_STATIC: &'static str = "DEP_FIREFLY_LLVM_CORE_LINK_STATIC";
const ENV_LLVM_LINK_LLVM_DYLIB: &... |
#[doc = "Reader of register IM"]
pub type R = crate::R<u32, super::IM>;
#[doc = "Writer for register IM"]
pub type W = crate::W<u32, super::IM>;
#[doc = "Register IM `reset()`'s with value 0"]
impl crate::ResetValue for super::IM {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
//! Installing signal handlers allows us to handle traps and out-of-bounds memory
//! accesses that occur when runniing webassembly.
//!
//! This code is inspired by: https://github.com/pepyakin/wasmtime/commit/625a2b6c0815b21996e111da51b9664feb174622
use crate::call::recovery;
use nix::libc::{c_void, siginfo_t};
use n... |
use async_trait::async_trait;
use data_types::{sequence_number_set::SequenceNumberSet, TableId};
use generated_types::influxdata::iox::wal::v1::sequenced_wal_op::Op;
use std::{collections::HashMap, sync::Arc, time::Duration};
use tokio::sync::watch::Receiver;
use wal::{SequencedWalOp, WriteResult};
use crate::{
ca... |
{{replace def.keys.NewObjs $objs=objs}}
|
use crate::ir::eval::prelude::*;
impl IrEval for ir::IrScope {
type Output = IrValue;
fn eval(
&self,
interp: &mut IrInterpreter<'_>,
used: Used,
) -> Result<Self::Output, IrEvalOutcome> {
interp.budget.take(self)?;
let guard = interp.scopes.push();
for ir ... |
use std::rc::Rc;
use crate::env::Env;
use crate::expr::{compile_expr, compile_fn_expr};
use crate::helper::allocate_env;
use anyhow::{anyhow, Error};
use inkwell::{
builder::Builder,
context::Context,
module::Module,
values::{FunctionValue, PointerValue},
AddressSpace,
};
use serde_json::Value;
pu... |
#![crate_name = "ovr"]
#![crate_type = "lib"]
#![feature(link_args, path, core, std_misc)]
#![allow(non_upper_case_globals)]
extern crate cgmath;
extern crate libc;
use libc::{c_int, c_uint, c_void, c_float, c_double};
use std::default::Default;
use std::ptr;
use std::old_path::BytesContainer;
use cgmath::Quaternion... |
use scanner_proc_macro::insert_scanner;
use std::collections::HashMap;
fn f(x: u64, memo: &mut HashMap<u64, u64>) -> u64 {
if x <= 4 {
return x;
}
if let Some(&ans) = memo.get(&x) {
return ans;
}
let ans = f(x / 2, memo) * f((x + 1) / 2, memo) % 998244353;
memo.insert(x, ans);
... |
extern crate crypto;
use crypto::digest::Digest;
use crypto::md5::Md5;
fn main() {
let mut digest = Md5::new();
digest.input_str("signme");
println!("{}", digest.result_str());
}
|
/*
* hurl (https://hurl.dev)
* Copyright (C) 2020 Orange
*
* 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 ... |
use crate::board::*;
const MAX_DEPTH: u32 = 4;
pub struct Move {
pub start: (usize, usize),
pub end: (usize, usize),
value: i32,
}
impl PartialEq for Move {
fn eq(&self, mov: &Move) -> bool {
self.value == mov.value
}
}
impl PartialOrd for Move {
fn partial_cmp(&self, other: &Move) ->... |
//! Macros for creating compile-time EOSIO names and symbols.
//!
//! Creating EOSIO names:
//!
//! ```
//! use eosio_macros::n;
//! assert_eq!(n!("test"), 14_605_613_396_213_628_928);
//! assert_eq!(n!("1234"), 614_248_767_926_829_056);
//! assert_eq!(n!("123451234512"), 614_251_535_012_020_768);
//! assert_eq!(n!("eo... |
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... |
extern crate rand;
use rand::distributions::{IndependentSample, Range};
use std::collections::HashMap;
pub struct LSystem {
alphabet: Vec<char>,
constants: Vec<char>,
start: String,
rules: HashMap<char, String>,
}
impl LSystem {
/// Some guarantees of a LSystem:
/// 1. Every char in start is ... |
/*
Copyright 2020 Timo Saarinen
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
d... |
#[macro_use]
#[derive(Clone, Copy)]
pub enum Key {
Key1, Key2, Key3, Key4, Key5, Key6, Key7, Key8, Key9, Key0, A, B, C, D, E, F, G, H, I, J, K, L, M,
N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Escape, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
F13, F14, F15, Snapshot, Scroll, Pause, Insert, Home, Delete... |
// 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.
mod config;
mod validators;
use {
config::{Config, ConfigContext},
failure::{format_err, Error},
fidl::endpoints::{create_proxy, Request, Requ... |
fn main() {
// This struct presents unique challenges to the type reader as it is both arch-specific
// and one of those definitions has nested types. This combination is tricky because
// traditional scope resolution is insufficient.
windows::core::build_legacy! {
Windows::Win32::System::Diagno... |
/*
* Integration tests for vsv.
*
* Author: Dave Eddy <dave@daveeddy.com>
* Date: February 19, 2022
* License: MIT
*/
use anyhow::Result;
mod common;
#[test]
fn usage() -> Result<()> {
let assert = common::vsv()?.arg("-h").assert();
assert.success().stderr("");
Ok(())
}
#[test]
fn external_succe... |
use std::ffi::OsStr;
use std::path::Path;
use std::str::FromStr;
use serde::{de, Deserialize, Deserializer};
use strum::{EnumString, IntoStaticStr};
/// Programming language or file format being edited in a buffer.
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, EnumString, IntoStaticStr)]
pub enum Syntax {
#[s... |
use byteorder::LittleEndian;
use crate::io::Buf;
use crate::mysql::protocol::Capabilities;
// https://dev.mysql.com/doc/dev/mysql-server/8.0.12/page_protocol_basic_err_packet.html
// https://mariadb.com/kb/en/err_packet/
#[derive(Debug)]
pub struct ErrPacket {
pub error_code: u16,
pub sql_state: Option<Box<st... |
use std::rc::Rc;
use crate::chunk::{Constant, Chunk};
use crate::op::*;
use crate::scanner::Token;
const U8_SIZE: usize = (u8::MAX as usize) + 1;
#[derive(PartialEq)]
enum ChunkTag {
Script,
Function,
}
struct Local {
pub name: Rc<Token>,
pub depth: i32,
pub is_captured: bool,
}
impl Local {
... |
use crossterm::event::KeyModifiers;
use crossterm::event::{poll, read, Event, KeyCode, KeyEvent};
use std::collections::HashMap;
macro_rules! key_map {
($($key:expr => $val: expr), *) => {
{
let mut map = HashMap::<KeyCode, u8>::new();
$(
map.insert(KeyCode::Char($k... |
use common::privkey::key_pair_from_seed;
use crate::WithdrawFee;
use crate::utxo::rpc_clients::{ElectrumProtocol};
use futures::executor::block_on;
use futures::future::join_all;
use mocktopus::mocking::*;
use super::*;
fn electrum_client_for_test(servers: &[&str]) -> UtxoRpcClientEnum {
let mut client = ElectrumC... |
mod test_utils;
mod accept {
use super::test_utils::TestServer;
use async_h1::{client::Encoder, server::ConnectionStatus};
use async_std::io::{self, prelude::WriteExt, Cursor};
use http_types::{headers::CONNECTION, Body, Request, Response, Result};
#[async_std::test]
async fn basic() -> Result<... |
use std::{collections::HashMap, hash::Hash, rc::Rc};
use crate::{
algorithm::{Components, ComponentsIter, Point, Sorted, TaggedComponent, TaggedComponentExt},
chromset::LexicalChromRef,
properties::{WithRegion, WithRegionCore},
records::{Bed3, Bed4},
};
//use super::{Components, ComponentsIter, Point,... |
mod affine_expr;
mod affine_map;
pub(crate) mod attributes;
mod block;
mod context;
mod function;
mod location;
mod module;
mod operations;
mod region;
mod symbols;
pub(crate) mod types;
mod values;
pub use self::affine_expr::*;
pub use self::affine_map::*;
pub use self::attributes::*;
pub use self::block::*;
pub use ... |
use std::collections::BTreeMap;
use std::fs::{self, File};
use std::io::Write;
use std::net::SocketAddr;
use std::net::TcpStream;
use std::os::unix::fs::PermissionsExt;
use std::path::PathBuf;
use std::process::{Command, Stdio};
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
use anyhow::{Context, ... |
pub type StockId = String;
pub type Quantity = u32;
#[derive(Debug, Clone)]
pub enum Stock {
Nothing,
OutOfStock { id: StockId },
InStock { id: StockId, qty: Quantity },
}
pub trait CommandHandle<S, E> {
fn handle(&self, state: S) -> Option<E>;
}
pub trait EventApply<S> {
fn apply(&self, state: ... |
// Copyright 2017 Amagicom AB.
//
// 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
// except according to... |
use std::io::Read;
fn main() {
const MOD: u32 = 20201227;
const PUB_SUB: u32 = 7;
let mut input = String::new();
std::io::stdin().read_to_string(&mut input).unwrap();
let pub_keys: Vec<u32> = input.lines().map(|line| line.parse().unwrap()).collect();
let loop_size = (1..).try_fold(1, |acc, i... |
pub mod natural;
pub mod object;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Error {
/// Number exceeded 32 bits
NaturalOverflow,
/// Non-'case' nodes may not have hidden children
NonCaseHiddenChild,
/// 'case' nodes may have at most one hidden child
CaseMultipleHiddenChildren,
/... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.