text stringlengths 8 4.13M |
|---|
use crate::container::incomplete_vector_from_container_response;
use crate::container::responses::ListContainersResponse;
use crate::core::prelude::*;
use azure_core::headers::add_optional_header;
use azure_core::headers::request_id_from_headers;
use azure_core::prelude::*;
use futures::stream::{unfold, Stream};
use ht... |
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct OAuth2Application {
pub client_id: Option<String>,
pub client_secret: Option<String>,
pub created: Option<String>,
pub id: Option<i64>,
pub name: Option<String>,
pub redirect_uris: Option<Vec<String>>,
}
impl OAuth2Application ... |
use hydroflow::tokio_stream::wrappers::IntervalStream;
use hydroflow::util::cli::{ConnectedDemux, ConnectedDirect, ConnectedSink};
use hydroflow::util::serialize_to_bytes;
use hydroflow_datalog::datalog;
#[hydroflow::main]
async fn main() {
let mut ports = hydroflow::util::cli::init().await;
let broadcast_port... |
use crate::days::day7::{parse_input, default_input, Bag};
use std::collections::{HashMap, HashSet, VecDeque};
pub fn run() {
println!("{}", color_bags_str(default_input()).unwrap())
}
pub fn color_bags_str(input : &str) -> Result<i32, ()> {
color_bags(parse_input(input))
}
pub fn color_bags(rules : HashMap<S... |
use console::style;
use dialoguer::{theme, Input, Select};
use std::fs;
use std::path::{Path, PathBuf};
use shared_child::SharedChild;
use std::sync::Arc;
use std::sync::RwLock;
use std::net::TcpStream;
use std::net::ToSocketAddrs;
use crate::er::{self, Result};
pub struct ConfigDir(pub PathBuf);
impl ConfigDir {
... |
extern crate mioco;
extern crate time;
use mioco::Mioco;
fn skynet(num: u32, size: u32, div: u32) -> u64 {
if size == 1 {
return num as u64;
}
let mut sum = 0u64;
let mut v = Vec::with_capacity(div as usize);
for i in 0..div {
let sd: u32 = size / div as u32;
let sub_num... |
use std::path::Path;
use serde_json::Value;
use veloci::*;
use super::common;
static TEST_FOLDER: &str = "test_all";
lazy_static! {
static ref TEST_PERSISTENCE: persistence::Persistence = {
let indices = r#"
["*GLOBAL*"]
features = ["All"]
["commonness"]
facet = tr... |
pub mod bench;
pub mod bristol;
|
// Export the enum variants, without the enum
mod foo {
export t1;
enum t { t1, }
}
fn main() { let v = foo::t1; }
|
pub fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>()
.split_whitespace()
.map(|e| e.parse().ok().unwrap())
.collect()
}... |
// Make sure that fn-to-block coercion isn't incorrectly lifted over
// other tycons.
fn coerce(b: fn()) -> native fn() {
fn lol(f: native fn(fn()) -> native fn(),
g: fn()) -> native fn() { ret f(g); }
fn fn_id(f: native fn()) -> native fn() { ret f }
ret lol(fn_id, b);
//!^ ERROR mismatched... |
extern crate tch;
//use std::f64::consts::PI;
use tch::{kind, Tensor, manual_seed, no_grad};
use hello::{Distribution, MultivariateNormal, Scale};
fn main() {
// let sigma = Tensor::eye(8, kind::FLOAT_CPU);
// let sigma2 = sigma.expand(&[6, 1, 8, 8], true).contiguous();
// sigma2.requires_grad();
// le... |
use azure_core::Context;
use azure_cosmos::prelude::*;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
// First we retrieve the account name and master key from environment variables.
// We expect master keys (ie, not resource constrained)
let master_key ... |
use std::convert::TryFrom;
use std::io;
use std::io::Write;
use failure::Error;
use hyper::body::Buf;
use hyper::body::HttpBody;
use hyper::body::Sender;
use md5::digest::FixedOutput;
use md5::digest::Input;
use tokio::io::AsyncReadExt as _;
use tokio::io::AsyncWrite;
use tokio::io::AsyncWriteExt as _;
use tokio::prel... |
use anyhow::{Context, Result};
pub fn parse_rust_into_ast(rust_source: &str) -> Result<syn::File> {
syn::parse_str(rust_source).with_context(|| "Parse error")
}
|
use crate::helpers;
use std::env;
// Parallel tests on the same env variable causes problems.
// #[test]
// fn should_use_application_port_env_var_if_specified() {
// helpers::initialize();
// env::set_var("APPLICATION_PORT", "8001");
// let port = 8001;
// env::set_var("APPLICATION_PORT", port.to_str... |
struct Lyndon {
n: usize,
k: u8,
buf: Option<Vec<u8>>,
}
impl Lyndon {
fn new(n: usize, k: u8) -> Self { Self { n, k, buf: None } }
}
impl Iterator for Lyndon {
type Item = Vec<u8>;
fn next(&mut self) -> Option<Self::Item> {
match &mut self.buf {
None => {
// Initialise
let mut v = Vec::with_capac... |
use crate::chain_spec::{ChainSpec, TELEMETRY_URL};
use hex_literal::hex;
use jsonrpc_core::serde_json::Map;
use sc_service::{config::TelemetryEndpoints, ChainType};
#[cfg(not(feature = "parachain"))]
use sp_core::crypto::UncheckedInto;
use zeitgeist_primitives::{constants::BASE, types::AccountId};
pub fn battery_park_... |
extern crate cc;
use walkdir::WalkDir;
fn main() {
compile_and_link_c_files();
}
fn compile_and_link_c_files() {
let mut build = cc::Build::new();
// Recursively traverse all files add them to the compiler.
for entry in WalkDir::new("c_lib")
.into_iter()
.filter_map(Result::ok)
... |
use lmdb::{Cursor, Database, Environment, Transaction};
use std::collections::HashMap;
use std::fs::create_dir_all;
use std::path::PathBuf;
use thiserror::Error;
use crate::Record;
use crate::RoQuery;
/// Storage provides a simple interface for interacting with databases
pub struct Storage {
env: Environment,
... |
use std::slice;
fn get_node_value(l:&mut slice::Iter<usize>) -> usize{
let header = l.take(2).collect::<Vec<&usize>>();
let n_node = *header[0];
let n_metadata = *header[1];
let mut child_nodes = Vec::new();
for _ in 0..n_node {
child_nodes.push(get_node_value(l));
}
if n_node == ... |
///// chapter 3 "using functions and control structures"
///// program section:
//
fn main() {
let negafive = abs(-5);
println!("{}", negafive);
}
fn abs(x: i32) -> i32 {
if x > 0 { x } else { x * x }
}
///// output should be:
/*
*/// end of output
|
use bytes::{Buf, BytesMut};
use std::cmp::{self};
use std::collections::VecDeque;
use std::io::IoSlice;
pub fn fill_read_buf(src: &mut BytesMut, dst: &mut [u8]) -> usize {
if src.is_empty() {
return 0;
}
let mut n = src.len();
if n > dst.len() {
n = dst.len();
}
dst[0..n].copy_f... |
use failure::Fallible;
use protobuf_gen::Config;
#[test]
fn unittest_yellow_book() -> Fallible<()> {
env_logger::try_init().unwrap_or_default();
let mut config = Config::new("protos", Some("proxy"));
config.add_source("lib_tests/src/person.rs", "yellow_book");
config.add_source("lib_tests/src/city.rs... |
use super::toml_parser;
use super::toml_completeness;
use super::toml_generator;
use std::path::Path;
pub fn generate_build_toml(
input_file_name: &str,
output_file_name: &str,
update: bool,
) -> Result<(), ()> {
if Path::new(output_file_name).exists() && !update {
return Ok(());
}
let parsed_toml_at... |
/// Email an email address belonging to a user
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct Email {
pub email: Option<String>,
pub primary: Option<bool>,
pub verified: Option<bool>,
}
impl Email {
/// Create a builder for this object.
#[inline]
pub fn builder() -> EmailB... |
//!
//! This module gives a handler for the invalid opcode exception.
//!
use super::InterruptStackFrame;
pub extern "C" fn invalid_opcode_handler(esf: *const InterruptStackFrame) -> ! {
unsafe {
panic_args!("Invalid opcode \
\n\t\tInstruction Pointer: 0x{:x} \
\n\t\tCode segment: {} \
... |
use mantle::kernel;
use mantle::kio;
use ::core;
static mut DEFAULT_STACK: [u8; 65536] = [0; 65536];
extern {
fn mantle_main(bi: &kernel::BootInfo, executable_start: usize);
}
#[no_mangle]
#[naked]
pub unsafe extern fn _start() {
asm!("
.extern __executable_start
add $$65536, %rsp
andq $$0xffffffffff... |
use super::molecule::tab_menu::{self, TabMenu};
use super::organism::modal_resource::{self, ModalResource};
use crate::arena::{block, resource, ArenaMut, BlockKind, BlockMut, BlockRef};
use crate::libs::random_id::U128Id;
use isaribi::{
style,
styled::{Style, Styled},
};
use kagura::prelude::*;
use nusa::prelud... |
use crate::obj::Twzobj;
use crate::ptr::Pptr;
use std::ffi::c_void;
/* TODO: handle allocation failures */
extern "C" {
fn __runtime_twz_object_init_alloc(base: *const c_void, off: u64) -> i32;
fn __runtime_twz_object_realloc(
base: *const c_void,
p: *const c_void,
owner: *mut *const c_void,
len: usize,
f... |
use super::super::atom::{
btn::Btn,
common::Common,
fa,
heading::{self, Heading},
slider::{self, Slider},
text::Text,
};
use super::super::organism::{
popup_color_pallet::{self, PopupColorPallet},
room_modeless::RoomModeless,
};
use super::ShowingModal;
use crate::arena::{block, BlockMut... |
use actix::prelude::Message;
use actix::{Handler, MessageResult};
use chrono;
use diesel;
use diesel::prelude::*;
use uuid;
use crate::db::schema::span;
#[derive(Debug, Insertable, Queryable)]
#[table_name = "span"]
pub struct SpanDb {
pub trace_id: String,
pub id: String,
parent_id: Option<String>,
na... |
use crate::bus::Bus;
use twz::device::{BusType, Device};
use twz::TwzErr;
const PCIE_BUS_HEADER_MAGIC: u32 = 0x88582323;
const PCIE_HEADER_MULTIFUNCTION: u8 = 1 << 7;
const KACTION_CMD_PCIE_INIT_DEVICE: i64 = 1;
pub struct PcieBus {
root: Device,
}
#[derive(Debug, Copy, Clone)]
#[repr(C)]
struct PcieInfo {
magic: ... |
fn retrieve_seat_id(val: &str) -> i32 {
let row : i32 = val.char_indices()
.take(7)
.map(|(i, c)| if c=='B' { 1 << (6-i) } else { 0 })
.sum();
let col : i32 = val.char_indices()
.skip(7)
.take(3)
... |
use crate::er::Result;
use crate::project::ProjectConfig;
use crate::server::{SshConn, SyncBase, SyncSentCache, SyncSet};
use crate::utils::{self, CliEnv};
use failure::format_err;
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
use std::process;
#[derive(Serialize, Deseria... |
use crate::domain::domain::SysUser;
use crate::domain::vo::SysRoleVO;
use serde::{Deserialize, Serialize};
///登录数据
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SignInVO {
pub user: Option<SysUser>,
pub permissions: Vec<String>,
pub access_token: String,
pub role: Option<SysRoleVO>,
}
imp... |
/// An enum to represent all characters in the CJKUnifiedIdeographsExtensionC block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum CJKUnifiedIdeographsExtensionC {
/// \u{2a700}: '𪜀'
CjkIdeographExtensionCFirst,
/// \u{2b734}: '𫜴'
CjkIdeographExtensionCLast,
}
impl Into<char> for CJKUn... |
//! Library that contains utility functions for tests.
//!
//! It also contains a test module, which checks if all source files are covered by `Cargo.toml`
extern crate hyper;
extern crate regex;
extern crate rustc_serialize;
pub mod rosetta_code;
use std::fmt::Debug;
/// Implementation detail of the `test_sort` ma... |
//! A library for handling debian files and other tasks related to the debian package
//! repository. For extracting and retrieving data from `.deb` files please go to
//! <file::Deb>.
//!
//! Using this library requires a few common linux packages installed. These are
//! `tar`, `mkdir`, and `ar` (part of `binutils`).... |
// This file is part of dpdk. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/dpdk/master/COPYRIGHT. No part of dpdk, including this file, may be copied, modified, propagated, or distributed except accordin... |
use async_std::io::{self, Read, Write};
use async_std::net::UdpSocket;
use async_std::task;
use crc::crc32;
use crossbeam_utils::Backoff;
use rand::random;
use std::cell::Cell;
use std::cmp::min;
use std::collections::{HashMap, VecDeque};
use std::io::{Error, ErrorKind};
use std::net::SocketAddr;
use std::pin::Pin;
use... |
#[test]
fn percentage_position_bottom_right() {
let layout = stretch::node::Node::new(
stretch::style::Style {
size: stretch::geometry::Size {
width: stretch::style::Dimension::Points(500f32),
height: stretch::style::Dimension::Points(500f32),
..De... |
use amethyst::{
prelude::{
World,
Builder,
WorldExt
},
ecs::Entity,
assets::{
Handle
},
core::transform::Transform
};
use amethyst_gltf::GltfSceneAsset;
use super::behaviour::{CanTransform,RotateDirection};
pub struct Soldier {
entity: Entity,
position: (... |
#![feature(globs)]
#![allow(non_snake_case_functions)]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
extern crate libc;
use libc::types::common::c95::c_void;
use rinapi::prelude::*;
mod rinapi;
extern "stdcall" fn window_procedure(
window : Window ,
message : UINT ,
wParam : WPARAM ,
lParam : LPARAM... |
use crate::{
hex::coordinates::{
cubic::CubicVector,
direction::{HexagonalDirection, NUM_DIRECTIONS},
ring::{BigRingIter, RingIter},
HexagonalVector,
},
vector::Vector2ISize,
};
use std::ops::{Mul, MulAssign};
#[derive(
Default,
Clone,
Copy,
PartialEq,
Eq... |
fn main() {
//
// ─── VARIABLES AND MUTABILITY ───────────────────────────────────────────────────
//
// Variables are immutable by default
let immutable_variable = 5;
println!("The value of immutable_variable is: {}", immutable_variable);
// immutable_variable = 6;
// Since ... |
fn main() {
let mut x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
// A constant can be set globally
const MAX_POINTS: u32 = 100_000;
println!("Max points: {}", MAX_POINTS);
// Shadowing. Differs from mut vars because 1) we use 'let' each time,
// 2) we can... |
/*
Primitive Types
Integer: u8, i8 u16, i16, u32, i32, u64, i64, u128, i128 (Number fof bits)
Floats: f32, f64
Boolean: bool
Charaters: char
Tuples
Arrays
*/
pub fn run() {
// Default is i32
let a = 5;
// Default is f64
let b = 3.5;
// Explicit type
let c: i64 = 9843754938;
println!("{:?... |
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
let stdin = stdin();
let stdin = stdin.lock();
let token: String = stdin
.bytes()
.map(|c| c.expect("failed to read char") as char)
.skip_while(|c| c.is_whitespace())
.take_while(|c| !c.is_whitespace())
... |
#![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 Conversion {
pub id: String,
pub settings: ConversionSettings,
#[serde(default, skip_serializing_if = "... |
use std::fmt::{self, Debug, Formatter};
use std::future::Future;
use std::pin::Pin;
use std::str;
use std::task::{Context, Poll};
use base64::Engine;
use futures::future::BoxFuture;
use futures::TryFutureExt;
use http::header::{CONTENT_TYPE, LOCATION};
use http::uri::{Parts, PathAndQuery, Uri};
use rand::RngCore;
use ... |
use std::fs::File;
use std::io::{prelude::*, BufReader};
use std::path::PathBuf;
use std::time::{Duration, Instant};
use cadical::{self, TimeoutTerminator};
#[allow(dead_code)]
fn bench<T>(func: impl FnOnce() -> T) -> (Duration, T) {
let t_start = Instant::now();
let res = func();
let t_end = Instant::now... |
// Copyright 2021 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
//! Pkcs11 context and initialization types
/// Directly get the PKCS #11 operation from the context structure and check for null pointers.
macro_rules! get_pkcs11 {
($pkcs11:expr, $func_name:ident) => {
($pkcs11
... |
use std::time::Duration;
use super::AggregateTarget;
use crate::{
bson::{doc, Document},
bson_util,
cmap::StreamDescription,
concern::{ReadConcern, ReadConcernLevel},
error::{ErrorKind, WriteFailure},
operation::{
test::{self, handle_response_test},
Aggregate,
Operation,... |
frame_support::decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {
fn integrity_test() {}
fn integrity_test() {}
}
}
|
#[doc = "Register `FTSR2` reader"]
pub type R = crate::R<FTSR2_SPEC>;
#[doc = "Register `FTSR2` writer"]
pub type W = crate::W<FTSR2_SPEC>;
#[doc = "Field `FT35` reader - FT35"]
pub type FT35_R = crate::BitReader;
#[doc = "Field `FT35` writer - FT35"]
pub type FT35_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>... |
// SPDX-License-Identifier: Apache-2.0
use crate::evp;
use cipher_bench::{Aead, AeadBuilder};
use std::os::raw::c_int;
use std::ptr;
pub struct Aes128GcmCtxBuilder {
iv: Option<Vec<u8>>,
}
impl Aes128GcmCtxBuilder {
pub fn new() -> Self {
Self { iv: None }
}
fn build(&mut self, key: &[u8], f... |
// 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>,... |
use structopt::StructOpt;
#[derive(Debug, Clone)]
pub struct CleanUpConfig {
pub delay_test_results: u32,
pub delay_spans: u32,
pub delay_reports: u32,
pub schedule: u32,
}
impl Default for CleanUpConfig {
fn default() -> Self {
CleanUpConfig {
delay_test_results: 40 * 24 * 60 *... |
use std::sync::Arc;
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
use vulkano::command_buffer::{AutoCommandBufferBuilder, CommandBuffer};
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
use vulkano::descriptor::PipelineLayoutAbstract;
use vulkano::device::{Device, Queue};
use vulkano::pipel... |
#![feature(test)]
extern crate test;
use sudoku::{Sudoku, BruteForce};
use self::test::Bencher;
use std::fs::File;
use std::io::BufReader;
mod sudoku;
#[bench]
fn bench_solve_wicked(b: &mut Bencher) {
let file = File::open("../samples/wicked.txt").unwrap();
let original = Sudoku::new(BufReader::new(file));
... |
use specs::*;
#[derive(Copy, Clone, Debug, Default, Component)]
#[storage(NullStorage)]
pub struct IsPlayer;
#[derive(Copy, Clone, Debug, Default, Component)]
#[storage(NullStorage)]
pub struct IsMissile;
#[derive(Copy, Clone, Debug, Default, Component)]
#[storage(NullStorage)]
pub struct IsPowerup;
#[derive(Copy, ... |
extern crate byteorder;
extern crate csv;
extern crate gilrs;
extern crate i2cdev;
extern crate image;
extern crate rust_pigpio;
extern crate serde;
extern crate serde_json;
extern crate robot;
//use rust_pigpio::*;
use std::fs;
use std::process::Command;
use std::str;
use std::sync::mpsc::{self, TryRecvError};
use s... |
use std::iter::FromIterator;
pub struct SimpleLinkedList<T> {
head: Option<Box<Node<T>>>,
length: usize,
}
struct Node<T> {
value: T,
next: Option<Box<Node<T>>>,
}
impl<T> SimpleLinkedList<T> {
pub fn new() -> Self {
SimpleLinkedList {
head: None,
length: 0,
... |
struct Artwork {
name: String,
}
fn main() {
let art1 = Artwork {
name: "Boy with Apple".to_string(),
};
}
|
use crate::things::thing::Thing;
pub struct Scenery {
pub thing: Thing,
}
impl Scenery {}
|
mod sqlstate_detail;
use std::fmt::Display;
use serde::{Deserialize, Serialize};
use self::sqlstate_detail::{SqlStateCategory, SqlStateClass, SqlStateDetail};
/// SQLSTATE.
///
/// Errors for specific SQL part (`SQL/JRT`, for example) are omitted.
///
/// See: <https://en.wikipedia.org/wiki/SQLSTATE>
#[allow(missin... |
use std::path::{PathBuf};
use std::fs::File;
use std::str::FromStr;
use std::io::{self, Read, Write};
use std::fmt;
use void::Void;
use boolinator::Boolinator;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(name = "pundoc", about = "Convert Markdown to LaTeX / PDF")]
pub struct Config {
#[struc... |
// an attribute is metadata applied to some module, crate or item. This
// metadata can be used to/for:
//
// - conditional compilation of code
// - set crate name, version and type (binary or library)
// - disable lints (warnings)
// - enable compile features (macros, glob imports, etc.)
// - link to a foreign li... |
use std::cmp::Ord;
use std::ops::Deref;
use anyhow::{anyhow, Result};
use itertools::Itertools as _;
use crate::{utils, Challenge};
pub struct Day01;
impl Challenge for Day01 {
const DAY_NUMBER: u32 = 1;
type InputType = SortedVec<u32>;
type OutputType = u32;
fn part1(input: &Self::InputType) -> R... |
#[doc = "Reader of register CLK_TRIM_ECO_CTL"]
pub type R = crate::R<u32, super::CLK_TRIM_ECO_CTL>;
#[doc = "Writer for register CLK_TRIM_ECO_CTL"]
pub type W = crate::W<u32, super::CLK_TRIM_ECO_CTL>;
#[doc = "Register CLK_TRIM_ECO_CTL `reset()`'s with value 0x001f_0003"]
impl crate::ResetValue for super::CLK_TRIM_ECO_... |
use artell_domain::scheduler::{Scheduler, SchedulerRepository};
#[derive(Debug, Error)]
pub enum Error {
#[error("scheduler is not initialized yet")]
SchedulerNotInitialized,
#[error(transparent)]
Others(#[from] anyhow::Error),
}
pub async fn execute(scheduler_repo: impl SchedulerRepository) -> Result... |
use crate::repo_wrapper::RepoSourceWrapper;
use crypto::digest::Digest;
use crypto::sha1::Sha1;
use fnv::FnvHashMap;
use fs_extra::dir::{copy, remove, CopyOptions};
use git2::Repository;
use log;
use log::{debug, info, warn};
use reqwest;
pub use reups::DBBuilderTrait;
pub use reups_lib as reups;
use std::collections::... |
#![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 PartnerResponse {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub etag: Option<i64>,
#[s... |
#[doc = "Register `GICD_PIDR0` reader"]
pub type R = crate::R<GICD_PIDR0_SPEC>;
#[doc = "Field `PIDR0` reader - PIDR0"]
pub type PIDR0_R = crate::FieldReader<u32>;
impl R {
#[doc = "Bits 0:31 - PIDR0"]
#[inline(always)]
pub fn pidr0(&self) -> PIDR0_R {
PIDR0_R::new(self.bits)
}
}
#[doc = "GICD p... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - GPIO port mode register"]
pub gpiox_moder: GPIOX_MODER,
#[doc = "0x04 - GPIO port output type register"]
pub gpiox_otyper: GPIOX_OTYPER,
#[doc = "0x08 - GPIO port output speed register"]
pub gpiox_ospeedr: GPIOX_OSP... |
#![cfg(test)]
//use problem1::{sum, dedup, filter};
//use problem2::mat_mult;
//use problem3::sieve;
use problem4::{hanoi, Peg};
#[test]
fn test_hanoi_3_disks() {
let result = hanoi(3, Peg::A, Peg::B, Peg::C);
assert_eq!(vec![
(Peg::A, Peg::C),
(Peg::A, Peg::B),
(Peg::C, Peg::B),
... |
use std::io;
fn read_question() -> String {
let mut input = String::new();
match io::stdin().read_line(&mut input) {
Ok(_) => {
input
}
Err(error) => {
println!("error: {}", error);
input
}
}
}
fn string_to_vector(input: String) -> Vec<u8... |
fn main() {
let length = 5000;
let mut y = vec![4.; length];
y[6] = 3.14;
y.push(4.89);
println!("{}, {}, {}", y[6], y[4999], y[5000]);
}
|
use super::LocatedSpan;
use nom::{
Slice, InputIter, Compare, CompareResult,
FindToken, FindSubstring, ParseTo, Offset
};
type StrSpan<'a> = LocatedSpan<&'a str>;
type BytesSpan<'a> = LocatedSpan<&'a [u8]>;
#[test]
fn it_should_call_new_for_u8_successfully() {
let input = &b"foobar"[..];
let output =... |
use crate::{
file_stream::new_file_stream,
utils::{not_found_response, server_error_response},
};
use http::HeaderMap;
use http_service::Body;
use std::{fs::File, ops::Range, path::PathBuf};
use tide::Response;
pub struct FileRequest {
path: Option<PathBuf>,
}
impl FileRequest {
pub fn new(path: Optio... |
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::hash::Hash;
use std::cmp::Eq;
use ndarray::Array;
use ndarray::Array2;
use rand::prelude::*;
use rand::rngs::SmallRng;
pub struct Stack<T> {
inner: Vec<T>,
}
impl<T> Stack<T> {
pub fn new() -> Stack<T> {
... |
use lazy_static::lazy_static;
pub fn evil_mode() -> bool {
ARGS.evil_mode
}
struct Args {
evil_mode: bool,
}
lazy_static! {
static ref ARGS: Args = {
let args: Vec<String> = std::env::args().skip(1).collect();
let first_arg = args.get(0);
let evil_mode = first_arg
.ma... |
use types::Position;
use rmp::value::{Value, Integer};
use supported_languages::SupportedLanguage;
use std::str::FromStr;
#[derive(Debug)]
pub enum NeovimRPCEvent {
NewCursorPosition(Position),
TextChangedI,
BufRead(SupportedLanguage),
}
impl NeovimRPCEvent {
pub fn new(event: &str, values: Vec<Value>... |
use crate::lex::*;
use crate::parse::*;
use noisy_float::prelude::*;
use std::collections::{HashMap, VecDeque};
use std::io::{Read, Write};
use std::{fmt, process};
#[derive(Debug, Clone)]
pub struct Evaluator {
macros: HashMap<Sym, Sym>,
stack: Vec<Sym>,
work: VecDeque<Sym>,
}
impl fmt::Display for Evalu... |
mod world;
use std::f64::consts::PI;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_angles_on_axis() {
let p1 = world::Point {x: 0.0, y: 0.0};
// Edge cases
let p2 = world::Point {x: 0.0, y: 1.0};
assert_eq!(PI / 2.0, world::get_angle(p1, p2));
let p2 = world::Point {x: -1.0, y... |
#![allow(dead_code)]
use glium::{
glutin::{event, event_loop},
Display,
};
use fnv::FnvHashMap;
use crate::engine;
pub enum Request<'a, 'b: 'a> {
Event {
event: &'a event::Event<'b, ()>,
should_update_ui: &'a mut bool,
should_exit: &'a mut bool,
},
SetUi {
needs_r... |
use vsl_ast::VSLEntity;
use std::hash::Hash;
pub trait VSLDecl: VSLEntity {
fn get_name(&self) -> &String;
}
|
//! Hubcaps provides a set of building blocks for interacting with the Github API
//!
//! # Examples
//!
//! Typical use will require instantiation of a Github client. Which requires
//! a user agent string, a `hyper::Client`, and set of `hubcaps::Credentials`.
//!
//! The hyper client should be configured with tls.
/... |
#[doc = "Reader of register MT_STATUS"]
pub type R = crate::R<u32, super::MT_STATUS>;
#[doc = "Reader of field `BLESS_STATE`"]
pub type BLESS_STATE_R = crate::R<bool, bool>;
#[doc = "Reader of field `MT_CURR_STATE`"]
pub type MT_CURR_STATE_R = crate::R<u8, u8>;
#[doc = "Reader of field `HVLDO_STARTUP_CURR_STATE`"]
pub ... |
#[derive(Debug)]
struct RpcCaller {
addr: String,
user: String,
pass: String,
}
#[derive(Debug)]
struct ChainConfig {
port_decimal: u32,
users: Vec<String>,
}
fn main() {
println!("This is a demo demonstrating a lightning payments across 2 different chains");
let mut chains = std::collec... |
#![feature(
cell_update,
never_type,
exhaustive_patterns,
generators,
generator_trait
)]
use log::{debug, info, trace};
use nes::ppu::PpuStep;
use nes::NesStep;
use sdl2::controller::Button as SdlButton;
use sdl2::event::Event as SdlEvent;
use sdl2::keyboard::Keycode as SdlKeycode;
use std::fs;
use... |
use std::fmt;
use crate::common::*;
#[derive(Clone, Debug, PartialEq)]
pub struct Warning {
pub check_name: String,
line: LineEntry,
message: String,
}
impl Warning {
pub fn new(line: LineEntry, check_name: &str, message: String) -> Self {
let check_name = String::from(check_name);
Se... |
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
#[derive(FromRow, Deserialize, Serialize)]
pub struct Dataset {
pub id: i32,
pub short_name: String,
pub name: String,
pub description: String,
pub units: String,
}
|
use super::Redis;
use crate::{config::user_tags_redis_key, errors::Error};
use octo_budget_lib::auth_token::UserId;
use redis::Pipeline;
pub async fn increment_tags(
user_id: UserId,
tags: Vec<String>,
redis: &Redis,
) -> Result<(), Error> {
let key = user_tags_redis_key(user_id);
let mut pipeline... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use super::*;
use num_bigint::BigUint;
use utils::SliceReader;
// BASIC ALGEBRA
// ======================================================... |
fn main() {
let ctx_lines = 2;
let query = "mm";
let source = "\
Lorem ipsum dolor sit amet, consectetur adipiscing elit,\n\
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n\
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo cons... |
use std::fmt::Debug;
use std::marker::PhantomData;
use std::ops::AddAssign;
use guion::aliases::ESColor;
use guion::env::Env;
use guion::style::selector::{StyleSelector, StyleSelectorAppend};
use guion::style::selectag::standard::StdSelectag;
use guion::util::border::Border;
use guion::style::selectag::StyleSelectag;
... |
use lapin::{BasicProperties, options::BasicPublishOptions};
use super::PublisherOptions;
#[derive(Clone, Debug)]
pub struct Publisher {
options: PublisherOptions
}
impl Publisher {
pub fn new(publisher_options: PublisherOptions) -> Self {
Publisher {
options: publisher_options
}
... |
use clap::{App, Arg};
use log::LogLevelFilter;
use std::str::FromStr;
use Route;
use Logger;
use http::{Request, Response};
use server::Server;
struct Settings {
log_level_filter: LogLevelFilter
}
pub struct Router {
routes: Vec<Route>
}
impl Router {
pub fn new() -> Router {
let settings = Rou... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.