text stringlengths 8 4.13M |
|---|
use crate::*;
/// Sprites are conceptually both a reference to an image, and the sub region of the image
/// which represents the logical sprite.
pub trait CommonSprite<R: CommonRenderer>: Sized + Clone {
/// Construct a new sprite from an image. The image contents are copied to a texture
/// in RGBA8 format. The en... |
use std;
use bincode;
use mio_more;
#[derive(Debug)]
pub enum Error {
Io(std::io::Error),
Bincode(bincode::Error),
Timer(mio_more::timer::TimerError),
InvalidId,
}
impl From<std::io::Error> for Error {
fn from(other: std::io::Error) -> Self {
Error::Io(other)
}
}
impl From<bincode::Er... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: [email protected]
* Generated by: https://openapi-generator.tech
*/
/// FormulaAndFunctionEventsDataSource : Data source for event platform-based queries.
/// Data source ... |
use boxfnonce::BoxFnOnce;
use entity_template::EntityTemplate;
use std::any::Any;
use std::collections::HashMap;
use worker::schema::{Command, CommandRequestInterface, CommandResponseInterface, Component,
GeneratedSchema};
use worker::{CommandStatus, ComponentId, Connection, EntityId, RequestId};
u... |
#![allow(clippy::identity_op)]
use crate::encoder::JpegColorType;
/// Conversion from RGB to YCbCr
#[inline]
pub fn rgb_to_ycbcr(r: u8, g: u8, b: u8) -> (u8, u8, u8) {
// To avoid floating point math this scales everything by 2^16 which gives
// a precision of approx 4 digits.
//
// Non scaled conver... |
use crate::types::buffer::ebo::EBO;
use crate::types::buffer::vao::VAO;
use crate::types::buffer::vbo::VBO;
use crate::types::data::data_layout::DataLayout;
use gl::types::*;
pub type VAOBuilder<'a> = VertexArrayObjectBuilder<'a>;
pub struct VertexArrayObjectBuilder<'a> {
pub vbo: VBO,
pub vbo_data: &'a [f32]... |
use std::fs;
fn solve(input: &Vec<&str>, right: usize, down: usize) -> usize {
let mut count: usize = 0;
let mut x: usize = 0;
for a in (0..input.len()).step_by(down) {
if input[a].chars().nth(x).unwrap() == '#' {
count += 1;
}
for _ in 0..right {
if x == input[a].len()-1 {x = 0;}
else... |
//!
//! Rust Firebird Client
//!
//! Transaction struct tests
//!
mk_tests_default! {
use crate::{FbError, Connection, Transaction};
use rsfbclient_core::FirebirdClient;
macro_rules! recreate_tbl_fmtstring{
() => {"recreate table {} ( id INT NOT NULL PRIMARY KEY, description VARCHAR(20) );"};
}
macro_r... |
pub struct Player {}
impl Player {
pub fn new() -> Player {
Player {}
}
pub fn version(&self) -> String {
String::from("0.1.0")
}
}
|
use error::Err;
/// Exponential Moving Average
/// Formula :
pub fn ema(data: &[f64], period: usize) -> Result<Vec<f64>, Err> {
if period > data.len() {
return Err(Err::NotEnoughtData);
}
let mut ema = Vec::new();
let mut j = 1;
// get period sma first and calculate the next period period ... |
use crate::{
document::Document,
schema::{self, Collection, CollectionName, InvalidNameError, Name, Schematic, View},
Error,
};
/// A database stored in `BonsaiDb`.
#[derive(Debug)]
pub struct Database;
impl Collection for Database {
fn collection_name() -> Result<CollectionName, InvalidNameError> {
... |
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen(start)]
pub fn wasm_main() {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
main();
}
use instant;
#[cfg(target_arch = "android")]
use ndk_glue;
use std::iter;
#[repr(C)]
#[derive(Debug, ... |
use crate::r#type::Type;
#[derive(Debug, Clone)]
pub struct Bound {
pub name: String,
pub bound: Vec<Type>,
}
|
use std::thread;
use std::net::{TcpListener, TcpStream};
use std::io::{Read, Write};
use std::env;
use std::str;
const BUFFERBYTES: usize = 20;
fn client_handshake(mut stream: TcpStream) {
let mut data = [0 as u8; BUFFERBYTES]; // using 20 byte buffer
while match stream.read(&mut data) {
Ok(size) => ... |
use std::error::Error;
use futures::{Async, Poll};
use futures::future::{Future, IntoFuture, Shared, SharedError, SharedItem};
use rayon::ThreadPool;
use specs::{Component, DenseVecStorage};
use {BoxedErr, SharedAssetError, StoreId};
/// One of the three core traits of this crate.
///
/// You want to implement this ... |
pub const PIXELS_PER_TIME: f64 = 100.0;
pub const PIXELS_PER_SEMITONE: f64 = 8.0;
use misc::Vector;
use data::{State, DragType};
use edited_note::NoteDrawingInfo;
impl State {
pub fn client_to_time (&self, client: f64)->f64 {
client / PIXELS_PER_TIME
}
pub fn client_to_pitch (&self, client: f64)->f64 {
... |
extern crate bitmap_io;
use bitmap_io::*;
use std::fs::File;
#[allow(unused_must_use)]
fn main() {
let mut bmp_file = File::open("test_24-uncompressed.bmp").unwrap();
let test_24_uncompressed = Bitmap::from_file(&mut bmp_file).unwrap();
let mut bmp_file = File::open("test_32-uncompressed.bmp").unwrap()... |
use exonum::crypto::{PublicKey, Hash};
encoding_struct! {
#[derive(Eq, PartialOrd, Ord)]
struct Offer {
wallet: &PublicKey,
amount: u64,
tx_hash: &Hash,
}
}
impl Offer {
pub fn remove_amount(&mut self, amount: u64) {
*self = Offer::new(self.wallet(), self.amount() - amo... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Resource {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(d... |
#[doc = "Register `ETH_MACVR` reader"]
pub type R = crate::R<ETH_MACVR_SPEC>;
#[doc = "Field `SNPSVER` reader - SNPSVER"]
pub type SNPSVER_R = crate::FieldReader;
#[doc = "Field `USERVER` reader - USERVER"]
pub type USERVER_R = crate::FieldReader;
impl R {
#[doc = "Bits 0:7 - SNPSVER"]
#[inline(always)]
pub... |
use std::io;
use std::net::SocketAddr;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::time::{Duration, Instant};
use bytes::Bytes;
use failure::{format_err, Error};
use futures::prelude::*;
use futures::ready;
use log::{debug, info, warn};
use tokio::time::{delay_until, interval, Delay, Interval};
use cr... |
use esolangs::brainfuck::{brainfuck, brainfuck_include};
#[test]
fn mandelbrot() {
brainfuck_include!("tests/bf/mandelbrot.b");
}
#[test]
fn numwarp() {
brainfuck_include!("tests/bf/numwarp.b");
}
#[test]
fn dfbi() {
brainfuck_include!("tests/bf/dbfi.b");
}
// http://brainfuck.org/tests.b
#[test]
fn te... |
use super::bit;
use super::timer::{Timers};
use super::cartridge::{Cartridge};
pub struct Bus {
ram1: [u8; 4 * 1024],
ram2: [u8; 4 * 1024],
highRam: [u8; 127],
cart: Option<Cartridge>,
pub interruptEnableRegister: u8,
pub interruptRequestRegister: u8,
pub timerRegisters: Timers
}
pub enum... |
/*
Copyright 2019-2023 Didier Plaindoux
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... |
#[derive(Debug, Copy, Clone)]
pub struct Squircle {
pub p0: kurbo::Point,
pub p1: kurbo::Point,
pub p2: kurbo::Point,
pub radius: f64,
pub smoothness: f64,
}
impl Squircle {
pub fn to_curve(&self) -> Vec<kurbo::Point> {
let Squircle {
p0,
p1,
p2,
... |
use crate::Number;
use super::Term;
///A term which divides one stored term by another
pub struct FractionTerm<T: Number>
{
numerator: Box<dyn Term<T> + Send + Sync>,
denominator: Box<dyn Term<T> + Send + Sync>
}
impl<T: Number> FractionTerm<T>
{
///Creates a fraction term from the given numerator and... |
#[doc = "Register `HASH_CSR19` reader"]
pub type R = crate::R<HASH_CSR19_SPEC>;
#[doc = "Register `HASH_CSR19` writer"]
pub type W = crate::W<HASH_CSR19_SPEC>;
#[doc = "Field `CS19` reader - CS19"]
pub type CS19_R = crate::FieldReader<u32>;
#[doc = "Field `CS19` writer - CS19"]
pub type CS19_W<'a, REG, const O: u8> = c... |
use super::{traits::*, transaction::Transaction};
use crate::{Geometry, TableFlags, WriteMap, RO, RW};
use anyhow::Context;
use std::{
collections::BTreeMap,
fs::DirBuilder,
ops::Deref,
path::{Path, PathBuf},
};
use tempfile::tempdir;
#[derive(Debug)]
enum DbFolder {
Persisted(std::path::PathBuf),
... |
#[doc = "Register `GINTSTS` reader"]
pub type R = crate::R<GINTSTS_SPEC>;
#[doc = "Register `GINTSTS` writer"]
pub type W = crate::W<GINTSTS_SPEC>;
#[doc = "Field `CMOD` reader - Current mode of operation"]
pub type CMOD_R = crate::BitReader;
#[doc = "Field `MMIS` reader - Mode mismatch interrupt"]
pub type MMIS_R = cr... |
//! Small program that convert uint to hex (and vice versa)
#![warn(
missing_docs,
absolute_paths_not_starting_with_crate,
anonymous_parameters,
box_pointers,
clashing_extern_declarations,
deprecated_in_future,
elided_lifetimes_in_paths,
explicit_outlives_requirements,
indirect_stru... |
#![cfg_attr(test, feature(test))]
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
use bytes::Bytes;
mod byte_buffer;
mod compression_type;
mod encoding_type;
mod error;
mod node;
mod node_types;
mod options;
mod printer;
mod reader;
mod sixbit;
mod text_reader;
mod to_text_xml;
mod types;
mod v... |
use std::{self, env, fs};
mod parking_lot;
enum Mode {
File,
Interactive,
}
fn main() {
let args: Vec<String> = env::args().collect();
let mode = if args.len() == 1 {
Mode::Interactive
} else {
Mode::File
};
let mut parking = parking_lot::ParkingLot::new();
match mo... |
struct Solution;
impl Solution {
pub fn valid_mountain_array(a: Vec<i32>) -> bool {
let n = a.len();
if n < 3 {
return false;
}
let mut idx = 0;
// 递增
while idx + 1 < n && a[idx] < a[idx + 1] {
idx += 1;
}
// 最高点不能是数组的第一个位置或最后... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 9