text stringlengths 8 4.13M |
|---|
use crate::output::{ErrorKind, TestCase};
use regex::Regex;
use url::Url;
lazy_static::lazy_static! {
static ref TEST_CASE_RE: Regex = Regex::new(r"[0-9]+ \[INFO\] kitty: Current test: [0-9]+").expect("A valid regex");
static ref PATH_PARAMETERS_RE: Regex = Regex::new(r"[0-9]+ \[INFO\] kitty: Compiled url in (... |
// defines the 4 kinds of message classes
mod message_class;
pub use message_class::MessageClass;
mod message_method;
pub use message_method::MessageMethod;
mod transaction_id;
pub use transaction_id::TransactionID;
mod attributes;
pub use attributes::*;
#[derive(Debug, Eq, PartialEq)]
pub struct Message {
... |
#[derive(Debug)]
pub struct Rectangle {
width: u32,
height: u32,
}
impl Rectangle {
pub fn build_rectangle(width: u32, height: u32) -> Rectangle {
Rectangle { width, height }
}
pub fn square(size: u32) -> Rectangle {
Rectangle::build_rectangle(size, size)
}
pub fn area(&se... |
use crate::cpu::Register;
use crate::util::*;
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub struct Multiply {
long: bool,
signed: bool,
accumulate: bool,
set_condition_codes: bool,
operand1: Register,
operand2: Register,
operand3: Register,
destination: Register,
}
impl Multiply {
... |
use parameterized_macro::parameterized;
#[parameterized(y = { 1, 2, 3 })]
fn my_test(x: i32) {}
fn main() {}
|
extern crate clap;
#[macro_use]
extern crate prettytable;
/// The CLI module
mod cli;
/// The comparators module
mod comparators;
/// The investment module
mod investment;
/// The loan module
mod loan;
use clap::App;
use cli::invest::{execute_invest_sub_command, invest_sub_commands, SUB_INVEST};
use cli::loan::{execu... |
use regex::Regex;
use std::time::Duration;
pub fn parse_duration(dur: &str) -> Result<Duration, String> {
let re = Regex::new(r"([\d\.]{1,})\s?([a-z])").unwrap();
let mut duration = Duration::new(0, 0);
for cap in re.captures_iter(dur) {
let num: f32 = cap[1]
.parse()
.map_e... |
use std::cell::RefCell;
use std::io::{self, Read, Write};
use std::net::{SocketAddr, ToSocketAddrs, TcpListener, TcpStream, Shutdown};
use std::time::Duration;
use openssl::ssl::{self, SslContext, SslMethod, Ssl, SslStream};
use openssl::dh::DH;
use openssl::x509::X509FileType;
use super::types::Result;
/// Abstract... |
use rand::distributions::{Uniform, Exp, Alphanumeric};
use std::collections::HashMap;
use rand::prelude::*;
#[derive(Default)]
pub struct UserData {
name: String,
username: String,
age: String,
email: String,
bio: String,
}
use super::*;
pub fn evo_algo(gens: i32, rate: f32, verbose: bool) {
... |
/// An enum to represent all characters in the KhmerSymbols block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum KhmerSymbols {
/// \u{19e0}: '᧠'
KhmerSymbolPathamasat,
/// \u{19e1}: '᧡'
KhmerSymbolMuoyKoet,
/// \u{19e2}: '᧢'
KhmerSymbolPiiKoet,
/// \u{19e3}: '᧣'
KhmerSymb... |
#![no_main]
#![no_std]
// Simple Timer Example STM32F401RE
// LED on Pin A5 (user LED on Nucleo Board)
// nmt @ nt-com 2021
/// IMPORTS
use core::cell::RefCell;
use stm32f4::stm32f401;
use stm32f4::stm32f401::interrupt;
use cortex_m;
use cortex_m_rt::entry;
#[allow(unused_extern_crates)]
extern crate panic_halt; ... |
// This example loops the microphone input back to the speakers, while applying echo cancellation,
// creating an experience similar to Karaoke microphones. It uses PortAudio as an interface to the
// underlying audio devices.
use ctrlc;
use failure::Error;
use portaudio;
use std::{
sync::{
atomic::{AtomicB... |
mod nrom;
mod mmc1;
mod uxrom;
mod cnrom;
mod mmc3;
pub mod serialize;
use nrom::Nrom;
use mmc1::Mmc1;
use uxrom::Uxrom;
use cnrom::Cnrom;
use mmc3::Mmc3;
use std::cell::RefCell;
use std::fs::File;
use std::io::Read;
use std::rc::Rc;
pub trait Mapper {
fn read(&self, address: usize) -> u8;
fn write(&mut self... |
use sp_std::prelude::*;
use codec::Codec;
use super::org::{OrgName, Org};
pub type GetResult<AccountId> = Option<Org<AccountId, OrgName>>;
pub type GetMultiResult<AccountId> = Vec<Option<Org<AccountId, OrgName>>>;
pub type ListResult<AccountId> = Vec<Org<AccountId, OrgName>>;
sp_api::decl_runtime_apis! {
pub t... |
#[doc = "Reader of register DDRPHYC_BISTBER2"]
pub type R = crate::R<u32, super::DDRPHYC_BISTBER2>;
#[doc = "Reader of field `DQBER`"]
pub type DQBER_R = crate::R<u32, u32>;
impl R {
#[doc = "Bits 0:31 - DQBER"]
#[inline(always)]
pub fn dqber(&self) -> DQBER_R {
DQBER_R::new((self.bits & 0xffff_ffff... |
pub mod coin;
pub mod dec_coin;
pub mod tx_msg;
pub mod result;
pub mod address;
pub use coin::*;
pub use address::*;
pub use dec_coin::*;
pub use result::*;
pub use tx_msg::*; |
//!
//! Module containing all the necessary for playing Go.
//! The goban structure. The stone structure.
//!
#[cfg(not(feature = "thread-safe"))]
use std::rc::Rc;
#[cfg(feature = "thread-safe")]
use std::sync::Arc;
#[cfg(not(feature = "thread-safe"))]
type Ptr<T> = Rc<T>;
#[cfg(feature = "thread-safe")]
type Ptr<T... |
use std::io;
pub fn question6() {
println!("Enter Numerator?");
let mut number1 = String::new();
io::stdin().read_line(&mut number1)
.expect("Failed to read line");
let number1: i32 = number1.trim().parse()
.expect("Please type a number!");
println!("Enter Denominator?"... |
mod image;
pub use image::VdiImage; |
use std::{
collections::HashMap,
fs,
hash::{Hash, Hasher},
ops::{Deref, DerefMut},
time::Duration,
};
use anyhow::{bail, Context as _, Result};
use dotenv::dotenv;
use futures::prelude::*;
use rand::{seq::SliceRandom, thread_rng};
use rspotify::{
model::{idtypes::Track, playing, track, FullTrac... |
extern crate ispc;
fn main() {
let mut cfg = ispc::Config::new();
let ispc_files = vec!["src/simple.ispc"];
for s in &ispc_files[..] {
cfg.file(*s);
}
// For a portable program we can explicitly compile for each target ISA
// we want. Then ISPC will pick the correct ISA at runtime to ca... |
use std::path::PathBuf;
use clap::arg_enum;
use structopt::StructOpt;
use omnicolor_rust::palettes::*;
use omnicolor_rust::{Error, GrowthImageBuilder, SaveImageType, RGB};
arg_enum! {
#[derive(Debug, PartialEq)]
enum PaletteOpt{
Uniform,
Spherical,
}
}
#[derive(Debug, StructOpt)]
struct ... |
use futures::future::{self, Either, Future, FutureExt};
fn main() {
let _ = example(100);
}
fn example(min_len: usize) -> impl Future<Output = String> {
async_read_file("foo.txt").then(move |content| {
if content.len() < min_len {
Either::Left(async_read_file("bar.txt").map(|s| content + &... |
// 17.17 Multi Serch
fn multisearch(b: &[u8], t: &[&[u8]]) {}
#[test]
fn test() {}
|
pub mod lexer;
pub mod token;
pub mod expr;
pub mod parse_error;
pub mod module;
use std::{
collections::VecDeque,
iter::IntoIterator
};
use self::{
expr::{
BasicExpr,
BinOp,
UnaryOp,
Type
},
token::{
Token,
TokenValue,
TokenStream,
T... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Data Register, UARTDR"]
pub uartdr: UARTDR,
#[doc = "0x04 - Receive Status Register/Error Clear Register, UARTRSR/UARTECR"]
pub uartrsr: UARTRSR,
_reserved2: [u8; 16usize],
#[doc = "0x18 - Flag Register, UARTFR"]
... |
extern crate gcc;
#[cfg(windows)]
fn main() {
gcc::compile_library("libadmincheck.a", &["./src/os/users/admincheck.c"]);
}
#[cfg(not(windows))]
fn main() {}
|
// https://beta.atcoder.jp/contests/abc003/tasks/abc003_2
macro_rules! scan {
($t:ty) => {
{
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().parse::<$t>().unwrap()
}
};
($($t:ty),*) => {
{
... |
#![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 operations {
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub async f... |
pub mod init;
pub mod task;
pub mod interrupt;
//pub mod syscall;
|
use crate::hittable::{aabb::Aabb, hittable_list::HittableList, HitRecord, Hittable, Hittables};
use crate::ray::Ray;
use rand::prelude::*;
use rand::rngs::SmallRng;
use std::cmp::Ordering;
#[derive(Debug, Clone)]
pub struct BvhNode {
pub bbox: Aabb,
pub left: Box<Hittables>,
pub right: Box<Hittables>,
}
i... |
// TODO: Cleanup
#![allow(dead_code)]
#![allow(unused_imports)]
use anyhow::{anyhow, Context, Result};
use async_std::io;
use async_std::io::BufReader;
use async_std::os::unix::net::UnixStream;
use async_std::prelude::*;
use async_std::sync::Arc;
use async_std::task;
use async_trait::async_trait;
use clap::Clap;
use e... |
use super::constants::{CRED_DEF, GET_CRED_DEF};
use super::did::ShortDidValue;
use super::identifiers::cred_def::CredentialDefinitionId;
use super::identifiers::schema::SchemaId;
use super::{get_sp_key_marker, ProtocolVersion, RequestType};
use crate::common::error::prelude::*;
use crate::utils::qualifier::Qualifiable;... |
use std::collections::HashMap;
use std::ops::Deref;
use std::rc::Rc;
pub mod program;
use program::Program;
#[derive(Hash, PartialEq, Eq, Clone)]
pub enum ProgramType {
ShapedProgram,
UnshapedProgram,
ScreenProgram,
}
pub struct WebGlF32Vbo(web_sys::WebGlBuffer);
pub struct WebGlI16Ibo(web_sys::WebGlBuf... |
//! This crate defines a buffer data structure optimized to be written to and read from standard
//! `Vec`s.
//!
//! [`VecCopy`] is particularly useful when dealing with plain data whose type is determined at
//! run time. Note that data is stored in the underlying byte buffers in native endian form, thus
//! requesti... |
use ::core::sync::atomic::{AtomicU64, Ordering};
// Use a WASM specialized allocator in the hopes of reducing code size.
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
static COUNTER: AtomicU64 = AtomicU64::new(0);
#[no_mangle]
extern "C" fn count() -> u64 {
// Daily reminder ... |
#[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::PADREGI {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w m... |
use std::cell::RefCell;
use std::rc::Rc;
use crate::treenode::TreeNode;
pub fn build_tree(inorder: Vec<i32>, postorder: Vec<i32>) -> Option<Rc<RefCell<TreeNode>>> {
fn build_tree_by_slice(inorder: &[i32], postorder: &[i32]) -> Option<Rc<RefCell<TreeNode>>> {
match postorder.len() {
0 => None,
... |
#[derive(Debug, Clone)]
pub enum ModuleMsgEnum {
MsgProcessing(crate::processor::ProcessorMsg),
MsgClaManager,
MsgCla(crate::cla::ClaMessage),
MsgCLI,
MsgLogging,
MsgStorage,
MsgUserMgr(crate::user::UserMgrMessage),
MsgAppAgent(crate::agent::AgentMessage),
... |
//! The 65816 instruction set architecture, the ISA that the SNES's processor
//! implements.
//!
//! This module provides functions for assembling, disassembling, and
//! manipulating machine code for the 65816.
mod instruction;
mod mnemonic;
pub use instruction::Instruction;
pub use mnemonic::Mnemonic;
|
use board_formatter;
use board::Board;
const OFFSET: usize = 1;
pub fn split_board_into_rows(expanded_board: &[String], size: i32) -> Vec<Vec<String>> {
let chunks = expanded_board.chunks(size as usize);
let mut rows: Vec<Vec<String>> = Vec::new();
for chunk in chunks {
let row: Vec<String> = chun... |
//vim: tw=80
extern crate futures;
extern crate tokio_ as tokio;
extern crate futures_locks;
mod mutex;
mod rwlock;
|
fn main() {
let n = read();
// 0:C 1:S 2:F
let vec = read_lines(n - 1);
for i in 0..n {
let mut t = 0;
for j in i..n-1 {
if t < vec[j][1] {
t = vec[j][1];
} else if t % vec[j][2] == 0 {
// do nothing
} else {
... |
#[doc = "Reader of register PWR_CTL"]
pub type R = crate::R<u32, super::PWR_CTL>;
#[doc = "Writer for register PWR_CTL"]
pub type W = crate::W<u32, super::PWR_CTL>;
#[doc = "Register PWR_CTL `reset()`'s with value 0"]
impl crate::ResetValue for super::PWR_CTL {
type Type = u32;
#[inline(always)]
fn reset_va... |
use std::io;
fn shift_and_print(txt: String) -> String {
println!("{}", txt);
let mut temp = String::from(txt);
let char = temp.chars().nth(0).unwrap();
temp.push(char);
temp.remove(0);
temp
}
fn main(){
let mut input = String::new();
let mut num = String::new();
println!("Enter some text: ");
match io::st... |
use crate::prelude::*;
/// Re-exports all commonly used items of this module.
pub mod prelude {
pub use super::{
BitAnd
};
}
mod marker {
use crate::prelude::*;
use crate::ExprMarker;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct BitAndMarker;
impl ExprMarker for ... |
extern crate gtk;
use gtk::prelude::*;
use gtk::{Window, WindowType};
//most widgets are defined in glade. any defined in code are here
pub fn build_file_chooser() -> gtk::FileChooserDialog {
let dialog = gtk::FileChooserDialog::new (
Some("Choose DireFilectory"),
Some(&Window::ne... |
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
input! {
n: usize,
k: usize,
p: [f64; n]
}
let mut a = vec![0.0; n];
for i in 0..n {
a[i] = (p[i] + 1.0) / 2.0;
}
let mut sum = a.iter().t... |
#[doc = "Reader of register HDP_GPOVAL"]
pub type R = crate::R<u32, super::HDP_GPOVAL>;
#[doc = "Writer for register HDP_GPOVAL"]
pub type W = crate::W<u32, super::HDP_GPOVAL>;
#[doc = "Register HDP_GPOVAL `reset()`'s with value 0"]
impl crate::ResetValue for super::HDP_GPOVAL {
type Type = u32;
#[inline(always... |
// This file is part of Substrate.
// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the F... |
fn variablesImmutable() {
let x = 5;
println!("The value of x is: {}", x);
// Error: default variables is immutable
x = 6;
println!("The value of x is: {}", x);
}
fn variablesMutable() {
let mut x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
}... |
#[derive(Debug, Clone, Copy)]
pub enum AppStateType {
Tree,
Help,
Preview,
}
|
//! Takes ownership of the input data.
//!
//! Choose this implementation if:
//!
//! 1. You already have the data loaded in-memory, but it is not properly
//! aligned, and its size is relatively small, so reallocating it is acceptable – use the
//! [`new`](`OwnedBytes::new`) function for this.
//!
//! ## Perform... |
use std::{fs, collections::VecDeque};
#[derive(Clone, Debug, Default)]
struct Square {
height: usize,
start: bool,
end: bool,
steps_to_end: Option<usize>,
}
#[derive(Debug, Default)]
struct Grid {
squares: Vec<Vec<Square>>,
width: usize,
length: usize,
start: Option<(usize, usize)>,
... |
include!(concat!(env!("OUT_DIR"), "/scaii.rts.rs"));
|
use glib;
use gstreamer;
use gstreamer_rtsp_server;
use gstreamer_rtsp_server::prelude::*;
#[derive(Clone, Debug)]
pub struct RTSPServer {
pub pipeline: String,
port: u16,
event_loop: glib::MainLoop,
}
impl Default for RTSPServer {
fn default() -> Self {
RTSPServer {
pipeline: "vid... |
#[derive(Debug)]
pub struct HideConfig<'a> {
pub payload_path: &'a str,
pub carrier_path: &'a str,
pub output_path: Option<&'a str>,
pub strategy: Option<&'a str>,
}
#[derive(Debug)]
pub struct RevealConfig<'a> {
pub carrier_path: &'a str,
pub output_path: Option<&'a str>,
pub strategy: Opt... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use crate::{errors::MerkleTreeError, hash::Hasher};
use core::slice;
use math::log2;
use utils::collections::{BTreeSet, HashMap, Vec};
mo... |
use Vec3;
use cgmath::Vector2;
use cgmath::InnerSpace;
use cgmath::dot;
use std;
#[derive(Eq, PartialEq, Copy, Clone, Debug, Hash)]
pub struct Rect<F> {
pub min : Vector2<F>,
pub max : Vector2<F>,
}
pub type RectI = Rect<i32>;
#[derive(PartialEq, Debug, Copy, Clone)]
pub struct LineSegment {
pub from:... |
#[doc = "Writer for register CRYP_K2LR"]
pub type W = crate::W<u32, super::CRYP_K2LR>;
#[doc = "Register CRYP_K2LR `reset()`'s with value 0"]
impl crate::ResetValue for super::CRYP_K2LR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Write proxy for field `K9... |
use chrono::*;
use std::collections::HashMap;
use ::serde::Serialize;
use rusqlite::{params, Connection};
use crate::db::account_dao::{
Account,
AccountDao
};
#[derive(Debug, Serialize)]
pub struct Budget {
pub guid: String,
pub name: String,
pub num_periods: i32,
pub start_date: NaiveDate,
... |
//! Generate a `Default` impl based on field-level defaults in `serde` attributes.
//!
//! # Usage
//! On a struct that derives `Serialize` or `Deserialize`, add `DefaultFromSerde`.
//!
//! ```rust
//! # use serde_default::DefaultFromSerde;
//! #[derive(Debug, DefaultFromSerde, PartialEq, Eq)]
//! pub struct MyStruct {... |
use crate::model::SessionToken;
use crate::model::AccountInfo;
use crate::resource::Resource;
use crate::xml::AccountInfoXmlParser;
use std::io::Read;
pub struct AccountInfoResource {
pub token: SessionToken
}
impl Resource<AccountInfo> for AccountInfoResource {
fn parse(&self, bytes: impl Read) -> Result<A... |
use sdl2::keyboard::Scancode;
use std::collections::HashSet;
pub fn poll_buttons(strobe: &u8, event_pump: &sdl2::EventPump) -> Option<u8> {
if *strobe & 1 == 1 {
let mut button_states = 0;
let pressed_keys: HashSet<Scancode> = event_pump.keyboard_state().pressed_scancodes().collect();
for k... |
#![feature(test)]
use dev_util::impl_benchmark;
impl_benchmark!(blake, Blake28);
impl_benchmark!(blake, Blake32);
impl_benchmark!(blake, Blake48);
impl_benchmark!(blake, Blake64);
impl_benchmark!(blake, Blake224);
impl_benchmark!(blake, Blake256);
impl_benchmark!(blake, Blake384);
impl_benchmark!(blake, Blake512);
|
#[doc = "Reader of register ICPENDR7"]
pub type R = crate::R<u32, super::ICPENDR7>;
#[doc = "Writer for register ICPENDR7"]
pub type W = crate::W<u32, super::ICPENDR7>;
#[doc = "Register ICPENDR7 `reset()`'s with value 0"]
impl crate::ResetValue for super::ICPENDR7 {
type Type = u32;
#[inline(always)]
fn re... |
use crate::asset::*;
use crate::property::Property;
use crate::property::PropertyContext;
use crate::reader::*;
use crate::util::read_bytes;
use anyhow::*;
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use serde::Deserialize;
use std::collections::HashMap;
use std::convert::TryInto;
pub static mut STRUCT... |
use crate::appcontract::{AppContract, AppContractContract};
use crate::common::{AirdropRewards, Ownable, SupportsAirdrop};
//use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::{near_bindgen, AccountId};
//use near_contract_standards::non_fungible_token::NonFungibleToken;
use near_sdk::Balance... |
use std::collections::HashSet;
use std::path::Path;
use structopt::StructOpt;
use crate::dictionary::Dictionary;
use crate::errors::AppResultU;
#[derive(Debug, StructOpt)]
pub struct Opt {
/// Only words
#[structopt(short = "w", long)]
only_words: bool,
}
pub fn lemmas<T: AsRef<Path>>(opt: Opt, dicti... |
use messagebus::{Action, Bus, Event, SharedMessage, TypeTag};
use serde_derive::{Deserialize, Serialize};
use std::borrow::Cow;
#[derive(Debug, Deserialize, Serialize)]
#[repr(u16)]
pub enum ProtocolHeaderActionKind {
Nop,
Error,
Send,
Response,
BatchComplete,
Flush,
Flushed,
Synchro... |
//! This is a comment
mod suite1 {
#[test]
fn case1() {
assert_eq!(2 + 2, 4);
}
#[test]
fn case2() {
assert_eq!(2 + 2, 4);
}
}
mod suite2 {
#[test]
fn case1() {
assert_eq!(2 + 2, 4);
}
#[test]
fn case2() {
assert_eq!(2 + 2, 4);
}
}
|
#[doc = "Register `RCC_QSPICKSELR` reader"]
pub type R = crate::R<RCC_QSPICKSELR_SPEC>;
#[doc = "Register `RCC_QSPICKSELR` writer"]
pub type W = crate::W<RCC_QSPICKSELR_SPEC>;
#[doc = "Field `QSPISRC` reader - QSPISRC"]
pub type QSPISRC_R = crate::FieldReader;
#[doc = "Field `QSPISRC` writer - QSPISRC"]
pub type QSPISR... |
use std::io::Write;
use byteorder::{BigEndian, ByteOrder};
// use memmap::{Protection, Mmap, MmapView};
use crc::crc32;
#[derive(Debug)]
pub enum MessageError {
SizeMismatch,
ChecksumMismatch,
}
/// Size of a message with empty key and empty data.
pub const MINIMUM_MESSAGE_SIZE: i32 = 4 + 1 + 1 + 8 + 4 + 4;
... |
use rand::Rng;
use ggez::{
graphics::{ Text, TextFragment, Font, Scale, Rect },
graphics, Context,
nalgebra::Point2
};
use std::{ env, fs };
#[derive(Debug, Copy, Clone)]
pub struct Stats {
pub bertrand_killed: u64,
pub shots: u64,
pub powerups_activated: u64,
pub hits_taken: u64,
pub t... |
mod frame_buffer;
use anyhow::{anyhow, bail, Context};
use frame_buffer::{FrameBufferContext, RgbaFrameBuffer};
use rustzx_core::{
host::{
FrameBuffer, Host, HostContext, RomFormat, RomSet, Screen, Snapshot, StubIoExtender, Tape,
},
zx::machine::ZXMachine,
};
use rustzx_utils::{
io::{DynamicAss... |
use std::convert::TryFrom;
use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Result as FmtResult;
use pest::error::Error as PestError;
use pest::Parser as PestParser;
use super::Label;
use super::Literal;
use super::Register;
use crate::parser::Parser;
use crate::parser::Rule;
/// An argument to an instr... |
#[doc = "Writer for register TX_DATA_FIFO_WR4"]
pub type W = crate::W<u32, super::TX_DATA_FIFO_WR4>;
#[doc = "Register TX_DATA_FIFO_WR4 `reset()`'s with value 0"]
impl crate::ResetValue for super::TX_DATA_FIFO_WR4 {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc ... |
use bitbuffer::{BitRead, BitWrite};
use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[derive(BitRead, BitWrite, Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct Header {
#[size = 8]
pub demo_type: String,
pub version: u32,
pub protocol: u32... |
///
/// ## tcp.rs
///
/// ref: https://tools.ietf.org/html/rfc793
/// ref: https://tools.ietf.org/html/rfc7323
/// ref: https://tools.ietf.org/html/rfc2018
use crate::util::{bytes_to_u16, bytes_to_u32};
use log::{debug, warn};
use num_derive::{FromPrimitive};
use num_traits::{FromPrimitive};
// options
// https://www.... |
//! Infinite Minesweeper with a variety of other features.
#![warn(missing_docs)]
#![warn(rust_2018_idioms)]
#![warn(clippy::all)]
#![deny(clippy::correctness)]
mod game;
mod gui;
mod render;
use gui::DISPLAY;
const TITLE: &str = "Infinite Minesweeper";
fn main() {
gui::show_gui();
}
|
pub use mapper0::Mapper0;
pub use mapper1::Mapper1;
pub use mapper10::Mapper10;
pub use mapper2::Mapper2;
pub use mapper3::Mapper3;
pub use mapper4::Mapper4;
pub use mapper7::Mapper7;
pub use mapper9::Mapper9;
use super::MirrorMode;
mod mapper0;
mod mapper1;
mod mapper10;
mod mapper2;
mod mapper3;
mod mapper4;
mod ma... |
fn main() {
println!("Node started. Please connect other nodes to 192.168.0.1:8988");
}
|
use std::env;
use serenity::{
async_trait,
model::{gateway::Ready, interactions::{Interaction, InteractionResponseType, ApplicationCommand}},
prelude::*,
};
use serenity::model::prelude::*;
use image_of_images_creator::*;
use std::sync::Arc;
use image::ColorType;
use std::time::Duration;
use std::io::{Read,... |
// Sometimes an `Option` needs to interact with a `Result`, or a
// `Result<T, Error1>` needs to interact with a `Result<T, Error2>`.
// In those cases, we want to manage our different error types in a way
// that makes them composable and easy to interact with.
//
// In the following code, two instances of `unwrap` ... |
#![feature(custom_attribute, decl_macro, proc_macro_hygiene)]
#[macro_use]
extern crate rocket;
#[macro_use]
extern crate serde;
#[cfg(test)]
extern crate mocktopus;
pub mod routes;
/// Prepares a `rocket::Rocket` for usage.
///
/// # Examples
///
/// ```
/// use data_server::*;
/// let rocket: rocket::Rocket = se... |
extern crate reqwest;
use std::io;
fn main() {
let mut res = reqwest::get("https://api.challonge.com/v1/tournaments/tournament.json?api_key=THQwE1NobDxeWTRbAb8ACEtrUV4jDse7C6N7PwvU").unwrap();
res.copy_to(&mut io::stdout()).unwrap();
}
|
/// Solves the Day 06 Part 1 puzzle with respect to the given input.
pub fn part_1(input: String) {
let mut ages = parse_ages(input);
for _ in 0..80 {
simulate(&mut ages);
}
let fish: u64 = ages.iter().sum();
println!("{}", fish);
}
/// Solves the Day 06 Part 2 puzzle with respect to the ... |
use {quote, syn, utils};
use quote::TokenStreamExt;
use proc_macro2::{self, Span};
/// Represents an event of a smart contract.
pub struct Event {
/// The name of the event.
pub name: syn::Ident,
/// The canonalized string representation used by the keccak hash
/// in order to retrieve the first 4 bytes required ... |
use super::{RegU16, RegU8};
use crate::hardware::{
Cpu,
Flag::{self, *},
};
use crate::memory::Memory;
pub fn load(cpu: &mut Cpu, mem: &mut Memory, src: &RegU8, dest: &RegU8) {
let value = cpu.get_reg_u8(mem, src);
cpu.set_reg_u8(mem, dest, value);
}
pub fn load_plus(cpu: &mut Cpu, mem: &mut Memory, s... |
#[doc = "Register `AHB2LPENR` reader"]
pub type R = crate::R<AHB2LPENR_SPEC>;
#[doc = "Register `AHB2LPENR` writer"]
pub type W = crate::W<AHB2LPENR_SPEC>;
#[doc = "Field `DCMILPEN` reader - Camera interface enable during Sleep mode"]
pub type DCMILPEN_R = crate::BitReader<DCMILPEN_A>;
#[doc = "Camera interface enable ... |
use crate::instructions::{Opcodes, Instruction};
use std::collections::HashMap;
// Status register
#[allow(non_snake_case)]
#[derive(Default, Debug)]
pub struct SREG {
I: bool, // Global Interrupt Enable
T: bool, // Bit Copy Storage
H: bool, // Half Carry Flag
S: bool, // Sign Bit
V: bool, // Two's... |
use std::collections::BTreeMap;
use std::fmt;
use crate::types::ParameterValue;
/// A command that should be benchmarked.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Command<'a> {
/// The command name (without parameter substitution)
name: Option<&'a str>,
/// The command that should be executed (w... |
use std::path::PathBuf;
error_chain! {
types {
Error, ErrorKind, ResultExt, Result;
}
errors {
DatabaseTooNew(version: usize, supported: usize) {
display("The database version ({}) is too new, up to version {} is supported", version, supported)
}
DestinationDoe... |
//! Ethane is an alternative web3 implementation with the aim of being slim and simple.
//! It does not depend on futures or any executors. It currently supports http and
//! websockets (both plain and TLS) and inter process communication via Unix domain sockets (Unix only). For
//! http and websockets it also supports... |
pub mod rank;
pub use rank::Rank;
pub mod suit;
pub use suit::Suit;
use std::cmp::Ordering;
use std::hash::Hash;
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub struct Card(pub(crate) Rank, pub(crate) Suit);
impl Card {
pub fn new(rank: Rank, suit: Suit) -> Self {
Card(rank, suit)
}
pub f... |
extern crate peroxide;
use peroxide::*;
fn main() {
let a = ml_matrix("1 2;3 4");
let pqlu = a.lu().unwrap();
pqlu.l.print();
pqlu.u.print();
println!("{:?}", pqlu.p);
println!("{:?}", pqlu.q);
a.inv().unwrap().print();
let b = ml_matrix("1 2 2;4 5 6;7 8 9");
b.inv().unwrap().prin... |
use std::thread;
use std::sync::Arc;
use metered::{metered, Throughput, HitCount};
use std::panic::catch_unwind;
#[derive(Default, Debug, serde::Serialize)]
pub struct Biz {
metrics: BizMetrics,
}
#[metered(registry = BizMetrics)]
impl Biz {
#[measure([HitCount, Throughput])]
pub fn biz(&self) {
l... |
pub enum Direction {
Up,
Down,
Left,
Right,
}
pub fn move_d(d: Direction) {
match d {
Direction::Up => println!("up"),
Direction::Down => println!("down"),
Direction::Left => println!("left"),
Direction::Right => println!("right"),
}
}
pub fn run() {
move_d(... |
#[doc = "Register `DMAIER` reader"]
pub type R = crate::R<DMAIER_SPEC>;
#[doc = "Register `DMAIER` writer"]
pub type W = crate::W<DMAIER_SPEC>;
#[doc = "Field `TIE` reader - Transmit interrupt enable"]
pub type TIE_R = crate::BitReader;
#[doc = "Field `TIE` writer - Transmit interrupt enable"]
pub type TIE_W<'a, REG, c... |
use log::info;
use wgpu::util::DeviceExt;
use super::{state, texture, traits::Binding};
#[derive(Debug)]
pub enum BufferUsage {
Vertex,
Uniform,
Index,
Transform,
}
impl From<BufferUsage> for wgpu::BufferUsage {
fn from(buf: BufferUsage) -> Self {
match buf {
BufferUsage::Vert... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.