text stringlengths 8 4.13M |
|---|
mod constants;
use clap::{App, Arg};
use log::*;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let cli_matches = parse_cli();
init_log(&cli_matches);
logtopus::run(&cli_matches.value_of("config"))
}
fn init_log(matches: &clap::ArgMatches) {
let loglevel = match matches.occurrence... |
mod ship;
mod ocean;
use ocean::*;
use ship::*;
use std::io::{self, Write};
use text_io::read;
fn main() {
let mut ocean = Ocean::new();
ocean.place_ships_randomly();
loop {
if game_over(&ocean) {
println!("Congratulations! You've won the game!");
println!("--------------... |
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::registry::base::{Command, Notifier, State},
crate::registry::service_context::ServiceContext,
crate::switchboard::base::{Accessibil... |
#[doc = "Register `ISR` reader"]
pub type R = crate::R<ISR_SPEC>;
#[doc = "Field `GIF1` reader - global interrupt flag for channel 1"]
pub type GIF1_R = crate::BitReader;
#[doc = "Field `TCIF1` reader - transfer complete (TC) flag for channel 1"]
pub type TCIF1_R = crate::BitReader;
#[doc = "Field `HTIF1` reader - half... |
//! User module to handle users
use error::*;
use std::collections::HashMap;
use std::fs::File;
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
/// Database of user
pub struct Users(Arc<Mutex<HashMap<String, String>>>, PathBuf);
impl Users {
/// Load a database or create a... |
use crate::days::day23::{parse_input, default_input, Node};
use std::collections::HashMap;
pub fn run() {
println!("{}", circle_str(default_input()).unwrap())
}
pub fn circle_str(input : &str) -> Result<i64, ()> {
circle(parse_input(input))
}
pub fn circle(circle : Vec<i64>) -> Result<i64, ()> {
let mut ... |
// Copyright 2015 click2stream, 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... |
use hex;
use single_byte_xor_cipher;
pub struct ScoredXorStrings {
pub score: i32,
pub encrypted_strings: String
}
impl ScoredXorStrings {
fn new() -> ScoredXorStrings {
ScoredXorStrings {
score: 0,
encrypted_strings: String::new()
}
}
}
pub fn detect_single_xo... |
/// Platform specific constants
///
pub use super::board::consts::*;
pub const KERNEL_OFFSET: usize = 0x80100000;
pub const MEMORY_OFFSET: usize = 0x8000_0000;
pub const USER_STACK_OFFSET: usize = 0x80000000 - USER_STACK_SIZE;
pub const USER_STACK_SIZE: usize = 0x10000;
pub const MAX_DTB_SIZE: usize = 0x2000;
|
use crate::{BoxFuture, Result};
use std::any::Any;
pub trait Provider: Any + Send + Sync {
fn cancel(&self);
fn commit(&self) -> BoxFuture<'_, Result<()>>;
}
|
use libbgmrank::{Histogram, Item, MAX_RATING};
mod init;
fn get_all_items(args: &init::Args) -> Vec<Item> {
let mut result = vec![];
for category in args.categories.iter() {
for state in args.states.iter() {
println!("fetching {}: {}/{}", args.username, category, state);
result... |
use http_router::class_view::{HttpWays, ViewBuilder};
extern crate futures;
extern crate hyper;
extern crate hyper_tls;
use baidu;
use futures::{future, Future, Stream};
// use hyper::client::HttpConnector;
use http_router::constraint::{INDEX, NOTFOUND};
use hyper::client::HttpConnector;
use hyper::{Body, Chunk, Client... |
use super::vector::{Vec2, Vec2f, Vec2i, Vec3, Vec3f, Vec3i, Vector};
use std::io::{self, Read, Write};
use std::thread;
use termion::raw::IntoRawMode;
use termion::{clear, color, cursor};
fn render<W: Write>(out: &mut W, pixel: &PixelBuffer) {
match pixel.color {
Color::Red => write!(out, "{}#", color::Fg(... |
use std::io::Write;
use std::mem;
use byteorder::{ByteOrder, WriteBytesExt};
use nom::*;
use errors::{PcapError, Result};
use pcapng::block::Block;
use pcapng::blocks::timestamp::{self, ReadTimestamp, Timestamp};
use pcapng::options::{parse_options, Opt, Options};
use traits::WriteTo;
pub const BLOCK_TYPE: u32 = 0x0... |
mod set_1;
mod set_2;
mod set_3;
mod set_4;
|
use sqlx::database::HasArguments;
pub type Query<'a> =
sqlx::query::Query<'a, sqlx::Sqlite, <sqlx::Sqlite as HasArguments<'a>>::Arguments>;
pub type QueryAs<'a, T> =
sqlx::query::QueryAs<'a, sqlx::Sqlite, T, <sqlx::Sqlite as HasArguments<'a>>::Arguments>;
|
use anyhow::Context;
use rusqlite::{named_params, params, OptionalExtension, Transaction};
use stark_hash::StarkHash;
use web3::types::H256;
use crate::{
consts::{GOERLI_GENESIS_HASH, MAINNET_GENESIS_HASH},
core::{
Chain, ClassHash, ContractAddress, ContractRoot, ContractStateHash, EthereumBlockHash,
... |
mod colors;
mod list_separator;
mod number;
mod operator;
mod quotes;
mod unit;
pub use self::colors::Rgba;
pub use self::list_separator::ListSeparator;
pub use self::number::{NumValue, Number};
pub use self::operator::Operator;
pub use self::quotes::Quotes;
pub use self::unit::{Dimension, Unit};
|
use nu_test_support::{nu, pipeline};
#[test]
fn checks_any_row_is_true() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo [ "Ecuador", "USA", "New Zealand" ]
| any $it == "New Zealand"
"#
));
assert_eq!(actual.out, "true");
}
#[test]
fn checks_any_... |
mod message_destinations;
mod mvec;
mod registry;
pub(crate) mod channel;
pub(crate) mod subscribe_loop;
pub(crate) mod subscribe_loop_supervisor;
// Explicitly allow clippy::module_inception here. We just reexport everything
// from this module to list all the dependencies cleanly in a separate file.
// This nesting... |
#![allow(non_camel_case_types)]
/*!
Structural aliases for even array size up to 32.
*/
use super::names::{
I0,I1,I2,I3,I4,I5,I6,I7,
I8,I9,I10,I11,I12,I13,I14,I15,
I16,I17,I18,I19,I20,I21,I22,I23,
I24,I25,I26,I27,I28,I29,I30,I31,
};
use crate::IntoFieldMut;
/*
fn main() {
use std::fmt::Write;
... |
// Graphic manager of subte
extern crate pancurses as curses;
use std::cmp::*;
use std::collections::*;
use fourthrail::*;
/* */
pub const INNER_HEIGHT : i32 = 24;
pub const INNER_WIDTH : i32 = 80;
/* */
pub const MAP_DISPLAY_WIDTH : i32 = 60;
pub const MAP_DISPLAY_HEIGHT : i32 = 22;
pub const MAP_DISPLAY_STEP... |
#[doc = "Reader of register CTRL"]
pub type R = crate::R<u32, super::CTRL>;
#[doc = "Writer for register CTRL"]
pub type W = crate::W<u32, super::CTRL>;
#[doc = "Register CTRL `reset()`'s with value 0x00f8_0000"]
impl crate::ResetValue for super::CTRL {
type Type = u32;
#[inline(always)]
fn reset_value() ->... |
use super::watch::{Watch, WatchHandle};
#[cfg(feature = "admission-webhook")]
use crate::admission::WebhookFn;
use crate::operator::Watchable;
use crate::Operator;
use kube::api::ListParams;
/// Builder pattern for registering a controller or operator.
pub struct ControllerBuilder<C: Operator> {
/// The controller... |
pub mod astar;
pub mod dijkstra;
pub use super::BaseMap;
|
#[doc = "Register `CCIPR` reader"]
pub type R = crate::R<CCIPR_SPEC>;
#[doc = "Register `CCIPR` writer"]
pub type W = crate::W<CCIPR_SPEC>;
#[doc = "Field `USART1SEL` reader - USART1 clock source selection"]
pub type USART1SEL_R = crate::FieldReader<USART1SEL_A>;
#[doc = "USART1 clock source selection\n\nValue on reset... |
use std::collections::HashMap;
#[derive(Debug)]
pub enum Stmt {
PenUp,
PenDown,
Forward(i32),
Backward(i32),
Turn(i32),
ChangeColor(Color),
ChangeColorRGB(i32, i32, i32),
Label(String),
Loop(String, i32),
}
#[derive(Debug, Copy, Clone)]
pub enum Color {
Red,
Green,
Blu... |
use generics::{Generic, Unit};
trait Accumulate {
fn acc(self) -> u64;
}
impl Accumulate for Unit {
fn acc(self) -> u64 {
13
}
}
#[derive(Generic)]
struct Foo;
#[test]
fn struct_unit() {
let foo = Foo;
assert_eq!(foo.into_repr().acc(), 13);
}
|
use nom::number::complete::{le_i8, le_u8, le_u16, le_f32};
use serde_derive::{Serialize};
use super::parserHeader::*;
#[derive(Debug, PartialEq, Serialize)]
pub struct MarshalZone {
pub m_zoneStart: f32,
pub m_zoneFlag: i8
}
named!(pub parse_mashall_zone<&[u8], MarshalZone>,
do_parse!(
m_zoneStart... |
use std::fmt::{self, Display};
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
pub enum IntPredicate {
EQ,
NE,
UGT,
UGE,
ULT,
ULE,
SGT,
SGE,
SLT,
SLE,
}
impl Display for IntPredicate {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
IntP... |
extern crate document;
use self::PrincipalNodeType::*;
use super::XPathEvaluationContext;
use super::node_test::XPathNodeTest;
use super::nodeset::Nodeset;
use super::nodeset::Node::ElementNode;
pub enum PrincipalNodeType {
Attribute,
Element,
}
/// A directed traversal of Nodes.
pub trait XPathAxis {
/... |
use std::convert::TryFrom;
use std::convert::TryInto;
use bytes::Bytes;
use http::{Method, Response, StatusCode};
use crate::service::{ServiceClient, API_VERSION};
/// Execute the request to get the twin of a module or device.
pub(crate) async fn get_twin<T>(
service_client: &ServiceClient,
device_id: String... |
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... |
fn main() {
// Type annotated variable
let _a_float: f64 = 1.0;
// This variable is an `i32`
let mut _an_integer = 5i32;
// Error! The type of a variable can't be changed
// an_integer = true;
}
|
use nu_ansi_term::{Color, Style};
use serde::Deserialize;
#[derive(Deserialize, PartialEq, Eq, Debug)]
pub struct NuStyle {
pub fg: Option<String>,
pub bg: Option<String>,
pub attr: Option<String>,
}
pub fn parse_nustyle(nu_style: NuStyle) -> Style {
// get the nu_ansi_term::Color foreground color
... |
use crossterm::{
cursor,
event::{poll, read, Event, KeyCode},
execute, queue,
style::{Print, ResetColor},
terminal::{self, disable_raw_mode, enable_raw_mode, ClearType},
Result,
};
use std::{
io::{stdout, Write},
time::Duration,
};
fn game_loop<W>(w: &mut W) -> Result<()>
where
W: W... |
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| ... |
mod lexer;
pub use lexer::*;
#[cfg(test)]
mod lexer_test;
|
use crate::core::authentication_password::InvitationLink;
use crate::core::{env, Account, ServiceError, ServiceResult};
use lettre::smtp::authentication::Credentials;
use lettre::{SendableEmail, SmtpClient, Transport};
use lettre_email::EmailBuilder;
fn send_standard_mail(account: &Account, subj: &str, message: String... |
fn main() {
println!("Hello, world!");
another_function();
parameter_function(1, 3.54);
}
fn another_function() {
println!("another function here")
}
// Parameterized functions
fn parameter_function(x: i32, y:f64) {
println!("Values of x and y are {} and {}", x, y)
}
// Function with return
fn r... |
use sfml::window;
use sfml::window::{window_style};
use sfml::system;
use sfml::graphics::{RenderWindow, RenderTarget, View};
pub fn create(width: u32, height: u32) -> (RenderWindow, View) {
let (mut w,v) = (
create_window(width, height),
create_view(width as f32, height as f32)
);
w.set_v... |
fn main() {
let s: String = {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim_end().to_owned()
};
let mut t = String::new();
let append_txts = ["dream", "dreamer", "erase", "eraser"];
while t.len() < s.len() {
for append_txt i... |
use rustler::types::truthy::Truthy;
use rustler::{Encoder, Env, NifResult, Term};
use rustler::{NifMap, NifRecord, NifStruct, NifTuple, NifUnitEnum, NifUntaggedEnum};
#[derive(NifTuple)]
pub struct AddTuple {
lhs: i32,
rhs: i32,
}
pub fn tuple_echo<'a>(_env: Env<'a>, args: &[Term<'a>]) -> NifResult<AddTuple> ... |
use std::{collections::HashMap, marker::PhantomData, path::Path};
use crate::{
io,
prelude::*,
shader::{ActiveShader, BindUniform},
};
use futures::future::try_join_all;
use image::{DynamicImage, GenericImageView};
// Each marker struct represents a different texture target (e.g. TEXTURE_2D)
#[derive(Clone)]
pu... |
use std::iter;
use std::marker::PhantomData;
use std::ops::RangeFrom;
use tll::ternary::{Nat, Pred, NatPred, Succ, NatSucc, Triple, NatTriple, Term, Zero, One, Two};
use iterator::{Iterator, NonEmpty};
pub struct Enumerate<L: Nat, I: Iterator<L>, P: Nat> {
phantom: PhantomData<(L, P)>,
iter: I,
}
impl<L: N... |
//! Utility module
use lib::*;
pub type Hash = [u8; 32];
/// Converts u32 to right aligned array of 32 bytes.
pub fn pad_u32(value: u32) -> Hash {
let mut padded = [0u8; 32];
padded[28] = (value >> 24) as u8;
padded[29] = (value >> 16) as u8;
padded[30] = (value >> 8) as u8;
padded[31] = value as u8;
padded
}
... |
use SafeWrapper;
use ir::{User, Instruction, Value, AtomicOrdering, SynchronizationScope, AtomicBinaryOp};
use sys;
pub struct AtomicRMWInst<'ctx>(Instruction<'ctx>);
impl<'ctx> AtomicRMWInst<'ctx>
{
pub fn new(op: AtomicBinaryOp,
pointer: &Value,
value: &Value,
orderi... |
pub mod datetime;
pub mod interfaces;
pub mod util;
|
use glium::texture::{cubemap::Cubemap, CubeLayer, TextureCreationError};
use glium::{Frame, Surface, Display, BlitTarget, framebuffer::{SimpleFrameBuffer, ValidationError}, uniforms::MagnifySamplerFilter};
use derive_more::{Error, From};
use crate::textures::{load_texture, TextureLoadError};
use crate::draw::{EnvDrawIn... |
use errors::*;
use {OutputParameters, Parameters};
use tfdeploy::analyser::Analyser;
use tfdeploy::analyser::{DimFact, ShapeFact, TensorFact};
/// Handles the `analyse` subcommand.
pub fn handle(params: Parameters, optimize: bool, output_params: OutputParameters) -> Result<()> {
let model = params.tfd_model;
... |
#![no_main]
#![no_std]
#![feature(lang_items)]
#![feature(global_asm)]
#![feature(asm)]
#![allow(dead_code)]
use core::panic::PanicInfo;
global_asm!(include_str!("syscall_interrupts.s"));
#[no_mangle] // don't mangle the name of this function
pub extern "C" fn _start() -> ! {
let hello_world = "HELLO WORLD\n";
... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - RCC clock control register"]
pub cr: CR,
#[doc = "0x04 - RCC internal clock source calibration register"]
pub icscr: ICSCR,
#[doc = "0x08 - RCC clock configuration register"]
pub cfgr: CFGR,
_reserved3: [u8; 0x0... |
//use tokio::io::BufStream;
use tokio::net::{TcpStream, UnixStream};
pub enum Stream {
Unix(UnixStream),
Tcp(TcpStream),
}
impl From<TcpStream> for Stream {
#[inline]
fn from(stream: TcpStream) -> Self {
//Self::Tcp(BufStream::with_capacity(2048, 2048, stream))
Self::Tcp(stream)
}
}... |
// 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 crate::Example;
pub fn test_basic_proof_verification(e: Box<dyn Example>) {
let proof = e.prove();
assert!(e.verify(proof).is... |
use std::ops::BitAnd;
///Describes the encoding of a register
///
/// Bit masks can be AND'd together to form the the output mask
#[derive(Clone,Copy,Debug,PartialEq,Eq)]
#[repr(u32)]
pub enum Encode {
/// This is the error condition
NONE = 0x00000000u32,
/// X86 requires. Using a REX prefix causes an erro... |
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
#[serde(transparent)]
pub struct True(bool);
impl Default for True {
fn default() -> Self {
Self(true)
}
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(transparent)]
pub struct False(bool);
#[allow(clippy::derivable_impl... |
use core::cmp::Ordering;
/// Wrapper around usize for easy pointer math.
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct Address(usize);
impl Address {
/// Construct Self from usize
#[inline(always)]
pub fn from(val: usize) -> Address {
Address(val)
}
/// Offset from `base`
#[inl... |
use std::{env, path};
use ggez::event::{self, EventHandler};
use ggez::nalgebra::Point2;
use ggez::{filesystem, graphics, timer};
use ggez::{Context, GameResult};
const PHYSICS_SIMULATION_FPS: u32 = 100;
const PHYSICS_DELTA_TIME: f64 = 1.0 / PHYSICS_SIMULATION_FPS as f64;
impl EventHandler for TheFinalTouch {
fn... |
use std::collections::HashMap;
use std::io::{stdout, Read, Write};
use std::fs::File;
use curl::easy::{Easy, List};
use serde_json::Value as JSONValue;
use error::OpenstackError;
use memmap::MmapOptions;
use indicatif::{ProgressBar, ProgressStyle};
use objectstore::{create_file, download_from_object_store, open_file... |
#[doc = "Register `DAC_SHRR` reader"]
pub type R = crate::R<DAC_SHRR_SPEC>;
#[doc = "Register `DAC_SHRR` writer"]
pub type W = crate::W<DAC_SHRR_SPEC>;
#[doc = "Field `TREFRESH1` reader - DAC Channel 1 refresh Time (only valid in sample &amp; hold mode) Refresh time= (TREFRESH\\[7:0\\]) x T LSI"]
pub type TREFRESH1... |
#[doc = "Register `MMC_RX_INTERRUPT` reader"]
pub type R = crate::R<MMC_RX_INTERRUPT_SPEC>;
#[doc = "Field `RXCRCERPIS` reader - MMC Receive CRC Error Packet Counter Interrupt Status"]
pub type RXCRCERPIS_R = crate::BitReader;
#[doc = "Field `RXALGNERPIS` reader - MMC Receive Alignment Error Packet Counter Interrupt St... |
use crate::instruction::Instruction;
use crate::addressing_modes::AddressingMode;
pub static OPCODES : [Option<(Instruction, AddressingMode)>; 256 ] = [
Some((Instruction::Brk, AddressingMode::Implied)), // 0x00
Some((Instruction::Ora, AddressingMode::XIndexedIndirect)), // 0x01
None,... |
use super::{Error, Result};
use crate::model::{Product, Wishlist};
use mongodb::bson::oid::ObjectId;
pub trait ProductDao: Send + Sync {
fn get_products_by_id(&self, ids: &[ObjectId]) -> Result<Vec<Product>>;
fn get_archived_products(&self, page: usize, per_page: usize) -> Result<Vec<Product>>;
fn get_prod... |
use self::basic::BasicMemory;
mod basic;
const NES_MEMORY_SIZE: usize = 65536;
pub trait Memory {
fn fetch(&self, addr: u16) -> u8;
fn store(&mut self, addr: u16, value: u8) -> u8;
}
pub type NesMemorySpace = [u8; NES_MEMORY_SIZE];
pub struct NesMemory {
memory: BasicMemory<NesMemorySpace>,
}
impl Nes... |
#[cfg(test)]
mod tests {
use crate::util::pkcs7_pad;
use std::str;
// Ninth cryptopals challenge - https://cryptopals.com/sets/2/challenges/9
#[test]
fn challenge9() {
assert_eq!(
"YELLOW SUBMARINE\x04\x04\x04\x04",
str::from_utf8(&pkcs7_pad(&"YELLOW SUBMARINE".as_by... |
use crate::row::Row;
use dfa_optimizer::{Row as DfaRow, Table as DfaTable};
use log::*;
use std::collections::{BTreeMap, BTreeSet};
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::iter::FromIterator;
use std::path::Path;
use log::debug;
pub type StateSet = BTreeSet<usize>;
#[derive(Debug, Clone, Defau... |
use std::rc::Rc;
use crate::common::{ Value, Table, BuiltIn, RustFunc };
use crate::vm::{ VM, RuntimeError };
pub fn tbl_builtin(tbl: &Table, name: &str, func: &'static BuiltIn) {
let rf = RustFunc {
name: name.clone().into(),
func: func
};
tbl.insert(Value::String(name.into()), Value::NativeFunc(Rc::n... |
mod window;
fn main() {
window::make_window();
}
|
use std::borrow::Cow;
use anyhow::Result;
use crate::env_file::entry::Entry;
use crate::env_file::{Env, Var};
pub struct EnvDiffController {
update_var_fn: Box<dyn Fn(&mut Var) -> Result<Cow<Var>>>,
delete_var_fn: Box<dyn Fn(&Var) -> Result<bool>>,
}
impl EnvDiffController {
pub fn new<UVF: 'static, DVF... |
use super::traits::Circular;
pub fn parse(data: &str) -> usize {
let mut chars = data.chars().circular().peekable();
let mut sum: usize = 0;
loop {
let step: u32 = match (chars.next(), chars.peek()) {
(Some(chr1), Some(chr2)) if chr1 == *chr2 => {
chr1.to_digit(10).exp... |
//! Link: https://adventofcode.com/2019/day/9
//! Day 9: Sensor Boost
//!
//! You've just said goodbye to the rebooted rover and left Mars when you receive
//! a faint distress signal coming from the asteroid belt. It must be the Ceres monitoring station!
//!
//! In order to lock on to the signal, you'll need to bo... |
use rocket::serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)]
#[serde(crate = "rocket::serde")]
pub enum PayloadType {
Offer,
Answer,
Candidate,
Watch,
}
#[derive(Deserialize, Serialize)]
#[serde(crate = "rocket::serde")]
pub struct Payload {
pub pt: PayloadType,
pub payload: ... |
use std::fs::File;
use std::io::Read;
use std::collections::HashMap;
use scan_fmt::*;
//use chrono::{DateTime, TimeZone, NaiveDateTime, Utc};
type Year = i32;
type Month = i32;
type Day = i32;
type Hour = i32;
type Min = i32;
type Kind = String;
type Id = i32;
#[derive(Debug, Eq, PartialEq, Hash)]
struct D... |
fn it_works() {}
|
pub mod backend;
pub mod crdt;
use backend::{CrdtBackend, MemoryBackend};
use crdt::Crdt;
impl Crdt<String> for String {
fn merge(self, other: String) -> String {
match self.len() > other.len() {
true => self,
false => other
}
}
}
#[derive(Eq, PartialEq, Ord, PartialOr... |
use winapi::um::profileapi::{QueryPerformanceCounter, QueryPerformanceFrequency};
use winapi::um::winnt::LARGE_INTEGER;
const TICKS_PER_SECOND: u64 = 10000000;
//TODO: mark everything as unsafe
pub struct StepTimer {
qpc_frequency: LARGE_INTEGER,
qpc_last_time: LARGE_INTEGER,
qpc_max_delta: u64,
elap... |
use chrono::NaiveDateTime;
use diesel::prelude::*;
use diesel::pg::PgConnection;
use schema::horus_videos;
use models::traits::passwordable;
#[derive(AsChangeset, Queryable, Serialize, Identifiable, Insertable)]
#[table_name = "horus_videos"]
pub struct HVideo
{
pub id: String,
pub title: Option<String>,
... |
use anyhow::Result;
use isahc::prelude::*;
use openssl::hash::MessageDigest;
use openssl::pkey::PKey;
use openssl::rsa::Rsa;
use openssl::sign::Signer;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
const BASE: &str = "https://api.bunq.com";
#[derive(Serialize)]
struct Installation<'a> {
client_public... |
use swf_tree as ast;
use nom::IResult;
use nom::{be_f32 as parse_be_f32, be_u16 as parse_be_u16, be_u32 as parse_be_u32, le_u8 as parse_u8, le_u32 as parse_le_u32};
use ordered_float::OrderedFloat;
use parsers::avm1::parse_actions_block;
use parsers::basic_data_types::{parse_le_fixed8_p8, parse_le_fixed16_p16, parse_st... |
use serenity::model::interactions::ApplicationCommandInteractionData;
pub fn extract_option(data: &ApplicationCommandInteractionData, key: &str) -> Option<String> {
let opt = data
.options
.iter()
.find(|&opt| opt.name == key)
.map(|v| v.value.clone());
if let Some(Some(arg)) = ... |
//! # Vectors
//! This crate takes in some form of a vector and outputs all related data that is required.
//! We'll try to implement it in the terminal for now but porting it over to the web shouldn't be that hard.
//! Need to learn some basic wasm + svelte for that though.
//!
//! ## Process
//! Takes in vector
//!
/... |
#[doc = "Register `DMACCARxBR` reader"]
pub type R = crate::R<DMACCARX_BR_SPEC>;
#[doc = "Field `CURRBUFAPTR` reader - Application Receive Buffer Address Pointer"]
pub type CURRBUFAPTR_R = crate::FieldReader<u32>;
impl R {
#[doc = "Bits 0:31 - Application Receive Buffer Address Pointer"]
#[inline(always)]
p... |
use opendp::err;
use crate::core::{FfiDomain, FfiMeasure, FfiMeasureGlue, FfiMeasurement, FfiResult, FfiTransformation};
use crate::util;
use crate::util::Type;
use opendp::chain::{make_chain_mt_glue, make_chain_tt_glue, make_composition_glue};
#[no_mangle]
pub extern "C" fn opendp_core__make_chain_mt(measurement1: *... |
use std::error::Error;
type Result<T> = ::std::result::Result<T, Box<dyn Error>>;
macro_rules! err {
($($tt:tt)*) => { return Err(Box::<dyn Error>::from(format!($($tt)*))) }
}
pub struct IntCodeVm {
pub state: StateVm,
pub ram: Vec<isize>,
pub current_position: usize,
pub relative_position: isize... |
#![cfg(feature = "llvm-10-or-greater")]
//! These tests simply ensure that we can parse all of the `.bc` files in LLVM 10's `test/Bitcode` directory without crashing.
//! We only include the `.bc` files which are new or have changed since LLVM 9 (older ones are covered in llvm_9_tests.rs or llvm_8_tests.rs).
//! Human... |
$NetBSD: patch-compiler_rustc__target_src_spec_netbsd__base.rs,v 1.7 2023/01/23 18:49:04 he Exp $
For the benefit of powerpc, when libatomic-links is installed,
search the directory containing the symlinks to -latomic.
--- compiler/rustc_target/src/spec/netbsd_base.rs.orig 2022-12-12 16:02:12.000000000 +0000
+++ comp... |
use clap::{App, Arg};
use rawpb_core::parse_to_pretty;
use std::io::{Read, Write};
type IoResult<T> = Result<T, std::io::Error>;
enum InputFormatType {
Binary,
HexString,
Base64,
}
impl InputFormatType {
pub fn new(fmt: &str) -> Self {
if fmt == "h" {
Self::HexString
} els... |
pub fn exist(board: Vec<Vec<char>>, word: String) -> bool {
let m = board.len();
if m == 0 {
return false;
}
let n = board[0].len();
let mut marked = vec![vec![false; n]; m];
let directions = vec![
(-1, 0), // 上
(0, 1), // 右
(1, 0), // 下
(0, -1), // 左
... |
extern crate libc;
extern crate rctl;
#[cfg(feature = "serialize")]
extern crate serde_json;
#[cfg(feature = "serialize")]
fn main() {
let uid = unsafe { libc::getuid() };
let subject = rctl::Subject::user_id(uid);
let serialized = serde_json::to_string(&subject).expect("Could not serialize RCTL subject... |
#[doc = "Reader of register DDRCTRL_DRAMTMG1"]
pub type R = crate::R<u32, super::DDRCTRL_DRAMTMG1>;
#[doc = "Writer for register DDRCTRL_DRAMTMG1"]
pub type W = crate::W<u32, super::DDRCTRL_DRAMTMG1>;
#[doc = "Register DDRCTRL_DRAMTMG1 `reset()`'s with value 0x0008_0414"]
impl crate::ResetValue for super::DDRCTRL_DRAMT... |
use std::time::{Duration, Instant};
use backoff::{backoff::Backoff, Clock, SystemClock};
/// A [`Backoff`] wrapper that resets after a fixed duration has elapsed.
pub struct ResetTimerBackoff<B, C = SystemClock> {
backoff: B,
clock: C,
last_backoff: Option<Instant>,
reset_duration: Duration,
}
impl<B... |
use std::sync::Arc;
use async_trait::async_trait;
use common::error::Error;
use common::result::Result;
use identity::domain::user::{UserId, UserRepository};
use publishing::domain::author::{Author, AuthorId, AuthorRepository};
use publishing::domain::publication::PublicationRepository;
pub struct AuthorTranslator {... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - GPIO port mode register"]
pub moder: MODER,
#[doc = "0x04 - GPIO port output type register"]
pub otyper: OTYPER,
#[doc = "0x08 - GPIO port output speed register"]
pub ospeedr: OSPEEDR,
#[doc = "0x0c - GPIO port ... |
#![deny(missing_docs)]
//! A 3D game engine with built-in editor.
#[macro_use]
extern crate bitflags;
extern crate camera_controllers;
extern crate gfx;
extern crate gfx_debug_draw;
extern crate gfx_device_gl;
extern crate gfx_text;
extern crate piston_meta;
extern crate piston_window;
extern crate sdl2_window;
exter... |
use actix_files as fs;
use actix_multipart::Multipart;
use actix_web::{middleware, web, App, Error, HttpResponse, HttpServer};
use futures::{StreamExt, TryStreamExt};
use std::collections::BTreeMap;
use std_logger::request;
use tokio::sync::mpsc;
use futures::executor;
use bytes::BytesMut;
use handlebars::Handlebars;... |
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::INTSET {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mu... |
use std::collections::hash_map::DefaultHasher;
use std::hash::Hasher;
fn main() {
//struct Sentence {
// id: u32,
// clause: u64,
//}
//struct Block {
// timestamp: ,
// source_host: ,
// data: ,
// prev_hash: ,
// nonce: ,
//}
let mut hasher = DefaultHasher::new();
hasher.write(b"sv0001");
pri... |
use gfx;
use gfx_core;
use gfx_device_gl;
pub type Resources = gfx_device_gl::Resources;
pub type CommandBuffer = gfx_device_gl::CommandBuffer;
pub type Encoder = gfx::Encoder<Resources, CommandBuffer>;
pub type Device = gfx_device_gl::Device;
pub type Factory = gfx_device_gl::Factory;
pub use gfx::format::TextureFor... |
use silkenweb::{
element_list::OrderedElementList,
elements::{button, div, hr, Button},
mount,
signal::Signal,
Builder,
};
use silkenweb_tutorial_common::define_counter;
// ANCHOR: main
fn main() {
// ANCHOR: new_list
let list = Signal::new(OrderedElementList::new(div()));
// ANCHOR_END... |
use runestick::{ContextError, Module, Panic, Stack, Value, VmError};
use std::cell;
use std::io;
/// Provide a bunch of `std` functions which does something appropriate to the
/// wasm context.
pub fn module() -> Result<Module, ContextError> {
let mut module = Module::new(&["std"]);
module.function(&["print"],... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.