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: support@datadoghq.com
* 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;
}
// 最高点不能是数组的第一个位置或最后... |
// Copyright 2013-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-MI... |
#[doc = "Reader of register DDRCTRL_STAT"]
pub type R = crate::R<u32, super::DDRCTRL_STAT>;
#[doc = "Reader of field `OPERATING_MODE`"]
pub type OPERATING_MODE_R = crate::R<u8, u8>;
#[doc = "Reader of field `SELFREF_TYPE`"]
pub type SELFREF_TYPE_R = crate::R<u8, u8>;
#[doc = "Reader of field `SELFREF_CAM_NOT_EMPTY`"]
p... |
// 17.7 Baby names
// Uses the UnionSet data structure, which has ammortized O(1)
// insertion and retrieval. O(n) time, O(n) extra space.
use std::collections::HashMap;
trait UnionSet<Id> {
fn join(&mut self, a: Id, b: Id);
fn get_union(&mut self, id: Id) -> Id;
}
impl UnionSet<usize> for HashMap<usize, us... |
#![feature(test)]
// https://github.com/bastion-rs/numanji/issues/1
use std::fmt::{Debug, Error, Formatter};
use std::sync::Arc;
enum ArcList<T> {
Cons(T, Arc<Self>),
Nil,
}
impl<T> ArcList<T> {
fn is_nil(&self) -> bool {
match self {
Self::Nil => true,
_ => false,
... |
use super::{into_std_seek_pos, DynamicAssetImpl, DynamicDataRecorderImpl};
use rustzx_core::{
error::IoError,
host::{DataRecorder, LoadableAsset, SeekFrom, SeekableAsset},
};
use std::{
fs::File,
io::{Read, Seek, Write},
};
pub struct FileAsset {
file: File,
}
impl From<File> for FileAsset {
... |
use plotly::common::{DashType, Line, Mode, Title};
use plotly::layout::Axis;
use plotly::{Layout, Plot, Scatter};
pub fn scatter_plot(x: Vec<f32>, y: Vec<f32>, c: &str, title: &str) {
let trace1 = Scatter::new(x, y).name(c).mode(Mode::Markers);
let layout = Layout::new()
.title(Title::new(title))
... |
#![allow(non_snake_case)]
use std::collections::HashMap;
use std::path::Path;
use image;
use image::GenericImage;
use cgmath::{vec2, vec3, Rad, InnerSpace};
use super::mesh::{Mesh, Vertex, Texture};
use crate::utils::common::*;
use crate::entity::Entity;
use crate::types::*;
const SCALE: f32 = 40.0;
const MAX_PIXEL_... |
use std::io::{self, Read};
use std::string::FromUtf8Error;
fn main() {
let iter = EntryIterator::from_stream(io::stdin());
for (i, entry) in iter.enumerate() {
let header = entry.header;
if i == 0 {
if header.has_magic() {
println!("This looks like a valid tar file.... |
use std::collections::HashMap;
// just under a minute to brute force pt 2 with the same solution...
const TURNS: usize = 30000000;
pub fn solve(input: &str) -> usize {
let initial_numbers = process(input);
let mut number_timestamps = HashMap::new();
let mut previous_number: Option<usize> = None;
for... |
use std::thread;
use std::time::Duration;
use actix::*;
#[derive(Debug)]
struct c_struct {
left: Vec<String>,
right: Vec<String>
}
impl c_struct {
fn new() -> Self {
Self{
left:vec![],
right : vec![]
}
}
fn make_a_b(&mut self){
while !self.left.is_em... |
struct Solution();
// use std::collections::HashMap;
impl Solution {
// //
pub fn single_number(nums: Vec<i32>) -> i32 {
// let length=nums.len();
// let mut num_count=HashMap::new();
// for i in 0..length{
// match num_count.remove(&nums[i]){
// Some(_value)=... |
use std::cell::RefCell;
#[derive(Debug, Clone)]
struct UnionFind<T> {
cell: RefCell<Vec<T>>,
}
macro_rules! impl_UnionFind {
($( $ty:ty ),*) => ($(
impl UnionFind<$ty> {
fn new(size: usize) -> Self {
UnionFind {
cell: RefCell::new(vec![0; size]),
... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use super::{models, API_VERSION};
#[non_exhaustive]
#[derive(Debug, thiserror :: Error)]
#[allow(non_camel_case_types)]
pub enum Error {
#[error(transparent)]
Operations_List(#[from] operations::l... |
mod generic;
mod point;
mod rect;
mod size;
pub use {
generic::{GeomUnit, NonNegativeFloat, NonNegativeGeomUnit},
point::{FloatPoint, IntPoint, Point},
rect::{FloatRect, IntRect, Rect},
size::{FloatSize, IntSize, Size},
};
|
use middle::middle::*;
use std::fmt;
pub struct Mangled<T>(pub T);
pub trait Mangle {
fn mangle(&self) -> Mangled<&Self> {
Mangled(self)
}
fn mangle_into(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error>;
}
impl<'a, T: Mangle> fmt::Display for Mangled<&'a T> {
fn fmt(&self, f: &mut fm... |
use std::{future::Future, marker::PhantomData, rc::Rc};
use super::engine::Engine;
use crate::rvals::{FromSteelVal, IntoSteelVal, Result, SteelVal};
use crate::stop;
use crate::{
rerrs::{ErrorKind, SteelErr},
rvals::FutureResult,
};
use futures::FutureExt;
/// Trait for allowing any function that satisfies th... |
mod bitnot;
mod bitand;
mod bitor;
mod bitxor;
pub mod prelude {
pub use super::{
BitNot,
BitAnd,
BitOr,
BitXor
};
}
pub use self::bitnot::prelude::*;
pub use self::bitand::prelude::*;
pub use self::bitor::prelude::*;
pub use self::bitxor::prelude::*;
|
use crate::{
ParseAssetError, ParseNameError,
ParseSymbolError, ReadError, WriteError
};
use keys::error as KeyError;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Clone, Debug)]
pub enum Error {
BytesReadError(ReadError),
BytesWriteError(WriteError),
FromHexError(hex::FromHexError... |
use crate::byte::Byte;
use crate::word::Word;
use crate::cpu::Cpu;
use crate::byte_le;
use crate::program::Program;
use crate::memory::MemorySpace;
use gdnative::prelude::*;
#[derive(NativeClass)]
#[inherit(Node)]
pub struct Artefact {
cpu: Cpu,
program: Option<Program>,
}
type GodotTrits = Int32Array;
type ... |
//! Write a function that returns the largest element in a list.
//! Basic implementation
fn main() {
let vec = vec![2,6,5,0,10,23,12];
println!("The largest number is {} ", find_largest_num(vec));
}
fn find_largest_num(list: Vec<u32>) -> u32 {
let mut largest: u32 = 0;
for x in &list {
if x > &l... |
#[doc = "Register `PWR_CR1` reader"]
pub type R = crate::R<PWR_CR1_SPEC>;
#[doc = "Register `PWR_CR1` writer"]
pub type W = crate::W<PWR_CR1_SPEC>;
#[doc = "Field `LPDS` reader - LPDS"]
pub type LPDS_R = crate::BitReader;
#[doc = "Field `LPDS` writer - LPDS"]
pub type LPDS_W<'a, REG, const O: u8> = crate::BitWriter<'a,... |
use serde::ser::{Serialize, Serializer, SerializeStruct};
use std::vec::Vec;
use std::fmt;
#[derive(Clone)]
pub enum Button {
PAYLOAD(String,String),
URL(String,String),
QUICKPAYLOAD(String,String),
}
impl fmt::Display for Button {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
wr... |
extern crate adventofcode;
use adventofcode::d10::{Map, Point};
use std::io;
use std::io::BufRead;
fn best_point(map: &Map) -> (Point, usize) {
map.visible_from()
.iter()
.fold((Point(0, 0), 0), |(p, pcount), (&q, &qcount)| {
if qcount > pcount {
(q, qcount)
... |
// LNP/BP Core Library implementing LNPBP specifications & standards
// Written in 2020 by
// Dr. Maxim Orlovsky <orlovsky@pandoracore.com>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. Thi... |
use async_trait::async_trait;
use s3::creds::Credentials;
use s3::Bucket;
use crate::config::ServiceConfig;
use crate::file::{FileError, FileProvider, FileResult};
#[derive(Clone)]
pub struct S3 {
config: ServiceConfig,
bucket: Bucket,
}
impl S3 {
pub fn new(config: ServiceConfig) -> Self {
Self... |
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::domain::ui_interaction::UiInteraction;
use crate::domain::ui_layout::UiLayout;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct UiLibrary {
pub name: String,
pub presets: Vec<UiLibraryPreset>
}
impl Default for UiLibrary... |
use serde_json::{Value};
use bytes::Bytes;
use warp::{Filter};
#[tokio::main]
async fn main() {
// POST /v1/receive/:log_name
let log_receiver = warp::post()
.and(warp::path("v1"))
.and(warp::path("receive"))
.and(warp::path::param())
.and(warp::body::bytes())
.map(|log... |
use variant_count::VariantCount;
use crate::commands::Command;
use crate::commands::ledger::LedgerCommand;
use crate::commands::anoncreds::AnoncredsCommand;
use crate::commands::anoncreds::issuer::IssuerCommand;
use crate::commands::anoncreds::prover::ProverCommand;
use crate::commands::anoncreds::verifier::VerifierCom... |
fn main() {
(0..10).map(|x| x*x);
(0..10).map(|x| {
fn f(y: u32) -> u32 {
y*y
}
let z = f(x+1) * f(x+2);
z*z
});
fn f<T>(g: T, x: u32) -> u32
where T: Fn(u32) -> u32
{
g(x+1) * g(x+2)
}
f(|x|{x*x}, 2);
(0..10).map(|x| x*x)
... |
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::MutexGuard;
use linked_hash_map::Entry;
u... |
mod components;
mod connection;
mod flags;
mod future;
mod keystate;
mod pingdata;
mod powerups;
mod units;
mod upgrades;
mod vector2;
mod connection_events;
pub mod collision;
pub mod config;
pub mod systemdata;
pub(crate) mod gamemode;
pub use self::components::*;
pub use self::config::Config;
pub use self::conne... |
// other library used for correctness checks
extern crate fid;
use fid::{FID, BitVector};
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
fn xorshift(mut x: u64) -> u64 {
x ^= x << 13;
x ^= x >> 7;
x ^= x << 17;
x
}
const SIZE: usize = 1_000_000;
#[test]
/// Check that t... |
#![windows_subsystem = "windows"]
#[macro_use]
extern crate clap;
mod editor;
mod internal;
mod keyboard;
mod operations;
mod plugins;
mod property_creator;
mod property_editor;
mod support;
mod tools;
use drg::asset::*;
use editor::*;
use std::env;
use std::path::*;
fn main() {
let matches = clap_app!(DRGEditor ... |
#![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... |
use hacspec_lib::prelude::*;
#[test]
fn test_unsigned_public_integers() {
unsigned_public_integer!(LargeInteger, 233);
let a = LargeInteger::from_literal(1);
let b = LargeInteger::from_literal(2);
let c = a + b;
assert_eq!(c, LargeInteger::from_literal(3));
}
#[test]
#[should_panic]
fn test_unsign... |
#[derive(Clone, Deserialize)]
pub struct Target {
pub name: String,
pub shared_secret: String,
pub index_key: String,
pub encrypt_key: String,
}
#[derive(Deserialize)]
pub struct Config {
pub target: Vec<Target>,
}
|
use std::ops::Bound;
use std::sync::Arc;
use anyhow::{Context, Result};
use async_trait::async_trait;
use chrono::{DateTime, Duration, Utc};
use serde_derive::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
use sqlx::{postgres::PgConnection, Acquire};
use svc_agent::{
mqtt::{
IntoPublishableM... |
use std::net::IpAddr;
use std::str::FromStr;
use crate::error::{LookoutError, Result};
use crate::types::ASn;
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct TracerouteResult {
pub header: TracerouteHeader,
pub hops: Vec<TracerouteHop>,
}
#[derive(Clone, Debug, Eq, PartialEq, Serial... |
#![warn(rust_2018_idioms)]
#![allow(dead_code)]
pub mod association;
pub mod chunk;
pub mod error;
pub mod error_cause;
pub mod packet;
pub mod param;
pub(crate) mod queue;
pub mod stream;
pub(crate) mod timer;
pub(crate) mod util;
|
#![recursion_limit = "1024"]
use crate::pages::{Login, Person, PersonsList};
use wasm_bindgen::prelude::*;
use yew::html;
use yew::prelude::*;
mod database;
mod pages;
mod person;
mod user;
enum Page {
Login,
PersonsList,
OnePerson(Option<person::Person>),
}
struct AuthApp {
page: Page,
current... |
mod actions;
pub mod keyboard;
mod mode_actions;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use self::actions::{Action, Response};
use self::keyboard::{KeyStroke, Keyboard};
use self::mode_actions::ModeActions;
use crate::core::ClientToClientWriter;
use failure::Error;
use xi_rpc::Peer;
lazy_static... |
use crate::gpio::*;
use embedded_hal::spi::{FullDuplex, Mode, Phase, Polarity};
use esp8266::{IO_MUX, SPI1};
use void::Void;
#[derive(Copy, Clone, Eq, PartialEq)]
#[repr(u8)]
pub enum SpiClock {
Spi2MHz = 40,
Spi4MHz = 20,
Spi5MHz = 16,
Spi8MHz = 10,
Spi10MHz = 8,
Spi16MHz = 5,
Spi20MHz = 4... |
pub mod msg;
pub mod constants;
|
use std::fmt::Debug;
use bevy::{
ecs::{entity::Entity, world::World},
math::{Quat, Vec3},
prelude::Transform,
reflect::{TypeUuid, Uuid},
};
use serde::{Deserialize, Serialize};
pub mod app;
pub mod builtin;
pub mod command;
pub mod data;
pub mod de;
pub mod loader;
pub mod manager;
pub mod registry;
... |
use ringbuf::Consumer;
use stainless_ffmpeg::prelude::*;
use std::collections::HashMap;
use std::ffi::{c_void, CStr, CString};
use std::io::{Cursor, Error, ErrorKind, Result};
use std::mem;
use std::ptr::null_mut;
use std::str::from_utf8_unchecked;
unsafe fn to_string(data: *const i8) -> String {
if data.is_null() {... |
//! Handles the managment of an inactive page table.
use super::super::TEMPORARY_MAP_TABLE;
use super::current_page_table::CURRENT_PAGE_TABLE;
use super::frame_allocator::FRAME_ALLOCATOR;
use super::page_table::{Level4, PageTable};
use super::page_table_entry::*;
use super::page_table_manager::PageTableManager;
use su... |
pub mod allocator;
pub mod allocators;
mod bumpallocator;
pub mod dump_linear_scan;
pub mod embedded_meta_data;
pub mod large_object_allocator;
pub mod linear_scan;
pub mod malloc_allocator;
pub use self::allocator::Allocator;
pub use self::bumpallocator::BumpAllocator;
pub use self::large_object_allocator::LargeObjec... |
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use common::result::Result;
use crate::domain::interaction::{Like, Reading, Review, View};
use crate::domain::publication::PublicationId;
use crate::domain::reader::ReaderId;
#[async_trait]
pub trait InteractionRepository: Sync + Send {
async fn find_vie... |
use artell_domain::image::{Format, Image, ImageRepository};
use rusoto_core::{region::Region, ByteStream};
use rusoto_s3::{PutObjectRequest, S3Client, S3};
pub struct S3ImageRepository {
client: S3Client,
bucket: String,
}
impl S3ImageRepository {
pub fn new(bucket: String) -> Self {
let client = ... |
use rocket::http::Status;
use rocket_contrib::json::Json;
use serde_json::Value;
use crate::models::author::{Author, NewAuthor};
use crate::models::client_wrapper::DBConnection;
use crate::requests::util;
#[get("/")]
pub fn all(mut db_conn: DBConnection) -> Json<Value> {
let (status, authors) = match db_conn.clie... |
use crate::cartridge::{BankType, BankWindow, BaseMapper, Mapper, MemAttr};
use crate::cartridge::{ChrRom, NesHeader, PrgRom};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct State {
inner: BaseMapper,
}
impl State {
pub fn new(header: &NesHeader, prg_rom: &PrgRom, c... |
#[doc = "Register `DMACTxCR` reader"]
pub type R = crate::R<DMACTX_CR_SPEC>;
#[doc = "Register `DMACTxCR` writer"]
pub type W = crate::W<DMACTX_CR_SPEC>;
#[doc = "Field `ST` reader - Start or Stop Transmission Command"]
pub type ST_R = crate::BitReader;
#[doc = "Field `ST` writer - Start or Stop Transmission Command"]
... |
use std::sync::Once;
use std::error::Error;
use std::fs;
fn read_report_csv(filename: &str) -> Result<Vec<i32>, Box<dyn Error>> {
//panic if no file found
//panic if no values read from file
unimplemented!("Function unimplemented");
}
fn main() {
println!("Hello, world!");
}
#[cfg(test)]
mod tests {... |
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*/
#![warn(missing_debug_implementations, missing_docs)]
//! Index configuration.
use vector::Metric;
use super::index_write_parameters::IndexWriteParameters;
/// The index configuration
#[derive(Debug, Clone)]
pub s... |
use apllodb_shared_components::{ApllodbResult, SchemaIndex, ShortName};
use serde::{Deserialize, Serialize};
/// Column name.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
pub struct ColumnName(ShortName);
impl ColumnName {
/// Constructor.
///
/// # Failures
//... |
//! # JsonRPC
//!
//! This module contains the the utilities needed do build the JsonRPC api, both HTTP and
//! WebSockets, which can then directly served by `warp`.
//!
//! `warp` is a HTTP framework which is built around filters, this module is used to build filters
//! that mimics the Tendermint API.
mod api;
mod ut... |
#[derive(Debug, Serialize)]
pub struct Book {
pub id: i32,
pub title: String,
#[serde(rename = "authorId")]
pub author_id: i32,
pub published: bool,
}
impl From<postgres::Row> for Book {
fn from(row: postgres::Row) -> Self {
Book {
id: row.get(0),
title: row.get(... |
#![cfg(test)]
use color_eyre::eyre::{eyre, Result};
use pretty_assertions::assert_eq;
use super::*;
use crate::template::block::{Block, BlockKind, If, IfExpr, IfOp, Var, VarEnv, VarEnvSet};
use crate::template::source::Source;
use crate::template::span::ByteSpan;
#[test]
fn parse_single_text() -> Result<()> {
crate... |
use std::convert::TryInto;
use std::fmt;
use std::num::TryFromIntError;
use chrono::{NaiveTime, Timelike};
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct ExtendedTime {
hour: u8,
minute: u8,
}
impl fmt::Debug for ExtendedTime {
fn fmt(&self, f: &mut fmt::Formatter) -> std::result... |
use simple_logger::SimpleLogger;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::path::PathBuf;
use std::process::{exit, Command, Stdio};
use structopt::StructOpt;
use log::{error, info};
#[derive(StructOpt, Debug)]
#[structopt(name = "cargo-remote", bin_name = "cargo")]
enum Op... |
mod test_blocks;
mod test_functions;
mod test_operators;
mod test_primitives;
mod test_tables;
mod test_types;
mod test_variables;
mod test_statements;
pub mod utils;
|
use rocket::catch;
use rocket_contrib::{json, json::JsonValue};
#[catch(504)]
pub fn index() -> JsonValue {
json!({ "message": "Evaluation timed out." })
}
|
extern crate advent_of_code_2017_day_x;
use advent_of_code_2017_day_x::*;
#[test]
fn part_1_example() {
// FIXME
}
|
#![allow(proc_macro_derive_resolution_fallback)]
use crate::schema::passwords;
use chrono::NaiveDateTime;
use serde::Serialize;
use serde_derive::Deserialize;
#[derive(Debug, Queryable, Serialize, Deserialize, Identifiable, PartialEq, AsChangeset)]
#[table_name = "passwords"]
pub struct PasswordModel {
pub id: u32... |
mod disease_sh;
mod gitlab;
use crate::{error::ProcessingError, fuzzers, metadata, search::read_runs};
use indicatif::ParallelProgressIterator;
use rayon::prelude::*;
use std::{fmt, fs, fs::File, path::Path, str::FromStr, time::Instant};
#[derive(Debug)]
pub enum Target {
AgeOfEmpires2Api(TargetKind),
Ccccatal... |
use crate::rendering::Instance;
use cgmath::prelude::*;
use rand::prelude::*;
use std::ops::{Add, Div, DivAssign, Mul};
use web_sys::WebGlRenderingContext as GL;
use crate::{
quadtree::Quadtree, quadtree::Rectangle as Rect, rendering::Rectangle, rendering::Triangle,
utils::ScreenSpaceEncoder,
};
#[derive(Debu... |
pub fn max_profit(prices: Vec<i32>) -> i32 {
let mut profit = 0;
let n = prices.len();
if n == 0 {
return 0
}
let mut max_price = prices[n-1];
for i in (0..n-1).rev() {
profit = std::cmp::max(profit, max_price - prices[i]);
max_price = std::cmp::max(max_price, prices[i]);... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.