text stringlengths 8 4.13M |
|---|
use crate::storepaths::StorePaths;
use crate::{Opt, STORE};
use atty::{self, Stream};
use colored::{self, ColoredString, Colorize};
use env_logger::Builder;
use log::{Level, LevelFilter};
use std::io;
use std::io::prelude::*;
use std::path::Path;
use std::time::Duration;
#[derive(Debug, Clone, PartialEq)]
pub struct ... |
use std::cell::{Cell, RefCell};
use std::collections::HashSet;
use std::mem;
use std::ptr::null_mut;
use bincode;
use flate2;
use libc::c_void;
use bw;
use save::{fread_num, fread, fwrite, fwrite_num, SaveError, LoadError, print_text};
use save::{SaveMapping, LoadMapping};
use send_pointer::SendPtr;
use units::{unit_... |
// MIT License
//
// Copyright (c) 2021 Miguel Peláez
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modif... |
use azure_core::errors::AzureError;
use azure_core::headers::{utc_date_from_rfc2822, CommonStorageResponseHeaders};
use chrono::{DateTime, Utc};
use hyper::header::HeaderMap;
use std::convert::TryInto;
#[derive(Debug, Clone)]
pub struct PutMessageResponse {
pub common_storage_response_headers: CommonStorageRespons... |
pub mod legacy;
pub mod xdg;
|
use crate::logic::main::{get_distance, get_intersection, get_polygon_lines};
use crate::Ray;
use crate::Shape;
use macroquad::prelude::*;
const WALL_THICKNESS: f32 = 1.0;
pub struct Wall {
pub x1: f32,
pub y1: f32,
pub x2: f32,
pub y2: f32,
pub color: Vec4,
pub texture: Texture2D,
pub z_off... |
use util::*;
#[derive(Clone, Copy, Debug)]
enum Instruction {
North(i32),
South(i32),
West(i32),
East(i32),
Left(i32),
Right(i32),
Forward(i32),
}
fn rotate(wx: &mut i32, wy: &mut i32, rotation: i32) {
match rotation.rem_euclid(360) {
90 => {
let tmp = *wy;
... |
#[doc = "Register `ICFR` writer"]
pub type W = crate::W<ICFR_SPEC>;
#[doc = "Field `CC1IF` writer - Clear COMP channel 1 Interrupt Flag"]
pub type CC1IF_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
#[doc = "Field `CC2IF` writer - Clear COMP channel 2 Interrupt Flag"]
pub type CC2IF_W<'a, REG, const O: u8> = ... |
mod md5;
pub use md5::Md5PuzzleTask;
pub use md5::Md5PuzzleSolution;
|
#[doc = "Register `RGSR` reader"]
pub type R = crate::R<RGSR_SPEC>;
#[doc = "Field `OF0` reader - Trigger overrun event flag"]
pub type OF0_R = crate::BitReader<OF0_A>;
#[doc = "Trigger overrun event flag\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum OF0_A {
#[doc = "0: No new trigger... |
//const WALL :char = '#';
//const SPACE:char = ' ';
const SPIKES: [char; 2] = ['╱', '╲'];
extern crate termion;
use termion::raw::IntoRawMode;
use termion::event::Key;
use std::io::{Write, stdout};
use crate::termion::input::TermRead;
#[derive(Debug, Copy, Clone, PartialEq)]
struct Vec2 {
pub x: f64,
pub y:... |
use super::*;
pub fn handle_u_type(regfile: &mut [u32], bytes: &[u8], pc: &mut u32, _extensions: &Extensions) -> Result<(), ExecutionError> {
let opcode = get_opcode(bytes);
let rd = get_rd(bytes);
let immediate = decode_u_type_immediate(bytes);
if opcode == 0x17 { // auipc
regfile[rd as ... |
#[doc = "Reader of register FIFO_ST"]
pub type R = crate::R<u32, super::FIFO_ST>;
#[doc = "Writer for register FIFO_ST"]
pub type W = crate::W<u32, super::FIFO_ST>;
#[doc = "Register FIFO_ST `reset()`'s with value 0x02"]
impl crate::ResetValue for super::FIFO_ST {
type Type = u32;
#[inline(always)]
fn reset... |
//! This module is a port of ogsudo's `lib/util/term.c` with some minor changes to make it
//! rust-like.
use std::{
ffi::c_int,
fs::{File, OpenOptions},
io::{self, Read, Write},
mem::MaybeUninit,
os::fd::{AsRawFd, RawFd},
sync::atomic::{AtomicBool, Ordering},
};
use libc::{
c_void, cfgeti... |
extern crate proc_macro_bug_impl;
use proc_macro_bug_impl::some_macro;
#[some_macro(0)]
struct Abc {}
#[some_macro(0)]
struct Cde {}
fn main() {}
|
//! Logging and log syntax highlighting.
use colored::{ColoredString, Colorize};
use prefix::{Name, Prefix};
use std::fmt::Debug;
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
static VERBOSITY: AtomicUsize = ATOMIC_USIZE_INIT;
pub const ERROR: usize = 1;
pub const INFO: usize = 2;
pub const DEBU... |
use strum::{Display, EnumIter};
#[derive(Debug, Display, EnumIter)]
pub enum HypervisorTraits {
// P4 Traits
ApexProcessP4Ext,
ApexPartitionP4,
ApexTimeP4Ext,
ApexErrorP4Ext,
ApexQueuingPortP4Ext,
ApexSamplingPortP4Ext,
// P1 Traits
ApexProcessP1Ext,
ApexTimeP1Ext,
ApexEven... |
#[no_mangle]
pub extern fn doubler(x: f64) -> f64 {
println!("Called with x={}", x);
x * 2.
}
|
// Copyright 2017 PingCAP, 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::fmt;
// START OMIT
#[derive(Debug)]
struct Struct {
a: u8,
b: u32,
c: bool,
}
fn main() {
let s = Struct {a: 7, b: 3333, c: true, }; // HL
println!("{}", s);
}
// END OMIT
impl fmt::Display for Struct {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({}, {}, ... |
use crate::highlighter::*;
use bitflags::bitflags;
use std::cmp::{max, min};
use std::fmt;
bitflags! {
struct Block: u8 {
const NONE = 0b00;
const FULL = 0b11;
const TOP = 0b01;
const BOTTOM = 0b10;
}
}
impl fmt::Display for Block {
fn fmt(&self, f: &mut fmt::Formatter) -> ... |
use std::sync::Arc;
use crossbeam_channel::Sender;
use serde::Serialize;
use crate::stdio_server::rpc::{Call, RpcClient};
use crate::stdio_server::vim::Vim;
/// Current State of Vim/NeoVim client.
#[derive(Serialize)]
pub struct State {
#[serde(skip_serializing)]
pub tx: Sender<Call>,
#[serde(skip_seria... |
#[macro_export]
macro_rules! make_response {
($name:ident, $inner:ident, $func:ident) => {
pub type $name = AniListResponse<Single<$inner>>;
impl $name {
pub fn $func(&self) -> Option<$inner> {
self.data.item.to_owned()
}
}
};
}
#[macro_export]
m... |
#![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 CloudError {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub error: Option<CloudErrorBody>,
... |
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use crate::provider::CredentialsProvider;
use smithy_http::middleware::AsyncMapRequest;
use smithy_http::operation::Request;
use std::future::Future;
use std::pin::Pin;
/// Middleware stage that reques... |
use crate::Operation;
use failure::Fallible;
use std::collections::HashMap;
use uuid::Uuid;
mod inmemory;
mod kv;
pub use self::kv::KVStorage;
pub use inmemory::InMemoryStorage;
/// An in-memory representation of a task as a simple hashmap
pub type TaskMap = HashMap<String, String>;
#[cfg(test)]
fn taskmap_with(mut... |
use criterion::{criterion_group, criterion_main, Criterion};
use rust_fizzbuzz::{fizzbuzz_kronke, fizzbuzz_kronke_branchless};
use rust_fizzbuzz::fizzbuzz_kronke_inverted;
use rust_fizzbuzz::fizzbuzz_lsitarski;
use std::time;
pub fn fizzbuzz(c: &mut Criterion) {
let mut group = c.benchmark_group("FizzBuzz");
... |
use super::*;
use frame_system::RawOrigin;
use frame_benchmarking::{benchmarks, account};
use sp_runtime::traits::{Bounded, Dispatchable};
const SEED: u32 = 0;
benchmarks! {
_ {
let u in 1..1000 => ();
}
create_multisig_wallet {
let u in ...;
let creator: T::AccountId = account(... |
use toml;
use std::fs::File;
use std::io::prelude::*;
use std::net::SocketAddr;
#[derive(Deserialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct ServerConfig {
pub interface_and_port: SocketAddr,
pub max_ping_ms: u64,
}
#[derive(Deserialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struc... |
enum Color {
Red,
Green,
Blue,
RGBColor(u8, u8, u8), // tuple
CmykColor { // struct
cyan: u8,
magenta: u8,
yellow: u8,
black: u8
}
}
enum Gender {
TheMan,
Chupakabra,
TheWoman
}
struct User {
gender: Gender,
favorite_color: Color
}
pub fn ru... |
use std::io::Result;
use std::pin::Pin;
use std::task::{Context, Poll};
use discovery::ServiceDiscover;
use protocol::Protocol;
use stream::{AsyncReadAll, AsyncWriteAll, Request, Response};
macro_rules! define_endpoint {
($($top:tt, $item:ident, $type_name:tt, $ep:expr);+) => {
#[derive(Clone)]
pu... |
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>,... |
// Copyright (c) 2017 The Noise-rs Developers.
//
// 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. All files in the
// project carrying such notice may not be cop... |
// figure.rs Example using a figure
//
// Copyright (c) 2017 Douglas P Lau
//
extern crate footile;
use footile::{ FillRule, PlotterBuilder };
fn main() {
let mut p = PlotterBuilder::new()
.width(64)
.height(64)
.... |
use super::OM_uint32;
extern "C" {
#[link_name = "GSS_C_DELEG_FLAG_SHIM"]
pub static GSS_C_DELEG_FLAG: OM_uint32;
#[link_name = "GSS_C_MUTUAL_FLAG_SHIM"]
pub static GSS_C_MUTUAL_FLAG: OM_uint32;
#[link_name = "GSS_C_REPLAY_FLAG_SHIM"]
pub static GSS_C_REPLAY_FLAG: OM_uint32;
#[link_name ... |
#![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 ClusterProperties {
#[serde(rename = "clusterId", skip_serializing)]
pub cluster_id: Option<String>,
#[... |
fn main() {
println!("Hello, world!");
my_function(123);
let a = {
let b = 4;
// 这句不能有分号,否则为表达式,不产生返回值
b+1
};
println!("a:{}", a);
println!("five():{}", five());
println!("=============");
test_loop();
println!("=============");
test_for();
}
fn my_func... |
mod header;
pub use header::Header; |
use ansi_term::Style;
use console::strip_ansi_codes;
use pulldown_cmark::{Options, Parser};
use std::convert::TryInto;
use std::fs;
use std::io::{self, Read};
use std::path::PathBuf;
use structopt::StructOpt;
use syncat_stylesheet::Stylesheet;
use terminal_size::{terminal_size, Width};
mod dirs;
mod printer;
mod str_w... |
use super::{Environment, Event, MarketData, Order};
use crate::economy::Market;
use crate::traders::Action;
use async_trait::async_trait;
use binance_async::Binance;
use sqlx::PgPool;
use std::time::Duration;
struct MarketValueChange {
symbol: String,
value: f64,
timestamp: i64,
}
pub struct Historical {
... |
#[doc = "Register `AXIMC_PERIPH_ID_3` reader"]
pub type R = crate::R<AXIMC_PERIPH_ID_3_SPEC>;
#[doc = "Field `CUST_MOD_NUM` reader - CUST_MOD_NUM"]
pub type CUST_MOD_NUM_R = crate::FieldReader;
#[doc = "Field `REV_AND` reader - REV_AND"]
pub type REV_AND_R = crate::FieldReader;
impl R {
#[doc = "Bits 0:3 - CUST_MOD... |
// Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Defines messages used for communication between Trichechus and Cronista for storing and
//! retrieving persistent data.
use serde::{Deserialize, S... |
use csv::ReaderBuilder;
use std::io;
use structopt::StructOpt;
/// Read newline delimited data from stdin and structurally parse based on delimiters
#[derive(StructOpt, Debug)]
struct Cli {
/// The character delimiter used to split a line into fields
#[structopt(short = "d", long = "delimiter", default_value =... |
// 2019-01-06
// Les fonctions associées sont définies dans un bloc d'implémentation mais ne
// prennent pas self comme paramètre.
// Ici on va définir une fonction associée construira une instance de struct.
// square() fabriquera une instance de Rectangle qui sera un carré.
use std::io;
#[derive(Debug)]
// Défini... |
#[cfg(test)]
mod tests {
use tests_writing::libx::x;
use tests_writing::liby::y;
use tests_writing::test_helper::helper;
#[test]
fn test_together() {
assert_eq!(x() + y(), 66);
assert_eq!(helper(), "Hello");
}
}
|
use serde::{de, ser};
use std::fmt;
pub type SerdeResult<T> = std::result::Result<T, SerdeError>;
#[derive(Debug)]
pub struct SerdeError {
err: Box<ErrorCode>,
}
impl SerdeError {
pub(crate) fn create(msg: impl Into<ErrorCode>) -> Self {
Self {
err: Box::new(msg.into()),
}
}
... |
pub mod models;
pub mod schema;
pub mod listdao;
|
// Copyright 2020 EinsteinDB Project Authors. Licensed under Apache-2.0.
use super::{AckedIndexer, VoteResult};
use crate::util::Union;
use crate::HashSet;
use crate::MajorityConfig;
use std::cmp;
/// A configuration of two groups of (possibly overlapping) majority configurations.
/// Decisions require the support of... |
// Copyright 2019, 2020 Wingchain
//
// 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... |
#[doc = "Reader of register NVIC_IPR0"]
pub type R = crate::R<u32, super::NVIC_IPR0>;
#[doc = "Writer for register NVIC_IPR0"]
pub type W = crate::W<u32, super::NVIC_IPR0>;
#[doc = "Register NVIC_IPR0 `reset()`'s with value 0"]
impl crate::ResetValue for super::NVIC_IPR0 {
type Type = u32;
#[inline(always)]
... |
use std::fmt::{self, Display};
use amethyst::input::{BindingTypes};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub enum AxisBinding {
ZAxis,
YAxis,
XAxis,
}
#[derive(Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub enum ActionBinding... |
pub use self::alloca::AllocaInst;
pub use self::load::LoadInst;
pub use self::extract_value::ExtractValueInst;
pub use self::vaarg::VAArgInst;
pub use self::cast::*;
pub mod alloca;
pub mod load;
pub mod extract_value;
pub mod vaarg;
pub mod cast;
use ir::Instruction;
pub struct UnaryInst<'ctx>(Instruction<'ctx>);... |
use anyhow::{anyhow, Context, Error, Result};
use fehler::{throw, throws};
use rusoto_core::Region;
use rusoto_ec2::{
DescribeInstancesRequest, Ec2 as _, Ec2Client, Instance,
RebootInstancesRequest, StartInstancesRequest, StopInstancesRequest,
TerminateInstancesRequest,
};
use rusoto_logs::{
CloudWatchL... |
use wasm_bindgen::JsValue;
use wasm_bindgen_test::*;
use js_sys::*;
#[wasm_bindgen_test]
fn new() {
let error = Error::new(&"some message".into());
assert_eq!(JsValue::from(error.message()), "some message");
}
#[wasm_bindgen_test]
fn set_message() {
let error = Error::new(&"test".into());
error.set_me... |
fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
panic!("Please supply an input file as argument 1");
}
let input_string = std::fs::read_to_string(&args[1]).expect("Failed to load input");
let mut names: Vec<&str> = input_string
.trim()
.spl... |
use crate::message::{ExchangeReply, TraderRequest};
use crate::trader::subscriptions::HandleSubscriptionUpdates;
use crate::types::{DateTime, StdRng};
pub mod examples;
pub mod subscriptions;
pub trait Trader: HandleSubscriptionUpdates {
fn exchange_to_trader_latency(rng: &mut StdRng, dt: DateTime) -> u64;
fn... |
#![allow(dead_code)]
use pwasm_abi::eth::EndpointInterface;
use pwasm_abi_derive::eth_abi;
#[eth_abi(DoubleArrayEndpoint, DoubleArrayClient)]
pub trait DoubleArrayContract {
fn double_array(&mut self, v: [u8; 16]);
}
const PAYLOAD_SAMPLE_1: &[u8] = &[
0x71, 0x3d, 0x4b, 0x80,
0x12, 0x24, 0x36, 0x48, 0x60, 0x72, 0... |
#[macro_use]
extern crate serde_derive;
extern crate futures;
extern crate futures_cpupool;
extern crate serde;
extern crate serde_json;
extern crate tokio_minihttp;
extern crate tokio_proto;
extern crate tokio_service;
extern crate hyper;
use std::io;
use futures::{BoxFuture, Future};
use futures_cpupool::CpuPool;
... |
// exercise.rs
use std::collections::HashMap;
use std::fmt::Debug;
use std::fs::File;
use std::io;
use std::io::{ErrorKind, Read};
use std::env;
fn main() {
println!("Hello, Rust!");
let a: [i32; 5] = [1, 2, 3, 4, 5];
let b = [3; 5];
// let mut index = String::new();
// std::io::stdin()
// ... |
use std::{borrow::Cow, convert::TryInto};
use num_traits::{FromPrimitive, ToPrimitive};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use crate::{document::Document, schema::view};
/// A document's entry in a View's mappings.
#[derive(PartialEq, Debug)]
pub struct Map<K: Key = (), V: Serialize = ()> {
... |
use clap::{App, Arg};
use cocore::{convert, Representation};
use std::io;
use std::io::prelude::*;
use std::process::exit;
fn main() {
let matches = App::new("cocore")
.version("0.1.0")
.about("converts color representation such as HSL colors and RGB colors")
.author("KoharaKazuya")
... |
//! This module contains an [`ExtendedTable`] structure which is useful in cases where
//! a structure has a lot of fields.
//!
#![cfg_attr(feature = "derive", doc = "```")]
#![cfg_attr(not(feature = "derive"), doc = "```ignore")]
//! use tabled::{Tabled, tables::ExtendedTable};
//!
//! #[derive(Tabled)]
//! struct Lan... |
mod token;
mod spanned;
use proc_macro::TokenStream;
use syn::{parse_macro_input, DeriveInput};
/// The entry point for the derive macro
#[proc_macro_derive(Builder, attributes(builder, each))]
pub fn derive_builder(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
tok... |
use actix_web::{get, HttpResponse, Responder, Result as WebResult};
use serde_json::json;
use octo_budget_lib::auth_token::UserId;
#[get("/{user_id}/")]
pub async fn show(_current_user_id: UserId) -> WebResult<impl Responder> {
Ok(HttpResponse::Ok().json(json!({})))
}
|
#[doc = "Register `CALR` reader"]
pub type R = crate::R<CALR_SPEC>;
#[doc = "Register `CALR` writer"]
pub type W = crate::W<CALR_SPEC>;
#[doc = "Field `CALM` reader - Calibration minus"]
pub type CALM_R = crate::FieldReader<u16>;
#[doc = "Field `CALM` writer - Calibration minus"]
pub type CALM_W<'a, REG, const O: u8> =... |
extern crate chrono;
extern crate env_logger;
#[macro_use]
extern crate log;
extern crate kata_rs;
use kata_rs::kata::*;
fn main() {
env_logger::init();
info!("Hello, world!");
it_works();
}
|
// Copyright 2022 Alibaba Cloud. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
mod protocols;
mod utils;
#[cfg(unix)]
use protocols::r#async::{empty, streaming, streaming_ttrpc};
use ttrpc::context::{self, Context};
#[cfg(unix)]
use ttrpc::r#async::Client;
#[cfg(windows)]
fn main() {
println!(... |
#[doc = "Register `CR` reader"]
pub type R = crate::R<CR_SPEC>;
#[doc = "Register `CR` writer"]
pub type W = crate::W<CR_SPEC>;
#[doc = "Field `HSION` reader - HSI clock enable Set and cleared by software. Set by hardware to force the HSI to ON when the product leaves Stop mode, if STOPWUCK = 1 or STOPKERWUCK = 1. Set ... |
// https://adventofcode.com/2018/day/5
use std::fs::File;
use std::io::{BufRead, BufReader};
fn reacts(x: char, y: char) -> bool {
(x != y) && (x.to_lowercase().to_string() == y.to_lowercase().to_string())
}
fn polymer_react(ps: &str) -> String {
let mut poly: Vec<char> = vec![];
for c in ps.chars() {
... |
use serde::*;
use serde_tuple::*;
use std::time::SystemTime;
use crate::util::temporal;
#[derive(Clone, Debug, Serialize, Deserialize_tuple)]
pub struct Aircraft {
pub icao24: String,
pub callsign: Option<String>, // Can be null if not received
pub origin_country: String,
pub time_position: O... |
pub mod CasperMessage;
pub mod DeployService;
pub mod DeployService_grpc;
pub mod Either;
pub mod ProposeService;
pub mod ProposeService_grpc;
pub mod RhoTypes;
pub mod routing;
pub mod routing_grpc;
pub mod scalapb;
mod empty {
pub use protobuf::well_known_types::Empty;
} |
use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::num::ParseIntError;
use std::str::FromStr;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
enum Direction {
Up,
Down,
Left,
Right,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
struct Seg... |
/// Rotations in degrees
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, PartialOrd, Ord,
)]
pub struct Rot(usize);
// Right
pub const DEG_0: Rot = Rot(0);
// Up
pub const DEG_90: Rot = Rot(90);
// Left
pub const DEG_180: Rot = Rot(180);
// Down
pub const DEG_270: Rot = Rot(27... |
use nu_engine::get_full_help;
use nu_protocol::{
ast::Call,
engine::{Command, EngineState, Stack},
Category, IntoPipelineData, PipelineData, Signature, Value,
};
#[derive(Clone)]
pub struct Url;
impl Command for Url {
fn name(&self) -> &str {
"url"
}
fn signature(&self) -> Signature {... |
extern crate ndarray;
use super::loss_layer::{LayerWithLoss, SigmodWithLoss};
use crate::functions::*;
use crate::layers::{Embedding1d, Embedding2d};
use crate::model::Model;
use crate::types::{Arr1d, Arr2d, Arr3d};
use crate::util::*;
use itertools::izip;
use ndarray::{s, Array, Array1, Array2, Array3, Axis, Ix2};
pu... |
/// An enum to represent all characters in the Georgian block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Georgian {
/// \u{10a0}: 'Ⴀ'
CapitalLetterAn,
/// \u{10a1}: 'Ⴁ'
CapitalLetterBan,
/// \u{10a2}: 'Ⴂ'
CapitalLetterGan,
/// \u{10a3}: 'Ⴃ'
CapitalLetterDon,
/// \u... |
pub struct IsDisabled;
pub struct IsEnabled;
pub struct IsInput;
pub struct IsOutput;
pub struct Unknown;
pub struct Pin<STATE, DIRECTION> {
pub state: STATE,
pub direction: DIRECTION,
pub pin_mask: u32
}
pub trait PinWrite {
fn set_high(&self);
fn set_low(&self);
}
pub trait PinRead {
fn get... |
// use std::fmt;
use std::io;
use thiserror::Error;
// #[derive(Debug)]
// pub struct StatsError {
// pub msg: String,
// }
//
// impl fmt::Display for StatsError {
// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// write!(f, "Display: {}", self)
// }
// }
//
// impl From<&str> for St... |
use super::contracts::ContractedFunctionExt;
use super::options::ApplyContract;
use super::options::ApplyContracts;
use super::options::UseCallback;
use super::options::UseCallbacks;
use super::{
heap::UpValueHeap,
stack::{Stack, StackFrame},
};
use crate::{
compiler::{
constants::{ConstantMap, Cons... |
#![warn(clippy::pedantic)]
#![warn(clippy::nursery)]
#![forbid(unsafe_code)]
// #![warn(clippy::restriction)]
/**
* MIT License
*
* termail - Copyright (c) 2021 Larry Hao
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "So... |
fn main() {
let mut num = String::new();
std::io::stdin().read_line(&mut num).unwrap();
let num = num.trim().parse::<u32>().unwrap();
println!("{}:{}:{}", num / 3600, (num % 3600) / 60, num % 60);
}
|
use core::{ops, slice};
use stable_deref_trait::StableDeref;
use crate::{
sealed,
traits::{IntoSlice, IntoSliceFrom, IntoSliceTo, Truncate},
AsMutSlice, AsSlice, OwningSlice,
};
/// Owning slice of a `BUFFER` where `start == 0`
#[derive(Clone, Copy)]
pub struct OwningSliceTo<BUFFER, INDEX>
where
BUFF... |
fn main() {
enum Continent {
Europe,
Asia,
Africa,
America,
Oceania,
}
let continent = Continent::Asia;
match continent {
Continent::Europe => let a = 7;,
Continent::Asia => let a = 7,
Continent::Africa => fn aaa() {},
Continent::... |
#[doc = "Register `WKUPCR` reader"]
pub type R = crate::R<WKUPCR_SPEC>;
#[doc = "Register `WKUPCR` writer"]
pub type W = crate::W<WKUPCR_SPEC>;
#[doc = "Field `WKUPC1` reader - Clear Wakeup pin flag for WKUP. These bits are always read as 0."]
pub type WKUPC1_R = crate::BitReader;
#[doc = "Field `WKUPC1` writer - Clear... |
use super::errors;
use json;
use snailquote;
// Get the esbuild arguments from the esbuild.config.json data structure
pub fn args_from_config_json_value(
json: json::JsonValue,
) -> Result<String, errors::ConfigParseError> {
let mut args: Vec<String> = vec![];
let mut entries: Vec<String> = vec![];
let... |
use core::cmp::min;
use core::marker::PhantomData;
use core::mem;
use core::pin::Pin;
use core::sync::atomic::{compiler_fence, Ordering};
use core::task::{Context, Poll};
use embassy::interrupt::InterruptExt;
use embassy::io::{AsyncBufRead, AsyncWrite, Result};
use embassy::util::{Unborrow, WakerRegistration};
use emba... |
use core::str::from_utf8_unchecked;
use alloc::borrow::Cow;
use alloc::string::String;
use alloc::vec::Vec;
#[cfg(feature = "std")]
use std::io::{self, Write};
use crate::functions::*;
use crate::utf8_width;
/// Encode text used in an unquoted attribute. Except for alphanumeric characters, escape all characters whi... |
use std::collections::HashMap;
use std::fmt::Formatter;
use std::net::IpAddr;
use std::str::FromStr;
use serde::de::{Unexpected, Visitor};
use serde::ser::*;
use serde::Serializer;
use serde::{Deserializer, Serialize};
use sqlx::types::ipnetwork::IpNetwork;
use sqlx::types::Uuid;
use crate::common::SideType;
use crat... |
use super::program::ShaderData;
use crate::engine::base::*;
#[derive(Debug)]
pub struct Frame {
pub width: usize,
pub height: usize,
pub buffer: Vec<PixelBuffer>,
}
#[derive(Debug)]
pub struct PixelBuffer {
pub coord: Vec2,
pub color: (u8, u8, u8, u8),
pub z: u8, //z buffer
pub varying: Op... |
#[cfg(test)]
mod tests {
use crate::intcode::{Intcode, Interrupt};
use crate::util;
use crate::util::ListInput;
#[test]
fn test_advent_puzzle_1() {
let mut output = None;
let ListInput(rom) = util::load_input_file("day09.txt").unwrap();
let mut program = Intcode::new(&rom);
... |
use std::{path::PathBuf, str::FromStr};
use tts::{
backend::{
gcp::{
GcpAudioConfigRequest, GcpConfig, GcpTts, GcpVoiceRequest, GenderCode, LanguageCode,
VoiceCode,
},
openjtalk::{OpenJTalk, OpenJTalkConfig},
},
error::TtsError,
TtsEngine,
};
pub enum Tt... |
use amethyst::{
assets::Handle,
core::transform::Transform,
ecs::{Component, DenseVecStorage, Entity},
prelude::*,
renderer::{SpriteRender, SpriteSheet},
};
use super::ai::AI;
use crate::pong::{ARENA_HEIGHT, ARENA_WIDTH};
pub const PADDLE_HEIGHT: f32 = 16.0;
pub const PADDLE_WIDTH: f32 = 4.0;
pub ... |
mod resend;
mod service;
use crate::{resend::Resender, service::OutboxServiceConfig};
use actix::Actor;
use anyhow::Context;
use async_trait::async_trait;
use dotenv::dotenv;
use drogue_cloud_registry_events::{
sender::{KafkaEventSender, KafkaSenderConfig},
stream::{EventHandler, KafkaEventStream, KafkaStreamC... |
//! Translation state.
use cranelift_codegen::ir;
use cranelift_frontend;
use cranelift_frontend::Variable;
use llvm_sys::prelude::*;
use llvm_sys::target::*;
use std::collections::HashMap;
/// Information about Ebbs that we'll create.
pub struct EbbInfo {
pub num_preds_left: usize,
}
impl Default for EbbInfo {
... |
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0
mod pool;
pub use pool::*;
|
extern "C" {
pub fn esp_task_wdt_reset();
} |
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead, BufReader};
pub type Env = HashMap<String, String>;
pub fn init_env() -> Env {
let file = File::open(".env").expect("couldn't open file: .env");
let mut env = HashMap::new();
for line in BufReader::new(file).lines() {
let ke... |
use super::{Asset, Processor};
use crate::bundler::Emitter;
/// Simply skip any incoming assets
#[derive(Default)]
pub struct SkipProcessor {}
impl Processor for SkipProcessor {
fn process(&mut self, _asset: Asset, _emitter: &mut Emitter) -> anyhow::Result<()> {
Ok(())
}
}
|
use std::fs::File;
use std::io::prelude::*;
use std::io::{copy, BufReader, Error, ErrorKind, Result};
use std::net::{TcpListener, TcpStream};
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
enum Message {
Connected(TcpStream),
Quit,
}
fn main() -> Result<()> {
let (host, port) = ("127.0.0.1... |
//! A collection of objects for the Rainfusion website.
pub mod rainfusion;
use redis::{FromRedisValue, ToRedisArgs};
use std::collections::HashMap;
/// A generic trait to allow objects to be used easily with
/// database backends in glass.
pub trait Sortable {
type DataType: FromRedisValue + ToRedisArgs + Clone;... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.