text stringlengths 8 4.13M |
|---|
mod number;
mod operator;
mod token;
extern crate clap;
use std::collections::VecDeque;
use clap::{App, Arg, value_t};
use number::{Number, NumberBase};
use operator::Operator;
use token::Token;
//////////////////////////////////////////////////////////////////////
/// Utils Common
/////////////////////////////////... |
use super::schema::{grades, users};
#[derive(Queryable, Debug, PartialEq, Eq)]
pub struct User {
pub id: i32,
pub username: String,
pub password: String,
pub role: String,
}
impl User {
/// Only exists for the unit tests
pub fn new(username: &str, passwd: &str, role: &str) -> Self {
Se... |
use std::net::SocketAddr;
use chrono::prelude::*;
use hydroflow::hydroflow_syntax;
use hydroflow::scheduled::graph::Hydroflow;
use hydroflow::util::{UdpLinesSink, UdpLinesStream};
use crate::helpers::{deserialize_json, serialize_json};
use crate::protocol::EchoMsg;
pub(crate) async fn run_server(outbound: UdpLinesSi... |
#![allow(unused)]
#[macro_use]
extern crate rayon;
extern crate roots;
extern crate extendr_api;
use extendr_api::prelude::*;
mod filter;
use filter::FilteringResult;
//Wrapping functions for R
#[extendr]
fn perform_filtering_for_r(update_type: String, q: Vec<f64>, alpha: f64, delta_t: f64, first_apri... |
mod actions;
mod audio;
mod base;
mod digger;
mod loading;
mod map;
mod menu;
mod ui;
use crate::actions::ActionsPlugin;
use crate::audio::InternalAudioPlugin;
use crate::base::BasePlugin;
use crate::digger::DiggerPlugin;
use crate::loading::LoadingPlugin;
use crate::map::MapPlugin;
use crate::menu::MenuPlugin;
use cr... |
#[doc = "Register `APB2SMENR` reader"]
pub type R = crate::R<APB2SMENR_SPEC>;
#[doc = "Register `APB2SMENR` writer"]
pub type W = crate::W<APB2SMENR_SPEC>;
#[doc = "Field `SYSCFGSMEN` reader - SYSCFG clocks enable during Sleep and Stop modes"]
pub type SYSCFGSMEN_R = crate::BitReader<SYSCFGSMEN_A>;
#[doc = "SYSCFG cloc... |
use serde::Deserialize;
use serde::Serialize;
pub type Score=u32;
pub type Id=u32;
#[derive(Debug)]
pub struct Date(pub u16, pub u8, pub u8);
#[derive(Debug, Serialize, Deserialize)]
pub struct Thread {
pub listing: Listing,
pub comments: Vec<Comment>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct L... |
//! Most basic explorable structure: a sequence of values.
//!
//! # Remarks
//!
//! With the ``prelude`` module, we can easily convert ``IntoIterator``s
//! into ``Sequence`` for ease of use. The same can be achieved with the
//! ``new`` method.
//!
//! # Examples
//!
//! Quick plot.
//! ```no_run
//! use preexplorer:... |
use itertools::Either;
use super::HalfJoinState;
pub struct SymmetricHashJoin<'a, Key, I1, V1, I2, V2, LhsState, RhsState>
where
Key: Eq + std::hash::Hash + Clone,
V1: Clone,
V2: Clone,
I1: Iterator<Item = (Key, V1)>,
I2: Iterator<Item = (Key, V2)>,
LhsState: HalfJoinState<Key, V1, V2>,
Rh... |
#![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 LocalizableString {
pub value: String,
#[serde(rename = "localizedValue", default, skip_serializing_if = "O... |
use std::cmp::Ordering;
use std::collections::{HashMap, HashSet, BinaryHeap};
use super::types::SiteId;
use super::map::{Map, River};
#[derive(Serialize, Deserialize)]
pub struct Graph {
neighs: HashMap<SiteId, HashSet<SiteId>>,
}
enum Visit {
Visited,
NotYetVisited(usize),
}
#[derive(Default)]
pub stru... |
//! This module defines various utilities that do not belong in other modules.
use std::fmt::{self, Debug, Display, Formatter};
use std::hash::*;
use std::mem;
use alloc::raw_vec::RawVec;
use string_interner::StringInterner;
/// Defines an interned string, which can be cheaply cloned.
pub struct InternedString<'cx>... |
//! This is a small procedural macro to load your `.env` file at compile time. That way you can use
//! [`std::env!`][] to load environment variables and fail the build if a variable is missing.
//!
//! All it does is call the [dotenv](https://crates.io/crates/dotenv) crate.
//!
//! # Example
//!
//! `.env` file:
//!
/... |
/**
* 对目录下的文件进行自动分类到类型目录
* by shaipe 20190726
*/
use std::env;
use std::path::Path;
use std::fs::{read_dir, create_dir, copy, remove_file};
use std::io;
use std::io::prelude::*;
use std::fs::OpenOptions;
fn main(){
// 获取输入的参,参数为待处理的路径
let args: Vec<String>= env::args().collect();
let dir_str = if ar... |
use anyhow::{anyhow, Result};
use clap::{self, Clap, ValueHint};
use frodobuf::{
codegen::rust,
render::{OutputLanguage, RenderConfig, Renderer},
};
use frodobuf_schema::model::Schema;
use midl_parser::parse_string;
use std::{fs, path::PathBuf};
#[derive(Clap, Debug)]
#[clap(name = "midl", about, version)]
str... |
use std::{
convert::{TryFrom, TryInto},
fmt,
ops::Deref,
};
use thiserror::Error;
use crate::Error;
use librespot_protocol as protocol;
// re-export FileId for historic reasons, when it was part of this mod
pub use crate::FileId;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SpotifyItemTy... |
use naming;
use std::path::PathBuf;
pub struct Options {
pub out_path: PathBuf,
pub package_prefix: Option<String>,
pub id_converter: Option<Box<naming::Naming>>,
pub modules: Vec<String>,
}
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
#[path = "../src/char_offset.rs"]
mod char_offset;
use char_offset::char_offset_impl;
pub fn char_offset_impl_original(c: char) -> usize {
match c {
' '..='~' => c as usize,
'\u{0000}' => 0x00,
'☺' => 0x01,
'☻'... |
//! Command processor
use std::cell::RefCell;
use std::fmt;
use std::rc::Rc;
use unicode_segmentation::UnicodeSegmentation;
use super::history::{Direction, History};
use super::keymap::{Anchor, At, CharSearch, RepeatCount, Word};
use super::keymap::{InputState, Refresher};
use super::line_buffer::{LineBuffer, WordAct... |
use config::{ConfigError, Config, File, Environment};
/// Settings managing the data collection process
#[derive(Debug, Deserialize)]
pub struct DataCollectionSettings {
/// How many samples to take from the sensor for each data collection. These samples will be
/// averaged together, and that average will be ... |
// This file is part of Substrate.
// Copyright (C) 2017-2021 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... |
use std::ffi::OsStr;
use std::ffi::OsString;
use std::fs::File;
use std::io;
use std::os::unix::prelude::*;
use std::path::{Path, PathBuf};
use std::sync::RwLock;
use hashbrown::HashMap;
use hashbrown::HashSet;
use crate::elfkit::{self, ld_so_cache::LdsoCache, Elf};
fn replace_slice<T: Copy>(buf: &[T], from: &[T], t... |
fn main() {
println!("{:?}", pkcs7("YELLOW SUBMARINE", 20));
}
fn pkcs7(str: &str, len: usize) -> String {
format!("{:\x04<1$}", str, len)
}
#[test]
fn test_pkcs7() {
assert_eq!(
pkcs7("YELLOW SUBMARINE", 20),
"YELLOW SUBMARINE\x04\x04\x04\x04"
);
}
|
use crate::{DatabaseName, SessionId};
use serde::{Deserialize, Serialize};
use super::with_tx::SessionWithTx;
/// Session with open database.
///
/// This session means there is no open transaction.
/// Only limited SQLs are valid for this type of session (auto-commit is work for query-processor. It must Create this ... |
//! wmata is a simple interface to the [WMATA](https://wmata.com)'s API.
//!
//! # Design
//! wmata provides two main interfaces: [`MetroBus`] and [`MetroRail`].
//!
//! ## [`MetroBus`]
//! The interface to WMATA's MetroBus related methods
//!
//! ## [`MetroRail`]
//! The interface to WMATA's MetroRail related methods
... |
pub mod bitmap;
pub mod consts;
pub mod error;
pub mod utility {
pub fn hexdump(data: &[u8]) {
use alloc::prelude::*;
let mut index: usize = 0;
for bytes in data.chunks(16) {
println!(
"{:08x}: {}",
index,
bytes
... |
use lapin::ConnectionProperties;
// ConnectionProperties extension
pub trait LapinAsyncIoExt {
fn with_async_io(self) -> Self
where
Self: Sized,
{
self.with_async_io_reactor()
}
fn with_async_io_reactor(self) -> Self
where
Self: Sized;
}
impl LapinAsyncIoExt for Conne... |
use boolinator::Boolinator;
use regex::Regex;
#[derive(Copy, Clone)]
struct State<V: Fn(&str, &str) -> bool> {
fields: Option<u8>,
count: usize,
validator: V,
}
impl<V: Fn(&str, &str) -> bool> State<V> {
pub fn new(validator: V) -> Self {
Self {
fields: Some(0),
count: ... |
use diesel::RunQueryDsl;
use radmin::diesel::PgConnection;
use radmin::serde::{Deserialize, Serialize};
use radmin::uuid::Uuid;
use crate::models::contacts::ContactTag;
use crate::schema::contact_tags;
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Insertable)]
#[table_name = "contact_tags"]
pub struct Con... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: support@datadoghq.com
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use crate::apis::ResponseContent;
use super::{Error, configuration};
/// struct for typ... |
use core::alloc::{GlobalAlloc, Layout};
use core::cmp::min;
use core::ops::Deref;
use core::ptr::NonNull;
use alloc::alloc::{Allocator, Global};
use x86_64::VirtAddr;
use heap::LinkedListAllocator;
use crate::uses::*;
use crate::futex::Futex;
use crate::misc::mlayout_of;
pub mod heap;
#[derive(Debug)]
pub struct Me... |
//! Simulation running functions.
use crate::{Engine, Input, Output, Tracer};
use arctk::{err::Error, ord::X, tools::ProgressBar};
use rand::thread_rng;
use rayon::prelude::*;
use std::sync::{Arc, Mutex};
/// Run a multi-threaded render simulation.
/// # Errors
/// if the progress bar can not be locked.
#[allow(clipp... |
use crate::test_utils::*;
use std::net::TcpStream;
use vndb_rs::{
common::get::{
character::{GetCharacterResults, CHARACTER_FLAGS},
producer::{GetProducerResults, PRODUCER_FLAGS},
release::{GetReleaseResults, RELEASE_FLAGS},
staff::{GetStaffResults, STAFF_FLAGS},
ulist::{GetU... |
extern crate itertools;
mod graphpath;
fn main() {
}
|
use aoc_lib::AocImplementation;
use std::collections::VecDeque;
use itertools::Itertools;
use std::ops::Range;
fn main() {
let day7 = Day7 {
program_input: 5
};
day7.start(7)
}
struct Day7 {
program_input: i32
}
impl AocImplementation<i32> for Day7 {
fn process_input(&self, input: &str) -... |
#[cfg(test)]
mod tests {
use matrix::*;
use vector::*;
use traits::*;
use std::f32;
type Mat2 = Matrix2<f32>;
type Mat3 = Matrix3<f32>;
type Mat4 = Matrix4<f32>;
type Vec2 = Vector2<f32>;
type Vec3 = Vector3<f32>;
type Vec4 = Vector4<f32>;
// -------------------------... |
use std::{fs, collections::HashSet};
type Instruction = (char, usize);
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
struct Point {
x: isize,
y: isize,
}
impl Point {
fn touching(&self, other: &Self) -> bool {
let x_distance = self.x - other.x;
let y_distance = self.y - othe... |
use crate::prelude::*;
use crate::{EntriesListView, GenericView, TreeView};
use futures::stream::{self, StreamExt};
use std::sync::{Arc, Mutex};
pub(crate) fn format(input: Vec<Value>, host: &mut dyn Host) {
let last = input.len() - 1;
for (i, item) in input.iter().enumerate() {
let view = GenericView:... |
#[doc = "Reader of register RTC_HWCFGR"]
pub type R = crate::R<u32, super::RTC_HWCFGR>;
#[doc = "Reader of field `ALARMB`"]
pub type ALARMB_R = crate::R<u8, u8>;
#[doc = "Reader of field `WAKEUP`"]
pub type WAKEUP_R = crate::R<u8, u8>;
#[doc = "Reader of field `SMOOTH_CALIB`"]
pub type SMOOTH_CALIB_R = crate::R<u8, u8>... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: support@datadoghq.com
* Generated by: https://openapi-generator.tech
*/
/// WidgetDefinition : [Definition of the widget](https://docs.datadoghq.com/dashboards/widgets/).
#[... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: support@datadoghq.com
* Generated by: https://openapi-generator.tech
*/
/// PagerDutyServiceKey : PagerDuty service object key.
#[derive(Clone, Debug, PartialEq, Serialize, ... |
#[doc = "Register `CFGR` reader"]
pub type R = crate::R<CFGR_SPEC>;
#[doc = "Register `CFGR` writer"]
pub type W = crate::W<CFGR_SPEC>;
#[doc = "Field `CM4L` reader - CM4L"]
pub type CM4L_R = crate::BitReader;
#[doc = "Field `CM4L` writer - CM4L"]
pub type CM4L_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
#[... |
/*
* Rust自習(std::time::Instant)
* CreatedAt: 2019-07-26
*/
fn main() {
let ins = std::time::Instant::now();
println!("{:?}", ins);
}
|
use rand::rngs::ThreadRng;
use super::Material;
use crate::ray::Ray;
use crate::shape::HitRecord;
use crate::vec3::{Color, Vec3};
pub struct Metal {
color: Color,
fuzz: f64,
}
impl Metal {
pub fn new(color: Color, fuzz: f64) -> Self {
Self { color, fuzz }
}
}
impl Default for Metal {
fn ... |
/*
Copyright 2016 Robert Lathrop
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, softwar... |
use super::auto::{HasInner, Abstract};
use super::container::{Container, ContainerInner};
use super::control::{Control};
use super::member::{Member, AMember, MemberBase};
define_abstract! {
SingleContainer: Container {
outer: {
fn set_child(&mut self, child: Option<Box<dyn Control>>) -> Option<... |
// q0079_word_search
struct Solution;
impl Solution {
pub fn exist(board: Vec<Vec<char>>, word: String) -> bool {
let ref mut used_pos = vec![];
let mut pos_pos = vec![];
for (i, line) in board.iter().enumerate() {
for (j, _) in line.iter().enumerate() {
pos_pos... |
use response::{Links, Meta};
#[derive(Deserialize, Debug, Clone)]
pub struct Pages {
pub first: Option<String>,
pub prev: Option<String>,
pub next: Option<String>,
pub last: Option<String>,
}
#[derive(Deserialize)]
pub struct RawPagedResponse<T> {
pub collection: Vec<T>,
pub links: Links,
... |
//! Union-find data structure, see [`UnionFind`].
use slotmap::{Key, SecondaryMap};
/// Union-find data structure.
///
/// Used to efficiently track sets of equivalent items.
///
/// <https://en.wikipedia.org/wiki/Disjoint-set_data_structure>
#[derive(Default, Clone)]
pub struct UnionFind<K>
where
K: Key,
{
l... |
/* CANOpen */
/* Standard Industrial Protocol */
/* Uses Include - Robotics, Remote I/O, Safety I/O */
/* General Functions */
pub mod sdo;
pub mod pdo;
pub mod nmt;
use crate::stm32hal::{can::CanMsg};
/* State Commands For CANOpen */
pub const BOOTUP: u8 = 0x00; // Boot up (Initialising)
pub const STOPPE... |
fn main() {
use std::io::{self, BufRead};
let stdin = io::stdin();
let snumber = stdin.lock().lines().next().unwrap().unwrap()
.parse::<i32>().unwrap();
let grid = (1..=300).map(|x| (1..=300).map(|y|
(((x+10)*y + snumber)*(x+10)/100)%10 - 5
).collect::<Vec<i32>>()).collect::<V... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: support@datadoghq.com
* Generated by: https://openapi-generator.tech
*/
/// WidgetFormula : Formula to be used in a widget query.
#[derive(Clone, Debug, PartialEq, Serialize... |
//! Command line interface for operations on the EFI `BootNext` variable.
use clap::{Parser, Subcommand};
use efibootnext::Adapter;
/// The command line app invocation.
#[derive(Parser)]
#[command(name = "efibootnext")]
#[command(about = "Control BootNext EFI variable.", long_about = None)]
struct Invocation {
//... |
//! This example demonstrates reading a csv string to a [`Table`] struct.
//!
//! * Note the necessary step of representing the string as a byte array.
fn main() {
let syscalls = "\
0,INDIR,,\"int sys_syscall(int number, ...)\"\n\
1,STD,,\"void sys_exit(int rval)\"\n\
2,STD,,\"int sys_fork(... |
extern crate num;
extern crate ring;
use self::num::BigUint;
use self::ring::digest::{ digest, SHA256 };
use std::cmp::Ordering;
use std::fmt::Write;
use block::Block;
const TARGET_BITS: u64 = 3;
pub fn run_pow(blk: &mut Block) {
let mut hash_int;
let mut hash: Vec<u8> = vec![];
let mut nonce = 0u64... |
use core::mem;
use core::alloc::Layout;
use core::sync::atomic::AtomicPtr;
use core::cell::Cell;
use core::cmp::max;
use sys::PAGE_SIZE;
use crate::uses::*;
use crate::collections::LinkedList;
use crate::ptr::{UniqueMut, UniquePtr, UniqueRef};
use crate::{alloc, dealloc, impl_list_node};
use super::{Allocation, MemOw... |
use alloc::vec::Vec;
use util::{uint_from_bytes, Hash};
use crate::consts::{IV32, IV64, SIGMA};
macro_rules! g32 {
($self:ident, $block:expr, $r:expr, $i:expr, $a:expr, $b:expr, $c:expr, $d:expr) => {
$self.v[$a] = $self.v[$a]
.wrapping_add($self.v[$b])
.wrapping_add($block[SIGMA[... |
fn main() {
// When a specfic vector holds a specific type, the type is specified
// the type is specified withi the angle brackets
// We are sayint that the type here here will hold elements of i32 type
let v: Vec<i32> = Vec::new();
// Don't need the type annotation "Vec<i32>" here because compiler... |
use {
crate::{Backend, RawSession},
cookie::{Cookie, CookieBuilder},
serde_json,
std::{borrow::Cow, collections::HashMap, fmt, sync::Arc},
tsukuyomi::{
error::{Error, Result},
future::{Poll, TryFuture},
input::{Cookies, Input},
},
};
#[cfg(feature = "secure")]
use cookie... |
use super::Byte;
use super::{coerce_whitespace, discard};
use std::iter;
#[derive(Clone)]
pub struct Input<'a> {
bytes: &'a [Byte],
}
impl<'a> Input<'a> {
#[doc(hidden)]
// TODO: This can probably made private with little effort
// since most usages of this field
// need to be moved in here anyway.
... |
extern crate tar = "tar";
#[test]
fn test_data_len() {
let tar = tar::new("/Users/matuzak/workspace/rust-tar/tests/tar_test.tar");
let data = tar.read();
assert_eq!(data.len(), 13);
}
#[test]
fn test_fields() {
let tar = tar::new("/Users/matuzak/workspace/rust-tar/tests/tar_test.tar");
let path = ... |
pub mod line;
pub mod sector;
pub mod triangle;
pub mod triangulate;
pub mod wall;
|
use std::fmt;
#[derive(Debug, Clone)]
pub enum Component {
Property(String),
Index(usize),
}
#[derive(Debug, Clone)]
pub struct PathBuf {
components: Vec<Component>,
}
impl PathBuf {
pub fn new() -> PathBuf {
PathBuf { components: vec![] }
}
pub fn push_index(&mut self, index: usize)... |
fn main() {
println!("part one: {}", find_last(&[1, 0, 15, 2, 10, 13], 2020));
println!("part one: {}", find_last(&[1, 0, 15, 2, 10, 13], 30000000));
}
fn find_last(nums: &[usize], nth_num: usize) -> usize {
let mut cache = vec![std::usize::MAX; nth_num];
for (i, &n) in nums.iter().enumerate() {
... |
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| ... |
mod compute_submission;
mod get_args;
mod get_orig_state;
mod orig_state;
mod submission;
mod utilities;
mod write_submission;
use compute_submission::compute_submission;
use get_args::get_args;
use get_orig_state::get_orig_state;
use orig_state::OrigState;
use write_submission::write_submission;
fn sort_libs(orig_st... |
fn main () {
repeat("Hello", 3);
}
fn repeat(string: &str, times: i32) {
for _n in 0..times {
println!("{}", string)
}
}
|
use std::io;
pub enum StorageError
{
KeyNotFound, //Key is not available
CorruptStorage, //database file broken or something like that
Custom(String), //Custom error string
KeyIoError(io::Error), //io error when accessing key handle
ValueIoError(io::Error), //io error when accessing value handle
}
|
fn main() {
let x = 5; // 尾部注释
// 注释
// 多行注释
// 每行用 //
}
|
// Copyright 2020 Alex Dukhno
//
// 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 ... |
#![cfg_attr(feature = "unstable", feature(test))]
// Launch program : cargo run --release < input/input.txt
// Launch benchmark : cargo +nightly bench --features "unstable"
/*
Benchmark results:
running 4 tests
test tests::test_part_1 ... ignored
test bench::bench_parse_input ... bench: 98,888 ns/it... |
//! LimitTracker type and Messenger trait to demonstrate [RefCell<T>] usage.
//!
//! [refcell<t>]: https://doc.rust-lang.org/book/ch15-05-interior-mutability.html
use std::cell::RefCell;
use the_book::ch15::sec05::{LimitTracker, Messenger};
fn main() {
let cacher = Cacher::new();
let mut tracker = LimitTracke... |
use super::{schema::groups, user::User, PostgresPool};
use anyhow::Context;
use diesel::prelude::*;
#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
#[belongs_to(User)]
pub struct Group {
pub id: uuid::Uuid,
pub user_id: uuid::Uuid,
pub name: String,
pub created_at: chrono::DateTime<c... |
use iron::prelude::*;
use regex::{Regex, Captures};
use common::http::*;
use common::utils::*;
use services::comment::*;
use services::comment::create_comment as service_create_comment;
use services::comment::delete_comment as service_delete_comment;
use services::comment_vote::*;
use services::user::get_user_id;
use ... |
use amethyst::{
core::transform::Transform,
ecs::prelude::{Entity, World},
prelude::*,
};
use crate::components::{Destination, Sprite, Sprites, Velocity, Worker};
pub fn init_worker(world: &mut World, local: Transform) -> Entity {
world
.create_entity()
.with(Worker {})
.with(l... |
//! Module for the user-facing [`Context`] object.
use std::any::Any;
use std::future::Future;
use std::marker::PhantomData;
use instant::Instant;
use tokio::sync::mpsc::UnboundedSender;
use tokio::task::JoinHandle;
use super::graph::StateData;
use super::state::StateHandle;
use super::{StateId, SubgraphId};
/// Th... |
pub mod payload_types;
pub mod payload_serializers;
|
use thiserror::Error;
use warp::{reject::Reject, Rejection, Reply};
#[derive(Error, Debug, serde::Serialize)]
#[serde(untagged)]
pub enum Error {
#[error("Database error")]
DbError(
#[from]
#[serde(skip)]
sqlx::Error,
),
#[error(transparent)]
Session(#[from] super::SessionE... |
// Corresponds to the R:N and W:N in the memory access text
#[derive(Debug, PartialEq)]
pub enum AccessType {
Read,
Write,
}
// Helps us keep track of the different results when trying to access a page
// MissSimple simply means that we can push the page because we have space in physical memory
// MissReplace... |
use crate::{
cmd::*,
keypair::{KeyTag, KeyType, Network, KEYTYPE_ED25519_STR, NETTYPE_MAIN_STR},
mnemonic::SeedType,
result::Result,
wallet::{ShardConfig, Wallet},
};
use std::path::PathBuf;
#[derive(Debug, StructOpt)]
/// Create a new wallet
pub enum Cmd {
Basic(Basic),
Sharded(Sharded),
}... |
use device::LuxaforDeviceDescriptor;
pub const FULL_FLAG : LuxaforDeviceDescriptor = LuxaforDeviceDescriptor {
vendor_id: 0x04d8,
product_id: 0xf372
}; |
#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
//! ???
use rayon::prelude::*;
use rustagious::{gen_phase_fn, Person, Phase};
use std::collections::HashMap;
//type Res = (String, u64, String, u64, String, u64);
type Res = (u64, u64);
fn main() {
println!("a, ac, c, ca, offset, a_test, b_test, n, ... |
#[doc = "Register `APB2SECSR` reader"]
pub type R = crate::R<APB2SECSR_SPEC>;
#[doc = "Field `SYSCFGSECF` reader - SYSCFGSECF"]
pub type SYSCFGSECF_R = crate::BitReader;
#[doc = "Field `TIM1SECF` reader - TIM1SECF"]
pub type TIM1SECF_R = crate::BitReader;
#[doc = "Field `SPI1SECF` reader - SPI1SECF"]
pub type SPI1SECF_... |
// Copyright © 2019 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
extern crate vmm;
#[macro_use(crate_version, crate_authors)]
extern crate clap;
use clap::{App, Arg};
use std::process;
use vmm::config;
fn main() {
let cmd_arguments = App::new("cloud-hypervisor")
.version(crate_version!... |
//! Responses from MetroBus related methods from the WMATA API.
use crate::{Route, Stop};
use chrono::{DateTime, FixedOffset};
use serde::Deserialize;
#[derive(Deserialize, Debug)]
#[serde(rename_all = "PascalCase")]
pub struct BusPositions {
/// See [`BusPosition`].
pub bus_positions: Box<[BusPosition]>,
}
#... |
use std::ffi::CStr;
use assets::AssetId;
use crypto::{PublicKey, Signature};
use hex::FromHex;
use libc::{c_char, size_t};
use error::{Error, ErrorKind};
pub fn hex_string(bytes: Vec<u8>) -> String {
let strs: Vec<String> = bytes.iter().map(|b| format!("{:02x}", b)).collect();
strs.join("")
}
pub fn parse_s... |
use crate::{
enum_default, enum_display, enum_fmt_impl, enum_impls, impl_enums,
};
use std::fmt::Binary;
use std::fmt::Display;
use std::fmt::LowerHex;
use std::fmt::Octal;
use std::fmt::UpperHex;
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
enum Weight {
Default,
Bold = 1,
Dim = 2,
}
#[derive(C... |
// https://doc.rust-lang.org/std/primitive.u32.html
fn main() {
proconio::input! {
n: usize,
a: [i32; n]
}
println!("{}", a.iter()
.map(|x| x.trailing_zeros())
.min()
.unwrap()
);
}
|
use preexplorer::prelude::*;
fn main() -> anyhow::Result<()> {
let times = vec![1., 10., 100.];
let values = vec![1, 2, 4];
(times, values)
.preexplore()
.set_title("My Title")
.set_logx(-3) // Negative values imply logx(10), gnuplot sintaxis
.plot("identifier")?;
Ok(()... |
use crate::network_group::{Group, NetworkGroup};
use crate::{multiaddr::Multiaddr, ProtocolId, ProtocolVersion, SessionType};
use p2p::{secio::PeerId, SessionId};
use std::collections::HashMap;
use std::time::{Duration, Instant};
#[derive(Clone, Debug)]
pub struct PeerIdentifyInfo {
pub client_version: String,
}
... |
use std::{fs, io};
fn main() -> io::Result<()> {
let input = fs::read_to_string("input.txt")?
.trim()
.split('\n')
.map(|x| x.parse().expect("not a number"))
.collect::<Vec<u64>>();
for a in &input {
if *a < 2020 {
for b in &input {
if a + b ... |
/// An enum to represent all characters in the CJKUnifiedIdeographsExtensionF block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum CJKUnifiedIdeographsExtensionF {
/// \u{2ceb0}: '𬺰'
CjkIdeographExtensionFFirst,
/// \u{2ebe0}: '𮯠'
CjkIdeographExtensionFLast,
}
impl Into<char> for CJKUn... |
extern crate byteorder;
extern crate i2cdev;
extern crate rust_pigpio;
use self::rust_pigpio::pwm::*;
use self::rust_pigpio::*;
pub struct Servo {
pub pwm_pin: u32,
}
impl Servo {
pub fn init(&self) {
set_mode(self.pwm_pin, OUTPUT).unwrap();
servo(self.pwm_pin, 0).unwrap();
//set_pwm_... |
/* This is part of mktcb - which is under the MIT License ********************/
use snafu::{Snafu};
#[derive(Debug, Snafu)]
#[snafu(visibility(pub))]
pub enum Error {
#[snafu(display("Failed to initialize logging"))]
LogInitFailed {
},
#[snafu(display("The version must be of format 'X.Y'. Found {}", ... |
use std::borrow::Borrow;
use std::collections::{hash_map, HashMap};
use std::fmt::{self, Debug};
use std::hash::{BuildHasher, Hash};
use std::iter::FromIterator;
use std::ops::{Deref, DerefMut, Index};
use std::panic::UnwindSafe;
/// A [`HashMap`](std::collections::HashMap) using [`ABuildHasher`](crate::ABuildHasher) ... |
use ::rgb::{ToRGB, RGB};
pub struct HSV {
h: f32,
s: f32,
v: f32
}
impl HSV {
pub fn from_hsv(h: f32, s: f32, v: f32) -> HSV {
HSV {h: h, s: s, v: v}
}
pub fn get_values(&self) -> (f32, f32, f32) {
(self.h, self.s, self.v)
}
}
impl ToRGB for HSV {
fn to_rgb(&self) -> ... |
#![cfg_attr(feature = "nightly", feature(alloc))]
#![cfg_attr(not(test), no_std)]
#[cfg(test)]
extern crate core;
#[cfg(all(not(test), feature = "use_std"))]
#[macro_use]
extern crate std;
// Use liballoc on nightly to avoid a dependency on libstd
#[cfg(feature = "nightly")]
extern crate alloc;
#[cfg(not(feature = "n... |
use std::fs::File;
use std::io::{ ErrorKind, Read };
fn read_from_file() -> Result<String, io::Error> {
let mut s = String::new();
// what is ? is immediatly return if Enum type: Error through From Func
// From convert from Error type to Function Error Type
// must using in return Result func
File:... |
use crate::zx::video::colors::{ZXBrightness, ZXColor};
pub enum FrameBufferSource {
Screen,
Border,
}
pub trait FrameBuffer {
type Context: Clone;
/// Creates canvas size with required dimensions (`width`, `height`)
fn new(width: usize, height: usize, source: FrameBufferSource, context: Self::Cont... |
#[test]
fn cpuid() {
let cpuid = unsafe { &*crate::peripheral::CPUID::PTR };
assert_eq!(address(&cpuid.base), 0xE000_ED00);
assert_eq!(address(&cpuid.pfr), 0xE000_ED40);
assert_eq!(address(&cpuid.dfr), 0xE000_ED48);
assert_eq!(address(&cpuid.afr), 0xE000_ED4C);
assert_eq!(address(&cpuid.mmfr), ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.