text stringlengths 8 4.13M |
|---|
pub fn is_leap_year(year: u64) -> bool {
let div_by_4 = year % 4 == 0;
let div_by_100 = year % 100 == 0;
let div_by_400 = year % 400 == 0;
(div_by_100 && div_by_400) || (div_by_4 & !div_by_100)
}
|
// 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... |
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use hydroflow::scheduled::graph::Hydroflow;
use hydroflow::scheduled::graph_ext::GraphExt;
use hydroflow::scheduled::handoff::{Iter, VecHandoff};
use hydroflow::scheduled::query::Query as Q;
use timely::dataflow::operators::{Concatenate, Filter, In... |
fn binary_search(v: &Vec<i32>, target: i32) -> Option<i32> {
let mut min: usize = 0;
let mut max: usize = v.len() - 1;
let mut found: Option<i32> = None;
while min <= max {
let mid: usize = min + (max - min) / 2;
if target == v[mid] {
found = Some(target);
break... |
impl Solution {
pub fn h_index(mut citations: Vec<i32>) -> i32 {
let (mut res,n) = (0,citations.len());
citations.sort_unstable();
for i in (1..=n).rev(){
if citations[n -i] >= i as i32{
res = i as i32;
break;
}
}
res
... |
pub(crate) mod history; |
/*
chapter 4
primitive types
char
*/
fn main() {
let n = 'n';
println!("{}", n);
let heart = '❤';
println!("{}", heart);
}
// output should be:
/*
n
❤
*/
|
// base16.rs
use std::vec;
enum DecodeSize {
Done(uint), // on success
Fail(uint, ~str), // on failure
}
static BASE16_TABLE: &'static [u8] = bytes!("0123456789ABCDEF");
static BASE16_DECODE_MAP: [u8, ..256] = [
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
25... |
use libc::{c_int, c_ushort, c_void, setsockopt, socklen_t, SOL_SOCKET};
use std::io::Error;
use std::mem::{forget, size_of_val};
use std::os::unix::io::RawFd;
use std::ptr::null;
#[repr(C)]
#[derive(Debug)]
pub struct Op {
code: u16,
jt: u8,
jf: u8,
k: u32,
}
impl Op {
pub fn new(code: u16, jt: u8... |
#[doc = "Reader of register XTAL_CLK_DIV_CONFIG"]
pub type R = crate::R<u32, super::XTAL_CLK_DIV_CONFIG>;
#[doc = "Writer for register XTAL_CLK_DIV_CONFIG"]
pub type W = crate::W<u32, super::XTAL_CLK_DIV_CONFIG>;
#[doc = "Register XTAL_CLK_DIV_CONFIG `reset()`'s with value 0"]
impl crate::ResetValue for super::XTAL_CLK... |
use *;
impl<T> Reactor<T> {
/// Evaluate bool.
pub fn eval_bool(&self, id: ptr::Bool, env: &mut Environment<T>) -> bool
where T: Float, f64: Cast<T>
{
use fns::Bool::*;
match self[id] {
Data(a) => a,
Not(a) => !self.eval_bool(a, env),
And(a, b) =... |
use std::collections::HashSet;
use std::mem;
use std::path::PathBuf;
use std::thread;
use std::time::Duration;
use std::time::Instant;
use std::vec;
use clap;
use futures::Future;
use futures_cpupool::CpuPool;
use num_cpus;
use output::Output;
use output::OutputJob;
use convert::utils::*;
use misc::*;
use misc::ar... |
fn count_orbits(map: &[(&str, &str)]) -> usize {
let mut count = 0;
for (mut target, _) in map {
count += 1;
while let Some((t, _)) = map.iter().find(|(_, x)| x == &target) {
count += 1;
target = t;
}
}
count
}
fn list_orbits<'a>(map: &[(&'a str, &'a str)... |
#[allow(unused_imports)]
use super::prelude::*;
use super::intcode::IntcodeDevice;
type Input = IntcodeDevice;
pub fn input_generator(input: &str) -> Input {
input.parse().expect("Error parsing the IntcodeDevice")
}
pub fn part1(input: &Input) -> u32 {
let base_device = input;
let mut device = input.clone... |
use futures::{future, Future, Stream};
use hyper::http::uri::InvalidUri;
use hyper::Uri;
use hyper::{self, Body, Client, Request};
use hyper_tls::HttpsConnector;
use std::io::{self, Error, ErrorKind};
use tokio_core::reactor::Core;
use url::form_urlencoded;
#[derive(Debug)]
pub enum ClientError {
Error(Error),
... |
/// EditUserOption edit user options
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct EditUserOption {
pub active: Option<bool>,
pub admin: Option<bool>,
pub allow_create_organization: Option<bool>,
pub allow_git_hook: Option<bool>,
pub allow_import_local: Option<bool>,
pub e... |
use chrono::{DateTime, Utc};
pub trait RetryPolicy {
/// Determine if a task should be retried according to a retry policy.
fn should_retry(&self, n_past_retries: u32) -> RetryDecision;
}
/// Outcome of evaluating a retry policy for a failed task.
pub enum RetryDecision {
/// Retry after the specified tim... |
use crate::errors::ConnectorXError;
#[cfg(feature = "src_oracle")]
use crate::sources::oracle::OracleDialect;
use fehler::{throw, throws};
use log::{debug, trace, warn};
use sqlparser::ast::{
BinaryOperator, Expr, Function, FunctionArg, Ident, ObjectName, Query, Select, SelectItem,
SetExpr, Statement, TableAlia... |
//! Path Stroking
//!
//! # Example
//!
//! // Input Path
//! let mut path = agg::Path::new();
//! path.move_to( 0.0, 0.0);
//! path.line_to(100.0, 100.0);
//! path.line_to(200.0, 50.0);
//!
//! // Stroke
//! let mut stroke = agg::Stroke::new( path );
//! stroke.width(2.5);
//! s... |
extern crate pcap_file;
use pcap_file::pcap::{PacketHeader, PcapHeader, PcapReader, PcapWriter};
static DATA: &[u8; 1455] = include_bytes!("little_endian.pcap");
#[test]
fn read() {
let pcap_reader = PcapReader::new(&DATA[..]).unwrap();
//Global header len
let mut data_len = 24;
for pcap in pcap_re... |
use algebra::biginteger::{BigInteger, BigInteger256};
use num_bigint::BigUint;
use std::cmp::Ordering::{Equal, Greater, Less};
use std::convert::TryInto;
const BIGINT256_NUM_BITS: i32 = 256;
const BIGINT256_LIMB_BITS: i32 = 64;
const BIGINT256_LIMB_BYTES: i32 = BIGINT256_LIMB_BITS / 8;
const BIGINT256_NUM_LIMBS: i32 =... |
use std::cell::RefCell;
use std::ops::Range;
use nom::branch::alt;
use nom::bytes::complete::{take, take_till1, take_while};
use nom::character::complete::{anychar, char};
use nom::combinator::{all_consuming, map, not, recognize, rest, verify};
use nom::sequence::{delimited, preceded, terminated};
type LocatedSpan<'a... |
use lazy_static::lazy_static;
use envconfig::Envconfig;
#[derive(Debug)]
pub struct Settings {
pub rpc: crate::rpc::Config,
pub service: crate::srv::Config,
pub db: crate::db::Config,
pub nats: Nats,
pub redis: Redis,
}
#[derive(Debug, Clone, Envconfig)]
pub struct Nats {
#[envconfig(from = "... |
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate hdk;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate holochain_json_derive;
mod definitions;
use definitions::{ Definition, Catalog, valid_definition, valid_base_and_target };
use hdk::{
entry_definition::ValidatingEntryTyp... |
use log::error;
pub mod mem_map;
mod game_pad;
mod vram;
mod wram;
use self::game_pad::GamePad;
use self::vram::Vram;
use self::wram::Wram;
use self::mem_map::*;
use super::{Mmu, Rom};
pub struct BasicMMU {
rom: Rom,
wram: Wram,
vram: Vram,
game_pad: GamePad,
}
impl BasicMMU {
pub fn new<T: In... |
const POINTERS_IN_NODE: u64 = disk::SECTOR_SIZE / page::POINTER_SIZE;
struct Array<T> {
root: page::Pointer,
len: u64,
_phantom: PhantomData<T>,
}
impl Array<T> {
fn is_leaf(&self) -> bool {
self.len <= POINTERS_IN_NODE
}
fn for_each<F>(&self, fs: &fs::State, range: Range, f: F) -> Re... |
use friday_error::FridayError;
use std::time::Duration;
#[derive(Eq, PartialEq, PartialOrd, Ord)]
pub enum Status<A> {
Continue(A),
Retry(A, Duration),
Exit
}
// Karta is the swedish word for map
// Each Karta will guide a user towards Friday.
pub trait Karta {
// Used for error logging etc
fn nam... |
use std::collections::{BTreeMap, BinaryHeap, VecDeque};
use std::vec::Vec;
/// A limit specification.
#[derive(PartialEq, PartialOrd, Eq, Ord, Copy, Clone, Debug)]
pub enum Capacity {
Limit(usize),
Infinite,
}
impl ::std::str::FromStr for Capacity {
type Err = ::std::num::ParseIntError;
fn from_str(s:... |
use crate::errors::UErr;
use crate::output::p2s;
use crate::registry::{GCRootsTx, Register};
use crate::scan::Scanner;
use crate::statistics::{Statistics, StatsMsg, StatsTx};
use crate::storepaths::{Cache, Lookup, StorePaths};
use crate::App;
use anyhow::{Context, Result};
use ignore::{self, DirEntry, WalkParallel, Wa... |
// Copyright 2020 Shift Cryptosecurity AG
//
// 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 ... |
/*
* 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 juno::ast::*;
use juno::gen_js;
use juno::hparser;
fn do_gen(node: &Node, pretty: gen_js::Pretty) -> String {
use juno::ge... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
_reserved0: [u8; 0x04],
#[doc = "0x04 - peripheral mode configuration register"]
pub pmcr: PMCR,
#[doc = "0x08 - external interrupt configuration register 1"]
pub exticr1: EXTICR1,
#[doc = "0x0c - external interrupt configuration r... |
struct Solution;
impl Solution {
pub fn count_substrings(s: String) -> i32 {
let s = s.as_bytes();
let n = s.len() as i32;
let mut ans = 0;
for i in 0..(2 * n - 1) {
// i 是中心点,包括了空隙,所以还要求出对应的索引。
// [0, 0], [0, 1], [1, 1], [1, 2] ...
let mut l = i /... |
use crate::hittable::{HitRecord, Hittable};
use crate::ray::Ray;
use std::ops::Range;
use std::rc::Rc;
pub struct HittableList {
objects: Vec<Rc<dyn Hittable>>,
}
impl HittableList {
pub fn new() -> Self {
Self {
objects: Vec::new(),
}
}
pub fn add(&mut self, object: Rc<d... |
#![cfg(test)]
use crate::content::PostItem;
use crate::content::SeriesItem;
use crate::paths::AbsPath;
use crate::site::{Site, SiteOptions};
use crate::site_url::{HrefUrl, ImgUrl};
use crate::util::{load_templates, ParsedFile, ParsedFiles};
use camino::Utf8Path;
use camino::Utf8PathBuf;
use eyre::Result;
use hotwatch:... |
use crate::error::Result;
use crate::shared::{FileSystemResource, InstallActionKind, Name, PackageKind, Platform};
use crate::APP_NAME;
use regex::Regex;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs::read_dir;
use std::io::Write;
use std::path::PathBuf;
use std::s... |
/*
https://projecteuler.net
Starting with 1 and spiralling anticlockwise in the following way, a
square spiral with side length 7 is formed.
37 36 35 34 33 32 31
38 17 16 15 14 13 30
39 18 5 4 3 12 29
40 19 6 1 2 11 28
41 20 7 8 9 10 27
42 21 22 23 24 25 26
43 44 45 46 47 48 49
It is interest... |
use crate::{
qjs,
system::{create_dir_all, Path},
Artifact, BoxedFuture, Diagnostics, Input, Mut, Output, ParallelSend, ParallelSync, Ref,
Result, Set, Time, WeakArtifact, WeakSet,
};
use derive_deref::Deref;
use either::Either;
use futures::future::FutureExt;
use serde::Serialize;
use std::{
fmt::{... |
#![no_core]
#![feature(lang_items)]
#![feature(fundamental)]
#![feature(no_core)]
#![feature(optin_builtin_traits)]
#![feature(unboxed_closures)]
#![crate_name = "core"]
#![crate_type = "rlib"]
pub mod marker;
// mod ops;
// mod option;
// mod code;
pub mod prelude { pub mod v1 { } }
|
#![cfg(not(test))]
#![feature(lang_items)]
#![feature(start)]
#![feature(libc)]
#![feature(core)]
#![feature(no_std)]
#![no_std]
extern crate libc;
#[macro_use(assert, panic)]
extern crate core;
use libc::{dirent_t, c_int, c_char, DIR};
use libc::{closedir, getopt, strlen};
use core::str::{StrExt, from_utf8};
use co... |
use serde::{de, ser};
use serde_json::Number;
#[derive(Debug, PartialEq)]
pub struct Version {
value: u8,
}
impl Version {
/// Returns schema version value
pub fn value(&self) -> u8 {
self.value
}
}
impl Default for Version {
fn default() -> Version {
Version { value: 1 }
}
}
... |
pub(crate) mod interface_description;
pub use interface_description::*;
pub(crate) mod section_header;
pub use section_header::*;
pub(crate) mod enhanced_packet;
pub use enhanced_packet::*;
pub(crate) mod simple_packet;
pub use simple_packet::*;
pub(crate) mod common;
pub use common::*;
pub(crate) mod name_resolut... |
#![allow(unreachable_patterns)]
use std::fmt;
extern crate lalrpop_util;
#[macro_use] extern crate enum_methods;
pub mod ast;
pub mod tok;
pub mod parser;
pub unsafe trait SyntaxTrait { }
pub struct Postgres;
unsafe impl SyntaxTrait for Postgres { }
|
#[doc = "Register `APB1FZR1` reader"]
pub type R = crate::R<APB1FZR1_SPEC>;
#[doc = "Register `APB1FZR1` writer"]
pub type W = crate::W<APB1FZR1_SPEC>;
#[doc = "Field `DBG_TIM2_STOP` reader - TIM2 counter stopped when core is halted"]
pub type DBG_TIM2_STOP_R = crate::BitReader;
#[doc = "Field `DBG_TIM2_STOP` writer - ... |
use z80::Z80;
/*
** XOR r|$xx|(hl)
** Condition Bits: R000
** Clocks:
** r: 1
** $xx: 2
** (hl): 2
*/
pub fn xor(z80: &mut Z80, op: u8) {
let val = match op {
0xEE => {
z80.r.pc += 1;
z80.mmu.rb(z80.r.pc - 1)
},
0xAE => z80.mmu.rb(z80.r.get_hl()),
... |
// Copyright 2014 The Gfx-rs Developers.
//
// 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... |
//! Utilities related to RDF.
use std::str::FromStr;
use std::fmt;
use std::fmt::{Display, Formatter};
use language_tags;
/// Error type returned when trying to parse an invalid IRI.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct InvalidIriError {
/// The invalid IRI string that we tried to parse.
p... |
use ckb_error::{Error, ErrorKind};
use failure::Fail;
use std::fmt::Display;
#[derive(Fail, Debug, PartialEq, Clone, Eq, Display)]
pub enum DaoError {
InvalidHeader,
InvalidOutPoint,
InvalidDaoFormat,
Overflow,
ZeroC,
}
impl From<DaoError> for Error {
fn from(error: DaoError) -> Self {
... |
use {Document, Error, Revision};
use action::query_keys::*;
use document::WriteDocumentResponse;
use transport::{JsonResponse, JsonResponseDecoder, Request, StatusCode, Transport};
pub struct UpdateDocument<'a, T>
where
T: Transport + 'a,
{
transport: &'a T,
doc: &'a Document,
}
impl<'a, T> UpdateDocument... |
fn main() {
let _number = 12;
print!("{}", _number);
}
|
use azure_core::headers::CommonStorageResponseHeaders;
use azure_core::prelude::*;
use azure_storage::xml::read_xml;
use bytes::Bytes;
use http::response::Response;
use std::convert::TryInto;
#[derive(Debug, Clone)]
pub struct ListQueuesResponse {
pub common_storage_response_headers: CommonStorageResponseHeaders,
... |
//!
use crate::{dev::*, interfaces::Conn, types::MTU};
use std::sync::{Arc, Mutex};
// ///
// pub const OFFSET_BYTES: usize = 4;
// ///
// pub const HEADER_LENGTH: usize = 40;
/// Represents a running TUN interface.
///
/// ## What is TUN, what is Wireguard, and why do we use them?
///
/// flow:
/// ? (why) init... |
#[doc = "Register `VCTR33` reader"]
pub type R = crate::R<VCTR33_SPEC>;
#[doc = "Register `VCTR33` writer"]
pub type W = crate::W<VCTR33_SPEC>;
#[doc = "Field `B1056` reader - B1056"]
pub type B1056_R = crate::BitReader;
#[doc = "Field `B1056` writer - B1056"]
pub type B1056_W<'a, REG, const O: u8> = crate::BitWriter<'... |
#[doc = "Register `SECWM1R_PRG` reader"]
pub type R = crate::R<SECWM1R_PRG_SPEC>;
#[doc = "Register `SECWM1R_PRG` writer"]
pub type W = crate::W<SECWM1R_PRG_SPEC>;
#[doc = "Field `SECWM1_STRT` reader - Bank1 security WM area 1 start sector"]
pub type SECWM1_STRT_R = crate::FieldReader;
#[doc = "Field `SECWM1_STRT` writ... |
//! This is a classy "Forward" rendering pipeline.
//! It supports all materials except for `Inverse` blending.
//! It renders everything with a single pass, ordering opaque objects
//! first front-to-back, and then blended ones back-to-front on top.
//! TODO: apply actual lights in the shader. Currently hard-coded.
u... |
//! An API for auto-generating and obtaining copies of metadata cache
use crate::repository::{Ebuild, Repository};
use ::crypto::{digest::Digest, md5::Md5};
use ::directories::ProjectDirs;
use ::lru::LruCache;
use ::std::{
borrow::ToOwned,
fmt,
fs::{self, File},
io::{ErrorKind, Read},
os::unix::proc... |
/// A JSON Patch "move" operation.
///
/// Removes the value at a specified location and adds it to the target location.
///
/// [More Info](https://tools.ietf.org/html/rfc6902#section-4.4)
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct OpMove {
/// A string containing a JSON-Pointer value that... |
extern crate image;
extern crate rand;
extern crate rayon;
use std::env;
use std::path::Path;
use std::fs::File;
use std::io::Write;
use image::{Pixel, ImageBuffer, Rgba};
use rand::Rng;
use rayon::prelude::*;
const NUM_TRIANGLES: usize = 10;
const TRANSPARENCY: u8 = 230;
const N_ITERS: usize = 10_000;
const DOWNSC... |
use crate::*;
use std::sync::Arc;
use std::{fs::File, io, io::prelude::*, path::PathBuf};
use tracing;
pub struct PingResultProcessorCsvLogger {
common_config: Arc<PingResultProcessorCommonConfig>,
log_path: PathBuf,
log_file: File,
}
impl PingResultProcessorCsvLogger {
#[tracing::instrument(name = "C... |
#![allow(dead_code)]
//! A radio button widget with any widget as children
use std::marker::PhantomData;
use druid::theme;
use druid::widget::{Align, Flex, WidgetExt};
use druid::{
kurbo::{Point, Rect, Size},
LifeCycle, LifeCycleCtx,
};
use druid::{
BoxConstraints, Data, Env, Event, EventCtx, LayoutCtx, ... |
//! The Group Policy Object Editor stores registry-based configuration settings in two Registry.pol files, stored in folders
//! under the `<drive>:\Windows\System32\GroupPolicy\` folder. One file contains computer settings and the other file contains
//! user settings. The Group Policy Object Editor saves the settings... |
#[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... |
mod routing;
pub(crate) use self::routing::CoordIndex;
|
fn ulam(n: usize) -> usize {
let mut ulams = vec![1, 2];
let mut sieve = vec![1, 1];
let mut u = 2;
while ulams.len() < n {
sieve.resize(u + ulams[ulams.len() - 2], 0);
for i in 0..ulams.len() - 1 {
sieve[u + ulams[i] - 1] += 1;
}
for i in u..sieve.len() {
... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: support@datadoghq.com
* Generated by: https://openapi-generator.tech
*/
/// FormulaAndFunctionEventQueryGroupBy : List of objects used to group by.
#[derive(Clone, Debug, Pa... |
use std::future::Future;
pub fn spawn<F>(task: F)
where
F: Send + Future<Output = ()> + 'static,
{
cfg_if! {
if #[cfg(not(target_arch = "wasm32"))] {
tokio::spawn(task);
} else {
use wasm_bindgen_futures::spawn_local;
spawn_local(task);
}
}
}
|
fn main() {
tonic_build::configure()
.out_dir("src/protobuf")
.format(cfg!(debug_assertions)) // Release build environments might not have rustfmt installed
.compile(&["proto/codec.proto"], &["proto"])
.expect("Failed to compile StreamingFast Ethereum proto(s)");
}
|
use async_graphql::{Context, EmptyMutation, EmptySubscription, Object, Schema, SimpleObject};
use async_graphql_warp::graphql;
use std::convert::Infallible;
use warp::{Filter, Reply};
#[derive(SimpleObject)]
struct Product {
upc: String,
name: String,
price: i32,
}
struct Query;
#[Object(extends)]
impl Q... |
#[doc = "Reader of register CPSCTL"]
pub type R = crate::R<u32, super::CPSCTL>;
#[doc = "Writer for register CPSCTL"]
pub type W = crate::W<u32, super::CPSCTL>;
#[doc = "Register CPSCTL `reset()`'s with value 0"]
impl crate::ResetValue for super::CPSCTL {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
use x86_64::structures::idt::{ InterruptDescriptorTable, ExceptionStackFrame };
use x86_64::structures::tss::TaskStateSegment;
use x86_64::structures::gdt::{ GlobalDescriptorTable, Descriptor, SegmentSelector };
use x86_64::structures::idt::PageFaultErrorCode;
use x86_64::VirtAddr;
use lazy_static::lazy_static;
use spi... |
#![cfg(test)]
extern crate rand;
use self::rand::Rng;
use self::rand::distributions::uniform::SampleUniform;
use ::*;
use std::ops::Neg;
const NUM_TESTS: u16 = 10000;
const RANGE: isize = 500;
const RANGE_FLOAT: f32 = 500.0;
pub fn reverse_slice<T: Clone>(points: &[T]) -> Vec<T> {
points.iter().rev().cloned().... |
#[doc = "Register `ADC_CALFACT2` reader"]
pub type R = crate::R<ADC_CALFACT2_SPEC>;
#[doc = "Register `ADC_CALFACT2` writer"]
pub type W = crate::W<ADC_CALFACT2_SPEC>;
#[doc = "Field `LINCALFACT` reader - LINCALFACT"]
pub type LINCALFACT_R = crate::FieldReader<u32>;
#[doc = "Field `LINCALFACT` writer - LINCALFACT"]
pub... |
use futures::{StreamExt, TryStreamExt, executor::block_on};
use handlebars::Handlebars;
use std::path::PathBuf;
use std::error::Error;
use std::fs;
use std::collections::HashMap;
use serde::{
Serialize,
Deserialize
};
use serde_yaml;
use kube::{
api::{Api, WatchEvent, PostParams},
Client,
runtime::... |
use file;
pub fn run() {
let inputs = file::read_inputs("Day5.txt");
println!("Steps {}", solve(&"0\n3\n0\n1\n-3".to_string(), part1));
println!("Steps {}", solve(&"0\n3\n0\n1\n-3".to_string(), part2));
println!("Steps {}", solve(&inputs, part1));
println!("Steps {}", solve(&inputs, part2));
}
fn... |
use std::borrow::Borrow;
use std::env;
use std::ffi::{CStr, OsStr, OsString};
use std::fs::OpenOptions;
use std::os::unix::prelude::*;
use std::path::PathBuf;
use bstr::BString;
use clap::{App, Arg};
use regex::bytes::Regex;
use slog::*;
use slog_async::OverflowStrategy;
use dracut_install::{install_files_ldd, instal... |
#![deny(missing_docs)]
//! simplehttpserver is a re-implementation of Python's SimpleHTTPServer module in Rust. It's a
//! small utility that spawns a small HTTP server, serving static files from the current directory,
//! and is useful for serving HTML pages in a server context.
//!
//! By default, simplehttpserver r... |
pub(crate) mod factory;
|
use std::io::{stdin, print, println};
use std::io::stdio::flush;
use std::io::BufferedReader;
fn print_spaces(num:int) {
for _ in range(0, num) {
print(" ");
}
}
pub fn triangle_print(board:&[bool]) {
for line in range(0, 5) {
let prefix_spaces = (4 - line) * 4;
let start = (line * (line + 1)) / 2;
... |
use crate::ast::Connective;
use crate::parse;
use std::collections::{HashMap, HashSet, VecDeque};
#[derive(Debug, Clone)]
struct Node {
connectives: Vec<(FactId, Connective, bool)>,
closed: bool,
}
#[derive(Debug, Clone)]
struct Edge {
origin_node: NodeId,
fact: FactId,
to: NodeId,
}
#[derive(Deb... |
use embedded_time::TimeError;
use crate::network::Error as NetworkError;
use crate::services::data::Error as DataServiceError;
use core::cell::{BorrowError, BorrowMutError};
#[derive(Debug, PartialEq)]
pub enum GenericError {
BorrowError,
BorrowMutError,
Timeout,
Time(TimeError),
Unsupported,
}
i... |
#[doc = "Register `AHB3LPENR` reader"]
pub type R = crate::R<AHB3LPENR_SPEC>;
#[doc = "Register `AHB3LPENR` writer"]
pub type W = crate::W<AHB3LPENR_SPEC>;
#[doc = "Field `MDMALPEN` reader - MDMA Clock Enable During CSleep Mode"]
pub type MDMALPEN_R = crate::BitReader<MDMALPEN_A>;
#[doc = "MDMA Clock Enable During CSle... |
use itertools::Itertools;
#[derive(Debug)]
struct Item {
cost: u32,
damage: u32,
armour: u32,
}
#[derive(Debug)]
struct Player {
hp: i32,
damage: u32,
armour: u32,
}
impl Item {
fn weapon(cost: u32, damage: u32) -> Self {
Item {
cost,
damage,
ar... |
#![feature(alloc)]
#![feature(heap_api)]
#![feature(core_intrinsics)]
#![feature(shared)]
#![feature(get_type_id)]
extern crate alloc;
#[macro_use]
extern crate impl_any;
pub mod gc;
pub mod lang;
|
//! # PostgreSQL Driver
mod models;
mod schema;
use crate::core::{Csrf, Key, Service, User};
use crate::driver;
use crate::driver::Error;
use chrono::{DateTime, Utc};
use diesel::prelude::*;
use diesel::r2d2::ConnectionManager;
embed_migrations!("migrations/postgres");
#[derive(Clone)]
pub struct Driver {
pool: ... |
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Status {
Met,
NotMet,
Unknown,
}
#[derive(Debug, Clone, Copy)]
pub enum Field {
Age,
County,
ChildrenCount,
Income,
SingleParent,
}
#[derive(Debug)]
pub enum Type {
Boolean(bool),
IntRange(u32, u32),
IntEquals(u32),
... |
extern crate exitfailure;
extern crate l_compilator;
fn main() -> Result<(), exitfailure::ExitFailure> {
Ok(l_compilator::App::run()?)
}
|
use std::io;
use std::io::prelude::*;
use std::cmp;
fn main() {
let stdin = io::stdin();
let mut minmax_sum = 0; // part 1
let mut divides_sum = 0; // part 2
for line in stdin.lock().lines() {
// parse stuff
let line = line.unwrap();
let splitv : Vec<u32> = line.trim()
... |
use std::any::Any;
use std::cell::Cell;
use std::cell::RefCell;
use std::collections::HashMap;
use std::fmt;
use std::marker::PhantomData;
use std::mem;
use std::ops::Deref;
use std::ptr;
use std::rc::Rc;
use num_bigint::BigInt;
use num_complex::Complex64;
use num_traits::{One, Zero};
use crate::bytecode;
use crate::... |
extern crate rand;
use std::io;
use std::cmp::Ordering;
use rand::Rng;
#[derive(Debug)]
struct Person {
name: String,
email: String,
age: u32,
address: String,
}
impl Person {
fn add_age(&mut self) {
self.age += 30;
}
fn older(&self, other: &Person) -> bool {
self.age > ... |
pub use dencode;
#[cfg(feature = "json")]
pub mod json;
pub mod sbp;
|
use super::types::{ModuleLoader, ModuleResolver};
use super::types::{KEY, MODULE_ID_KEY};
// use duktape::{error::ErrorKind, error::Result, Callable, Context};
use super::internal;
use duktape::prelude::*;
use duktape::Key;
use duktape::{error::ErrorKind, error::Result};
use regex::Regex;
use std::path::Path;
pub stru... |
/*
* A sample API conforming to the draft standard OGC API - Features - Part 1: Core
*
* This is a sample OpenAPI definition that conforms to the conformance classes \"Core\", \"GeoJSON\", \"HTML\" and \"OpenAPI 3.0\" of the draft standard \"OGC API - Features - Part 1: Core\". This example is a generic OGC API Fea... |
use chrono;
pub type DateTime = chrono::DateTime<chrono::Utc>;
pub mod other;
pub mod private;
pub mod public;
pub mod reqs;
pub mod wsfeed;
|
#[doc = "Register `DFSDM2_CR1` reader"]
pub type R = crate::R<DFSDM2_CR1_SPEC>;
#[doc = "Register `DFSDM2_CR1` writer"]
pub type W = crate::W<DFSDM2_CR1_SPEC>;
#[doc = "Field `DFEN` reader - DFSDM enable"]
pub type DFEN_R = crate::BitReader;
#[doc = "Field `DFEN` writer - DFSDM enable"]
pub type DFEN_W<'a, REG, const O... |
//! Various model repository for easily interacting with the database.
use super::model::Gossip;
use super::model::Gossiper;
use super::model::NewGossip;
use super::model::NewGossiper;
use super::DatabaseWrapper;
use diesel::prelude::*;
pub struct GossipRepository;
impl GossipRepository {
/// Save a new gossip.... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use super::{models, API_VERSION};
#[non_exhaustive]
#[derive(Debug, thiserror :: Error)]
#[allow(non_camel_case_types)]
pub enum Error {
#[error(transparent)]
HealthApi_GetServiceStatus(#[from] he... |
use Configuration;
const RGBA_PIXELS_BYTE_COUNT: usize = 4;
const RGBA_FULL_OPAQUE: u8 = 255;
fn initialize_vector(width: u32, height: u32) -> Vec<u8> {
let max_capacity: usize = RGBA_PIXELS_BYTE_COUNT * (width * height) as usize;
let mut v: Vec<u8> = Vec::with_capacity(max_capacity);
v.resize(max_capaci... |
use std::fs::File;
use std::io::prelude::*;
use std::collections::HashMap;
use image::{ImageBuffer, Rgba};
use rusttype::{point, Font, Scale};
//FIXME: It's a bad way to get all glyphs
static GLYPH_DATA: &'static str = "qwertyuiop[]asdfghjkl;'zxcvbnm,./1234567890-=+`";
pub struct FontEngine{
pub glyph_list: HashM... |
use std::collections::HashMap;
use exonum::blockchain::Transaction;
use exonum::crypto;
use exonum::crypto::{PublicKey, Signature};
use exonum::messages::Message;
use exonum::storage::Fork;
use prometheus::{Histogram, IntCounter};
use currency::assets::AssetBundle;
use currency::error::Error;
use currency::service::C... |
use crate::errors::ApiError;
use crate::models::duels::Duel;
use crate::models::games::{Game, GameResult, NewGame};
use crate::models::matches::Match;
use crate::rating::*;
use crate::schema::duels::dsl::duels as table_duels;
use crate::schema::games::dsl::{
duel_id as col_duel_id, games as table_games, match_id as... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.