text stringlengths 8 4.13M |
|---|
use z80::Z80;
/*
** ADD A, r|(hl)|$xx
** Condition Bits: R0RR
** Clocks:
** r: 1
** $xx: 2
** hl: 2
*/
pub fn add_a(z80: &mut Z80, op: u8) {
let a = z80.r.a;
let val = match op {
0xC6 => {
z80.r.pc += 1;
z80.mmu.rb(z80.r.pc - 1)
},
0x86 => z80.mmu.r... |
use near_sdk::serde_json::json;
use near_sdk::AccountId;
use near_sdk_sim::transaction::ExecutionStatus;
use near_sdk_sim::DEFAULT_GAS;
use near_sdk::json_types::{U128, U64};
use crate::utils::init_without_macros as init;
// /**
// * FluxAggregator tests were ported from this file https://github.com/smartcontractkit... |
use crate::ErasureCoding;
use blst_rust::types::g1::FsG1;
use kzg::G1;
use std::iter;
use std::num::NonZeroUsize;
use subspace_core_primitives::crypto::kzg::Commitment;
use subspace_core_primitives::crypto::Scalar;
// TODO: This could have been done in-place, once implemented can be exposed as a utility
fn concatenate... |
use oxygengine::user_interface::raui::core::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(PropsData, Debug, Clone, Serialize, Deserialize)]
pub struct MenuState {
pub opened: bool,
}
impl Default for MenuState {
fn default() -> Self {
Self { opened: false }
}
}
|
#[doc(
brief = "Communication between tasks",
desc = "
Communication between tasks is facilitated by ports (in the receiving
task), and channels (in the sending task). Any number of channels may
feed into a single port. Ports and channels may only transmit values
of unique types; that is, values that are statica... |
pub mod fetch;
pub(crate) mod routing;
|
//! This crate only exists to work around Cargo bug [#5015].
//!
//! [#5015]: https://github.com/rust-lang/cargo/issues/5015
|
#[doc = "Register `DCKCFGR` reader"]
pub type R = crate::R<DCKCFGR_SPEC>;
#[doc = "Register `DCKCFGR` writer"]
pub type W = crate::W<DCKCFGR_SPEC>;
#[doc = "Field `TIMPRE` reader - TIMPRE"]
pub type TIMPRE_R = crate::BitReader<TIMPRE_A>;
#[doc = "TIMPRE\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)... |
use crate::item::*;
use crate::rect::*;
use crate::vec2::*;
use modelone::object::ApplyContext;
use modelone::change_value::ValueChange;
/// Describes the relationship of one item to another.
pub enum AnchorRelation {
Parent,
Sibling,
}
/// These are choices of combinations to anchor to.
pub enum AnchorFrom {
Non... |
extern crate rand;
extern crate image;
pub mod field;
#[test]
fn it_works() {
}
|
use std::fmt::Display;
use crate::{
scanner::{Token, TokenKind},
value::Value,
};
#[derive(thiserror::Error, Debug)]
pub enum InterpretError {
#[error(transparent)]
Compile(#[from] CompileError),
#[error(transparent)]
Runtime(#[from] RuntimeError),
}
#[derive(thiserror::Error, Debug)]
pub enu... |
#[no_mangle]
pub extern fn fibonacci_recursive(n: u32) -> u64 {
match n {
0 => 0,
1 => 1,
_ => fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2),
}
}
#[no_mangle]
pub extern fn fibonacci_non_recursive(n: u32) -> u64 {
match n {
0 => return 0,
1 => return 1,
... |
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>,... |
#[allow(dead_code, unused_attributes, bad_style)]
mod ffmpeg_ffi;
#[macro_use]
mod macroses;
mod codec;
pub mod error;
mod ffmpeg_const;
mod format;
mod resample;
#[link(name = "avutil")]
#[link(name = "avcodec")]
#[link(name = "avformat")]
#[link(name = "swresample")]
extern "C" {}
pub use codec::{Codec, Decoder, En... |
use crate::{content, message::*, saved, subscribe_irc, util, view};
use anyhow::Result;
use iced::{button, pane_grid, text_input, Application, Command, Element, Subscription};
use std::{collections::HashMap, sync::Arc};
// Do not use sync::Mutex to avoid dead lock
use futures::lock::Mutex;
// アプリケーションが保持する全ての情報
#[der... |
extern crate ocl;
use ocl::Buffer;
use ocl::ProQue;
use crate::scene_objects::scene_object::SceneObject;
use ocl::prm::{Uchar8, Float16};
use ocl::flags::MemFlags;
pub struct Scene {
scene_objects: Vec<Box<dyn SceneObject>>
}
impl Scene {
pub fn new() -> Self {
Scene {scene_objects: Vec::new()}
}
pub f... |
pub mod branch;
pub mod cast;
pub mod core;
pub mod op;
pub mod ty;
pub mod value;
|
use std::io::prelude::*;
use mio::*;
use mio::tcp::*;
use std::collections::HashMap;
use event_loop::*;
pub trait App : Send + 'static {
fn handle(&mut self, stream: &mut TcpStream);
fn duplicate(&self) -> Box<App>;
}
struct AppWithStream {
app: Box<App>,
stream: TcpStream,
}
impl AppWithStream {
... |
pub mod publishing;
|
use crate::container::responses::AcquireLeaseResponse;
pub type RenewLeaseResponse = AcquireLeaseResponse;
|
extern crate rabbit;
use std::borrow::Cow;
const KEYLEN: usize = 16;
const PADSTR: &'static str = "Thisismypadding!";
pub fn init(key: &str) -> rabbit::Rabbit {
let cipher: rabbit::Key = pad_key(key).as_bytes().into();
return rabbit::Rabbit::new(&cipher);
}
pub fn encrypt<'a>(rabbit: &mut rabbit::Rabbit, dat... |
struct ChristmasDay {
day: String,
gift: String,
}
fn main() {
let christmas_days: [ChristmasDay; 12] = [
ChristmasDay {
day: "first".to_string(),
gift: "a Partridge in a Pear Tree".to_string(),
},
ChristmasDay {
day: "second".to_string(),
... |
extern crate config as rsconfig;
use std::collections::HashMap;
use std::env;
use std::path::PathBuf;
use color::Color;
#[derive(Deserialize)]
pub struct Config {
pub dpi: f64,
pub colors: HashMap<String, Color>,
pub mpd: MpdConfig,
}
#[derive(Deserialize)]
pub struct MpdConfig {
pub host: Str... |
extern crate cc;
extern crate bindgen;
use std::process::Command;
use std::path;
fn main() {
let out_dir = std::env::var_os("OUT_DIR").map(|s| path::PathBuf::from(s).join("x264-build")).unwrap();
//let out_dir = std::env::current_dir().unwrap();
let install_dir = out_dir.join("x264-build");
let inner... |
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apache
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
* of this source tree.
*/
//! A... |
use std::sync::Once;
use std::sync::ONCE_INIT;
use std::cell::RefCell;
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::collections::LinkedList;
use util::AtomicOption;
use util::ArcCell;
use std::marker::PhantomData;
static mut EMPTY_SUB_REF: Opti... |
pub use core::prelude::v1::*;
pub use alloc::prelude::v1::*;
pub use alloc::{format, vec};
pub use core::mem::size_of;
pub use core::marker::PhantomData;
pub use core::ptr::{self, null, null_mut};
pub use core::cell::RefCell;
pub use sys_consts::SysErr;
pub use lazy_static::lazy_static;
pub use x86_64::{PhysAddr, Virt... |
pub mod instructions;
pub mod frame;
use super::objects::{ObjectRef, ObjectContent, Object};
use super::varstack::VarStack;
use self::instructions::{CmpOperator, Instruction};
use self::frame::{Block, Frame};
use std::fmt;
use std::collections::HashMap;
use std::io::Read;
use std::cell::RefCell;
use std::rc::Rc;
use s... |
// 16.22 Langton's Ant
// The grid will be represented by a map of coordinates.
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
struct V2 {
x: i32,
y: i32,
}
use std::{collections::HashMap, fmt};
impl std::ops::Add for V2 {
type Output = Self;
fn add(self, rhs: Self) -> Self {
V2 {
... |
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#![deny(warnings)]
#[macro_use]
extern crate clap;
#[macro_use]
extern crate failure;
extern crate fidl;
extern crate fidl_fuchsia_wlan_device as wlan;
ex... |
#![feature(globs)]
#![crate_type = "bin"]
#![feature(slicing_syntax)]
extern crate bmp;
use std::cmp::min;
use std::io;
use std::io::BufferedReader;
use std::os;
fn main() {
let args = os::args();
let orig_file_path = args[1].as_slice();
let b_img = bmp::BMPimage::open(orig_file_path);
let width = b_img.wi... |
use super::*;
use util::Error;
#[test]
fn test_tcp_type() -> Result<(), Error> {
//assert_eq!(TCPType::Unspecified, tcpType)
assert_eq!(TcpType::Active, TcpType::from("active"));
assert_eq!(TcpType::Passive, TcpType::from("passive"));
assert_eq!(TcpType::SimultaneousOpen, TcpType::from("so"));
ass... |
use url::Url;
use regex::Regex;
pub struct LinkParser {
base_url: Url,
}
impl LinkParser {
pub fn new(url: Url) -> LinkParser {
LinkParser {
base_url: url
}
}
pub fn parse(self, data: &str) -> Vec<Url> {
lazy_static! {
static ref PATTERNS : String = ve... |
#![no_std]
#![no_main]
program!(0xFFFFFFFE, "GPL");
use redbpf_probes::{bindings::udphdr, net::Transport, xdp::prelude::*};
#[xdp("redirect")]
pub fn redirect(ctx: XdpContext) -> XdpResult {
if let Ok(Transport::UDP(udp)) = ctx.transport() {
unsafe {
if u16::from_be((*udp).dest) == 7999 {
... |
// #![feature(duration_as_u128)]
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::{Duration, SystemTime};
use std::sync::mpsc;
// use std::thread::JoinHandle;
fn main() {
let (tx, rx) = mpsc::channel();
let now = SystemTime::now();
let handle = thread::spawn(move || {
{
// ... |
use super::*;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename = "line")]
pub struct Line {
pub x1: isize,
pub y1: isize,
pub x2: isize,
pub y2: isize,
}
impl Line {
pub fn new(x1: isize, y1: isize, x2: isize, y2: isize) -> Self
{
Self {
x1, y1, x2... |
#![allow(unknown_lints, needless_borrow)]
use quote;
use syn;
use syn::MetaItem::*;
use syn::Lit::*;
#[derive(Default, PartialEq, Debug)]
struct GlobalAttrData {
default_prefix: Option<String>,
}
fn get_smelter_attributes(attrs: &[syn::Attribute]) -> Vec<syn::MetaItem> {
let smelter_ident = syn::Ident::new(... |
#[cfg(test)]
mod bencho {
use for_each_element;
use serde_json;
use serde_json::{Deserializer, Value};
use IDHolder;
use test::Bencher;
#[bench]
fn name(b: &mut Bencher) {
let data: Vec<serde_json::Value> = (0..20000)
.map(|_| {
json!({
... |
// Copyright 2015-2016 Joe Neeman.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except accordin... |
use interpreter::Interpreter;
use parser::Parser;
use resolver::Resolver;
use scanner::Scanner;
mod ast;
mod environment;
mod interpreter;
mod parser;
mod resolver;
mod scanner;
mod token;
mod value;
struct Lox {}
impl Lox {
pub fn new() -> Self {
Self {}
}
pub fn run(&mut self, source: String) ... |
fn main() {
proconio::input! {
N: usize,
C: [[i32; N]; N]
}
let mut cmin = std::i32::MAX;
let mut ci: usize = 0;
let mut cj: usize = 0;
for i in 0..N {
for j in 0..N {
if C[i][j] < cmin{
cmin = C[i][j];
ci = i;
... |
pub enum DeviceEvent {
KeyPress,
KeyRelease,
ButtonPress,
ButtonRelease,
PointerMotion,
Button1Motion,
Button2Motion,
Button3Motion,
Button4Motion,
Button5Motion,
ButtonMotion,
} |
#[doc = "Reader of register FM_HV_DATA[%s]"]
pub type R = crate::R<u32, super::FM_HV_DATA>;
#[doc = "Writer for register FM_HV_DATA[%s]"]
pub type W = crate::W<u32, super::FM_HV_DATA>;
#[doc = "Register FM_HV_DATA[%s] `reset()`'s with value 0"]
impl crate::ResetValue for super::FM_HV_DATA {
type Type = u32;
#[i... |
use amethyst::{
core::{
transform::Transform,
//SystemDesc,
},
derive::SystemDesc,
ecs::{
Join,
ReadExpect,
System,
Entity,
SystemData,
//World,
Write,
WriteStorage
},
ui::UiText
};
use crate::game::*;
#[derive(SystemDesc)]
pub struct WinningSystem;
impl<'s>... |
use std::cell::RefCell;
use std::collections::HashSet;
use std::rc::Rc;
use std::sync::Arc;
use std::{cmp, fmt, mem};
use {Node, Value};
#[derive(Clone)]
enum Type {
Unit,
Sum(RcVar, RcVar),
Product(RcVar, RcVar),
}
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
pub enum FinalTypeInner {
Uni... |
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![feature(macro_rules)]
//#![feature(globs)]
fn return_subslice(s: &[u8]) -> &[u8]{
s.slice(2,s.len())
}
fn slice_out_first_two<T> (s: &[T]) -> &[T]{
assert!(s.len()>=2);
s.slice(0,2)
}
fn slice_out_first_two_nested<T> (s: &[T]) -> &... |
use clint::*;
use log::debug;
use std::thread::Builder;
use tokio;
use tokio::sync::mpsc::unbounded_channel;
const HELP: &str = "Async Interactive client built on tokio example";
fn print_help(config: &Config) {
let mut help = HELP.to_owned();
if let Some(cmd) = &config.exit_command {
help = format!("... |
use std::{borrow::Cow, fmt, time::Duration};
use serde::Serialize;
pub use crate::sdam::description::{server::ServerType, topology::TopologyType};
use crate::{
bson::DateTime,
error::Error,
hello::HelloCommandResponse,
options::ServerAddress,
sdam::ServerDescription,
selection_criteria::TagSet... |
use std::collections::btree_map;
use std::error::Error;
use crate::table::{Chamber, Row, Table, TableSchema};
#[derive(Debug)]
crate struct WhereSubcommand {
// XXX TODO: starting out with supporting just a single `column = value`
// condition, but should eventually expand to conj-/dis-junctions, &c.
//
... |
use crate::kernel::opcode;
use crate::kernel::stream::{self, statement::StatementStream};
use crate::kernel::State;
#[derive(Debug)]
pub struct Statement {
pub code: opcode::Statement,
pub proof: Option<(usize, usize)>,
}
#[derive(Debug)]
pub struct StatementIter {
data: std::vec::IntoIter<Statement>,
... |
use equality::precise::Vector2;
#[no_mangle]
fn extern "C" fn vector2_new() -> Vector2 {
}
|
//! Derive input types defined with `darling`.
//!
//! They parse `#[attributes(..)]` syntax in a declartive style.
use darling::*;
use syn::*;
// pub type Data = ast::Data<VariantArgs, FieldArgs>;
pub type Fields = ast::Fields<FieldArgs>;
#[derive(FromDeriveInput)]
#[darling(attributes(inspect), supports(struct_any... |
// import the flatbuffers runtime library
extern crate flatbuffers;
// import the generated code
#[allow(dead_code, unused_imports, non_snake_case)]
#[path = "./network_protocol_generated.rs"]
mod network_protocol_generated;
pub use network_protocol_generated::com::ibm::amoeba::common::network::protocol;
use crate::tr... |
use std::fs::File;
use std::io;
use std::io::prelude::*;
static mut FIRST_RUN: bool = true;
fn main() {
unsafe {
if FIRST_RUN {
FIRST_RUN = false;
println!("SMD Fixer v2.0.8 by Ali Deym\n");
}
}
println!("Enter file name (or exit): ");
let mut filename =... |
use std::cmp::{Ordering};
#[derive(PartialEq, Eq)]
pub enum LinkLayerType {
Novell8023,
Ethernet2,
}
#[derive(PartialEq, Eq)]
pub enum NetworkLayerType {
ARP,
IPv4,
IPv6,
Other,
}
#[derive(PartialEq, Eq)]
pub enum TransportLayerType {
ICMP,
TCP,
UDP,
Other,
}
#[derive(Partial... |
use super::{ENDPOINT, USERNAME};
use crate::client::{Claims, Jwt, UnauthorizedClient};
use crate::{CLIENT_CERT, CLIENT_KEY, SERVER_CA_CERT};
use anyhow::Result;
use serial_test::serial;
use server::server;
use std::collections::HashMap;
use tonic::transport::{Certificate, Identity};
#[tokio::test]
#[serial]
async fn s... |
fn main() {
let _a: i16 = -150;
let _b = -150 as i16;
let _c = -150 + _b - _b;
let _d = -150i16;
}
|
trait AbstractDisplay {
fn open(&self);
fn print(&self);
fn close(&self);
fn display(&self) {
self.open();
for i in 1..5 {
self.print();
}
self.close();
}
}
struct CharDisplay {
ch: char,
}
impl CharDisplay {
fn new(ch: char) -> CharDisplay {
... |
use serde::{Deserialize, Serialize};
use specs::error::NoError;
use specs::prelude::*;
use specs::saveload::{ConvertSaveload, Marker};
use specs_derive::*;
// Helper for serializing entities in serde
pub struct EntityMarker;
#[derive(Component, ConvertSaveload, Copy, Clone)]
pub struct FPSTracker {
pub for_time: ... |
use ncurses::{ACS_BLOCK, WINDOW, box_, mvwaddch, wrefresh};
use crate::chip8::{CHIP_WIDTH, CHIP_HEIGHT};
pub struct Screen {
window: WINDOW
}
impl Screen {
pub fn new(window: WINDOW) -> Self {
Screen {
window: window
}
}
pub fn update(&self, vram: [[bool; CHIP_WIDTH]; CHIP_HEIGHT]) {
fo... |
// Copyright 2017 The Grin Developers
//
// 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 agree... |
#![warn(clippy::pedantic)]
use libcnb_test::{assert_contains, BuildConfig, ContainerConfig, ContainerContext, TestRunner};
use std::time::Duration;
const PORT: u16 = 8080;
fn test_node(fixture: &str, builder: &str, expect_lines: &[&str]) {
TestRunner::default().build(
BuildConfig::new(builder, format!(".... |
#[derive(Debug, Deserialize, PartialEq, Eq, Clone)]
pub struct FilterOutput {
pub stream_label: String,
}
|
use eyre::eyre;
use eyre::Result;
use hotwatch::Event;
use lazy_static::lazy_static;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use serde::Serialize;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::fmt::Debug;
use std::fs;
use std::path::PathBuf;... |
use std::process::Child;
use crate::units::Second;
pub mod wallclocktimer;
#[cfg(windows)]
mod windows_timer;
#[cfg(windows)]
pub use self::windows_timer::get_cpu_timer;
#[cfg(not(windows))]
mod unix_timer;
#[cfg(not(windows))]
pub use self::unix_timer::get_cpu_timer;
/// Defines start functionality of a timer.
pu... |
// Iterator trait: https://doc.rust-lang.org/std/iter/trait.Iterator.html
// General information, including how to implement an iterator: https://doc.rust-lang.org/std/iter/index.html
fn main() {
}
#[test]
fn consuming() {
let v1 = vec![1, 2, 3];
let v1_iter = v1.iter(); // this consumes
// `sum` takes o... |
pub struct SQLParser {}
impl SQLParser {
pub fn new() -> SQLParser {
let sm = SQLParser {};
sm
}
}
|
pub mod hittable;
pub mod material;
pub mod sphere;
|
extern crate chrono;
mod settings;
use structopt::StructOpt;
use sustl::sustenance::*;
use sustl::sustenance_type::*;
use toduitl::journal::Journal;
use std::str::FromStr;
use settings::*;
#[derive(StructOpt)]
struct Cli {
#[structopt(subcommand)]
action: Action,
}
#[derive(StructOpt)]
enum Action {
Cre... |
use crate::headers;
use azure_core::AddAsHeader;
use http::request::Builder;
/// A collection of keys to partition on
///
/// You can learn more about partitioning [here](https://docs.microsoft.com/en-us/azure/cosmos-db/partitioning-overview)
pub type PartitionKeys = crate::to_json_vector::ToJsonVector;
impl AddAsHea... |
/// Replicates the Fn traits for stable build
pub trait StableFnOnce<Input> {
type Output;
fn stable_call_once(self,args:Input) -> Self::Output;
}
/// Replicates the Fn traits for stable build
pub trait StableFnMut<Input>: StableFnOnce<Input> {
fn stable_call_mut(&mut self,args:Input) -> Self::Output;
}
///... |
use std::path::Path;
use protobuf::stream::CodedInputStream;
use misc::*;
use zbackup::data::*;
use zbackup::disk_format::*;
use zbackup::disk_format::protobuf_types as raw;
pub struct DiskBackupInfo {
raw: raw::BackupInfo,
}
impl DiskBackupInfo {
pub fn read (
coded_input_stream: & mut CodedInputStream,
) ->... |
#![allow(dead_code)]
use std::marker::PhantomData;
use expr::*;
use fun::*;
use symbol::*;
pub struct Nil{}
impl Expr for Nil {
fn to_string() -> String {
"nil".to_string()
}
}
pub struct ConsCell<T1: Expr, T2: Expr> {
p1: PhantomData<T1>,
p2: PhantomData<T2>,
}
impl <T1: Expr, T2: Expr> Expr ... |
use crate::hash;
use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
use std::env;
use sysinfo::{CpuExt, System, SystemExt};
/// Describes a fingerprinted system.
///
/// ```
/// # use sightglass_fingerprint::Machine;
/// println!("Current machine fingerprint: {:?}", Machine::fingerprint());
/// ```
#[d... |
#[cfg(test)]
mod file_tests {
#[test]
fn it_counts_points_in_file() {
laszip::load_laszip_library();
let laz = laszip::LazReader::from_file("../data/building.laz");
assert_eq!(1473, laz.unwrap().get_number_of_points().unwrap());
}
}
|
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate serde_derive;
extern crate actix;
extern crate actix_web;
extern crate chrono;
extern crate dotenv;
extern crate env_logger;
extern crate futures;
extern crate num_cpus;
extern crate rand;
extern crate serde;
extern crate serde_json;
use actix::*;
use actix_w... |
use crate::metrics::MixMetric;
use reqwest::Response;
pub struct Request {
base_url: String,
path: String,
}
pub trait MetricsMixPoster {
fn new(base_url: String) -> Self;
fn post(&self, metric: &MixMetric) -> Result<Response, reqwest::Error>;
}
impl MetricsMixPoster for Request {
fn new(base_url... |
//! MetroBus route related enum and methods.
use crate::{
bus::{client::responses, traits::NeedsRoute},
date::Date,
error::Error,
location::RadiusAtLatLong,
requests::Fetch,
};
use serde::{
de::{Deserializer, Error as SerdeError},
Deserialize,
};
use std::{error, fmt, str::FromStr};
/// All... |
#![recursion_limit = "128"]
#[macro_use]
extern crate helix;
extern crate chrono;
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
use evtx::{EvtxParser, ParserSettings};
use std::path::PathBuf;
use std::time::SystemTime;
ruby! {
class EventAfter {
struct {
ts: i64,
rn: Option... |
use std::cmp;
use crate::error::ReturnError;
use crate::traits::{self, MakingUrlFormat};
#[cfg(feature = "async_mode")]
use crate::request_async;
#[cfg(feature = "sync_mode")]
use crate::request_sync;
/// provides users an option menu to choose one of the return format.
///
/// Users are expected to use appropriat... |
tonic::include_proto!("as/api");
|
use super::*;
#[derive(Debug, Clone, PartialEq)]
pub struct VocabularyVec<IndexT: ToFromUsize, CountT: ToFromUsize> {
pub ids: Vec<IndexT>,
pub vocabulary: Vocabulary<IndexT>,
pub counts: Vec<CountT>,
}
impl<IndexT: ToFromUsize, CountT: ToFromUsize> VocabularyVec<IndexT, CountT> {
pub fn default() -> ... |
use core::ptr;
// TODO: This SPI driver needs more testing...
pub struct Spi<'a> {
_lease: lease_ty!('a, SpiLease),
base_reg: u32,
}
bf!(SpiFifoCntReg[u32] {
baudrate: 0:5,
dev_select: 6:7,
is_outgoing: 13:13,
busy: 15:15
});
#[derive(Clone, Copy)]
#[allow(non_camel_case_types)]
enum Reg {
... |
//! Serde deserialize for password hashes
//!
//! The output from a hashing algorithm typically includes: the hash itself,
//! the salt, and the parameters used in the hashing.
//! This allows us to store the output in an unambigous fashion.
//!
//! However, not all algorithms had this foresight, and many instead wrote... |
use crate::schema::persons;
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
#[derive(GraphQLObject, PartialEq, Queryable, Debug, Serialize, Deserialize)]
pub struct Person {
pub id: i32,
pub name: String,
pub email: Option<String>,
pub phone: Option<String>,
pub tags: Vec<String>,
... |
use crate::types::{Face, Vertex};
pub fn rect() -> (Vec<Vertex>, Vec<Face>) {
let normal = [0., 0., 1.];
let tangent = [1., 0., 0.];
let v = vec![
Vertex {
position: [-0.5, 0.5, 0.],
normal,
uv: [0., 1.],
tangent,
},
Vertex {
... |
use std::fs::File;
use std::io::prelude::*;
use serde_json::{Value, Error};
use serde_json;
use models::Observables;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct CartesianPoint {
pub x: Option<f64>,
pub y: Option<f64>,
pub z: f64,
}
#[derive(Serialize, Deserialize, Debug)]
pub enum PlotTyp... |
use std::num::ParseIntError;
use std::convert;
use std::fmt;
use std::error::Error;
#[derive(Debug)]
struct AppError(String);
macro_rules! to_apperr {
($e:ident, $m:expr) => {
impl convert::From<$e> for AppError {
fn from(error: $e) -> AppError {
AppError(format!($m, error.descr... |
//multi return value
pub fn func_mult_return(x: i32, y: i32) -> (i32, i32) {
println!("{}", "-------------------------------");
println!("{}", x + y);
println!("{}", "-------------------------------");
(y, x)
}
//..会产生一个iterator ,它包含左边的数,排除在右边的数。
// 为了得到一个包含两端的范围的iterator,使用...符号
pub fn for_func() {
... |
//! Responses for DNS Commands
use atat::atat_derive::AtatResp;
use heapless::{consts, String};
/// 24.1 Resolve name / IP number through DNS +UDNSRN
#[derive(Clone, PartialEq, AtatResp)]
pub struct ResolveNameIpResponse {
#[at_arg(position = 0)]
pub ip_domain_string: String<consts::U128>,
}
|
use core;
#[panic_handler]
pub fn panic_handler(info: &core::panic::PanicInfo) -> ! {
log!("PANIC PANIC PANIC PANIC PANIC");
::input_barrier();
::gfx::log_clear();
log!("PANIC PANIC PANIC PANIC PANIC");
log!("{}", info);
log!("Press SELECT to power off.");
::gfx::draw_commit();
:... |
extern crate clap;
extern crate pgen;
extern crate serde_json;
#[cfg(not(test))]
fn main() {
use clap::{App, Arg};
let matches = App::new("Mongo DB Aggregation Pipeline Generator")
.version("0.3")
.author("Patrick Meredith <pmeredit@gmail.com>")
.about("Compiles an easy-to-use ML-like ... |
use std::io;
use std::fs;
use std::collections::VecDeque;
#[derive(Debug, PartialEq)]
enum ParamMode {
Position,
Immediate,
}
fn param_mode(digit: isize) -> ParamMode {
match digit {
0 => ParamMode::Position,
1 => ParamMode::Immediate,
_ => panic!("invalid parameter mode: {}", digit),
}
}
f... |
use std::path::PathBuf;
use anyhow::{ensure, Result};
use eth2_network_libp2p::NetworkConfig;
use serde::Deserialize;
use thiserror::Error;
#[derive(Debug, Error)]
enum Error {
#[error("missing executable path")]
MissingExecutablePath,
#[error("missing configuration")]
MissingConfiguration,
#[erro... |
extern crate diesel;
extern crate r2d2;
extern crate r2d2_diesel;
use diesel::PgConnection;
use r2d2_diesel::ConnectionManager;
pub type Pool = r2d2::Pool<ConnectionManager<PgConnection>>;
pub fn get_db_pool() -> Pool {
let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let manage... |
#[derive(Clone, Copy)]
pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
#[macro_export]
macro_rules! color {
($r:expr, $g:expr, $b:expr) => { Color { r: $r as f32, g: $g as f32, b: $b as f32, a: 1.0 } };
($r:expr, $g:expr, $b:expr, $a:expr) => { Color { r: $r as f32, g: $g as f32, b: $b as f3... |
use alga::general::{Real, SubsetOf, SupersetOf};
use alga::linear::Rotation;
use core::{SquareMatrix, OwnedSquareMatrix};
use core::dimension::{DimName, DimNameAdd, DimNameSum, U1};
use core::storage::OwnedStorage;
use core::allocator::{Allocator, OwnedAllocator};
use geometry::{PointBase, TranslationBase, IsometryBa... |
use std::fmt::{self, Display, Formatter};
use std::result;
use crate::compiler::lexer::Line;
/// Wrapped for parsing time errors
pub type Result<T> = result::Result<T, Error>;
/// Some Errors produced by parser and lexer which be dealt by parser for reporting syntax errors
#[derive(Debug, Clone, Eq, Partial... |
#[macro_use]
extern crate bitflags;
use byteorder::BigEndian;
use byteorder::ReadBytesExt;
use bytes::Buf;
use std::env;
use std::io::{self, BufRead, Cursor, Read, Write};
use std::net::{Shutdown, SocketAddr};
use std::sync::{Arc, Mutex};
use tokio;
use tokio::io::{copy, shutdown};
use tokio::net::{TcpListener, TcpStr... |
use azure_core::AddAsHeader;
use http::request::Builder;
use http::HeaderMap;
use std::borrow::Cow;
use std::collections::HashMap;
use std::convert::TryFrom;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Properties<'a, 'b>(HashMap<Cow<'a, str>, Cow<'b, str>>);
const HEADER: &str = "x-ms-properties";
impl<'a, 'b>... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.