text stringlengths 8 4.13M |
|---|
use dyn_clone::DynClone;
trait MyTrait: DynClone {
fn recite(&self);
}
impl MyTrait for String {
fn recite(&self) {
println!("{} ♫", self);
}
}
fn main() {
let line = "The slithy structs did gyre and gimble the namespace";
// Build a trait object holding a String.
// This requires St... |
use log::debug;
use std::path::PathBuf;
pub fn asset_path(name: &str) -> PathBuf {
let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
p.push("assets");
p.push(name);
debug!("asset path for {} is {:?}", name, p.as_path());
p
}
|
use std::time::Instant;
use glium::{
glutin::event::Event,
glutin::event_loop::{ControlFlow, EventLoop, EventLoopProxy},
glutin::window,
glutin::ContextBuilder,
Display,
};
use crate::command::Command;
use crate::input::Input;
use crate::output::Output;
pub struct MainLoop<CustomEvent: 'static> {... |
/*===============================================================================================*/
// 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
//
// ... |
extern crate rand;
use crate::assets::{T_BODY, T_CORNER, T_HEAD, T_TAIL};
use rand::distributions::{Distribution, Uniform};
use std::collections::VecDeque;
#[derive(Debug, PartialEq, Clone)]
pub enum MovingDirection {
Left,
Right,
Up,
Down,
}
impl MovingDirection {
pub fn from_axis(axis: &str, va... |
extern crate libc;
pub mod picosat;
#[cfg(test)]
mod picosat_tests;
|
#![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 AgreementTermsList {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub value: Vec<OldAgreementTe... |
use super::{Trader, Order, Action};
use crate::indicators::{MACDHistogram, Indicator};
use crate::economy::Monetary;
enum Safe {
Base,
Quote,
None
}
pub struct GobbleBadLongterm<T, const SAFE: &'static str>
where
T: Trader
{
trader: T,
safe: Safe,
}
impl<T, const SAFE: &'static str> T... |
#![allow(unused_variables)]
#![allow(dead_code)]
use std::net::{Ipv4Addr, Ipv6Addr};
fn main() {
enum_start();
enum_with_struct();
enum_def_with_type();
enum_similarity_to_struct();
option_enum_and_none_in_rust();
}
fn enum_start() {
enum IPAddrKind {
V4,
V6,
}
let ... |
#[doc = "Reader of register PERIPH_ID_1"]
pub type R = crate::R<u32, super::PERIPH_ID_1>;
#[doc = "Reader of field `PERIPH_ID_1`"]
pub type PERIPH_ID_1_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:7 - part number"]
#[inline(always)]
pub fn periph_id_1(&self) -> PERIPH_ID_1_R {
PERIPH_ID_1_R::new((... |
use super::Result;
use crate::model::Product;
pub trait ProductController: Send + Sync {
fn get_archived_products(&self, page: usize, per_page: usize) -> Result<Vec<Product>>;
}
|
use super::{RepositorySnapshots, Snapshot, SnapshotId};
use crate::{atomic::AtomicUpdate, error::Error};
use std::path;
impl RepositorySnapshots {
// Updates the snapshot state when taking a snapshot
pub fn update_state(&mut self, atomic: &mut AtomicUpdate, snapshot: &Snapshot, is_new_parent: bool) -> Result<... |
//! Hynitron CST816S touch panel driver
//!
//! Pins:
//! * P0.10 : Reset
//! * P0.28 : Interrupt (signal to the CPU when a touch event is detected)
//! * P0.06 : I²C SDA
//! * P0.07 : I²C SCL
//!
//! I²C
//! Device address : 0x15
//! Frequency : from 10Khz to 400Khz
use crate::hal::{
gpio::{p0, Floating, Input, O... |
//! This module is about communicating with our many robot
//! modules via a custom UDP protocol.
use message::{Message, WinchCommand};
use controller::ControllerPort;
use std::thread;
use bincode;
use config::Config;
use std::net::{SocketAddr, UdpSocket};
use std::io;
use std::io::Write;
use serde::Serialize;
use fyg... |
#[doc = "Register `LPTIM_CFGR` reader"]
pub type R = crate::R<LPTIM_CFGR_SPEC>;
#[doc = "Register `LPTIM_CFGR` writer"]
pub type W = crate::W<LPTIM_CFGR_SPEC>;
#[doc = "Field `CKSEL` reader - CKSEL"]
pub type CKSEL_R = crate::BitReader;
#[doc = "Field `CKSEL` writer - CKSEL"]
pub type CKSEL_W<'a, REG, const O: u8> = cr... |
pub mod codec;
pub mod messages;
|
//! Core protocol services.
pub mod peer;
pub mod router;
pub mod switch;
#[doc(inline)]
pub use peer::{Peer, PeerManager};
#[doc(inline)]
pub use router::Router;
#[doc(inline)]
pub use switch::Switch;
|
use ::components::find_named_child;
use ::waiting_late_init::*;
use amethyst::core::*;
use amethyst::ecs::*;
use amethyst_editor_sync::*;
#[derive(Debug, Clone, Copy, Serialize)]
pub struct BipedEntities {
pub body: SerializableEntity,
pub head: SerializableEntity,
}
impl Component for BipedEntities {
typ... |
use svc_agent::mqtt::Address;
use svc_agent::{AccountId, AgentId, Authenticable};
use svc_authn::{jose::Algorithm, token::jws_compact::TokenBuilder};
use super::TOKEN_ISSUER;
use crate::app::API_VERSION;
const TOKEN_EXPIRATION: i64 = 600;
const KEY_PATH: &str = "data/keys/svc.private_key.p8.der.sample";
lazy_static:... |
use std::borrow::Cow;
use std::error::Error;
pub trait BytesEncode {
type EItem: ?Sized;
fn bytes_encode(item: &Self::EItem) -> Result<Cow<[u8]>, Box<dyn Error>>;
}
pub trait BytesDecode<'a> {
type DItem: 'a;
fn bytes_decode(bytes: &'a [u8]) -> Result<Self::DItem, Box<dyn Error>>;
}
|
extern crate redox_termios;
extern crate syscall;
use std::fs::{self, File, OpenOptions};
use std::io::{self, Read, Write};
use std::os::unix::io::{FromRawFd, IntoRawFd, RawFd};
use std::process::{Child, Command, ExitStatus, Stdio};
use syscall::{Io, Pio};
const DEFAULT_COLS: u32 = 80;
const DEFAULT_LINES: u32 = 30;
... |
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
#![allow(clippy::default_trait_access)]
use bigdecimal::*;
use chrono::prelude::*;
use phonenumber::*;
use serde::*;
use std::{path::*, str::FromStr};
use structopt::*;
use tokio::stream::*;
use url::Url;
use yandex_money::*;
#[derive(Clone, Debug, Serialize, D... |
use actix_web::error::{ErrorForbidden, ErrorInternalServerError};
use actix_web::web::{Data, Json};
use actix_web::Error;
use futures::{
future::{self, Either},
Future,
};
use serde::Serialize;
use crate::auth::Auth;
use crate::db::logs::GetLogs;
use crate::Actors;
use chrono::NaiveDateTime;
#[derive(Debug, S... |
use std::io::Write;
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use crate::error::{RconError, RconError::CommandTooLong};
type PacketType = i32;
pub(crate) const TYPE_AUTH: PacketType = 3;
pub(crate) const TYPE_EXEC: PacketType = 2;
pub(crate) const TYPE_RESPONSE: PacketType = 0;
pub(crate) const TY... |
#[doc = "Register `TIM7_SMCR` reader"]
pub type R = crate::R<TIM7_SMCR_SPEC>;
#[doc = "Register `TIM7_SMCR` writer"]
pub type W = crate::W<TIM7_SMCR_SPEC>;
#[doc = "Field `SMS` reader - SMS"]
pub type SMS_R = crate::FieldReader;
#[doc = "Field `SMS` writer - SMS"]
pub type SMS_W<'a, REG, const O: u8> = crate::FieldWrit... |
pub mod router;
mod handler;
pub mod models; |
// Part Three: DRY Fusion
//
// Take the two programs written previously and factor
// out as much common code as possible, leaving you with two smaller programs
// and some kind of shared functionality.
//
use std::fmt;
use std::num;
use std::cmp;
pub trait Spread<T> {
fn spread(&self) -> int {}
}
en... |
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::collections::HashMap;
use regex::Regex;
pub fn exercise() {
let mask_regex = Regex::new(r"^mask = ([01: X]+)$").unwrap();
let memory_regex = Regex::new(r"^mem\[(\d+)\] = (\d+)$").unwrap();
let mut memory_map: HashMap<i32,String> = HashMap::new();
... |
// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
// Copyright (C) 2021 Subspace Labs, Inc.
// 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
//
... |
use std::collections::hash_map::RandomState;
use std::collections::HashMap;
use std::mem::size_of;
// Rust 的类型系统
pub fn first() {
// Rust 的类型系统是一种代数类型系统。数学上严格定义,非常严谨的一套理论
// 代数类型系统与代数的对比
// 类型:类比为代数中的变量
// 类型间的组合关系:类比为代数中数学运算
// 一个类型所有取值的可能性叫作这个类型的“基数”(Cardinality)
// unit: 1, ()
// bool: ... |
use std::collections::HashMap;
pub fn main() {
let result = Solution::find_repeat_number(vec![1, 2, 3, 4, 55, 3, 2, 1]);
println!("{}", result);
}
pub struct Solution;
impl Solution {
pub fn find_repeat_number(nums: Vec<i32>) -> i32 {
let mut map: HashMap<i32, &str> = HashMap::new();
for... |
// Copyright 2020 Eray Erdin
//
// 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 w... |
use hyper::client::response::Response;
use api_request::{ApiRequest, ApiRequestBuilder};
use std::rc::Rc;
use hyper::client::{Client, Body};
use hyper::client::RequestBuilder;
use hyper::client::request::Request;
use hyper::Url;
use hyper::net::{Fresh, Streaming};
use api_client::ApiClient;
use api_request::HttpMethod;... |
use crate::days::day24::{Direction, default_input, parse_input, Point};
use std::collections::HashSet;
pub fn run() {
println!("{}", hex_str(default_input()).unwrap());
}
pub fn hex_str(input : &str) -> Result<usize, ()> {
hex(parse_input(input))
}
pub fn hex(input : Vec<Vec<Direction>>) -> Result<usize, ()>... |
use crossbeam_queue;
use std::sync::atomic::Ordering::Relaxed;
use std::sync::atomic::{AtomicBool, AtomicI32};
use std::sync::Arc;
#[macro_use]
extern crate tower_web;
#[macro_use]
extern crate serde_json;
#[derive(Debug, PartialEq)]
enum Request {
AA(f32),
BB(f32),
}
struct JsonResource {
queue: Arc<cr... |
// This file is part of rss.
//
// Copyright © 2015-2017 The rust-syndication Developers
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the MIT License and/or Apache 2.0 License.
#![feature(test)]
extern crate rss;
extern crate test;
use rss::Channel;
use std::io:... |
use crate::{
api::{
extractors::{
auth::Auth,
},
errors::{ApiError, ApiResult, respond},
app_state::AppDatabase,
fields::{
Username,
Password,
Email,
Cursor as CursorField,
Id,
PaginationSize,... |
// 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.
//! This crate contains Winterfell STARK verifier.
//!
//! This verifier can be used to verify STARK proofs generated by the Winterfell ST... |
use std::cell::Cell;
use std::ptr;
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering, fence};
use util::alloc;
use util::consume::Consume;
use util::countedu16::{CountedU16, Transaction};
use util::maybe_acquire::{MAYBE_ACQUIRE, maybe_acquire_fence};
#[derive(Clone, Copy)]
enum ReaderState {
Single,
Mu... |
use std::cell::RefCell;
use std::rc::Rc;
use super::ArcDataSlice;
use super::hlc;
use super::object;
use super::paxos;
use super::store;
use super::transaction;
use super::*;
pub struct NullCRLState {
pub state_saves: usize,
pub alloc_saves: usize
}
pub struct NullCRL {
pub state: Rc<RefCell<NullCRLStat... |
use std::{
collections::{HashSet, LinkedList, VecDeque},
hash::Hash,
marker::PhantomData,
ops::{Add, AddAssign, Shl},
};
#[derive(Debug, Default)]
pub struct MultiResult<R, C> {
pub result: R,
pub collect: C,
}
impl<Q, R, C> Add<MultiResult<R, C>> for MultiResult<Q, C>
where
C: Semigroup,
... |
pub struct Observable<T> {
observers: Vec<Box<dyn Fn(&T)>>,
}
impl<T> Observable<T> {
pub fn new() -> Observable<T> {
Observable {
observers: Vec::new(),
}
}
pub fn subscribe<F>(&mut self, observer: F)
where
F: 'static + Fn(&T),
{
self.observers.push... |
#[macro_use]
extern crate clap;
use clap::{App, ArgMatches};
use ghash::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
macro_rules! impl_subcommands_matches {
($app:expr, $message:expr, $( $name:expr, $T:ident );+) => {
match $app.subcommand() {
$(
($nam... |
mod header;
mod message;
mod util;
pub(crate) use self::{
message::{Message, MessageFlags},
util::next_request_id,
};
|
use diesel::prelude::*;
use uuid::Uuid;
use diesel::result::Error as DError;
mod tables {
table! {
users(username) {
username -> Text,
password -> Text,
}
}
table! {
tokens(uuid) {
uuid -> Text,
}
}
}
use self::tables::{tokens, user... |
use diesel::{PgConnection, QueryResult};
use crate::db::types::Branch;
use chrono::NaiveDateTime;
use crate::db::money_nodes as nodes;
use serde::Deserialize;
pub fn all(conn: &PgConnection) -> i32 {
let nodes = nodes::all(conn).unwrap();
nodes.iter().map(|node| node.change).sum()
}
pub fn by_query(conn: &PgC... |
#[doc = "Reader of register FDCAN_TSCC"]
pub type R = crate::R<u32, super::FDCAN_TSCC>;
#[doc = "Writer for register FDCAN_TSCC"]
pub type W = crate::W<u32, super::FDCAN_TSCC>;
#[doc = "Register FDCAN_TSCC `reset()`'s with value 0"]
impl crate::ResetValue for super::FDCAN_TSCC {
type Type = u32;
#[inline(always... |
use rand::{random, Rng};
use std::borrow::Borrow;
use std::ops::Deref;
use nalgebra::distance;
use ndarray::prelude::*;
use std::slice::{from_raw_parts};
fn sum_2d_vector(vector: &Vec<Vec<f64>>) -> f64
{
let mut sum = 0.0;
for i in 0..vector.len()
{
for j in 0..vector[0].len()
{
... |
use std::{fmt, fs};
use simple_error::{SimpleResult, SimpleError};
use crate::instrument::{Instrument, Sample};
use crate::module_reader::module::module::read_mod;
use crate::module_reader::s3m::s3m::read_s3m;
use crate::module_reader::xm::xm::read_xm;
use crate::pattern::Pattern;
use crate::channel_state::channel_stat... |
#[doc = "Reader of register FDCAN_XIDFC"]
pub type R = crate::R<u32, super::FDCAN_XIDFC>;
#[doc = "Writer for register FDCAN_XIDFC"]
pub type W = crate::W<u32, super::FDCAN_XIDFC>;
#[doc = "Register FDCAN_XIDFC `reset()`'s with value 0"]
impl crate::ResetValue for super::FDCAN_XIDFC {
type Type = u32;
#[inline(... |
use std::{net::IpAddr, sync::Mutex};
use actix_web::{
get, http,
middleware::Logger,
web::{self, scope},
App, HttpRequest, HttpResponse, HttpServer, Responder,
};
use askama::Template;
use log::info;
mod scraper;
#[derive(Template)]
#[template(path = "front_page.html")]
struct FrontPageTemplate {}
... |
// =========================
// Ppprzlink Secure Transport
// =========================
use super::rusthacl::*;
use super::parser::{PprzDictionary, PprzMsgBaseType, PprzMsgClassID, PprzMessage,
PprzProtocolVersion};
use super::transport::PprzTransport;
use std::sync::Arc;
use std::mem;
use std::io::... |
use regex::Regex;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::process;
#[macro_use]
extern crate lazy_static;
fn is_valid(password: &str) -> bool {
lazy_static! {
static ref RE: Regex =
Regex::new(r"^(?P<min>\d+)-(?P<max>\d+)\s*(?P<char>\w): (?P<p... |
enum Fzv {
Value(u64),
Fizz(u64),
Buzz(u64),
FizzBuzz(u64),
}
fn main() {
for n in (1..100).map(fzbzing) {
println!("{}", n)
}
}
fn fzbzing(n: u64) -> u64 {
match n {
n if n % 15 == 0 => Fzv::FizzBuzz(n),
n if n % 5 == 0 => Fzv::Buzz(n),
n if n % 3 == 0 => F... |
// ===============================================================================
// Authors: AFRL/RQQA
// Organization: Air Force Research Laboratory, Aerospace Systems Directorate, Power and Control Division
//
// Copyright (c) 2017 Government of the United State of America, as represented by
// the Secretary of th... |
use crate::{syntax::*, prelude::*, typeck};
pub fn eval(term: Term) -> Term {
match (*term).clone() {
TmApp(f, x) => match ((*eval(f)).clone(), eval(x)) {
(TmAbs(v, _, y), x) => eval(subst(x, y, v)),
(f, x) => de::app(f, x),
},
TmTyApp(f, t) => match (*eval(f)).clone... |
#[doc = "Reader of register TIM_COUNTER_L"]
pub type R = crate::R<u32, super::TIM_COUNTER_L>;
#[doc = "Reader of field `TIM_REF_CLOCK`"]
pub type TIM_REF_CLOCK_R = crate::R<u16, u16>;
impl R {
#[doc = "Bits 0:15 - 16-bit internal reference clock. The clock is a free run-ning clock, incremented by a 0.625ms periodic... |
use alloc::alloc::{GlobalAlloc, Layout};
use libutil::mem::heap::LinkedListAllocator;
use crate::uses::*;
use crate::util::IMutex;
#[global_allocator]
static ALLOCATOR: GlobalAllocator = GlobalAllocator::new();
pub fn init()
{
ALLOCATOR.init();
}
// TODO: add relloc function
struct GlobalAllocator
{
allocer: IMu... |
mod db;
mod types;
pub use self::db::RequirementModel;
pub use self::types::{Field, Status, Type};
|
extern crate dotenv;
mod ws;
use std::env;
use actix_files::{Files, NamedFile};
use actix_web::Result as WebResult;
use actix_web::{get, web, App, HttpServer};
use dotenv::dotenv;
use sqlx::sqlite::SqlitePoolOptions;
use sqlx::SqlitePool;
use crate::ws::ws_index;
struct Country {
count: i32,
}
async fn get_co... |
use std::thread;
#[macro_use] extern crate lazy_static;
lazy_static! {
static ref A: Vec<u32> = {
vec![1, 2, 3]
};
}
fn main() {
thread::spawn(|| {
A[1];
});
thread::spawn(|| {
A[2];
});
}
|
#[doc = "Reader of register RCC_MP_TZAHB6LPENSETR"]
pub type R = crate::R<u32, super::RCC_MP_TZAHB6LPENSETR>;
#[doc = "Writer for register RCC_MP_TZAHB6LPENSETR"]
pub type W = crate::W<u32, super::RCC_MP_TZAHB6LPENSETR>;
#[doc = "Register RCC_MP_TZAHB6LPENSETR `reset()`'s with value 0x01"]
impl crate::ResetValue for su... |
#[doc = "Register `DINR1` reader"]
pub type R = crate::R<DINR1_SPEC>;
#[doc = "Field `DIN1` reader - Input data received from MDIO Master during write frames"]
pub type DIN1_R = crate::FieldReader<u16>;
impl R {
#[doc = "Bits 0:15 - Input data received from MDIO Master during write frames"]
#[inline(always)]
... |
use proc_macro2::{TokenStream, TokenTree};
use syn::parse::{Parse, ParseStream, Result};
use syn::spanned::Spanned;
use syn::token::Brace;
use syn::{braced, Block, Expr, Ident, Token};
#[derive(Debug)]
pub enum Tag {
/// <div id="app" class=*CSS>
/// <br />
Open {
name: Ident,
attrs: Vec<At... |
#[doc = "Reader of register CH7_DBG_CTDREQ"]
pub type R = crate::R<u32, super::CH7_DBG_CTDREQ>;
#[doc = "Reader of field `CH7_DBG_CTDREQ`"]
pub type CH7_DBG_CTDREQ_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:5"]
#[inline(always)]
pub fn ch7_dbg_ctdreq(&self) -> CH7_DBG_CTDREQ_R {
CH7_DBG_CTDREQ_R... |
//! Top-level syntax components, representing source files.
use std::fmt;
use std::path::Path;
use crate::syn::atom::Atom;
use crate::syn::fmt::ByteCounter;
use crate::syn::fmt::Format;
use crate::syn::fmt::Options;
use crate::syn::parse;
use crate::syn::parse::PestSpan;
pub use parse::Error;
/// A line comment in ... |
use arm::Isa;
use once_cell::sync::OnceCell;
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use std::process::Command;
fn devkit_arm_bin() -> &'static Path {
static DEVKIT_ARM: OnceCell<PathBuf> = OnceCell::new();
DEVKIT_ARM.get_or_init(|| {
let mut path = if let Ok(arm) = std::env::var("DEVKITA... |
pub mod parse;
pub mod tokenizer;
|
use crate::days::day5::default_input;
pub fn run() {
println!("{}", boarding_pass_str(default_input()).unwrap());
}
pub fn boarding_pass_str(input : &str) -> Result<i32, ()> {
let mut ids : Vec<_> = input.lines().map(|l| {
let row_indicators = &l[..7];
let col_indicators = &l[7..];
let... |
#![recursion_limit = "512"]
extern crate prost_build;
#[macro_use]
extern crate quote;
extern crate heck;
extern crate proc_macro2;
use heck::SnakeCase;
use proc_macro2::{Ident, Literal, Span};
use std::io;
use std::path::Path;
pub fn compile_protos<P>(protos: &[P], includes: &[P]) -> io::Result<()>
where
P: AsR... |
use std::cmp;
use std::collections::{HashMap, HashSet};
use std::io::{Read, Write, Seek, SeekFrom, Result as IoResult};
use std::sync::{Arc, Mutex};
use backupd::storage::{StorageManager, FileLen};
use backupd::server::BaacupImpl;
use futures::future::{self, Future, Loop, Either};
use backuplib::rpc::{Baacup, FileMet... |
//! `Park` trait
use futures_executor::Enter;
use std::task::Waker;
use std::time::Duration;
#[cfg(feature = "park-thread")]
mod park_thread;
#[cfg(feature = "park-thread")]
pub use self::park_thread::ParkThread;
/// A trait to allow combining (nesting) of runtime components (IO reactor, timers, pool of
/// futures)... |
use bevy::prelude::*;
use bevy::app::AppExit;
use bevy::app::Events;
use serde::Deserialize;
use bevy::reflect::{TypeUuid};
use crate::{player,asset_loader,AppState, game_controller, camera, ChangeStateEvent, GameState,
LevelResetEvent, Kid, theater_outside, Mode, BlipEvent};
pub struct CutsceneEvent {
}
... |
#![feature(collections)]
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate parser_combinators;
// TODO:
// - Benchmarks
// - Cache of last piece
// - merge consecutive insert, delete
// - snapshots
// - Allow String, &str, &[u8], and Vec<u8> as parameter to insert, append
/// A... |
use super::{Value, ValueDef, ValueError, ValueResult};
use std::result::Result as StdResult;
impl Value {
pub fn check(&self, def: &ValueDef) -> ValueResult<()> {
def.check(self)
}
}
impl ValueDef {
pub fn check(&self, value: &Value) -> ValueResult<()> {
match self {
ValueDef::... |
extern crate ralloc;
mod util;
use std::thread;
use std::sync::mpsc;
#[test]
fn mpsc_queue() {
util::multiply(|| {
{
let (tx, rx) = mpsc::channel::<Box<u64>>();
let handle = thread::spawn(move || {
util::acid(|| {
tx.send(Box::new(0xBABAFBABAF)... |
//! Rust library to open URLs and local files in the web browsers available on a platform, with guarantees of [Consistent Behaviour](#consistent-behaviour).
//!
//! Inspired by the [webbrowser](https://docs.python.org/2/library/webbrowser.html) python library.
//!
//! ## Examples
//!
//! ```no_run
//! use webbrowser;
/... |
#[doc = "Register `TTCSM` reader"]
pub type R = crate::R<TTCSM_SPEC>;
#[doc = "Field `CSM` reader - Cycle Sync Mark"]
pub type CSM_R = crate::FieldReader<u16>;
impl R {
#[doc = "Bits 0:15 - Cycle Sync Mark"]
#[inline(always)]
pub fn csm(&self) -> CSM_R {
CSM_R::new((self.bits & 0xffff) as u16)
}... |
mod access;
mod count;
mod insert;
mod rank;
mod remove;
mod select;
pub use self::{
access::{Access, Capacity},
count::Count,
insert::Insert,
rank::Rank,
remove::Remove,
select::{Select0, Select1},
};
|
lazy_static! {
pub static ref HTTP_CLIENT: reqwest::Client = reqwest::Client::new();
}
|
// https://www.reddit.com/r/dailyprogrammer/comments/a72sdj/20181217_challenge_370_easy_upc_check_digits/
use std::io;
fn main() {
let reader = io::stdin();
println!("Please enter a UPC");
loop {
let mut input = String::new();
reader.read_line(&mut input).expect("Failed to read line");
... |
#[doc = "Register `FMC_CSQAR1` reader"]
pub type R = crate::R<FMC_CSQAR1_SPEC>;
#[doc = "Register `FMC_CSQAR1` writer"]
pub type W = crate::W<FMC_CSQAR1_SPEC>;
#[doc = "Field `ADDC1` reader - ADDC1"]
pub type ADDC1_R = crate::FieldReader;
#[doc = "Field `ADDC1` writer - ADDC1"]
pub type ADDC1_W<'a, REG, const O: u8> = ... |
//! SPI Commands for the Waveshare 3.7" E-Ink Display
use crate::traits;
/// EPD3IN7 commands
///
/// Should rarely (never?) be needed directly.
///
/// For more infos about the addresses and what they are doing look into the pdfs
///
/// The description of the single commands is mostly taken from EDP3IN7 specificati... |
// Issue #922
use std;
import std::task;
fn f() {
}
fn main() {
task::spawn(bind f());
} |
use colored::{ColoredString, Colorize};
use std::fmt;
use std::str::FromStr;
use strum::EnumIter;
use crate::errors::TarotErrorKind;
use crate::traits::Representation;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, EnumIter)]
pub enum Suit {
Heart,
Spade,
Diamond,
Club,
}
impl fmt::Disp... |
extern crate image;
use image::DynamicImage;
use std::io;
use rust_image_proc_edge::module::edge_detection;
use rust_image_proc_edge::module::binarization;
use rust_image_proc_edge::module::color_reversal;
use rust_image_proc_edge::module::gray_scale;
use rust_image_proc_edge::module::gray_scale_2diff;
use rust_image_... |
extern crate iron;
use iron::{Chain, Iron, IronResult, Request, Response, StatusCode};
use iron::typemap::TypeMap;
use iron::headers::{CONTENT_LENGTH, HeaderMap};
/// This function returns a crafted response one might expect to get
/// from a HEAD request. Notably, this response is returning an empty body
/// as wel... |
use std::rand::random;
use std::os;
use std::io::File;
fn main() {
let args: ~[~str] = os::args();
if args.len() != 3 {
println!("Usage: {:s} <inputfile>", args[0]);
} else {
let fname = args[1].clone();
let fname2 = args[2];
let path = Path::new(fname.clone());
let path2 = Pat... |
// Copyright (C) 2021 Deeper Network Inc.
// 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unle... |
// Copyright (C) 2020 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use super::*;
/// `Content-Type` header ([RFC 7826 section 18.19](https://tools.ietf.org/html/rfc7826#section-18.19)).
#[derive(Debug, Clone, PartialEq, ... |
#[cfg(target_arch = "x86")]
use ::core::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use ::core::arch::x86_64::*;
pub(crate) struct BlockClassifier256 {
first: __m256i,
second: __m256i,
}
impl BlockClassifier256 {
#[target_feature(enable = "avx2")]
pub(crate) unsafe fn new(first: u8, second: u8) -> Se... |
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn examples() {
assert_eq!(in_array(
&["xyz", "live", "strong"],
&["lively", "alive", "harp", "sharp", "armstrong"],
), ["live", "strong"]);
assert_eq!(in_array(
&["live", "strong", "arp"],
... |
// Copyright 2021 Red Hat, Inc.
//
// 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 i... |
use std::error::Error;
use std::fs::File;
use std::io::{BufRead, BufReader};
#[derive(Eq, PartialEq)]
enum Direction {
Forward,
Up,
Down,
}
type ParseResult<T> = Result<T, Box<dyn Error>>;
fn main() {
let filename = "input/input.txt";
let result: ParseResult<Vec<(Direction, i32)>> = parse_input_f... |
pub use super::board::timer::{get_cycle, init, set_next};
pub fn read_epoch() -> u64 {
0
}
|
#[doc = "Register `IDR` reader"]
pub type R = crate::R<IDR_SPEC>;
#[doc = "Field `ID` reader - SPDIFRX identifier"]
pub type ID_R = crate::FieldReader<u32>;
impl R {
#[doc = "Bits 0:31 - SPDIFRX identifier"]
#[inline(always)]
pub fn id(&self) -> ID_R {
ID_R::new(self.bits)
}
}
#[doc = "SPDIFRX i... |
use actix::prelude::*;
use actix::registry::Registry;
use actix::registry::SystemRegistry;
use actix_web::{web, Error, HttpRequest, HttpResponse};
use actix_web_actors::ws;
use services::broadcast::BroadcastActor;
use services::client::ClientActor;
use services::issue::IssueService;
use services::{session::SessionActor... |
/*
Even wonder how to use it?
-> Type 'cargo doc --open'
-> then it'll build docs locally for you.
Note
The content depends on what u declared in the .toml
*/
extern crate rand;
use std::io;
use std::cmp::Ordering;
use rand::Rng;
fn main() {
/* Do using the 'cargo check' all... |
use std::collections::{BTreeMap, HashMap};
fn print_repr(map: BTreeMap<i32, i32>) {
for (k, v) in map {
if v == 1 {
print!("{}, ", k);
} else {
print!("{}^{}, ", k, v);
}
}
println!("");
}
fn repr(num: i32, last: i32, mut map: BTreeMap<i32, i32>) {
if last == 0 {
if num == 0 {
print_repr(map);
... |
use necsim_core::{
cogs::{CoalescenceRngSample, Habitat, LineageReference, LocallyCoherentLineageStore},
event::LineageInteraction,
landscape::{IndexedLocation, Location},
};
#[must_use]
pub fn sample_interaction_at_location<
H: Habitat,
R: LineageReference<H>,
S: LocallyCoherentLineageStore<H,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.