text stringlengths 8 4.13M |
|---|
use futures::executor::block_on;
use futures::{stream, StreamExt}; // 0.3.5
use reqwest::Client; // 0.10.6
const CONCURRENT_REQUESTS: usize = 2;
#[derive(Debug)]
pub struct Parser {
pub tickers: Vec<String>,
}
impl Parser {
pub fn parse(&self) {
println!("hello1 {:#?}", self);
for x in &self... |
use std::fmt;
use std::str::FromStr;
use crate::errors::ParseError;
/// Represents an RGB color.
#[derive(Copy, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Color {
/// red from 0-255
pub red: u8,
/// blue from 0-255
pub green: u8,
/// green... |
use super::*;
prelude_macros::implement_constructors! {
[i8, u8, i16, u16 , i32, u32, i64, u64, f16, f32],
{
Vec2 => {
(all: Num),
(x: Num, y: Num),
(fr: Vec2),
},
Vec3 => {
(all: Num),
(x: Num, y: Num, z: Num),
(x: Num, b: Vec2),
(a: Vec2, z: Num),
(fr: ... |
#[doc = "Reader of register CLKCTL"]
pub type R = crate::R<u32, super::CLKCTL>;
#[doc = "Writer for register CLKCTL"]
pub type W = crate::W<u32, super::CLKCTL>;
#[doc = "Register CLKCTL `reset()`'s with value 0"]
impl crate::ResetValue for super::CLKCTL {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
use std::ops::MulAssign;
use std::ops::{Add, AddAssign, Mul, Sub, SubAssign};
use matrix::Position;
use crate::ruleset::board_type::BoardType;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub struct Coordinate {
pub row: i16,
pub column: i16,
}
impl Coordinate {
pub fn new(row: i16, column: i16) ->... |
use rand::prelude::*;
use std::io;
/// Prompts the user to guess a number given in `secret` as attempt # `attempt`.
///
/// # Returns
/// `true` if the user was right, `false` otherwise.
pub fn guess(secret: u32, attempt: usize) -> bool {
println!("Guess a number between 0 and 9 (attempt {}/3) > ", attempt);
l... |
use std::{cmp::Ordering, iter};
use rosu_v2::prelude::{Score, User};
use crate::{
embeds::{Author, EmbedBuilder, EmbedData, Footer},
util::{
numbers::{with_comma_float, with_comma_int},
osu::{approx_more_pp, pp_missing, ExtractablePp, PpListUtil},
},
};
pub struct PPMissingEmbed {
aut... |
//! # postgrest-rs
//!
//! [PostgREST][postgrest] client-side library.
//!
//! This library is a thin wrapper that brings an ORM-like interface to
//! PostgREST.
//!
//! ## Usage
//!
//! Simple example:
//! ```
//! use postgrest::Postgrest;
//!
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! let cl... |
// Test that both states must have the same ObjectState.
// edition:2018
extern crate async_trait;
extern crate krator;
extern crate anyhow;
extern crate k8s_openapi;
use k8s_openapi::apimachinery::pkg::apis::meta::v1::Status;
use k8s_openapi::api::core::v1::Pod;
use krator::state::test::Stub;
use krator::{Transition... |
#![no_main]
mod common;
use highway::{HighwayHash, PortableHash};
libfuzzer_sys::fuzz_target!(|input: common::FuzzKey| {
let (key, data) = (input.key, &input.data);
let hash1 = PortableHash::new(key).hash64(data);
let hash2 = PortableHash::new(key).hash64(data);
assert_eq!(hash1, hash2);
PortableH... |
use super::{common_loan_args, parse_common_loan_args};
use clap::{App, Arg, ArgMatches, SubCommand};
pub const SUB_LOAN_INFO_AT: &str = "info-at";
const ARG_N_PERIOD: &str = "n-period";
/// Returns the loan info-at sub command
pub fn loan_info_subcommand<'a, 'b>() -> App<'a, 'b> {
SubCommand::with_name(SUB_LOAN_I... |
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apache
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
* of this source tree.
*/
use p... |
// Copyright (c) 2016 Anatoly Ikorsky
//
// 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 copied,
// m... |
// Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied,
// modified, or di... |
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct UserInfo {
pub email: String,
pub token: String,
pub username: String,
pub bio: Option<String>,
pub image: Option<String>,
}
|
#[doc = "Register `OTG_HCTSIZ14` reader"]
pub type R = crate::R<OTG_HCTSIZ14_SPEC>;
#[doc = "Register `OTG_HCTSIZ14` writer"]
pub type W = crate::W<OTG_HCTSIZ14_SPEC>;
#[doc = "Field `XFRSIZ` reader - XFRSIZ"]
pub type XFRSIZ_R = crate::FieldReader<u32>;
#[doc = "Field `XFRSIZ` writer - XFRSIZ"]
pub type XFRSIZ_W<'a, R... |
mod chapter_01;
mod chapter_16;
pub mod chapter_17;
fn main() {
println!("Done");
}
|
#[cfg(windows)]
const LINE_ENDING: &'static str = "\r\n";
#[cfg(not(windows))]
const LINE_ENDING: &'static str = "\n";
#[derive(Debug, PartialEq, Clone)]
pub struct GCode {
pub command: String,
pub x: f32,
pub y: f32,
pub z: f32 // Including a Z because some slicers will map a lift as a rais... |
pub mod draw_context;
pub mod std_shaders;
pub mod object;
use self::draw_context::DrawContext;
use glium;
use glium::{glutin, Display};
use glium::glutin::{ContextBuilder, EventsLoop, WindowBuilder};
use glium::glutin::Event;
use std::collections::hash_map::HashMap;
use support::font_loader::FontEngine;
use camera::... |
use serenity::{model::channel::Message, prelude::*};
use super::super::bot;
use super::super::bot::ContestData;
use super::super::dictionary;
use super::super::sort::Sorted;
use indexmap::IndexMap;
use crate::try_say;
use std::fs::File;
use std::io::{BufWriter, Write};
use std::str::from_utf8;
pub(crate) fn prob(ctx... |
/*
* Copyright Stalwart Labs Ltd. See the COPYING
* file at the top-level directory of this distribution.
*
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
* https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
* <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
* optio... |
use core::{
fmt,
hash::{Hash, Hasher},
};
pub enum EitherBoth<A, B> {
Left(A),
Right(B),
Both(A, B),
}
impl<A, B> fmt::Debug for EitherBoth<A, B>
where
A: fmt::Debug,
B: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use EitherBoth::*;
match self ... |
use hydroflow_datalog_core::{gen_hydroflow_graph, hydroflow_graph_to_program};
use proc_macro2::Span;
use quote::{quote, ToTokens};
/// Generate a Hydroflow instance from [Datalog](https://en.wikipedia.org/wiki/Datalog) code.
///
/// This uses a variant of Datalog that is similar to [Dedalus](https://www2.eecs.berkele... |
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct ResponseErr {
pub msg: String
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Header{
pub method: String,
pub token: String,
pub user: User
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Community {
... |
use std::collections::HashSet;
use aoc_lib::Solver;
#[derive(Debug)]
pub struct Day9 {
head_positions: Vec<Coord>,
tail_positions: HashSet<Coord>,
current_tail_position: Coord,
}
#[derive(Hash, PartialEq, Eq, Debug, Default, Clone, Copy, PartialOrd, Ord)]
struct Coord(i32, i32);
impl Solver for Day9 {
... |
use crate::get_attr_val;
use proc_macro as pm;
pub(crate) fn rewrite(attr: syn::AttributeArgs, mut item: syn::ItemFn) -> pm::TokenStream {
let unmangled = get_attr_val("unmangled", &attr);
if unmangled != item.sig.ident {
let tys = item.sig.inputs.iter().map(|arg| {
if let syn::FnArg::Typed... |
// Traits are similar to a feature often called interfaces in other languages, although with some differences.
pub trait Summary {
fn summarize_author(&self) -> String;
fn summarize(&self) -> String {
format!("(Read more from {}...)", self.summarize_author())
}}
// Trait implementation
pub struct... |
use std::cmp::Eq;
use std::fmt::Display;
use std::hash::Hash;
pub trait Logic: Hash + Eq + Display + Clone {
type Manager: Clone;
fn is_false(&self) -> bool;
fn is_true(&self) -> bool;
fn negated(&self) -> Self;
fn and(&self, other: Self) -> Self;
}
use smtlib;
impl Logic for smtlib::Term {
... |
//! Massage and work the auzten file to make sure we can deal with real data.
extern crate las;
macro_rules! autzen {
($name:ident, $major:expr, $minor:expr) => {
mod $name {
use las::{Builder, Read, Reader, Version, Write, Writer};
use std::io::Cursor;
#[test]
... |
#[doc = "Register `RCC_ADCCKSELR` reader"]
pub type R = crate::R<RCC_ADCCKSELR_SPEC>;
#[doc = "Register `RCC_ADCCKSELR` writer"]
pub type W = crate::W<RCC_ADCCKSELR_SPEC>;
#[doc = "Field `ADCSRC` reader - ADCSRC"]
pub type ADCSRC_R = crate::FieldReader;
#[doc = "Field `ADCSRC` writer - ADCSRC"]
pub type ADCSRC_W<'a, RE... |
use std::{
os::unix::prelude::CommandExt,
path::PathBuf,
process::Command,
time::{Duration, SystemTime},
};
/// Update the local nix-index database.
pub fn update_database() {
eprintln!("Updating nix-index database, takes around 5 minutes.");
Command::new("nix-index").exec();
}
/// Prints a wa... |
// 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 super::{StarkDomain, TracePolyTable, TraceTable};
use air::{Air, EvaluationFrame, TraceInfo};
use math::{fft, log2, polynom, StarkFiel... |
macro_rules! add_from {
($ctor:ident, $type:ty) => {
impl From<$type> for $crate::defaults::SudoDefault {
fn from(value: $type) -> Self {
$crate::defaults::SudoDefault::$ctor(value.into())
}
}
};
($ctor:ident, $type:ty, negatable$(, $vetting_function:... |
mod engine;
mod fuel_tank;
pub mod player;
pub use self::{engine::Engine, fuel_tank::FuelTank};
use amethyst::ecs::prelude::{Component, VecStorage};
/// This component is meant for player entities.
#[derive(Debug, Clone, Copy)]
pub struct PlayerBase {
pub id: usize,
}
impl Component for PlayerBase {
type St... |
fn scope_stuff() {
println!("OUTER --");
let outer = 15;
println!("outer = {}", outer);
{
println!("-- INNER --");
let inner = 134;
let outer = 136.5555_f32; // <-- Shadows other binding
println!("-- inner = {}", inner);
println!("-- outer = {}", outer);
... |
import std::{str, map, uint, int, option};
import std::map::hashmap;
import std::option::{none, some};
import syntax::ast;
import ast::{ty, pat, lit, path};
import syntax::codemap::{codemap, span};
import syntax::visit;
import std::io::{stdout, str_writer, string_writer};
import syntax::print;
import print::pprust::{pr... |
#[doc = "Reader of register LE_PING_TIMER_ADDR"]
pub type R = crate::R<u32, super::LE_PING_TIMER_ADDR>;
#[doc = "Writer for register LE_PING_TIMER_ADDR"]
pub type W = crate::W<u32, super::LE_PING_TIMER_ADDR>;
#[doc = "Register LE_PING_TIMER_ADDR `reset()`'s with value 0"]
impl crate::ResetValue for super::LE_PING_TIMER... |
#![cfg_attr(feature = "strict", deny(warnings))]
#![warn(
clippy::print_stderr,
clippy::print_stdout,
clippy::unwrap_used,
clippy::wildcard_imports
)]
mod completion;
mod composition;
mod diagnostics;
mod lang;
mod lsp;
mod server;
mod visitors;
#[cfg(feature = "wasm")]
mod wasm;
#[cfg(test)]
#[macro_u... |
use std::{sync::Arc, time::Duration};
use bson::doc;
use crate::{
error::Result,
event::{
cmap::{CmapEvent, CmapEventHandler, ConnectionCheckoutFailedReason},
command::CommandEventHandler,
},
runtime,
runtime::AsyncJoinHandle,
test::{
log_uncaptured,
spec::{unif... |
// cargo-deps: rand
// A simple allocator built using an implicit free list.
// (See also: stjepang/vec-arena)
//
// Compile this using either "rustc --test" or "cargo script".
#[cfg(not(test))]
extern crate rand;
#[derive(Clone, Debug)]
pub struct Pool<T> {
pub slots: Vec<Result<T, usize>>,
pub len: usize,
... |
#[doc = "Reader of register INTR_CAUSE2"]
pub type R = crate::R<u32, super::INTR_CAUSE2>;
#[doc = "Reader of field `PORT_INT`"]
pub type PORT_INT_R = crate::R<u32, u32>;
impl R {
#[doc = "Bits 0:31 - Each IO port has an associated bit field in this register. The bit field reflects the IO port's interrupt line (bit ... |
// just a one element tuple, wrapper around List
// this is whats called a tuple struct
pub struct IntoIter<T>(List<T>);
pub struct Iter<'a, T> {
next: Option<&'a Node<T>>,
}
pub struct IterMut<'a, T> {
next: Option<&'a mut Node<T>>,
}
impl<'a, T> Iterator for IterMut<'a, T> {
type Item = &'a mut T;
... |
//! Provides utility functions for generating data sequences
use crate::euclid::Modulus;
use std::f64::consts;
/// Generates a base 10 log spaced vector of the given length between the
/// specified decade exponents (inclusive). Equivalent to MATLAB logspace
///
/// # Examples
///
/// ```
/// use statrs::generate;
///... |
extern crate libc;
extern crate rsnl;
use libc::{c_int, c_void};
use rsnl::message::{NetlinkMessage, nl_msg, nlmsghdr};
use rsnl::message::expose::{nl_msg_ptr, nlmsghdr_ptr};
#[repr(C)]
struct genlmsghdr;
#[link(name="nl-genl-3")]
extern "C" {
fn genlmsg_valid_hdr(hdr: *const nlmsghdr, hdrlen: c_int) -> i32;
... |
// Copyright 2019 The xi-editor Authors.
//
// 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 ag... |
use std::fs;
use regex::Regex;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Instruction {
operation: String,
argument: isize,
}
impl Instruction {
pub fn new(operation: String, argument: isize) -> Instruction {
Instruction { operation, argument }
}
pub fn parse(line: &str) -> Instru... |
use crate::object::*;
use crate::object::text::Text;
use crate::surface;
use surface::{
Object,
Surface
};
use super::*;
use elements::Svg;
use elements::shape;
fn point(l: &shape::Line) -> Point
{
Point::new(l.x1, l.y1)
}
fn line(l: &shape::Line) -> Line
{
line![
(l.x1, l.y1),
(l.x2 ... |
use actix::prelude::*;
mod client;
mod codec;
pub use self::client::AdsClient as Client;
use std::process;
use futures::{future, Future};
use std::net::ToSocketAddrs;
use tokio_codec::FramedRead;
use tokio_io::AsyncRead;
use tokio_tcp::TcpStream;
pub use self::client::*;
pub use self::codec::types::*;
pub use self:... |
use crate::codes::*;
use crate::error::*;
use crate::file::*;
use crate::flags::*;
use crate::helpers::*;
use crate::signatures::*;
macro_rules! table {
($name:ident) => {
#[derive(Debug, Copy, Clone, Eq)]
pub struct $name<'a> {
pub(crate) row: RowData<'a>,
}
impl<'a> Ro... |
#[allow(unused_imports)]
use packed_simd::{
f32x16, f32x2, f32x4, f32x8, f64x2, f64x4, f64x8, i128x1, i128x2, i128x4, i16x16, i16x2,
i16x32, i16x4, i16x8, i32x16, i32x2, i32x4, i32x8, i64x2, i64x4, i64x8, i8x16, i8x2, i8x32,
i8x4, i8x64, i8x8, isizex2, isizex4, isizex8, m128x1, m128x2, m128x4, m16x16, m16x2... |
#[derive(Debug)]
enum Option<T>{
some(T),
none,
}
fn main() {
let number=Option::some(13);
let st=Option::some(String::from("Mehran"));
// let n:Option<T>=Option::none;
println!("{:#?}",number);
println!("{:#?}",st);
// println!("{:#?}",n);
}
|
fn main() {
proconio::input! {
n: i32,
k: i32,
}
let mut ans = 1;
let mut n = n;
while n >= k {
ans += 1;
n = n / k;
}
println!("{}", ans);
} |
//! Riddle crate containing providing the common API to which riddle renderers abide. This allows
//! secondary libraries to be defined in terms of the traits and structs defined in this crate
//! without needing to encode knowledge of any specific renderers.
mod renderer;
mod sprite;
mod sprite_font;
pub mod vertex;
... |
//! The so-called specification is unclear
//! on the matter of alternatives of compound types.
//! For now, we'll do the simpler thing.
use super::super::messages::WriteGTP;
use super::*;
use std::io;
#[derive(Debug)]
pub struct Value(simple_entity::Value);
impl From<simple_entity::Value> for Value {
fn from(v: si... |
use super::{
declaration::Declaration, definition::Definition, foreign_declaration::ForeignDeclaration,
foreign_definition::ForeignDefinition, type_definition::TypeDefinition,
};
#[derive(Clone, Debug, PartialEq)]
pub struct Module {
type_definitions: Vec<TypeDefinition>,
foreign_declarations: Vec<Fore... |
use parity_wasm::{deserialize_buffer, elements::Module};
use std::fs::read;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(
name = "kontrolleuer",
about = "Inspecting what assumptions a wasm binary has about its environment"
)]
struct Options {
/// Input file
#[structopt()]
file:... |
#[doc = "Register `SR` reader"]
pub type R = crate::R<SR_SPEC>;
#[doc = "Register `SR` writer"]
pub type W = crate::W<SR_SPEC>;
#[doc = "Field `AWD` reader - Analog watchdog flag"]
pub type AWD_R = crate::BitReader;
#[doc = "Field `AWD` writer - Analog watchdog flag"]
pub type AWD_W<'a, REG, const O: u8> = crate::BitWr... |
use alloc::boxed::Box;
use core::{marker::PhantomData, num::NonZeroU32};
use necsim_core::{
cogs::{Backup, Habitat},
intrinsics::{ceil, log2},
landscape::{LandscapeExtent, Location},
};
use crate::decomposition::Decomposition;
mod area;
mod weight;
#[cfg(test)]
mod test;
#[allow(clippy::module_name_rep... |
mod common;
use cached::cached;
use proptest::prelude::*;
use valis_automata::{
dfa::{standard::StandardDFA, DFA},
range_set::Range,
};
use valis_ds::{ops::Intersection, set::SetBase};
cached! {
THREE_OR_LESS_TRUE_THREE_OR_MORE_FALSE;
fn three_or_less_true_three_or_more_false() -> StandardDFA<bool, u8... |
#[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::AUX3 {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut ... |
use std::collections::HashMap;
use std::io;
// private let employee_to_department = HashMap::new();
fn list_employees_in_department(
department_name: String,
employee_to_department: &HashMap<String, String>,
) -> Vec<String> {
let mut employees: Vec<String> = Vec::new();
for (employeeName, departmentName) in e... |
extern crate cairo;
extern crate gdk;
extern crate gdk_sys;
extern crate gtk;
extern crate i3ipc;
extern crate time;
use std::cell::RefCell;
use std::ops::Range;
use std::process::Command;
use std::rc::Rc;
use std::thread;
use gtk::prelude::*;
use i3ipc::{I3Connection, I3EventListener, Subscription};
use relm::{Chann... |
pub mod cam;
pub mod plane;
pub mod settings;
pub mod world;
use bevy::prelude::*;
fn main() {
App::build()
.add_plugin(settings::SettingsPlugin)
.add_plugin(world::WorldPlugin)
.add_resource(Msaa { samples: 4 })
.add_plugin(plane::PlanePlugin)
.add_plugin(cam::CameraPlugin... |
mod cf;
mod request;
mod response;
pub mod prelude {
pub use crate::cf::Cf;
pub use crate::request::Request;
pub use crate::response::{Response, ResponseInit};
}
pub use cf::Cf;
pub use request::Request;
pub use response::{Response, ResponseInit};
|
use clap::Parser;
use image_encryption::{decrypt_image, encrypt_image, load_image, write_image};
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
pub enum Mode {
Enc,
Dec,
}
/// simple image encryption program
#[derive(Debug, Parser)]
struct Args {
/// encrypt an image or decrypt an encrypted one
#[cla... |
pub mod gillespie;
|
use chiropterm::*;
use euclid::{rect, size2};
use super::WidgetDimensions;
// TODO: "InternalWidgetDimensions" with an optional max and align
// ExternalWidgetDimensions with no max or align
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct InternalWidgetDimensions {
// widget will force its width below thi... |
/*!
# Advent of Code 2020 - Day 02
[Link to task.](https://adventofcode.com/2020/day/2)
How many password are valid based on password policies at the time?
Input file is in rows similar to "1-3 a: abcde". Number range implies how many
letters there has to be. After semicolon is the password itself. In this example
at... |
#[macro_use]
extern crate criterion;
extern crate netlink_packet_core;
extern crate netlink_packet_route;
extern crate pcap_file;
use criterion::Criterion;
use netlink_packet_core::NetlinkMessage;
use netlink_packet_route::RtnlMessage;
use pcap_file::PcapReader;
use std;
use std::fs::File;
fn bench(c: &mut Criterion)... |
#[doc = "Register `GTZC1_TZSC_PRIVCFGR3` reader"]
pub type R = crate::R<GTZC1_TZSC_PRIVCFGR3_SPEC>;
#[doc = "Register `GTZC1_TZSC_PRIVCFGR3` writer"]
pub type W = crate::W<GTZC1_TZSC_PRIVCFGR3_SPEC>;
#[doc = "Field `I3C2PRIV` reader - privileged access mode for I3C2"]
pub type I3C2PRIV_R = crate::BitReader;
#[doc = "Fi... |
//! Contains various pre-build expressions.
pub mod irreducibles;
pub mod operations;
|
//! This module implements the internal storage format for
//! the voxel data in each sector.
use crate::{block::Block, side::Side};
use core::slice;
/// The number of voxels that comprise one edge of a sector,
/// excluding padding.
pub const SECTOR_DIM_EXCL: usize = 16;
/// The number of voxels that are shared wit... |
use serde::{Deserialize, Serialize};
use super::asset_format::AssetFormat;
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct NativeFormat {
asset: Vec<AssetFormat>,
ext: Option<NativeFormatExt>,
}
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct NativeFormatExt {}
|
extern crate problem12;
use std::collections::HashMap;
use problem12::{rule_set, plants};
use std::fs;
fn main() -> Result<(), String> {
let input = fs::read_to_string("input/data.txt").map_err(|e| e.to_string())?;
let rules = rule_set::get_rule_set(&input);
let initial_state = "#.##.#.##..#.#...##...#...... |
pub
fn build_vector_verbose() -> Vec<i16> {
let mut v: Vec<i16> = Vec::<i16>::new();
v.push(10i16);
v.push(20i16);
v
}
|
use xtensa_lx_rt::exception::Context;
use xtensa_lx_rt::interrupt;
use crate::ram;
#[repr(u8)]
pub enum InterruptType {
SLC = 1,
SPI = 2,
GPIO = 4,
UART = 5,
CCOMPARE = 6,
SOFT = 7,
WDT = 8,
TIMER1 = 9,
}
impl InterruptType {
const fn mask(self) -> u32 {
1 << self as u8
... |
#[derive(Default, Debug, Clone, Copy)]
pub struct PerVerexParams {
pub in_pos: [f32; 4],
pub in_uv: [f32; 2],
pub in_color: [f32; 3],
pub in_normal: [f32; 3],
pub in_tangent: [f32; 3],
}
vulkano::impl_vertex!(
PerVerexParams,
in_pos,
in_uv,
in_color,
in_normal,
in_tangent
);
... |
use crate::rm::Error as RmError;
use thiserror::Error;
/// Error of Transaction Manager.
#[derive(Debug, Error)]
pub enum XaError {
/// Error was caused by one or multiple Resource Manager Errors.
#[error("Error was caused by one or multiple Resource Manager Errors")]
RmErrors(Vec<RmError>),
/// Error ... |
#![cfg_attr(not(feature = "std"), no_std)]
use liquid::storage;
use liquid_lang as liquid;
#[liquid::contract]
mod hello_world {
use super::*;
#[liquid(storage)]
struct HelloWorld {
name: storage::Value<String>,
}
#[liquid(methods)]
impl HelloWorld {
pub fn new(&mut self) {
... |
pub struct Stylesheet {
pub rules: Vec<Rule>,
}
impl Stylesheet {
pub fn new(rules: Vec<Rule>) -> Stylesheet {
Stylesheet { rules }
}
}
pub struct Rule {
pub selectors: Vec<Selector>,
pub declarations: Vec<Declaration>,
pub level: Origin,
}
impl Rule {
pub fn new(selectors: Vec<Se... |
use std::io::prelude::*;
use std::fs::File;
use std::error::Error;
use std::io::BufReader;
use std::cmp;
fn main() {
let reader = read_file("input.txt");
let result = parse(reader);
println!("{}", result)
}
fn parse(reader: BufReader<File>) -> i32 {
let mut total = 0;
for line in reader.lines() {... |
// Copyright 2018-2020, Wayfair GmbH
//
// 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... |
extern crate mylib;
use mylib::*;
const INPUT: &str = include_str!("../data/input.txt");
pub fn main() {
// part 1
let result = INPUT
.lines()
.map(|l| count_letters(l))
.fold((0usize, 0usize), |acc, (two, three)| {
(acc.0 + two, acc.1 + three)
});
// println!... |
use crate::ip::{IPv4, IPv6};
use crate::v2::error::ParseError;
use std::borrow::Cow;
use std::fmt;
use std::net::SocketAddr;
use std::ops::BitOr;
/// The prefix of the PROXY protocol header.
pub const PROTOCOL_PREFIX: &[u8] = b"\r\n\r\n\0\r\nQUIT\n";
/// The minimum length in bytes of a PROXY protocol header.
pub cons... |
mod energy_regen;
mod health_regen;
mod packet_handler;
mod poll_complete;
mod position_update;
mod register;
mod run_futures;
mod timer_handler;
pub mod collision;
pub mod handlers;
pub mod missile;
pub mod specials;
pub mod spectate;
pub use self::energy_regen::EnergyRegenSystem;
pub use self::health_regen::HealthR... |
use std::cmp::Ordering;
use std::fmt::{self, Display};
use std::str;
use common::{Literal, SqlType};
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub enum FunctionExpression {
Avg(Column, bool),
Count(Column, bool),
CountStar,
Sum(Column, bool),
Max(Column),
Min(Column)... |
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
#[allow(dead_code)]
struct Scanner<'a> {
cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
fn new(cin: StdinLock<'a>) -> Scanner<'a> {
Scanner { cin: cin }
}
fn read<T: FromStr>(&mut self) -> Option<T> {
let t... |
// El discurso de Zoe
//
// Copyright (C) 2016 GUL UC3M
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Th... |
/*
Module: int
*/
/*
Const: max_value
The maximum value of an integer
*/
// FIXME: Find another way to access the machine word size in a const expr
#[cfg(target_arch="x86")]
const max_value: int = (-1 << 31)-1;
#[cfg(target_arch="x86_64")]
const max_value: int = (-1 << 63)-1;
/*
Const: min_value
The minumum value ... |
/*
chapter 4
functions
function pointers
*/
fn plus_one(i: i32) -> i32 {
i + 1
}
fn main() {
// without type inference
let a: fn(i32) -> i32 = plusOne;
// with type inference
let b = plusOne;
let c = a(5);
println!("{}", b);
let d = c(6);
println!("{}", d);
}
// output should be... |
#![allow(non_camel_case_types)]
#![allow(dead_code)]
#![allow(const_err)] // TODO: check later without that
use libusb_sys as ffi;
use std::str::FromStr;
pub const FTDI_MAJOR_VERSION: u8 = 1;
pub const FTDI_MINOR_VERSION: u8 = 5;
pub const FTDI_MICRO_VERSION: u8 = 0;
pub const FTDI_VERSION_STRING: &str = "1.5.0";
pub... |
use std::fmt;
use slab::Slab;
pub struct Subscription {
key: usize,
}
#[derive(Debug)]
pub struct SubscriptionMissing;
impl fmt::Display for SubscriptionMissing {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Attempt to unsubscribe delegate without subscription")
}
}
impl ... |
enum Expr {
Add(i32, i32),
Sub(i32, i32),
Val(i32),
}
fn main() {
print_expr(Expr::Sub(40, 2));
print_expr(Expr::Add(40, 2));
println!("{}", uppercase(b'A'));
}
fn print_expr(expr: Expr) {
match expr {
Expr::Add(x, y) => println!("{}", x + y),
Expr::Sub(x, y) => println!("{... |
#[doc = "Register `SYSCFG_CMPENSETR` reader"]
pub type R = crate::R<SYSCFG_CMPENSETR_SPEC>;
#[doc = "Register `SYSCFG_CMPENSETR` writer"]
pub type W = crate::W<SYSCFG_CMPENSETR_SPEC>;
#[doc = "Field `MPU_EN` reader - MPU_EN"]
pub type MPU_EN_R = crate::BitReader;
#[doc = "Field `MPU_EN` writer - MPU_EN"]
pub type MPU_E... |
use askama::Template;
#[derive(Template)]
#[template(path = "base.html")]
pub struct Base {
pub henlo: Option<String>,
}
|
use context::{Context};
use std::vec::Vec;
use std::cell::Cell;
// pub type Middleware<T: Context> = fn(T, chain: &MiddlewareChain<T>) -> T;
pub type Middleware<T> = fn(T, chain: &MiddlewareChain<T>) -> T;
pub struct MiddlewareChain<T: Context> {
_chain_index: Cell<usize>,
pub middleware: Vec<Middleware<T>>
}
im... |
//! An implementation of the [MD4][1] cryptographic hash algorithm.
//!
//! # Usage
//!
//! ```rust
//! use md4::{Md4, Digest};
//! use hex_literal::hex;
//!
//! // create a Md4 hasher instance
//! let mut hasher = Md4::new();
//!
//! // process input message
//! hasher.update(b"hello world");
//!
//! // acquire hash d... |
#[derive(Debug, PartialEq)]
pub enum Comparison {
Equal,
Sublist,
Superlist,
Unequal,
}
pub fn sublist<A>(list_1: &[A], list_2: &[A]) -> Comparison
where A: PartialEq
{
match (list_1.len(), list_2.len()) {
(len_1, len_2) if len_1 < len_2 && is_sublist(list_1, list_2) => Comparison::Subl... |
use crate::requests::presence_topology_get::PresenceTopologyGetRequester;
use crate::{Client, Config, DirectoryClient};
use serde::{Deserialize, Serialize};
use topology::{CocoNode, MixNode, MixProviderNode, NymTopology};
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Coc... |
pub enum AddressingMode {
Immediate,
ZeroPage,
ZeroPageX,
ZeroPageY,
Absolute,
AbsoluteX,
AbsoluteY,
IndexedIndirect,
IndirectIndexed
}
pub enum JumpAddressingMode {
Absolute,
Indirect
}
pub enum SingleByteMnemonic {
ASL, CLC, CLD, CLI, CLV,
DEX, DEY, INX, INY, LSR,
NOP, ROL, ROR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.