text stringlengths 8 4.13M |
|---|
pub mod codegen;
pub mod helpers;
pub mod lexer;
pub mod logger;
pub mod master;
pub mod parser;
pub mod typecheck;
#[macro_use]
extern crate clap;
use clap::App;
use inkwell::context::Context;
fn main() {
let yaml = load_yaml!("cli.yml");
let matches = App::from_yaml(yaml).get_matches();
let filename = ... |
#![allow(dead_code)]
#![allow(non_camel_case_types)]
extern crate pcap;
use pcap::Packet;
use std::path::Path;
use std::ffi::CString;
use libc::{c_int, c_uint, c_char, c_uchar, timeval};
#[repr(C)]
#[derive(Copy, Clone)]
pub struct pcap_pkthdr {
pub ts: timeval,
pub caplen: c_uint,
pub len: c_uint,
}
pub... |
//! Jobs.
use std::{future::Future, sync::Arc};
use async_std::task;
/// Job context, that handles state
#[derive(Debug)]
pub struct JobContext<State> {
state: Arc<State>,
}
impl<State> JobContext<State> {
pub(crate) fn new(state: Arc<State>) -> Self {
Self { state }
}
/// Access app-global... |
//! Helpers to generate code from an IR instance and fully specified decisions.
mod cfg;
mod dimension;
mod function;
pub mod llir;
mod name_map;
mod printer;
mod size;
mod variable;
pub use self::cfg::Cfg;
pub use self::dimension::{Dimension, InductionLevel, InductionVar};
pub use self::function::*;
pub use self::nam... |
use neon::{
context::Context,
handle::Handle,
prelude::*,
result::Throw,
types::{JsArray, JsNull, JsObject, JsUndefined, JsValue},
};
use std::collections::HashMap;
pub fn is_null_or_undefined<'a, U: Value + 'a>(handle: Handle<'a, U>) -> bool {
handle.is_a::<JsNull>() || handle.is_a::<JsUndefin... |
use std::borrow::Cow;
use std::ffi::CStr;
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::sync::Arc;
use vulkano::descriptor::descriptor::{DescriptorDesc, ShaderStages};
use vulkano::descriptor::pipeline_layout::{PipelineLayoutDesc, PipelineLayoutDescPcRange};
use vulkano::device::Device;
use vulkan... |
extern crate chrono;
use self::chrono::prelude::{DateTime, Utc};
pub mod source;
use symbol::SymbolId;
#[derive(PartialEq, Clone, Debug)]
pub struct Ohlcv {
symbol_id: SymbolId,
datetime: DateTime<Utc>,
open: f64,
high: f64,
low: f64,
close: f64,
volume: u32
}
impl Ohlcv {
pub fn ne... |
// Copyright 2021 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 ... |
//! A `Retry-After` header implementation for Hyper
//!
//! This crate's repo is located at https://github.com/jwilm/retry-after.
//!
//! # Examples
//!
//! ```
//! extern crate chrono;
//! extern crate retry_after;
//!
//! use chrono::{Duration, UTC};
//! use retry_after::RetryAfter;
//!
//! # fn main() {
//! // Creat... |
use smithay::{
backend::input::{
AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent,
KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent,
},
input::{
keyboard::{keysyms, FilterResult},
pointer::{AxisFrame, Bu... |
use std::error;
use std::fmt;
use std::io;
// https://github.com/CommonWA/cwa-spec/blob/master/errors.md
pub const UNKNOWN: i32 = -1;
pub const INVALID_ARGUMENT: i32 = -2;
pub const PERMISSION_DENIED: i32 = -3;
pub const NOT_FOUND: i32 = -4;
pub const EOF: i32 = -5;
/// An error abstraction, all of the following valu... |
use std::collections::HashMap;
use std::io;
fn solver(n: u64, p: u64, q: u64, cache: &mut HashMap<u64, u64>) -> u64 {
if n == 0 {
return 1;
}
if cache.contains_key(&n) {
return *cache.get(&n).unwrap();
}
let a_p = solver(n / p, p, q, cache);
let a_q = solver(n / q, p, q, cache);... |
use game::{MAX_MOVES, Game};
pub struct Solver {
game: Game,
min_dist: i32
// TODO priority queue
}
impl Solver {
pub fn new(game: Game) -> Solver {
Solver {
game,
min_dist: MAX_MOVES
}
}
} |
use crate::window::{Window, Geometry};
use crate::stack::Stack;
use std::fmt::Debug;
mod fullscreen;
mod tall;
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum Layout {
Tall,
FullScreen,
}
impl Layout {
pub fn handle_layout<W>(&self, view: &Geometry, windows: Stack<Window<W>>) -> Stack<Window<W>> {
... |
use std::sync::Arc;
use sqlx::mysql::*;
use sqlx::Pool;
pub async fn new_connection_pool() -> sqlx::Result<Arc<Pool<MySql>>> {
let pool = MySqlPoolOptions::new()
.max_connections(5)
.connect("mysql://root:rootpassword@localhost:3306").await?;
Ok(Arc::new(pool ))
} |
pub trait Form {
fn html(&self) -> Vec<u8>;
} |
use std::collections::HashMap;
fn main() {
let lines = include_str!("input.txt").lines().collect::<Vec<_>>();
println!("Day 3 part 1: {}", overlapper(&lines[..]));
println!("Day 3 part 2: {}", not_overlapper(&lines[..]).unwrap().id);
}
struct Spec {
id: u32,
start: (u32, u32),
size: (u32, u32)... |
#[doc = "Reader of register AHBRSTR"]
pub type R = crate::R<u32, super::AHBRSTR>;
#[doc = "Writer for register AHBRSTR"]
pub type W = crate::W<u32, super::AHBRSTR>;
#[doc = "Register AHBRSTR `reset()`'s with value 0"]
impl crate::ResetValue for super::AHBRSTR {
type Type = u32;
#[inline(always)]
fn reset_va... |
/*
* Advent of Code 2019 - Day 1
*
* --- Part One ---
* The Elves quickly load you into a spacecraft and prepare to launch.
*
* At the first Go / No Go poll, every Elf is Go until the Fuel Counter-Upper. They haven't determined the amount of
* fuel required yet.
* Fuel required to launch a given module is bas... |
pub trait SessionApplication {
fn set_windowmanager();
fn set_config();
fn startup();
fn load_enviromentsettings();
fn load_keyboardsettings();
fn load_mousesettings();
}
|
//! Eval utilities
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use crate::{errors::OnChainError, Memory};
use bigint::{Gas, M256, U256};
#[cfg(not(feature = "std"))]
use core::cmp::min;
#[cfg(feature = "std")]
use std::cmp::min;
pub fn l64(gas: Gas) -> Gas {
gas - gas / Gas::from(64u64)
}
pub fn check_ra... |
fn main() {
delimit("creating a new vector (rare)");
let v: Vec<i32> = Vec::new();
println!("{:?}", v);
delimit("creating a vector more common (with `vec!` macro)");
let mut v = vec![1, 2, 3];
println!("{:?}", v);
for i in 4..10 {
v.push(i);
}
delimit("reading elements in ... |
extern crate sdl2;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use crate::grid::Grid;
use crate::renderer::Renderer;
use crate::row::Row;
use crate::events;
use crate::cell::Cell;
#[allow(dead_code)]
const BLACK: sdl2::pixels::Color = Color::RGB(0, 0, 0);
const WHITE: sdl2::pixels::... |
// 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 ... |
//! The compile-time representation of Piccolo code.
//!
//! Opcode bytes are currently unstable. Operands are little-endian.
//!
//! Index means the index in the chunk's constant table, and slot means the
//! index from the bottom of the call frame on the [`Machine`] stack.
//!
//! | Opcode | Operands ... |
use binary_search::BinarySearch;
use input_i_scanner::InputIScanner;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
macro_rules! scan {
(($($t: ty),+)) => {
($(scan!($t)),+)
};
($t: ty) => {
_i_i.scan::<$t>() as $... |
//! This module contains definitions for Timeseries specific Grouping
//! and Aggregate functions in IOx, designed to be compatible with
//! InfluxDB classic
use datafusion::prelude::Expr;
use snafu::Snafu;
use crate::window;
#[allow(missing_docs)]
#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(display(
... |
pub fn first_word(s: String) -> String {
let bytes = s.as_bytes();
let mut idx = 0;
for (i, &item) in bytes.iter().enumerate() {
if item == b' ' {
idx = i;
break;
}
}
println!("idx={}", idx);
slice_demo();
s[idx..].to_string()
}
fn slice_demo() {
... |
pub mod ant_ai;
pub mod random_move;
pub mod random_patrolling;
pub mod rat_ai;
pub mod spawning_equipment;
pub mod spawning_fruit;
|
use std::fs;
use std::io;
use stemmer::Stemmer;
use std::collections::HashMap;
fn main() {
println!("1. Read file and converted to lower case\n************");
let mut text = readfile().unwrap();
println!("{:#?}",text);
text = text.to_lowercase(); // converted to lower casse
println!("... |
// Applies Horner's rule to exponentiation
// Computes a^n by the left-to-right binary exponentiation algorithm
// Input: A number a and a list b(n) of binary digits b_I, ..., b_0
// in the binary expansion of a positive integer n
// Output: The value of a^n
fn lr_binary_exponentiation(a: u8, b: &[u8]) -> u64 {
... |
mod error;
use gstreamer::glib::{g_print, g_printerr};
use gstreamer::prelude::*;
use gstreamer::query::Seeking;
use gstreamer::*;
#[derive(Default)]
struct CustomData {
playing: bool, /* Are we in the PLAYING state? */
terminate: bool, /* Should we terminate execution? */
seek_e... |
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
extern crate hack_assembler;
pub use hack_assembler::lexer;
fn test_file_read_token_stream_integ(path: &Path) {
let display = path.display();
let mut file = match File::open(&path) {
Err(why) => panic!("failed to open {}:... |
use std::time::{SystemTime, Duration};
use segment::Metric;
// Define a metric..
#[derive(Metric)]
#[segment(measurement="cpuinfo")]
pub struct CpuInfo {
#[segment(time)]
timestamp: Duration,
#[segment(tag)]
descr: & 'static str,
#[segment(tag, rename="Host")]
host: String,
#[segment(t... |
#[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::PRESETCTRL {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'... |
use core::ops::Add;
use num_traits::FromPrimitive;
pub type Coord = i32;
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub struct Pos {
pub x: Coord,
pub y: Coord,
}
#[derive(Copy, Clone)]
pub enum ShiftDir {
Left,
Right,
}
/// Number of clockwise rotations
#[derive(Copy, Clone, PartialEq, Debu... |
// 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 core::JsRuntime;
fn main() {
let mut runtime = JsRuntime::new(Default::default());
runtime
.execute(
"<init>",
r#"
const toLog = [
SharedArrayBuffer,
ArrayBuffer,
Float64Array,
WebAssembly,
eval,
Math,
RegExp,
Atomics,
BigInt,
Date,
... |
use std::{error::Error, io, path::Path};
use serde::{Serialize, Deserialize};
pub const DEFAULT_CONFIG_PATH: &str = "./config.json";
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum DownloadQuality {
Raw,
Full,
Regular,
Small,
Thumb
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Co... |
/*
* Open Service Cloud API
*
* Open Service Cloud API to manage different backend cloud services.
*
* The version of the OpenAPI document: 0.0.3
* Contact: wanghui71leon@gmail.com
* Generated by: https://openapi-generator.tech
*/
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct CloudServerReso... |
#[doc = "Reader of register M4FDRL"]
pub type R = crate::R<u32, super::M4FDRL>;
#[doc = "Writer for register M4FDRL"]
pub type W = crate::W<u32, super::M4FDRL>;
#[doc = "Register M4FDRL `reset()`'s with value 0"]
impl crate::ResetValue for super::M4FDRL {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
use sqlx::{postgres::PgDone, PgPool};
use crate::application::dtos::answer_question_dto::AnswerQuestionData;
pub async fn insert(pool: &PgPool, answer: &AnswerQuestionData) -> Result<PgDone, sqlx::Error> {
sqlx::query_file!(
"src/infrastructure/repositories/sql/insert_student_answer.sql",
answer.i... |
use std::cmp::Ordering;
use std::collections::VecDeque;
use std::f32::consts::PI;
use std::fs::File;
use std::io::{BufRead, BufReader, Error as IOError};
use std::ops::{Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Sub, SubAssign};
use sdl2::{keyboard::Keycode, pixels::Color, rect::Point, render::Ca... |
use amethyst::{
ecs::prelude::*,
renderer::Rgba,
};
use amethyst_imgui::imgui;
use crate::Inspect;
impl<'a> Inspect<'a> for Rgba {
type SystemData = (ReadStorage<'a, Self>, Read<'a, LazyUpdate>);
const CAN_ADD: bool = true;
fn inspect((storage, lazy): &mut Self::SystemData, entity: Entity, ui: &imgui::Ui<'_>) {... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtCore/qjsonvalue.h
// dst-file: /src/core/qjsonvalue.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
/... |
pub type ITpmVirtualSmartCardManager = *mut ::core::ffi::c_void;
pub type ITpmVirtualSmartCardManager2 = *mut ::core::ffi::c_void;
pub type ITpmVirtualSmartCardManager3 = *mut ::core::ffi::c_void;
pub type ITpmVirtualSmartCardManagerStatusCallback = *mut ::core::ffi::c_void;
#[doc = "*Required features: `\"Win32_Securi... |
extern crate gl;
extern crate glutin;
extern crate graphics;
extern crate rand;
use std::ptr;
use std::mem;
use std::iter::repeat;
use std::str;
use std::ffi::CString;
use gl::types::*;
use glutin::VirtualKeyCode;
use graphics::{Mesh, Vector3, Matrix4, Quaternion};
use rand::distributions::{IndependentSample, Range};
... |
// Copyright 2017 Dasein Phaos aka. Luxko
//
// 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 a... |
#[derive(Clone)]
pub struct Serial {
interrupt: u8,
sb: u8,
sc: u8,
}
impl Serial {
pub fn init() -> Self {
Self {
interrupt: 0,
sb: 0,
sc: 0,
}
}
}
impl Serial {
pub fn step(&mut self, cycles: usize) {
// TODO: idk
}
... |
// Copyright 2013-2015 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-MI... |
// 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 ... |
use projecteuler::partition;
static COINS: &[usize] = &[1, 2, 5, 10, 20, 50, 100, 200];
fn main() {
//dbg!(binomial::binomial_coefficient(100, 50));
dbg!(solve(20));
dbg!(solve(200));
//dbg!(solve(200));
}
fn solve(n: usize) -> usize {
partition::partition_into(n, COINS)
}
|
use std::iter::FromIterator;
use rustc_serialize::json::{Json, ToJson};
pub struct Post {
pub title: String,
pub body: String
}
impl ToJson for Post {
fn to_json(&self) -> Json {
Json::Object(FromIterator::from_iter(vec![
("title".to_owned(), self.title.to_json()),
("body"... |
use std::io;
fn main() {
let mut total_fuel_req = 0;
let mut total_fuel_req_incl_extra_fuel = 0;
println!("Write each mass on a new line, and finish with an empty line when done.");
loop {
match read_mass() {
Some(num) => {
total_fuel_req += calculate_fuel_requirem... |
pub mod anoncreds;
pub mod crypto;
pub mod ledger;
pub mod pool;
pub mod signus;
pub mod wallet; |
/// 虚拟队列相关实现
/// ref: https://github.com/rcore-os/virtio-drivers/blob/master/src/queue.rs
/// thanks!
use volatile::Volatile;
use bitflags::bitflags;
use core::{mem::size_of, sync::atomic::{fence, Ordering}};
use core::ptr::NonNull;
use crate::util::align_up_page;
use super::dma::DMA;
use super::mmio::VirtIO... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type AttributedNetworkUsage = *mut ::core::ffi::c_void;
#[repr(transparent)]
pub struct CellularApnAuthenticationType(pub i32);
impl CellularApnAuthenticati... |
use super::xloc::*;
use super::VarResult;
use crate::ast::syntax_type::{FunctionType, FunctionTypes, SimpleSyntaxType, SyntaxType};
use crate::helper::err_msgs::*;
use crate::helper::str_replace;
use crate::helper::{
move_element, pine_ref_to_bool, pine_ref_to_color, pine_ref_to_f64, pine_ref_to_i64,
pine_ref_t... |
//! The main user interface from which the user will define systems to create.
//! They can also access and modify the `DataBase` of components to use in their
//! systems.
#[macro_use] mod utils;
mod edit_component;
mod edit_database;
use super::Config;
use error::{GrafenCliError, Result, UIErrorKind, UIResult};
use... |
use super::VarResult;
use crate::ast::stat_expr_types::VarIndex;
use crate::ast::syntax_type::{FunctionType, FunctionTypes, SimpleSyntaxType, SyntaxType};
use crate::helper::err_msgs::*;
use crate::helper::str_replace;
use crate::helper::{
move_element, pine_ref_to_bool, pine_ref_to_f64, pine_ref_to_f64_series, pin... |
use std::ops::{Deref, DerefMut};
use async_trait::async_trait;
use polars_core::frame::DataFrame;
use tokio::task::spawn_blocking;
use tonic::codec::CompressionEncoding;
use tonic::transport::Channel;
use tracing::{span, Instrument, Level};
use crate::api::click_house_client::ClickHouseClient;
pub use crate::api::{Qu... |
#[doc = "Reader of register UR17"]
pub type R = crate::R<u32, super::UR17>;
#[doc = "Reader of field `IO_HSLV`"]
pub type IO_HSLV_R = crate::R<bool, bool>;
impl R {
#[doc = "Bit 0 - I/O high speed / low voltage"]
#[inline(always)]
pub fn io_hslv(&self) -> IO_HSLV_R {
IO_HSLV_R::new((self.bits & 0x01... |
//! To run this code, clone the rusty_engine repository and run the command:
//!
//! cargo run --release --example sfx
//! This is an example of playing a sound effect preset. For playing your own sound effect file,
//! please see the `sound` example.
use rusty_engine::prelude::*;
fn main() {
let mut game = ... |
use input_i_scanner::InputIScanner;
use mod_int::ModInt998244353;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
macro_rules! scan {
(($($t: ty),+)) => {
($(scan!($t)),+)
};
($t: ty) => {
_i_i.scan::<$t>() as $t
... |
use measured_response::MeasuredResponse;
use arrayvec::ArrayVec;
const LAST_REQUEST_STORAGE_SIZE: usize = 10;
pub struct Summary {
pub total_requests: u64,
total_success: u64,
last_requests: ArrayVec<[MeasuredResponse; LAST_REQUEST_STORAGE_SIZE]>,
}
impl Default for Summary {
fn default() -> Summary... |
use backend::x86::x86function::X86Function;
use backend::x86::x86instr::X86Instr;
use backend::x86::x86register::X86Register;
use backend::MachinePrg;
#[derive(Debug)]
pub struct X86Prg {
pub functions: Vec<X86Function>,
}
impl MachinePrg<X86Register, X86Instr, X86Function> for X86Prg {
fn functions(&self) ->... |
use super::core_namespace::*;
use super::super::error::*;
use super::super::symbol::*;
use super::super::notebook::*;
use super::super::script_type_description::*;
use gluon::vm::api::*;
use desync::Desync;
use futures::*;
use std::sync::*;
///
/// Provides notebook functionality for a Gluon script host
///
pub stru... |
use std::io;
use std::net::{TcpListener, TcpStream};
use std::thread;
use std::time::Duration;
fn handle_client(mut stream: TcpStream) {
io::copy(&mut stream.try_clone().unwrap(), &mut stream);
}
fn main() {
let listener = TcpListener::bind("127.0.0.1:12345").unwrap();
for stream in listener.incoming() {
... |
// Copyright (c) 2020 DarkWeb Design
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish... |
mod bonus;
pub use self::bonus::Bonus;
use std::sync::Arc;
use types::{ClapItem, Score};
/// [`BonusMatcher`] only tweaks the match score.
#[derive(Debug, Clone, Default)]
pub struct BonusMatcher {
bonuses: Vec<Bonus>,
}
impl BonusMatcher {
pub fn new(bonuses: Vec<Bonus>) -> Self {
Self { bonuses }
... |
// Copyright (c) 2018-2022 Ministerio de Fomento
// Instituto de Ciencias de la Construcción Eduardo Torroja (IETcc-CSIC)
// 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 ... |
//! Crds Gossip Pull overlay
//! This module implements the anti-entropy protocol for the network.
//!
//! The basic strategy is as follows:
//! 1. Construct a bloom filter of the local data set
//! 2. Randomly ask a node on the network for data that is not contained in the bloom filter.
//!
//! Bloom filters have a fa... |
use std::error::Error;
use std::fs::metadata;
use std::path::Path;
use colored::*;
use log::*;
use tokio::process::Command;
use crate::ext::rust::PathExt;
use crate::stack::parser::AWSService;
const LOCALSTACK_S3_ENDPOINT: &str = "http://localhost:4572";
pub async fn wait_for_it() -> Result<(), Box<dyn Error>> {
... |
use winit::event::{VirtualKeyCode, ScanCode};
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
pub enum KeyCode {
Esc,
Num1,
Num2,
Num3,
Num4,
Num5,
Num6,
Num7,
Num8,
Num9,
Num0,
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
... |
use std::io::{BufRead, BufReader, Error, ErrorKind};
use std::process::{Command, Stdio};
use std::sync::mpsc::{Receiver, Sender, channel};
use std::thread;
use crate::line_details::{LineDetails, parse_line};
const QUIT_MESSAGE: &'static str = "QUIT_TASK";
pub fn process_files(num_workers: usize, directory: &str, ign... |
#![allow(dead_code)]
use std::{
error::Error as ErrorTrait,
fmt::{self, Debug, Display},
};
#[allow(unused_imports)]
pub use abi_stable_shared::test_utils::{must_panic, ShouldHavePanickedAt, ThreadError};
//////////////////////////////////////////////////////////////////
/// Checks that `left` and `right` p... |
#![allow(bad_style)]
extern crate gdi32;
extern crate winapi;
extern crate user32;
extern crate kernel32;
extern crate winmm;
pub mod window;
pub mod input;
pub mod file;
pub trait ToCU16Str {
fn to_c_u16(&self) -> Vec<u16>;
}
impl<'a> ToCU16Str for &'a str {
fn to_c_u16(&self) -> Vec<u16> {
self.en... |
#![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 DetectedFace(pub ::windows::core::IInspectable... |
// More convoluted in real life, does not matter here
use std::fmt::{self, Display, Formatter};
#[derive(Copy, Clone, Default, Debug)]
pub struct Foreground(pub u8, pub u8, pub u8);
#[derive(Copy, Clone, Default, Debug)]
pub struct Background(pub u8, pub u8, pub u8);
#[derive(Copy, Clone, Debug)]
pub enum Weight {
... |
//! https://github.com/lumen/otp/tree/lumen/lib/megaco/src/binary
use super::*;
test_compiles_lumen_otp!(megaco_ber_encoder imports "lib/megaco/src/binary/megaco_binary_encoder_lib");
test_compiles_lumen_otp!(megaco_binary_encoder imports "lib/megaco/src/binary/megaco_binary_encoder_lib");
test_compiles_lumen_otp!(me... |
use mod_int::ModInt998244353;
use proconio::input;
fn main() {
input! {
n: usize,
m: usize,
k: usize,
};
type Mint = ModInt998244353;
let mut dp = vec![Mint::new(0); m + 1];
for i in 1..=m {
dp[i] = Mint::new(1);
}
for _ in 1..n {
let mut nxt = vec!... |
use failure::Error;
use regex::RegexSet;
use serde_yaml;
use std::fs::File;
use std::io::Read;
#[derive(Debug, Deserialize, PartialOrd, Ord, Eq, PartialEq, Clone)]
pub struct Customer {
pub name: String,
job_pattern: String,
}
#[derive(Debug, Deserialize, PartialEq)]
pub struct Set {
customers: Vec<Custom... |
//! Implementation of the table gRPC service
#![deny(
rustdoc::broken_intra_doc_links,
rustdoc::bare_urls,
rust_2018_idioms,
missing_debug_implementations,
unreachable_pub
)]
#![warn(
missing_docs,
clippy::todo,
clippy::dbg_macro,
clippy::clone_on_ref_ptr,
clippy::future_not_sen... |
#![no_std]
#[macro_use]
extern crate crypto_tests;
extern crate kuznyechik;
use crypto_tests::block_cipher::{BlockCipherTest, encrypt_decrypt};
#[test]
fn kuznyechik() {
let tests = new_block_cipher_tests!("1");
encrypt_decrypt::<kuznyechik::Kuznyechik>(&tests);
}
|
// Copyright 2021 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 ... |
use std::process::Command;
fn main() {
let mut child = Command::new("sleep").arg("4").spawn().unwrap();
let _result = child.wait().unwrap();
println!("reached end of first batch");
let mut child2 = Command::new("sleep").arg("4").spawn().unwrap();
let _result2 = child2.wait().unwrap();
println!... |
fn main() {
let program: Vec<&str> = include_str!("./input.txt").lines().collect();
run_program(program[0]);
}
fn run_program(program: &str) -> isize {
let mut positions: Vec<isize> = program.split(",").map(|x| x.parse().unwrap()).collect();
let mut instruction_ptr = 0;
while instruction_ptr < pos... |
//! Asynchronous ARDOP TNC Interface
use std::convert::Into;
use std::fmt;
use std::net::SocketAddr;
use std::string::String;
use std::sync::Arc;
use std::time::Duration;
use async_std::prelude::FutureExt;
use futures::lock::Mutex;
use super::{DiscoveredPeer, PingAck, PingFailedReason, TncResult};
use crate::arq::{... |
#[doc = "Reader of register SR"]
pub type R = crate::R<u32, super::SR>;
#[doc = "Writer for register SR"]
pub type W = crate::W<u32, super::SR>;
#[doc = "Register SR `reset()`'s with value 0"]
impl crate::ResetValue for super::SR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
extern crate std;
extern crate eventual;
extern crate cql;
use std::borrow::Cow;
use std::io::Write;
use cql::*;
use self::eventual::{Future,Async};
use std::thread;
use std::time::Duration;
use std::io::{self, Read};
#[macro_use]
macro_rules! assert_response(
($resp:expr) => (
if match $resp.opcode { cq... |
fn main() {
let foo = [2, 5, 1, 2, 3, 4, 7, 7, 6];
let mut left = 0;
let mut right = foo.len() - 1;
let mut i = 0;
let mut lim = 0;
let mut sum = 0;
while i < foo.len() {
if foo[left] > foo[i] {
break;
} else {
left = i;
}
i += 1;
}... |
use ws::{connect, CloseCode};
use std::rc::Rc;
use std::cell::Cell;
use serde_json::{Value};
use crate::api::config::Config;
use crate::api::payment::data::*;
use crate::api::message::memo::*;
use crate::api::message::amount::Amount;
use hex;
use crate::api::message::local_sign_tx::{LocalSignTx};
use crate::base::... |
use std::io::prelude::*;
use std::net::TcpStream;
use std::net::TcpListener;
extern crate rust_web_server;
use rust_web_server::ThreadPool;
extern crate num_cpus;
static TEMPLATE: &[u8] = include_bytes!("../template.html");
fn main() {
let listener = TcpListener::bind("127.0.0.1:8080").unwrap();
let pool ... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[cfg(feature = "Win32_Management_MobileDeviceManagementRegistration")]
pub mod MobileDeviceManagementRegistration;
|
use num;
use num::Num;
use std::ops::Add;
use std::ops::AddAssign;
use std::ops::Div;
use std::ops::DivAssign;
use std::ops::Index;
use std::ops::IndexMut;
use std::ops::Mul;
use std::ops::MulAssign;
use std::ops::Sub;
use std::ops::SubAssign;
use crate::math;
use crate::types::{Float, Int};
use num::Integer;
use num... |
fn main() {
let numbers: Vec<i32> = (1..1000).collect();
let sum: i32 = numbers.iter().filter(|x| *x % 3 == 0 || *x % 5 == 0).sum();
println!("{:#?}", sum);
} |
//!Operaciones aceptadas por la virtual machine
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::io;
use crate::operation::Operation;
use crate::instruction::Instruction;
#[derive(Debug, Clone, Copy)]
struct Numeric {
v:usize,
s:usize
}
#[derive(Debug)]
struct Memory<'a> {
accumula... |
// UnionFind
// QuickFind: uses n-length array as network model. elements p and q are connected if they share
// the same array value
// It is SLOW: it takes a quadratic (N^2) array accesses to produce produce N unions of N nodes.
struct QuickFind(Vec<u32>);
impl QuickFind {
fn new(n: u32) -> QuickFind {
... |
use super::Command;
use clap::ArgMatches;
use colored::*;
use log::info;
use std::io::{self, Write};
use std::process;
use termion::clear;
use termion::event::Key;
use termion::input::TermRead;
use termion::raw::IntoRawMode;
struct Entry<'a>(&'a Command, usize);
pub fn run(matches: &ArgMatches, commands: &[Command]) ... |
// Built-in imports
use std::fmt;
// External uses
use num::BigUint;
use web3::types::H256;
// Workspace uses
use models::node::tx::{ChangePubKey, PackedEthSignature};
use models::node::{AccountId, Address, Nonce, PrivateKey, PubKeyHash, Token, Transfer, Withdraw};
use crate::error::SignerError;
fn signing_failed_err... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.