text stringlengths 8 4.13M |
|---|
use lazy_static::lazy_static;
use std::path::PathBuf;
use clap::Clap;
use serde::{
Serialize,
Deserialize,
};
lazy_static! {
pub static ref CONFIG_FILE_PATH: PathBuf = {
let mut path_buf = dirs::config_dir().unwrap();
path_buf.push("dftodo");
path_buf.push("config");
path_bu... |
use srt::SrtSocketBuilder;
use std::time::Instant;
use futures::prelude::*;
#[tokio::test]
async fn receiver_timeout() {
let _ = env_logger::try_init();
let a = SrtSocketBuilder::new_listen().local_port(1872).connect();
let b = SrtSocketBuilder::new_connect("127.0.0.1:1872").connect();
let (mut a, m... |
fn act2_7_1(n: u32, v1: &Vec<i32>, v2:&Vec<i32>) -> i32{
let mut v1_c = v1.clone();
let mut v2_c = v2.clone();
v1_c.sort();
v2_c.sort();
let mut ans: i32 = 0;
for i in 0..(v1_c.len()){
let index = ((n as i32) - (i as i32) - 1) as usize;
ans += v1_c[i] * v2_c[index];
}
return ans
}
#[cfg(test)]
mod tests {
... |
use serde;
use std::fmt;
use uuid;
pub mod ingestor;
pub mod report;
pub mod span;
pub mod streams;
pub mod test_result;
pub fn hello() -> &'static str {
"I am i'Krelln"
}
macro_rules! typed_id {
($name:ident) => {
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct $name(pub String);
... |
mod midi;
use anyhow::{anyhow, Context, Error, Result};
use futures::prelude::*;
use log::*;
use std::path::PathBuf;
use structopt::StructOpt;
use toio::{Cube, SoundOp};
use tokio::time::{delay_for, delay_until, Duration, Instant};
use crate::midi::PlaySet;
#[derive(Clone, Debug)]
pub struct Rule {
chs: Vec<u8>,... |
//! A small library dedicated to LASER path optimisation.
//!
//! The goal for the library is to provide a suite of useful tools for optimising linear vector
//! images for galvanometer-based LASER projection. To allow *lasy* LASERs to get more done.
//!
//! This crate implements the full suite of optimisations covered... |
#[doc = "Register `RQR` writer"]
pub type W = crate::W<RQR_SPEC>;
#[doc = "Field `ABRRQ` writer - Auto baud rate request Writing 1 to this bit resets the ABRF flag in the USART_ISR and requests an automatic baud rate measurement on the next received data frame. Note: If the USART does not support the auto baud rate fea... |
// 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 kiss3d::scene::SceneNode;
use na::{Translation3, UnitQuaternion, Vector3};
use nalgebra as na;
use std::f32::consts::FRAC_PI_2;
pub fn put_xyz_axis(node: &mut SceneNode, scale: f32) {
let axis_radius: f32 = scale * 0.1;
let axis_length: f32 = scale;
let arrow_radius: f32 = scale * 0.2;
let arrow_... |
/*!
* Sylphrena AI input program - https://github.com/ShardAi
* Version - 1.0.0.0
*
* Copyright (c) 2017 Eirik Skjeggestad Dale
*/
use input::syl_client::Sylclient;
use input::syl_nlp::Sylnlp;
pub struct Sylinput{
id: String,
client: Sylclient,
nlp: Sylnlp
}
impl Sylinput {
pub fn new(id: &str) ... |
pub mod report;
pub mod align; |
use crate::utils::generate_utxo_set;
use crate::{Net, Node, Spec};
use ckb_types::core::{BlockView, Capacity, TransactionView};
use ckb_types::packed::{Byte32, OutPoint};
use ckb_types::prelude::Entity;
use ckb_types::prelude::*;
use std::collections::{HashMap, HashSet};
pub struct FeeOfTransaction;
impl Spec for Fee... |
mod single_linked_list;
mod double_linked_list;
#[cfg(test)]
mod tests{
use crate::*;
#[test]
fn better_transaction_log_append() {
let mut transaction_log = double_linked_list::BetterTransactionLog::new_empty();
assert_eq!(transaction_log.length, 0);
transaction_log.append("INSER... |
// < begin copyright >
// Copyright Ryan Marcus 2020
//
// See root directory of this project for license terms.
//
// < end copyright >
use crate::models::*;
mod two_layer;
mod multi_layer;
mod lower_bound_correction;
pub struct TrainedRMI {
pub model_avg_error: f64,
pub model_avg_l2_error: f64,
p... |
//! Tests auto-converted from "sass-spec/spec/core_functions/color/change_color/error"
#[allow(unused)]
use super::rsass;
// From "sass-spec/spec/core_functions/color/change_color/error/args.hrx"
mod args {
#[allow(unused)]
use super::rsass;
// Ignoring "too_few", error tests are not supported yet.
/... |
use amethyst::core::{SystemDesc, Transform};
use amethyst::derive::SystemDesc;
use amethyst::ecs::{
Entities, Join, LazyUpdate, Read, ReadStorage, System, SystemData, World, WriteStorage,
};
use amethyst::input::{InputHandler, StringBindings};
use log::info;
use crate::state::{GameTimeController, Map, SpriteSheet... |
#[doc = "Register `DIER_output` reader"]
pub type R = crate::R<DIER_OUTPUT_SPEC>;
#[doc = "Register `DIER_output` writer"]
pub type W = crate::W<DIER_OUTPUT_SPEC>;
#[doc = "Field `CC1IE` reader - Capture/compare 1 interrupt enable"]
pub type CC1IE_R = crate::BitReader;
#[doc = "Field `CC1IE` writer - Capture/compare 1 ... |
//! Provides asynchronous [`ping`](ping) function. (especially for futures-io compatible streams)
//!
//! The [`ping`](ping) function here sends a ping request, and returns a [`Future`](std::future::Future) resolves to a result of [`Response`](Response).
//! If you want to send ping synchronously, see [`sync`](sync) mo... |
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(blog_os::test_runner)]
#![reexport_test_harness_main = "test_main"]
use core::panic::PanicInfo;
extern crate alloc;
use alloc::{boxed::Box, vec, vec::Vec};
use blog_os::{QemuExitCode, exit_qemu};
use blog_os::init;
use blog_os::serial_print;
u... |
use std::fs::File;
use std::io::prelude::*;
use std::cmp::Ordering;
fn read_data(filepath: &str) -> std::io::Result<String> {
let mut file = File::open(filepath)?;
let mut contents: String = String::new();
file.read_to_string(&mut contents)?;
Ok(contents.trim().to_string())
}
/// # Errors
///
/// Retu... |
use crate::*;
pub use numeric_types::*;
// Serialized format for metadata about a particular type of tile
#[derive(serde::Serialize, serde::Deserialize)]
pub struct TileType<'a> {
pub image: &'a str,
pub name: &'a str,
pub defense: HitPoints,
pub evade: AccuracyPoints,
pub move_cost: MapDistance,
}... |
#[doc = "Register `C2APB1ENR1` reader"]
pub type R = crate::R<C2APB1ENR1_SPEC>;
#[doc = "Register `C2APB1ENR1` writer"]
pub type W = crate::W<C2APB1ENR1_SPEC>;
#[doc = "Field `TIM2EN` reader - CPU2 TIM2 timer clock enable"]
pub type TIM2EN_R = crate::BitReader<TIM2EN_A>;
#[doc = "CPU2 TIM2 timer clock enable\n\nValue o... |
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use commands::{Action, Command, Mode};
use failure;
use parser;
use tokenizer;
#[derive(Debug)]
pub struct Red {
prompt: String,
pub current_line: usize,
pub data: Vec<String>,
pub mode: Mode,
pub path: Option<String>,
pub dir... |
// The screen in 1 indexed, not zero indexed.
pub fn move_cursor(row: usize, col: usize) {
// TODO add a camera/viewport
print!("\x1B[{row};{col}f", row = 1 + row, col = 1 + col);
}
|
//! The `recorder` module provides an object for generating a Proof of History.
//! It records Transaction items on behalf of its users.
use entry::Entry;
use hash::{hash, Hash};
use std::time::{Duration, Instant};
use transaction::Transaction;
pub struct Recorder {
last_hash: Hash,
num_hashes: u64,
num_t... |
use std::marker::PhantomData;
#[derive(Copy, Clone, Debug)]
pub struct Buf<'a> {
ptr: *const u8,
len: usize,
phantom: PhantomData<&'a u8>,
}
impl<'a> Buf<'a> {
pub unsafe fn from_raw(ptr: *const u8, len: usize) -> Self {
Self { ptr, len, phantom: PhantomData }
}
pub fn len(&self) -> u... |
#[doc = "Register `GPIOI_HWCFGR1` reader"]
pub type R = crate::R<GPIOI_HWCFGR1_SPEC>;
#[doc = "Field `AFRH_RES` reader - AFRH_RES"]
pub type AFRH_RES_R = crate::FieldReader<u32>;
impl R {
#[doc = "Bits 0:31 - AFRH_RES"]
#[inline(always)]
pub fn afrh_res(&self) -> AFRH_RES_R {
AFRH_RES_R::new(self.bi... |
// Copyright 2020 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
use super::constants::{PSA_MAX_PERSISTENT_KEY_IDENTIFIER, PSA_SUCCESS};
use super::psa_crypto_binding::{self, psa_key_id_t};
use super::utils::{self, KeyHandle};
use super::{LocalIdStore, MbedProvider};
use crate::authenticator... |
use preexplorer::prelude::*;
fn main() -> anyhow::Result<()> {
let data: Vec<Vec<f64>> = (0..10)
.map(|i| {
(0..10)
.map(|j| {
// Some computation
(i as f64).sin() * j as f64
})
.collect()
})
... |
use super::context::GraphQLContext;
use diesel::pg::PgConnection;
use juniper::{FieldResult, RootNode};
use super::data::Todos;
use super::models::{CreateTodoInput, Todo};
// The root GraphQL query
pub struct Query;
// The root Query struct relies on GraphQLContext to provide the connection pool
// needed to execute... |
extern crate nix;
use std::io;
use nix::unistd::{fork, ForkResult, execvp, chdir};
use nix::sys::wait;
use std::ffi::CString;
fn main() {
// Load config files if any exist
// Run command line
lsh_loop();
// Perform shutdown/cleanup
}
fn lsh_loop() {
loop {
print!(":> ");
... |
use failure::{Error, ResultExt};
use proc_macro2::TokenStream;
use quote::ToTokens;
use std::fs;
use std::io::Read;
use std::path::{Path, PathBuf};
#[derive(Debug, Clone, PartialEq)]
pub struct File {
pub path: PathBuf,
pub contents: Vec<u8>,
}
impl File {
pub fn from_disk<P: Into<PathBuf>>(path: P) -> Re... |
use runtime::cast;
use runtime::Slice;
type Handle = *();
struct TableHeader {
signature: u64,
revision: u32,
header_size: u32,
crc32: u32,
reserved: u32
}
struct TextInputProtocol;
struct SystemTable {
hdr: TableHeader,
firmware_vendor: *u16,
firmware_rev: u32,
console_in_h: Han... |
use bytes::{Buf, BufMut};
use crate::codec::error::CodecError;
use crate::codec::MAGIC_COOKIE;
use crate::messages::{Address, Attribute, IPKind};
use super::Result;
pub fn decode_attribute(buf: &mut dyn Buf, transaction_id: &[u8; 12]) -> Result<Attribute> {
let attribute_type = buf.get_u16();
let attribute_v... |
use crate::ast::Connective;
#[derive(Debug, Clone)]
pub enum Token {
Var(String),
Not,
And,
Or,
Implicate,
Biimplicate,
Comma,
Slash,
OpenParen,
CloseParen,
ForAll,
Exists,
}
fn lex(src: &str) -> Vec<Token> {
let mut tokens = vec![];
for (_i, c) in src.char_ind... |
/*===============================================================================================*/
// Copyright 2016 Kyle Finlay
//
// 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
//
// ... |
use log::warn;
use crate::{
nispor::{
ip::{nmstate_ipv4_to_np, nmstate_ipv6_to_np},
veth::nms_veth_conf_to_np,
vlan::nms_vlan_conf_to_np,
},
ErrorKind, Interface, InterfaceType, NetworkState, NmstateError,
VethConfig,
};
pub(crate) fn nispor_apply(
add_net_state: &NetworkSt... |
//
// Dungeon generation
//
use crate::{Map, Rect};
use rand::{thread_rng, Rng};
#[derive(Debug, Clone, Copy)]
struct Room {
x: u32,
y: u32,
width: u32,
height: u32,
}
impl Room {
fn distance_to(&self, room: &Room) -> i32 {
Rect {
x: self.x,
y: self.y,
... |
//! Partial Unix `resolv.conf(5)` parser
use std::cmp::min;
use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::net::{IpAddr, SocketAddr};
use std::time::Duration;
use crate::config::DnsConfig;
use crate::hostname::get_hostname;
/// port for DNS communication
const DNS_PORT: u16 = 53;
/// Maximum n... |
use actix_web::web;
use crate::apps;
pub fn init_routes(cfg: &mut web::ServiceConfig) {
cfg.service(apps::frontend_app::index)
.service(
web::scope("/public")
.wrap(middlewares::pwa_cache_headers::PwaCacheHeaders)
.service(actix_files::Files::new("/", "./reactap... |
use std::io::BufRead;
use std::time::Duration;
use std::time::Instant;
use timed_queue::TimedQueue;
fn put_them(tq: TimedQueue<usize>) {
let stdin = std::io::stdin();
for (idx, line) in stdin.lock().lines().enumerate() {
let line = line.unwrap();
let dur: u64 = line.parse().unwrap();
t... |
#[doc = "Register `PWR_MCUWKUPENR` reader"]
pub type R = crate::R<PWR_MCUWKUPENR_SPEC>;
#[doc = "Register `PWR_MCUWKUPENR` writer"]
pub type W = crate::W<PWR_MCUWKUPENR_SPEC>;
#[doc = "Field `WKUPEN1` reader - WKUPEN1"]
pub type WKUPEN1_R = crate::BitReader;
#[doc = "Field `WKUPEN1` writer - WKUPEN1"]
pub type WKUPEN1_... |
use crate::cli::CliOptions;
use crate::ext::{BufExt, MessageExt, ResultExt};
use crate::proto::{self, message::MessageType};
use crate::CreditcoinNode;
use core::fmt;
use dashmap::DashMap;
use futures::{Future, FutureExt as _, SinkExt, StreamExt};
use internment::Intern;
use secp256k1::SecretKey;
use std::collections::... |
use chrono::prelude::*;
#[path="../src/yahooapi.rs"]
mod yahooapi;
#[test]
fn test_parse() {
assert_eq!(yahooapi::parse_yahoo_date("202101161655"),
Ok(NaiveDate::from_ymd(2021, 1, 16).and_hms(16, 55, 0)));
}
|
use std::process::Command;
use failure::Error;
use serde_json;
use config::apis;
/// ExecCredentials is used by exec-based plugins to communicate credentials to
/// HTTP transports.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ExecCredential {
pub kind: Option<String>,
#[serde(rename = "apiVers... |
fn main() {
let mut v:Vec<i32> = vec![1,2,3,4,5];
//==== Immutable borrow
let first = &v[0];
//==== Mutable borrow
v.push(6);
println!("first{}",first);
} |
/*
chapter 4
syntax and semantics
*/
fn main() {
/* let a = 3; */
// error!
/* a = 4; */
let mut a = 3;
println!("{}", a);
// no problem!
a = 4;
println!("{}", a);
let mut b = 5;
/* let mut c = 6; */
let mut d = 7;
let mut e = 8;
let f = &mut b;
println!("{}... |
struct Solution;
impl Solution {
// 参考 https://leetcode-cn.com/problems/is-subsequence/solution/rust-0ms-2mb-by-qweytr_1/
pub fn is_subsequence(s: String, t: String) -> bool {
let mut iter_s = s.chars();
let mut iter_t = t.chars();
'outer: while let Some(x) = iter_s.next() {
... |
use std::sync::Arc;
use async_trait::async_trait;
use common::result::Result;
use crate::domain::catalogue::{Author, Category, Collection, CollectionService};
use publishing::domain::author::AuthorRepository;
use publishing::domain::category::CategoryRepository;
use publishing::domain::collection::{CollectionId, Col... |
// Based on idtree by SimonSapin
// https://github.com/SimonSapin/rust-forest/blob/master/idtree/lib.rs
use std::mem;
use std::ops::{Index, IndexMut};
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct NodeId {
index: usize,
}
impl NodeId {
pub fn detach<T>(self, tree: &mut Tree<T>) {
let (parent, prev... |
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(conservative_impl_trait)]
#[cfg(feature = "std")]
extern crate core;
extern crate wiring;
extern crate bit_field;
extern crate byteorder;
pub mod keys;
pub mod matrix;
pub mod decoder;
pub mod keycode;
pub mod keycodes;
#[macro_use]
pub mod layout;
pub mod qwerty;... |
//! Responses for General Commands
use atat::atat_derive::AtatResp;
use heapless::{consts, String};
/// 4.1 Manufacturer identification
/// Text string identifying the manufacturer.
#[derive(Clone, Debug, AtatResp)]
pub struct ManufacturerId {
#[at_arg(position = 0)]
pub id: String<consts::U64>,
}
/// 4.7 IME... |
use std::fs;
use std::fs::OpenOptions;
use std::io::prelude::*;
use std::path::Path;
use crate::mcc::agent::agent_queue::AgentQueue;
use crate::mcc::agent::speciated_agent_queue::SpeciatedAgentQueue;
use crate::mcc::maze::maze_queue::MazeQueue;
use crate::mcc::maze::speciated_maze_queue::SpeciatedMazeQueue;
use crate:... |
#![feature(const_str_len)]
extern crate env_logger;
extern crate fuse;
extern crate libc;
extern crate roxmltree;
extern crate time;
use fuse::{
FileAttr, FileType, Filesystem, ReplyAttr, ReplyData, ReplyDirectory, ReplyEmpty, ReplyEntry,
ReplyWrite, Request,
};
use libc::ENOENT;
use roxmltree::{Document, Edg... |
fn main() {
println!("Advent of Code - Day 1");
let input = data();
let fuel_sum: i32 = input.into_iter().map(|f| fuel_for_mass(*f)).sum();
println!("Part 1: Fuel for modules: {}", fuel_sum);
let fuel_with_fuel_sum: i32 = input.into_iter().map(|f| fuel_for_mass_plus_fuel(*f)).sum();
println!("Part 2: Fu... |
// Copyright 2018-2019 Mozilla
//
// 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 to in writing, sof... |
use stremio_core::types::addons::Manifest;
static STYLESHEET: &str = include_str!("../landing_style.css");
fn get_contact_html(addon_name: &str, email: &str) -> String {
format!(r#"
<div class="contact">
<p>Contact {} creator:</p>
<a href="mailto:{email}">{email}</a>
</div... |
use itertools::Itertools;
use std::collections::{BinaryHeap, HashSet};
use std::fs::File;
use std::io::{BufRead, BufReader};
type Coordinate = (usize, usize);
#[derive(Debug)]
struct Heightmap {
grid: Vec<Vec<u8>>,
num_rows: usize,
num_cols: usize,
inum_rows: isize,
inum_cols: isize,
}
impl Height... |
use crate::headers::from_headers::*;
use crate::prelude::*;
use crate::resources::collection::{IndexingPolicy, PartitionKey};
use azure_core::headers::{
content_type_from_headers, etag_from_headers, session_token_from_headers,
};
use azure_core::{collect_pinned_stream, Request as HttpRequest, Response as HttpRespon... |
use std::collections::btree_map::{self, BTreeMap};
partition_map![
/// This is a `PartitionBTreeMap`.
PartitionBTreeMap<K, V>
btree_map
BTreeMap
Ord
];
/*
impl<K, V> PartitionBTreeMap<K, V> where
K: Ord,
{
pub fn range<Q, R>(&self, range: R) -> Range<K, V> where
K: Borrow<Q>,
... |
use log::debug;
use tokio::sync::mpsc::{Receiver, Sender};
use crate::infrastructure::database;
use crate::Messages;
pub fn spawn_receiver(mut receiver: Receiver<Messages>, mut sender_end_channel: Sender<()>) {
tokio::spawn(async move {
while let Some(message) = receiver.recv().await {
match m... |
use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
pub struct Edge {
pub weight: i32,
pub target: i32, // Target node's id
}
// Reverse ordering is implemented to be able to use max binary heap
impl Ord for Edge {
fn cmp(&self, other: &Edge) -> Ordering {
other.weight.cmp(&self.w... |
use amethyst::{
assets::{DefaultLoader, Handle, Loader, ProcessingQueue},
core::transform::Transform,
prelude::*,
renderer::{SpriteRender, SpriteSheet, Texture},
};
use crate::camera::initialize_camera;
const MAP_HEIGHT: f32 = 100.0;
const MAP_WIDTH: f32 = 100.0;
const PARTICLE_RADIUS: f32 = 4.0;
pub... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - GPIO port mode register"]
pub gpioc_moder: GPIOC_MODER,
#[doc = "0x04 - GPIO port output type register"]
pub gpioc_otyper: GPIOC_OTYPER,
#[doc = "0x08 - GPIO port output speed register"]
pub gpioc_ospeedr: GPIOC_OSP... |
//! The GEOM subsystem of FreeBSD is an abstraction of storage topology inside the kernel.
//!
//! In math jargon, it is a "forest" of disconnected trees. The root(s) of these trees are
//! individual `Geom` objects of class `GeomClass::DISK` or similar (e.g., `MD` — Memory Disk).
//!
//! The leaves of the trees are `... |
use ckb_types::{
bytes::Bytes,
core::{cell::CellMeta, BlockExt, EpochExt, HeaderView},
packed::Byte32,
};
/// Script DataLoader
/// abstract the data access layer
pub trait DataLoader {
// load cell data and its hash
fn load_cell_data(&self, cell: &CellMeta) -> Option<(Bytes, Byte32)>;
// load ... |
use apllodb_shared_components::{SchemaIndex, SchemaName};
use serde::{Deserialize, Serialize};
use crate::{column::column_name::ColumnName, table::table_name::TableName};
/// Full name in storage-engine: `TableName . ColumnName`.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize, new... |
extern crate line_drawing;
use line_drawing::{VoxelOrigin, WalkVoxels};
fn main() {
let a = (0.0, 0.0, 0.0);
let b = (5.0, 6.0, 7.0);
for (i, (x, y, z)) in WalkVoxels::<f32, i8>::new(a, b, &VoxelOrigin::Center).enumerate() {
if i > 0 && i % 5 == 0 {
println!();
}
print!... |
use std::ffi::NulError;
use std::result;
use thiserror::Error;
/// The error type for `Map` operations.
#[derive(Error, Debug, Eq, PartialEq)]
pub enum Error {
#[error("The requested key wasn't found in the map")]
KeyNotFound,
#[error("The requested index was out of bounds")]
IndexOutOfBounds,
#[e... |
/*
chapter 4
primitive types
tuples
*/
fn main() {
let (a, b, c) = (1, 2, 3);
println!("b is {}", b);
println!("a is {}", a);
println!("c is {}", c);
}
// output should be:
/*
*/
|
#[derive(Debug)]
pub enum Error {
Io(std::io::Error),
InvalidMagic,
NotLittleEndianness,
Not64Bit,
InvalidStructureSize,
CanNotFindSection(String),
}
impl std::convert::From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Self::Io(e)
}
} |
use std::collections::HashMap;
#[derive(Serialize, Deserialize, Debug)]
#[allow(non_snake_case)]
//Labels, HostConfig
pub struct Container {
pub Id: String,
pub Image: String,
pub Status: String,
pub Command: String,
pub Created: u64,
pub Names: Vec<String>,
pub Ports: Vec<Port>,
pub Si... |
use pasture_core::{
math::expand_bits_by_3,
math::reverse_bits,
math::{MortonIndex64, AABB},
nalgebra::Point3,
nalgebra::Vector3,
};
use plotters::coord::types::RangedCoordf32;
use plotters::prelude::*;
use rand::{rngs::SmallRng, Rng, SeedableRng};
fn reversed_morton_index(point: &Point3<f64>, boun... |
use std::collections::HashMap;
use phf::{Map, phf_map};
use crate::utils::{get_bit, get_bit_slice};
static DEST_SYMBOLS: Map<&'static str, i16> = phf_map! {
"M" => 0b001, "D" => 0b010, "MD" => 0b011, "A" => 0b100, "AM" => 0b101,
"AD" => 0b110, "AMD" => 0b111
};
static COMP_SYMBOLS: Map<&'static str, i16> =... |
pub mod keeper;
pub mod querier;
|
// other library used for correctness checks
use fid::{FID, BitVector};
#[test]
/// Check that elias fano runs considering a lot of possible combinations.
fn test_all_ones() {
let mut r = rsdict::RsDict::new();
for _ in 0..65 {
r.push(true);
}
}
#[test]
/// Check that elias fano runs considering a ... |
$NetBSD: patch-vendor_backtrace_src_symbolize_gimli.rs,v 1.3 2023/01/23 18:49:04 he Exp $
Do mmap on NetBSD as well.
--- ./vendor/backtrace/src/symbolize/gimli.rs.orig 2022-04-04 11:10:55.000000000 +0000
+++ ./vendor/backtrace/src/symbolize/gimli.rs
@@ -38,6 +38,7 @@ cfg_if::cfg_if! {
target_os = "ios",
... |
extern crate puck;
#[macro_use]
extern crate puck_core;
extern crate cgmath;
extern crate rand;
#[macro_use]
extern crate serde_derive;
extern crate serde;
use cgmath::{Zero, InnerSpace, vec3, vec2, Rad};
use std::f64::consts::PI;
use puck_core::{Vec2f, Vec3f, Vec3, Tick, HashMap, TreeMap, Color, clamp};
use puck_co... |
use vulkano::device::{Device, DeviceExtensions, Queue};
use vulkano::swapchain::{self, ColorSpace, Swapchain, Surface};
use vulkano::sampler::{Filter, MipmapMode, Sampler, SamplerAddressMode,
UnnormalizedSamplerAddressMode};
use vulkano::image::{AttachmentImage, Dimensions, ImageUsage, ImmutableI... |
#![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 api {
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub async fn list_... |
pub mod connect;
pub mod decoder;
pub mod encoder;
pub mod packet;
pub mod publish;
pub mod subscribe;
pub mod utils;
pub use {
connect::{Connack, Connect, ConnectReturnCode, LastWill, Protocol},
decoder::decode_slice,
encoder::encode_slice,
packet::{Packet, PacketType},
publish::Publish,
subsc... |
#![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 TrackedResource {
#[serde(flatten)]
pub resource: Resource,
pub location: String,
#[serde(default, ... |
//! The config module contains all the structs relating to test implementation
//! configuration files.
use crate::error::ToolsetError::{InvalidConfigError, LanguageNotFoundError};
use crate::error::ToolsetResult;
use crate::io;
use serde::Deserialize;
use std::collections::HashMap;
use std::path::PathBuf;
use toml::V... |
#[allow(unused_imports)]
#[macro_use]
extern crate limn;
extern crate lipsum;
extern crate rand;
use lipsum::lipsum;
use rand::Rng;
mod util;
use limn::prelude::*;
use limn::widgets::list;
fn main() {
let window_builder = glutin::WindowBuilder::new()
.with_title("Limn list demo")
.with_min_dimen... |
use indicatif::{ProgressBar as IndicatifProgressBar, ProgressDrawTarget};
pub struct ProgressBar {
bar: Option<IndicatifProgressBar>,
}
macro_rules! forward_fn_impl {
($name: ident) => {
pub fn $name(&self) {
if let Some(ref progress_bar) = self.bar {
progress_bar.$name();
... |
#[doc = "Reader of register RCC_MP_AHB6LPENCLRR"]
pub type R = crate::R<u32, super::RCC_MP_AHB6LPENCLRR>;
#[doc = "Writer for register RCC_MP_AHB6LPENCLRR"]
pub type W = crate::W<u32, super::RCC_MP_AHB6LPENCLRR>;
#[doc = "Register RCC_MP_AHB6LPENCLRR `reset()`'s with value 0x0113_57a1"]
impl crate::ResetValue for super... |
use std::time::{Duration, SystemTime};
pub struct Counter {
last_time: SystemTime,
report_every: u8,
counter: u16,
}
impl Counter {
pub fn new(report_every: u8) -> Self {
log::trace!("insance of {}", std::any::type_name::<Self>());
Self {
last_time: SystemTime::now(),
... |
use crate::import::*;
use crate::process::{Dispatcher, DynHandler, Pid, Process, DispatchError};
use crate::node::{NodeController, RegisterGlobalHandler, FromNode, NodeStatus};
use crate::util::{RegisterRecipient, RpcMethod};
use crate::proto::{Update, ProcessList};
use crate::{NodeDispatch, MethodCall, Broadcast};
... |
#[macro_use]
extern crate lazy_static;
extern crate isatty;
extern crate json_highlight_writer;
extern crate regex;
pub mod input;
mod selection;
pub fn json_grep(config: input::Config) -> Result<(), Option<String>> {
let lens_patterns = match config.params {
Some(ref params) => {
input::param... |
macro_rules! index_type {
($t:ident) => {
#[derive(Ord, PartialOrd, Eq, PartialEq, Clone, Copy, Debug, Hash)]
pub(crate) struct $t {
index: u32,
}
impl From<usize> for $t {
fn from(index: usize) -> $t {
$t {
index: index as... |
struct Cat
{
weight: f64,
speed: f64
}
struct Dog
{
weight: f64,
speed: f64
}
trait Animal
{
fn max_speed(&self) -> f64;
}
impl Animal for Cat
{
fn max_speed(&self) -> f64
{
self.speed
}
}
impl Animal for Dog
{
fn max_speed(&self) -> f64
{
self.speed
}
}
struct SqueakyT... |
use crate::move_::Move;
/// Represents a transaction.
pub struct Transaction<Unit, SumNumber, Extra, MoveExtra>
where
Unit: Ord,
{
pub(crate) extra: Extra,
pub(crate) moves: Vec<Move<Unit, SumNumber, MoveExtra>>,
}
/// Used to index moves in a transaction.
pub struct MoveIndex(pub usize);
impl<Unit, SumNumb... |
use super::*;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[repr(transparent)]
pub struct MosaicSize(u8);
impl MosaicSize {
const_new!();
bitfield_int!(u8; 0..=3: u8, horizontal, with_horizontal, set_horizontal);
bitfield_int!(u8; 4..=7: u8, vertical, with_vertical, set_vertical);
}
|
use libc::c_uint;
use ffi;
bitflags! {
/// Postprocess Effects bitflags
pub flags PostprocessEffect: c_uint {
const CALC_TANGENT_SPACE = ffi::POSTPROCESS_CALC_TANGENT_SPACE,
const JOIN_IDENTICAL_VERTICES = ffi::POSTPROCESS_JOIN_IDENTICAL_VERTICES,
const MAKE_LEFT_HANDED = ffi::POSTPROCE... |
use arch::cpuio::{Port, UnsafePort};
// Cmd sent to begin PIC initialization
const CMD_INIT: u8 = 0x11;
// Cmd sent to acknowledge an interrupt
const CMD_END_OF_INTERRUPT: u8 = 0x20;
// The mode in which we want to run PIC
const MODE_8086: u8 = 0x01;
struct Pic {
offset: u8,
command: UnsafePort<u8>,
dat... |
#[doc = "Register `SKR` writer"]
pub type W = crate::W<SKR_SPEC>;
#[doc = "SRAM2 write protection key for software erase\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum KEY_AW {
#[doc = "83: 2. Write 0x53 into Key\\[7:0\\]"]
Key2 = 83,
#[doc = "202: 1. Write 0xCA int... |
use crate::{App, eval::Expr, utils::{self, Datatype, Var}};
use lsp_types::Url;
use rnix::{types::*, value::Value as ParsedValue, SyntaxNode};
use std::{
collections::{hash_map::Entry, HashMap},
path::PathBuf,
rc::Rc,
};
#[cfg(not(test))]
use std::fs;
use lazy_static::lazy_static;
use std::{process, str}... |
use crate::{Module, Trait};
use codec::{Decode, Encode};
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
use serde::{Deserialize, Serialize};
use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
Perbill,
};
impl_outer_origin! {
pub enum ... |
mod tasks_backend;
pub use tasks_backend::{DefaultTasksBackend, TasksBackend};
|
/// An enum to represent all characters in the Mro block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Mro {
/// \u{16a40}: '𖩀'
LetterTa,
/// \u{16a41}: '𖩁'
LetterNgi,
/// \u{16a42}: '𖩂'
LetterYo,
/// \u{16a43}: '𖩃'
LetterMim,
/// \u{16a44}: '𖩄'
LetterBa,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.