text stringlengths 8 4.13M |
|---|
#![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 ImageTemplateListResult {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub value: Vec<ImageTemp... |
// This pallet use The Open Runtime Module Library (ORML) which is a community maintained collection of Substrate runtime modules.
// Thanks to all contributors of orml.
// https://github.com/open-web3-stack/open-runtime-module-library
#![cfg_attr(not(feature = "std"), no_std)]
use codec::{Decode, Encode};
use frame_... |
use std::env;
use std::thread;
use std::sync::mpsc::{Sender, channel};
use std::net::{IpAddr, TcpStream};
use std::str::FromStr;
struct UserInput {
ip_address: IpAddr,
threads: u16,
starting_port: u16, //starting and ending port form a range of ports to scan
ending_port: u16,
}
impl UserInput {
f... |
use std::error::Error;
use std::fmt;
/// Error that can happen when swapping buffers.
#[derive(Debug, Clone, PartialEq)]
pub enum SwapBuffersError {
/// The corresponding context has been lost and needs to be recreated.
///
/// All the objects associated to it (textures, buffers, programs, etc.)
/// ne... |
#![cfg_attr(not(feature = "std"), no_std)]
pub use primitive_types::{U256};
pub mod balance;
use sp_runtime::{
DispatchError,
traits::{
StaticLookup,
},
};
use system::{
ensure_signed,
ensure_root,
};
use crate::cipher::{
EGICipher,
CipherFunctor,
};
use crate::proof::{
Cipher... |
#[doc = "Reader of register CM0_INT_CTL3"]
pub type R = crate::R<u32, super::CM0_INT_CTL3>;
#[doc = "Writer for register CM0_INT_CTL3"]
pub type W = crate::W<u32, super::CM0_INT_CTL3>;
#[doc = "Register CM0_INT_CTL3 `reset()`'s with value 0xf0f0_f0f0"]
impl crate::ResetValue for super::CM0_INT_CTL3 {
type Type = u3... |
// Copyright 2018 Steven Bosnick
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE-2.0 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 accord... |
use std::fmt;
#[allow(dead_code)]
#[derive(Debug)]
enum Status {
Online,
Offline,
}
#[allow(dead_code)]
#[derive(Debug)]
enum Color {
Red,
Green,
Blue,
Orange,
Custom(String),
}
impl fmt::Display for Color {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &*self {... |
use x25519_dalek;
use rand::RngCore;
use rand::CryptoRng;
use std::fmt;
use std::cmp::Eq;
use std::ops::Deref;
use std::str::FromStr;
use std::hash::{Hash, Hasher};
use std::convert::AsRef;
#[derive(Copy, Clone)]
pub struct PresharedSecret([u8; 32]);
impl FromStr for PresharedSecret {
type Err = (); // TODO: bet... |
use serde::Serialize;
#[derive(Serialize)]
pub struct Divider {
#[serde(rename = "type")]
block_type: String,
}
#[derive(Serialize)]
pub struct Text {
#[serde(rename = "type")]
block_type: String,
text: String,
}
impl Text {
pub fn new(text: String) -> Text {
Text {
block_... |
extern crate bincode;
extern crate csv;
#[macro_use]
extern crate serde_derive;
extern crate sled;
use std::io;
use bincode::{deserialize, serialize};
use csv::ReaderBuilder;
use sled::{ConfigBuilder, Tree};
#[derive(Debug, Serialize, Deserialize)]
struct Passwd {
username: String,
password: String,
uid:... |
use std::collections::HashMap;
#[derive(Debug)]
pub struct SymbolTable(HashMap<String, usize>);
impl SymbolTable {
pub fn new() -> Self {
let mut hashmap = HashMap::new();
hashmap.insert("SP".to_string(), 0);
hashmap.insert("LCL".to_string(), 1);
hashmap.insert("ARG".to_string(), 2)... |
impl Solution {
pub fn remove_duplicates(s: String) -> String {
let mut stack = vec![];
for byte in s.bytes() {
match stack.last() {
Some(&last) if last == byte => {
stack.pop();
}
_ => stack.push(byte),
};
... |
use std::fs::File;
use super::data::{Data, Storage};
use errors::Result;
pub struct DataBuilder {
buffer: Vec<u8>,
}
impl DataBuilder {
pub fn new() -> Self {
DataBuilder { buffer: Vec::new() }
}
pub fn write_blob(&mut self, data: &Data) -> Result<()> {
// TODO: Assert that data is bl... |
extern crate precod_compdag;
use precod_compdag::mat_mul;
use precod_compdag::BranchNode;
use precod_compdag::InputWithErrorBackProp;
use precod_compdag::LeafNode;
use precod_compdag::OutputWithErrorBackProp;
use precod_compdag::RootNode;
use rand;
use rand::prelude::*;
use rand_distr::Uniform;
use std::borrow::BorrowM... |
extern crate libc;
use std::process::exit;
use std::env;
use common::utils::{ compile_file, do_file };
mod parser;
mod common;
mod lexer;
mod vm;
enum Exec {
PrintBytecodeRecursive(String),
PrintBytecode(String),
DoFile(String),
Exit
}
fn get_name(name: Option<&String>, err: &str) -> Result<String, String>... |
extern crate geo;
extern crate line_intersection;
use line_intersection::{LineInterval, LineRelation};
use geo::{Coordinate, Line, Point};
use crate::GCode;
// TODO: Figure out a better spot for this - Austin Haskell
#[derive(Debug, Copy, Clone)]
pub struct Rectangle {
pub quad_x: i32,
pub quad_y: i32,
p... |
// https://adventofcode.com/2017/day/18
use std::io::{BufRead, BufReader};
use std::fs::File;
use std::collections::VecDeque;
fn main() {
let f = BufReader::new(File::open("input.txt").expect("Opening input.txt failed"));
// Parse instructions
let mut program = Vec::new();
for line in f.lines() {
... |
#![cfg_attr(not(feature = "std"), no_std)]
use ink_lang as ink;
#[ink::contract(version = "0.1.0")]
mod idata {
#[cfg(not(feature = "ink-as-dependency"))]
use ink_core::env::call::*;
use ink_core::env::EnvError;
use ink_core::storage;
use ink_prelude::vec::Vec;
//iflow
const GET_INTERPRETE... |
extern crate iui;
extern crate ui_sys;
use iui::controls::{Area, AreaDrawParams, AreaHandler, HorizontalBox, LayoutStrategy};
use iui::draw::{Brush, FillMode, Path, SolidBrush};
use iui::prelude::*;
use std::f64::consts::PI;
struct HandleCanvas {}
impl AreaHandler for HandleCanvas {
fn draw(&mut self, _area: &Are... |
use std::mem::MaybeUninit;
use std::convert::TryInto;
use std::sync::atomic::{AtomicBool, Ordering};
pub struct JitCodeDataPagePair {
locked: AtomicBool,
pub contents: *mut libc::c_void,
}
pub const PAGE_SIZE: usize = 4096;
impl<'a> JitCodeDataPagePair {
pub fn new() -> Self {
unsafe {
... |
use rand::{thread_rng, Rng};
pub fn private_key(p: u64) -> u64 {
thread_rng().gen_range(2, p)
}
pub fn public_key(p: u64, g: u64, a: u64) -> u64 {
let mut result: u64 = 1;
let mut g = g % p;
let mut a = a;
while a > 0 {
if a % 2 == 1 {
result = (result * g) % p;
}
... |
mod snapping_mech; // contains public snapping mechanism
extern crate rand;
extern crate rug;
use rand::{random, Open01};
use rand::distributions::{IndependentSample, Range};
use std::f64;
use std::io;
use rug::ops::Pow;
// Implementation of laplacian noise generator which uses snapping mechanism in its place
fn mai... |
use crate::{error::Error, Node};
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::hash::Hash;
use std::sync::{Arc, RwLock};
pub type InnerDependencyMap<I> = HashMap<I, HashSet<I>>;
pub type DependencyMap<I> = Arc<RwLock<InnerDependencyMap<I>>>;
/// Dependency graph
pub struct DepGraph<I>
where
I:... |
#![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 Operation {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serd... |
pub mod window;
pub mod dialog;
|
use super::nfa::{Nfa, NfaTable};
use std::{
collections::{
hash_map::Entry as HashEntry, BTreeSet, HashMap, HashSet, VecDeque,
},
fmt::{self, Debug, Write},
hash::Hash,
};
pub type DfaTable<T, S> = HashMap<S, HashMap<T, S>>;
pub struct Dfa<T, S> {
states: DfaTable<T, S>,
start: S,
accept: HashSet<S>... |
#[doc = "Reader of register CHAN_WORK_UPDATED"]
pub type R = crate::R<u32, super::CHAN_WORK_UPDATED>;
#[doc = "Reader of field `CHAN_WORK_UPDATED`"]
pub type CHAN_WORK_UPDATED_R = crate::R<u16, u16>;
impl R {
#[doc = "Bits 0:15 - If set the corresponding WORK register was updated, i.e. was already sampled during th... |
extern crate dhc;
fn main() {
dhc::init();
let ctx = dhc::Context::instance();
loop {
ctx.update();
std::thread::sleep(std::time::Duration::from_millis(3000));
}
}
|
extern crate clap;
use clap::{value_t, App, Arg};
use failure::Error;
use std::fs::File;
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::process;
use std::time::Instant;
static NAME: &str = env!("CARGO_PKG_NAME");
static VERSION: &str = env!("CARGO_PKG_VERSION");
static AUTHOR: &str = env!("CARGO... |
use serde::Serialize;
use common::error::Error;
use common::result::Result;
use crate::application::dtos::UserDto;
use crate::domain::user::{UserId, UserRepository};
#[derive(Serialize)]
pub struct GetAllResponse {
pub users: Vec<UserDto>,
}
pub struct GetAll<'a> {
user_repo: &'a dyn UserRepository,
}
impl... |
use std::cell::Cell;
use futures::unsync::oneshot::{channel, Receiver};
use futures::sync::oneshot::{channel as sync_channel, Receiver as SyncReceiver};
use actor::{Actor, AsyncContext};
use handler::{Handler, ResponseType};
use context::AsyncContextApi;
use contextcells::ContextProtocol;
use envelope::{Envelope, ToEn... |
use crate::read_pattern::ReadPattern;
use std::ops::{RangeBounds, Bound};
#[derive(Copy, Clone, Debug)]
pub struct RangePattern<T, R>(pub T, pub R);
impl<T, R> ReadPattern for RangePattern<T, R> where
T: ReadPattern,
R: RangeBounds<u32> {
fn read_pattern(&self, text: &str) -> Option<usize> {
if ... |
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use crate::host::*;
pub trait MapKey {
fn get_id(&self) -> Key32;
}
impl MapKey for str {
fn get_id(&self) -> Key32 {
get_key_id_from_string(self)
}
}
impl MapKey for String {
fn get_id(&self) -> Key32 {
get_key_i... |
pub mod logout;
pub mod challenge;
pub mod app_setup;
pub mod token;
pub mod index;
use rocket::request::{self, Request, FromRequest};
use rocket::{Outcome, State};
use rocket::http::Status;
use std::net::SocketAddr;
use r2d2::{Pool, PooledConnection};
use r2d2_postgres::{PostgresConnectionManager};
use postgres::Con... |
#[derive(Debug)]
pub struct Node<T> {
pub val: T,
pub next: Link<T>
}
pub type Link<T> = Option<Box<Node<T>>>;
|
use crate::{Client, ClientFactory, MssqlFactory, MssqlProvider};
use storm::{provider::ProviderFactory, BoxFuture, Error, Result};
/// This can wrap a ClientFactory and creates a transaction for each Client that are returned.
/// It is useful for integration tests making sure that all items are rollback once the test
... |
use shorthand::ShortHand;
#[derive(ShortHand, Default)]
pub struct Example {
optional: Option<String>,
}
#[test]
fn test_option_as_ref() { let _: Option<&String> = Example::default().optional(); }
fn main() {}
|
//#[macro_use]
//extern crate log;
//extern crate android_logger;
mod excel_to_json;
use excel_to_json::*;
use jni::objects::{JClass, JObject, JString};
use jni::sys::{jint, jobject};
use jni::{JNIEnv, JavaVM};
use serde_json::to_string;
//JNI加载完成
#[no_mangle]
pub extern "C" fn JNI_OnLoad(_jvm: JavaVM, _reserved: *m... |
use crate::runtime::Runtime;
use crate::subscription::subscribe_loop_supervisor::SubscribeLoopSupervisor;
use crate::transport::{Service, Transport};
use futures_util::lock::Mutex;
use std::sync::Arc;
mod presence;
mod publish;
mod subscribe;
#[cfg(test)]
mod tests;
/// # PubNub Client
///
/// The PubNub lib impleme... |
#[doc = "Register `APB2RSTR` reader"]
pub type R = crate::R<APB2RSTR_SPEC>;
#[doc = "Register `APB2RSTR` writer"]
pub type W = crate::W<APB2RSTR_SPEC>;
#[doc = "Field `AFIORST` reader - Alternate function I/O reset"]
pub type AFIORST_R = crate::BitReader<AFIORST_A>;
#[doc = "Alternate function I/O reset\n\nValue on res... |
use anyhow::Result;
use xilinx_dma::AxiDma;
use xilinx_dma::DmaBuffer;
fn main() -> Result<()> {
let dma_buffer_h2d = DmaBuffer::new("udmabuf0")?;
let dma_buffer_d2h = DmaBuffer::new("udmabuf1")?;
println!("{:?}", dma_buffer_h2d);
println!("{:?}", dma_buffer_d2h);
// do not use the whole buffer
... |
#![macro_use]
use crate::gpio::{AnyPin, Pin};
use crate::pac::gpio::vals::{Afr, Moder};
use crate::pac::gpio::Gpio;
use crate::pac::spi;
use crate::spi::{ByteOrder, Config, Error, Instance, MisoPin, MosiPin, SckPin, WordSize};
use crate::time::Hertz;
use core::marker::PhantomData;
use core::ptr;
use embassy::util::Unb... |
use std::collections::HashMap;
use std::marker::PhantomData;
use std::mem::take;
use std::path::Path;
use anyhow::{anyhow, Result};
use arrow2::array::TryExtend;
use log::*;
use super::{Dedup, Interaction, Key};
use crate::arrow::*;
use crate::io::{file_size, ObjectWriter};
use crate::util::logging::item_progress;
us... |
/// 使用者确保Slice持有的数据不会被释放。
#[derive(Clone)]
pub struct Slice {
ptr: usize,
len: usize,
}
impl Slice {
pub fn new(ptr: usize, len: usize) -> Self {
Self { ptr, len }
}
pub fn from(data: &[u8]) -> Self {
Self {
ptr: data.as_ptr() as usize,
len: data.len(),
... |
use bevy::prelude::{Vec2, Vec3};
use std::ops::Add;
use std::cmp::Ordering;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Position {
pub x: f32,
pub y: f32,
pub z: f32,
pub absolute: bool
}
impl Position {
pub fn new(x: f32, y: f32, z: f32) -> Self {
Position {
x, y, z,
... |
use xml::reader;
use std::fmt::{self, Display, Debug};
use std::error::Error as StdError;
use std::num;
use serde::de::Error as SerdeError;
pub enum Error {
ParseIntError(num::ParseIntError),
Syntax(reader::Error),
Custom(String),
}
pub type VResult<V> = Result<V, Error>;
macro_rules! expect {
($actu... |
use super::{utils::*, TrackOwner};
use serde_json::Value;
use serenity::{
client::Context,
framework::standard::{macros::command, Args, CommandResult},
model::channel::Message,
};
use songbird::{
input::{cached::Compressed, Metadata},
Bitrate,
};
use std::time::Duration;
use tracing::{info, warn};
... |
use super::types::DataType;
pub struct Regs<RegType: DataType> {
regs: [RegType; 32]
} |
use bincode::rustc_serialize::DecodingError;
use std::net::TcpStream;
use std::io::{Read, Error};
use commands::ServerCommand;
use ser_de::de;
pub struct Reader {
de_buf: Vec<u8>,
buf: [u8; 4098],
}
impl Reader {
pub fn new() -> Reader {
Reader {
de_buf: Vec::new(),
... |
use std::borrow::Cow;
pub trait Named<'a> {
fn name(&self) -> Cow<'a, str>;
}
pub trait FromRaw<'a, T> {
type Raw;
fn from_raw(raw: &'a Self::Raw) -> T;
} |
#[doc = "Register `CONF2R` reader"]
pub type R = crate::R<CONF2R_SPEC>;
#[doc = "Register `CONF2R` writer"]
pub type W = crate::W<CONF2R_SPEC>;
#[doc = "Field `OFFSET2` reader - Twelve-bit calibration offset for configuration 2"]
pub type OFFSET2_R = crate::FieldReader<u16>;
#[doc = "Field `OFFSET2` writer - Twelve-bit... |
extern crate random_choice;
#[cfg(test)]
mod tests {
use std::collections::BTreeMap;
use random_choice::random_choice;
#[test]
fn test_random_choice_f64() {
let capacity: usize = 500;
let mut samples: Vec<usize> = Vec::with_capacity(capacity);
let mut weights: Vec<f64> = Vec::w... |
#[derive(Copy, Clone, Debug)]
pub struct Vec2<T>
{
pub x: T, pub y: T
}
impl<T: std::ops::Neg<Output = T>> std::ops::Neg for Vec2<T>
{
type Output = Self;
fn neg(self) -> Self
{
Self::new(-self.x, -self.y)
}
}
impl<T: std::ops::Add<Output = T>> std::ops::Add for Vec2<T>
{
type Output =... |
// This file is part of Substrate.
// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// 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
//
// ht... |
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_variables)]
extern crate mongodb;
#[cfg(all(feature = "tokio-runtime", not(feature = "tokio-sync")))]
mod async_scram {
// ASYNC SCRAM CONNECTION EXAMPLE STARTS HERE
use mongodb::{options::ClientOptions, Client};
#[tokio::main]
async fn m... |
pub mod result;
pub use result::Res;
pub struct Engine {
text: Vec<char>,
position: usize,
// if an error was made, then error store the position were you fucked up
error: Option<usize>,
result: crate::result::Res,
}
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum Keys {
// if a valid char w... |
// https://github.com/frankmcsherry/blog/blob/master/posts/2018-05-19.md
use std::rc::Rc;
use std::cell::RefCell;
/// A sorted list of distinct tuples.
#[derive(Debug)]
pub struct Relation<Tuple: Ord> {
elements: Vec<Tuple>
}
impl<Tuple: Ord, I: IntoIterator<Item=Tuple>> From<I> for Relation<Tuple> {
fn ... |
use std::ops::{
Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, SubAssign,
};
#[derive(Copy, Clone)]
pub struct Vec3 {
e: [f32; 3],
}
impl Vec3 {
#[inline(always)]
pub fn new(e0: f32, e1: f32, e2: f32) -> Vec3 {
Vec3 { e: [e0, e1, e2] }
}
#[in... |
#![cfg(all(test, feature = "test_e2e"))]
#[macro_use]
extern crate log;
use azure_core::prelude::*;
use azure_storage::blob::container::PublicAccess;
use azure_storage::blob::prelude::*;
use azure_storage::core::prelude::*;
use bytes::Bytes;
#[tokio::test]
async fn put_append_blob() {
let account =
std::e... |
use std::collections::BTreeSet;
use std::error::Error;
use std::fs::{read_to_string, File};
use std::time::Duration;
use actix::{Actor, System};
use actix_web::{App, HttpServer};
use daemonize::Daemonize;
use nix::errno::Errno;
use nix::sys::signal;
use nix::unistd::Pid;
use crate::caltrain_status::{Direction, TrainT... |
use java_properties;
use quick_xml::events::{BytesEnd, BytesStart, BytesText, Event};
use quick_xml::{Error, Reader, Writer};
use std::fs::{self, File};
use std::io::{BufReader, BufWriter, Cursor};
use std::str;
use yaml_rust;
static INVALID_END_PATH_VEC: &[char] = &['/', '\\'];
//// validate project path,eg. applicati... |
use std::fs::File;
use std::path::PathBuf;
use std::process;
use structopt::StructOpt;
mod feed;
mod upload;
#[derive(Debug, StructOpt)]
#[structopt(about = "audiobook to podcast tool")]
enum Opt {
Feed {
#[structopt(long)]
title: String,
#[structopt(long)]
image: Option<PathBuf>,
... |
#[cfg(feature = "std")]
use std::vec::Vec;
#[cfg(not(feature = "std"))]
extern crate alloc;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
/// Rather than store `Option` elements, a SlotList uses a custom maybe type
/// that associates a number with each empty slot. These numbers allow the
/// collection to create ... |
//! A module to verify individual number
/// Size of individual number.
const INDIVIDUAL_NUMBER_DIGITS: usize = 12;
/// Verifies the individual number.
pub fn verify(number: &str) -> Result<(), ::VerifyError> {
let mut digits = number.chars()
.filter_map(|x| {
... |
mod mapmerge;
use std::collections::HashMap;
use mapmerge::MergeMap;
fn main() {
let mut map_merge = MergeMap::new();
for rounds in 0..10 {
let mut some_map = HashMap::with_capacity(1_000_000);
for i in 0..1_000_000 {
some_map.insert(i, i*2);
}
map_merge.me... |
use async_std::net::{TcpListener, TcpStream};
use futures_util::future::poll_fn;
use futures_util::io::AsyncReadExt;
use futures_util::io::AsyncWriteExt;
use hreq_h1::buf_reader::BufIo;
use hreq_h1::http11::poll_for_crlfcrlf;
use hreq_h1::Error;
mod common;
#[async_std::test]
async fn client_get_200_ok() -> Result<()... |
use crate::event::EventOnce;
use log::debug;
use std::cell::RefCell;
use std::pin::Pin;
use std::{
borrow::Cow,
ffi::CStr,
rc::{Rc, Weak},
};
use wlroots_sys::*;
#[derive(Debug, PartialEq)]
pub enum DeviceType {
Keyboard(*mut wlr_keyboard),
Pointer(*mut wlr_pointer),
Unknown,
}
pub struct Device {
devic... |
#[doc = "Reader of register DDRPHYC_DSGCR"]
pub type R = crate::R<u32, super::DDRPHYC_DSGCR>;
#[doc = "Writer for register DDRPHYC_DSGCR"]
pub type W = crate::W<u32, super::DDRPHYC_DSGCR>;
#[doc = "Register DDRPHYC_DSGCR `reset()`'s with value 0xfa00_001f"]
impl crate::ResetValue for super::DDRPHYC_DSGCR {
type Typ... |
// https://www.codewars.com/kata/57c1ab3949324c321600013f
use std::collections::HashMap;
fn to_leet_speak(s: &str) -> String {
let leet_map: HashMap<char, &str> = vec![
('A', "@"),
('B', "8"),
('C', "("),
('D', "D"),
('E', "3"),
('F', "F"),
('G', "6"),
... |
// 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... |
use tokio::process::Command;
use anyhow::{Result, Context};
use async_trait::async_trait;
use crate::{
services::model::{Nameable, Ensurable, is_binary_present},
helpers::ExitStatusIntoUnit
};
static NAME: &str = "kfp";
#[derive(Default)]
pub struct Kfp {}
impl Nameable for Kfp {
fn name(... |
// Create the Error, ErrorKind, ResultExt, and Result types
error_chain!{
foreign_links {
IOError(::std::io::Error);
PostgresError(::postgres::Error);
Utf8Error(::std::string::FromUtf8Error);
}
} |
#![allow(improper_ctypes)]
#![no_std]
#![no_main]
#![feature(lang_items)]
#![feature(int_uint)] // update fail_bounds_check
#![feature(no_std)]
#![crate_name="blinky"]
//extern crate libc;
use zero::std_types::*;
use libarm::stm32f4xx::*;
mod zero {
pub mod std_types;
pub mod zero;
}
#[macro_use]
mod libarm {
#... |
//! The commands from the specification that are listed as administrative.
use super::*;
/// Which version of the protocol is spoken?
///
/// # Comments
/// > For this specification 2.
pub fn protocol_version() -> Command {
command!("protocol_version" => (none) -> (int))
}
/// What is the name of the engine?
///
//... |
use std::collections::HashMap;
use std::io::prelude::*;
use std::fs::File;
extern crate csv;
extern crate rustc_serialize;
#[derive(RustcDecodable)]
struct Record {
mail_addr: String,
user_name: String,
}
struct Database {}
impl Database {
fn get_properties(db_name: String) -> HashMap<String, String> {
... |
#[doc = "Reader of register GPIO_OE"]
pub type R = crate::R<u32, super::GPIO_OE>;
#[doc = "Writer for register GPIO_OE"]
pub type W = crate::W<u32, super::GPIO_OE>;
#[doc = "Register GPIO_OE `reset()`'s with value 0"]
impl crate::ResetValue for super::GPIO_OE {
type Type = u32;
#[inline(always)]
fn reset_va... |
// see also 'tests/ok/07_vis2.rs'
#[macro_use]
extern crate parameterized_macro;
pub mod a {
#[parameterized(v = { Some(- 1), None })]
pub(in crate::b) fn my_test(v: Option<i32>) {}
}
mod b {
#[cfg(test)]
fn call() {
a::my_test::case_0(); // this is ok
}
}
fn main() {
if cfg!(test) {... |
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_std::{CanonicalAddr, Decimal, ReadonlyStorage, StdResult, Storage, Uint128};
use cosmwasm_storage::{
bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, Singleton,
};
static KEY_CONFIG: &[u8] = b"config";
#[derive(Ser... |
mod chat;
mod command;
mod key;
mod login;
mod onclose;
mod onopen;
mod ping;
mod pong;
mod say;
mod scoreboard;
mod signal;
pub use self::chat::ChatHandler;
pub use self::command::CommandHandler;
pub use self::key::KeyHandler;
pub use self::login::LoginHandler;
pub use self::onclose::OnCloseHandler;
pub use self::ono... |
#[doc = "Reader of register POWER_CTL"]
pub type R = crate::R<u32, super::POWER_CTL>;
#[doc = "Writer for register POWER_CTL"]
pub type W = crate::W<u32, super::POWER_CTL>;
#[doc = "Register POWER_CTL `reset()`'s with value 0"]
impl crate::ResetValue for super::POWER_CTL {
type Type = u32;
#[inline(always)]
... |
// MIT License
//
// Copyright (c) 2019-2021 Tobias Pfeiffer
//
// 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... |
mod caffeine;
mod menu_item;
mod notification;
mod sysbar;
pub use self::caffeine::Caffeine;
pub use self::menu_item::MenuItem;
pub use self::notification::Image as NotificationImage;
pub use self::notification::Notification;
pub use self::notification::Sound as NotificationSound;
pub use self::sysbar::SysBar;
|
use itertools::Itertools;
use std::collections::{HashMap, HashSet};
use std::fs;
type Position = [isize; 3];
type Vector = [isize; 3];
fn main() {
let filename = "input/test.txt";
let relative_beacon_positions_to_scanners = parse_input_file(filename);
let num_scanners = relative_beacon_positions_to_scanne... |
#[doc = "Register `RX_ORDSET` reader"]
pub type R = crate::R<RX_ORDSET_SPEC>;
#[doc = "Field `RXORDSET` reader - RXORDSET"]
pub type RXORDSET_R = crate::FieldReader;
#[doc = "Field `RXSOP3OF4` reader - RXSOP3OF4"]
pub type RXSOP3OF4_R = crate::BitReader;
#[doc = "Field `RXSOPKINVALID` reader - RXSOPKINVALID"]
pub type ... |
// < begin copyright >
// Copyright Ryan Marcus 2020
//
// See root directory of this project for license terms.
//
// < end copyright >
use crate::models::*;
use superslice::*;
use crate::models::utils::{plr, radix_index};
const NUM_RADIX_BITS: u8 = 20;
fn bottom_up_plr(data: &ModelDataWrapper) -> (Vec<u64>, ... |
pub mod temperature_conversion {
/// Represents a valid temperature in Fahrenheit or Celsius
pub enum Temperature {
F(f64),
C(f64),
}
// Convert Fahrenheit to Celsius
fn farenheit_to_celsius(f: f64) -> f64 {
(f - 32.0) * (5.0 / 9.0)
}
// Convert Celsius to Fahrenhei... |
// The `Iterator` trait is used to implement iterators over collections
// such as arrays.
//
// The trait requires only a method to be defined for the `next` element,
// which may be manually defined in an `impl` block or automatically
// defined (as in arrays and ranges).
//
// As a point of convenience for common ... |
pub mod user;
pub mod product; |
use proc_macro::TokenStream;
use quote::quote;
use syn;
#[proc_macro_derive(BindUniform)]
pub fn bind_uniform_derive(input: TokenStream) -> TokenStream {
let ast: syn::DeriveInput = syn::parse(input).unwrap();
let ident = &ast.ident;
let data = if let syn::Data::Struct(data) = &ast.data {
data
} else {
... |
//inner http client
trait HttpClient {
fn get(&self, path: &str) -> u16;
}
struct DefaultHttpClient {}
impl Default for DefaultHttpClient {
fn default() -> Self {
DefaultHttpClient{}
}
}
impl HttpClient for DefaultHttpClient {
fn get(&self, url: &str) -> u16 {
let resp = reqwest::get(u... |
extern {
fn test_start(f: extern fn());
fn test_end();
fn CppTest();
}
fn main() {
unsafe {
CppTest();
test_start(test_middle);
}
}
struct A;
impl Drop for A {
fn drop(&mut self) {
panic!()
}
}
extern fn test_middle() {
let _a = A;
foo();
}
fn foo() {
... |
use image;
use num_complex;
use colorscale;
use std::fs::File;
use std::env;
fn main() {
let mut param: Vec<String> = env::args().collect();
if param[1] == "animate" {
let file_out = File::create("animation.gif").unwrap();
let mut encoder = image::gif::GifEncoder::new(file_out);
le... |
use super::{ConnectorOptions, IntifaceCLIErrorEnum, IntifaceError};
use super::frontend::{self, FrontendPBufChannel};
use argh::FromArgs;
#[cfg(target_os = "windows")]
use buttplug::server::comm_managers::xinput::XInputDeviceCommunicationManagerBuilder;
use buttplug::server::{
comm_managers::{
btleplug::BtlePlug... |
use amethyst::{
assets::Loader,
ecs::Entity,
prelude::*,
ui::{Anchor, TtfFormat, UiText, UiTransform},
};
pub struct FpsText {
pub fps: Entity,
}
pub fn init_fps_display(world: &mut World) {
let font = world.read_resource::<Loader>().load(
"resources/fonts/square.ttf",
TtfForma... |
use charts::{Chart, ScaleLinear, MarkerType, PointLabelPosition, Color, ScatterView};
pub fn save_chart(data: &Vec<(f64, f64)>, labels: &(String, String)) {
let width = 1000;
let height = 700;
let (top, right, bottom, left) = (50, 40, 50, 60);
let mut parsed: Vec<(f32, f32)> = Vec::new();
for el in data {
... |
extern crate clap;
use clap::{Arg, App};
mod display;
mod clock;
fn main() {
let matches = App::new("fiv")
.version("0.1.0")
.author("kevin970401 <kevin970401@gmail.com>")
.about("fast image Viewer")
.arg(Arg::... |
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
match args.len() {
1 => {
println!("引数の個数が正しくありません");
}
2 => {
let number: i32 = match args[1].parse() {
Ok(x) => x,
Err(_) => {
eprintln... |
use serde::{Deserialize, Serialize};
use std::time::{Duration, SystemTime};
use crate::protocol::Protocol;
const HEADER: u8 = 0xc3;
#[derive(Copy, Clone, Serialize, Deserialize, Debug)]
pub enum FanStrength {
Low = 0x3,
Medium = 0x2,
High = 0x1,
Auto = 0x5,
}
#[derive(Copy, Clone, Serialize, Deseria... |
pub mod note_archive;
pub use note_archive::*;
pub mod user;
pub mod client;
pub mod goal;
pub mod collateral;
pub mod pronouns;
pub mod note_day;
pub mod note;
pub mod utils;
pub mod constants;
pub mod blank_enums;
pub const USR_FL: &str = "users.txt";
pub const CLT_FL: &str = "clients.txt";
pub const G_FL: &str = "... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.