text stringlengths 8 4.13M |
|---|
use crate::data::RideData;
use crate::data::RideWindowedData;
fn agg_u64(buffer: &[RideData], f: impl FnMut(&RideData) -> u64 + Copy) -> (u64, u64, u64, u64) {
let count = buffer.len() as u64;
let sum = buffer.iter().map(f).sum();
let max = buffer.iter().map(f).max().unwrap();
let min = buffer.iter().m... |
use prelude::*;
mod utills;
mod give;
mod info;
mod start;
pub fn register_command(sf: StandardFramework) -> StandardFramework {
sf.group("bp", |mut g| {
chain!(g;
give::register_command(g),
info::register_command(g),
start::register_command(g)
).prefix("bp")
})
}
|
use crate::domain::{BlockHeight, BlockTimestamp, EpochHeight};
use near_sdk::{
borsh::{self, BorshDeserialize, BorshSerialize},
env,
};
use std::cmp::Ordering;
#[derive(BorshSerialize, BorshDeserialize, Debug, Clone, Copy, PartialEq, Default)]
pub struct BlockTimeHeight {
block_height: BlockHeight,
blo... |
//! The Unix `fcntl` function is effectively lots of different functions
//! hidden behind a single dynamic dispatch interface. In order to provide
//! a type-safe API, rustix makes them all separate functions so that they
//! can have dedicated static type signatures.
#[cfg(not(any(
target_os = "emscripten",
... |
use super::*;
use proptest::prop_oneof;
use proptest::strategy::Strategy;
#[test]
fn without_non_empty_list_or_bitstring_returns_true() {
run!(
|arc_process| {
strategy::term(arc_process.clone())
.prop_filter("Right cannot be a list or bitstring", |right| {
... |
use proconio::input;
use std::collections::BTreeSet;
fn main() {
input! {
q: usize,
};
let mut set = BTreeSet::new();
for i in 0..q {
input! {
op: u8,
};
if op == 1 {
input! {
x: u32,
};
set.insert((x, i));
... |
// Copyright 2022 Datafuse Labs.
//
// 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 super::{CodecError, CodecResult};
use crate::client::schema::{Dictionary, Event, List, Services, Set, Status, Stream, Tuple};
use crate::client::Connection;
use protobuf::{CodedInputStream, Message};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::hash::Hash;
pub trait Decode<'a>
where
... |
// Copyright © 2016-2017 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#![cfg_attr(feature="cargo-clippy", allow(let_and_return))]
use rabble::Pid;
use haret::vr::{ClientOp, VrState, VrCtx};
use super::arbitrary::{Op, ClientRequest};
/// This is a model of the state of a VR replica set und... |
use std::ops::{Add, Div, Mul, Sub};
#[derive(Copy, Clone, Debug, Default)]
pub struct Vec3 {
pub e: [f32; 3],
}
impl Vec3 {}
impl Vec3 {
pub fn new() -> Vec3 {
Vec3 { e: [0.0, 0.0, 0.0] }
}
// translation component accessors
pub fn x(&self) -> f32 {
self.e[0]
}
pub fn y(&... |
use actix_http::{Method, Request};
use actix_web::{
dev::{self, Service, ServiceResponse},
test, Error,
};
use lazy_static::lazy_static;
use mockito::{Matcher, mock};
use reqwest::{Client, StatusCode};
use reqwest_middleware::ClientBuilder;
use reqwest_tracing::TracingMiddleware;
use crate::{api::PokemonInfo, ... |
/*
Some command line options go to cargo test, and some go to the resulting test
binary. To separate these two types of arguments, you list the arguments that go
to cargo test followed by the separator -- and then the ones that go to the test
binary. Running cargo test --help displays the options you can use with ca... |
use ring::test::{compile_time_assert_send, compile_time_assert_sync};
use webpki::DnsNameRef;
#[test]
fn test_dns_name_ref_traits() {
compile_time_assert_send::<DnsNameRef>();
compile_time_assert_sync::<DnsNameRef>();
let a = DnsNameRef::try_from_ascii(b"example.com").unwrap();
// `Copy`
{
... |
pub mod attribute;
pub mod channel_list;
pub mod cppstd;
pub mod envmap;
pub mod error;
pub mod frame_buffer;
pub mod frames_per_second;
pub mod header;
pub mod input_file;
pub mod input_part;
pub mod keycode;
pub mod multi_view;
pub mod output_file;
pub mod output_part;
pub mod preview_image;
pub mod rational;
pub use... |
use std::char;
use std::io::Read;
use crate::counters::{CodelChooser, DirectionPointer};
#[derive(Debug)]
pub enum Command {
Push,
Pop,
Add,
Subtract,
Multiply,
Divide,
Mod,
Not,
Greater,
Pointer,
Switch,
Duplicate,
Roll,
InNumber,
InChar,
OutNumber,
... |
use std::mem;
fn analyze_slice(slice: &[i32]) {
println!("first element of slice is {}", slice[0]);
println!("length of slice is {}", slice.len());
}
fn update_slice(slice: &mut [i32]) {
for e in slice {
*e += 3;
}
}
fn main() {
let mut xs: [i32; 7] = [1, 2, 3, 4, 5, 6, 7];
let ys: [i... |
pub trait VectorProperties {
fn length(&self) -> f64;
// TODO: Look at overloading so we have instance and static methods
fn add(vec1: &Self, vec2: &Self) -> Self;
fn sub(vec1: &Self, vec2: &Self) -> Self;
fn mul(vec1: &Self, vec2: &Self) -> Self;
fn lerp(vec1: &Self, vec2: &Self, t: f64) -> S... |
use clap::{crate_description, crate_name, App, Arg};
use console::style;
use solana_archiver_lib::archiver::Archiver;
use solana_clap_utils::{
input_parsers::keypair_of, input_validators::is_keypair_or_ask_keyword,
keypair::SKIP_SEED_PHRASE_VALIDATION_ARG,
};
use solana_core::{
cluster_info::{Node, VALIDATO... |
#[doc = "Reader of register C10ISR"]
pub type R = crate::R<u32, super::C10ISR>;
#[doc = "Reader of field `TEIF10`"]
pub type TEIF10_R = crate::R<bool, bool>;
#[doc = "Reader of field `CTCIF10`"]
pub type CTCIF10_R = crate::R<bool, bool>;
#[doc = "Reader of field `BRTIF10`"]
pub type BRTIF10_R = crate::R<bool, bool>;
#[... |
use std::io::{Read, Result as IOResult};
use crate::lump_data::{LumpData, LumpType};
use crate::PrimitiveRead;
#[derive(Copy, Clone, Debug, Default)]
pub struct Brush {
pub first_side: i32,
pub sides_count: i32,
pub contents: BrushContents
}
bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Defaul... |
// Copyright 2022 Datafuse Labs.
//
// 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 ... |
#![no_std]
/*!
# **Humansize**
## Features
Humansize is a humanization library for information size that is:
- Simple & convenient to use
- Customizable
- Supports byte or bit sizes
- `no-std`
- Optionally non-allocating
- Optionally accepts signed values
## How to use it...
Add humansize as a dependency to your pro... |
use core::fmt;
use core::marker::PhantomData;
use {Poll, Future, Stream, Sink, StartSend};
mod atomic_task;
pub use self::atomic_task::AtomicTask;
mod core;
#[cfg(feature = "use_std")]
mod std;
#[cfg(feature = "use_std")]
pub use self::std::*;
#[cfg(not(feature = "use_std"))]
pub use self::core::*;
pub struct Borr... |
use core::{sync::atomic::AtomicBool, usize};
use x86_64::instructions::port::{Port, PortReadOnly, PortWriteOnly};
use crate::svec::SVec;
// Assuming "typical" ports
const IO_BASE_PORT: u16 = 0x1F0;
/// 0x1F0
static mut DATA_REG: Port<u16> = Port::new(IO_BASE_PORT);
/// 0x1F1
static mut ERROR_REG: PortReadOnly<u16> =... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor 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 ... |
pub mod game;
pub mod simulation;
pub mod ui;
pub mod utils;
use ggez::{ContextBuilder, event};
use game::GameState;
use ui::{ui_manager::UIManager, ui_element::UIElement};
use utils::vector2::Vector2F;
const G: f32 = 2.0;
const TIME_STEP: f32 = 0.5;
const WIN_WIDTH: f32 = 1280.0;
const WIN_HEIGHT: f32 = 848.0;
fn ... |
#[allow(unused)]
fn color(red: f64, green: f64, blue: f64, alpha: f64) -> String {
fn quantize(f: f64) -> i64 {
(f.max(0.0).min(1.0) * 255.0) as i64
}
format!(
"#{:02X}{:02X}{:02X}{:02X}",
quantize(1.0 - alpha),
quantize(red),
quantize(green),
quantize(blue)
)
}
#[cfg(test)]
mod tests ... |
// auto generated, do not modify.
// created: Wed Jan 20 00:44:03 2016
// src-file: /QtNetwork/qnetworkproxy.h
// dst-file: /src/network/qnetworkproxy.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main bloc... |
use crate::ir::eval::prelude::*;
impl IrEval for ir::IrDecl {
type Output = IrValue;
fn eval(
&self,
interp: &mut IrInterpreter<'_>,
used: Used,
) -> Result<Self::Output, IrEvalOutcome> {
interp.budget.take(self)?;
let value = self.value.eval(interp, used)?;
... |
#[path = "with_function/with_arity_zero.rs"]
pub mod with_arity_zero;
test_stdout!(
without_arity_zero_returns_pid_to_parent_and_child_process_exits_badarity,
"badarity\n"
);
|
pub mod helpers;
|
use std::error::Error;
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::str::FromStr;
use serde::de::{self, Deserialize, Deserializer, Visitor};
use serde::ser::{Serialize, Serializer};
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ParseError {
InvalidFormat,
MissingOs,
UnknownArch(Unkn... |
#[doc = "Reader of register RIS"]
pub type R = crate::R<u32, super::RIS>;
#[doc = "Reader of field `WDTRIS`"]
pub type WDTRIS_R = crate::R<bool, bool>;
impl R {
#[doc = "Bit 0 - Watchdog Raw Interrupt Status"]
#[inline(always)]
pub fn wdtris(&self) -> WDTRIS_R {
WDTRIS_R::new((self.bits & 0x01) != 0... |
use crate::{
core::{
cppstd::CppString,
error::Error,
frame_buffer::FrameBufferRef,
header::{Header, HeaderRef},
preview_image::PreviewRgba,
Compression, LevelMode, LevelRoundingMode, LineOrder,
},
rgba::rgba::{Rgba, RgbaChannels},
};
use imath_traits::{Bound... |
use std::sync::mpsc::Sender;
use std::sync::Arc;
use crate::state::AppState;
use maltebl_chess::{chess_game::ChessGame, piece_logic::Color};
use druid::*;
pub mod action {
use druid::Selector;
pub const MAKE_MOVE: Selector<String> = Selector::new("make_move");
pub const MAKE_MOVE_FROM_NET: Selector<Str... |
// Copyright 2022 Datafuse Labs.
//
// 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 ... |
#[macro_use]
extern crate getset;
#[derive(CopyGetters, Default, Getters, MutGetters, Setters)]
struct RawIdentifiers {
#[get]
r#type: usize,
#[get_copy]
r#move: usize,
#[get_mut]
r#union: usize,
#[set]
r#enum: usize,
#[get = "with_prefix"]
r#const: usize,
#[get_copy = "with... |
use actix_web::{App,fs, http::{header, Method},middleware::{self,cors::Cors}};
use model::db::init;
use share::state::AppState;
use api::{home::{index,path},auth::{signup, signin}};
use api::article::{article,article_list, article_new};
use api::user::{user_info, user_delete, user_update};
pub fn app_state() -> App<... |
use alloc::alloc::{AllocError, Allocator, Layout};
use core::any::TypeId;
use core::convert::AsRef;
use core::fmt::{self, Debug};
use core::hash::{Hash, Hasher};
use core::ops::Range;
use core::ptr::{self, NonNull};
use anyhow::anyhow;
use super::{OpaqueTerm, Term, TupleIndex};
#[repr(C)]
pub struct Tuple([OpaqueTer... |
use advent::helpers;
use anyhow::{Context, Result};
use itertools::Itertools;
type Adapters = Vec<i64>;
fn parse_jolt_adapters(i: &str) -> Adapters {
helpers::lines_to_longs(i.trim())
}
fn prepare_jolt_adapters(adapters: Adapters) -> Adapters {
// Prepend 0 and append max_jolt + 3.
let final_device = *ad... |
pub use diesel::prelude::*;
table! {
admins (id) {
id -> Integer,
user_id -> Integer,
}
}
table! {
hashes (sha256) {
sha256 -> Char,
md5 -> Char,
}
}
table! {
player_stats (id) {
id -> Integer,
user_id -> Integer,
date -> Datetime,
p... |
pub mod decoder;
mod encoder;
use std::{
fs::File,
path::{Path, PathBuf},
thread::spawn,
};
use decoder::read_file;
use encoder::Encoder;
use explorer::Explorer;
mod explorer;
fn main() {
let (explorer, receiver) = Explorer::new();
let (mut encoder, encoder_reciver) = Encoder::new(receiver);
... |
/*
* Copyright 2020 Draphar
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writi... |
use std::vec::*;
use graphics::*;
use math::*;
use na::{Vector3};
pub trait RendererVertFrag{
fn render_mode (&self) -> usize;
fn shader_name (&self) -> String;
fn set_attrib_ptrs (&mut self);
fn construct (&mut self) -> bool;
fn deconstruct (&mut self) -> bool;
fn... |
/*
* hurl (https://hurl.dev)
* Copyright (C) 2020 Orange
*
* 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 ... |
pub mod note;
pub mod octave;
pub mod repeat;
pub mod tempo;
pub mod tone;
pub mod volume;
use crate::tokenize::{Token, TokenKind};
use std::fmt;
use tone::Effect;
#[macro_export]
macro_rules! try_or_ok_none {
($option:expr) => {
if let Ok(ok) = $option {
ok
} else {
return... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor 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 ... |
pub mod post;
pub mod schema;
pub use post::{NewPost, Post};
|
mod utils;
use self::utils::body_generators;
use ggez::{graphics, Context, GameResult};
use rand::Rng;
pub(crate) const GRID_SIZE: (i16, i16) = (10, 20);
pub(crate) const GRID_CELL_SIZE: (i16, i16) = (26, 26);
type ColorTuple = (u8, u8, u8, u8);
/// Trait implementation for turning a Segment into graphics Rectangl... |
extern crate chrono;
use self::chrono::prelude::{DateTime, Utc};
use direction::Direction;
use signal::Signal;
use signal::detector::{DetectSignal, DetectSignalError};
use symbol::SymbolId;
pub struct Always {
symbol_id: SymbolId,
direction: Direction
}
impl Always {
pub fn new(symbol_id: SymbolId, direct... |
use std::iter::Iterator;
use crate::util::CrdtCollection;
#[derive(Clone)]
pub struct SmallVectorImpl<V> {
next_local_id: u32,
local_author: u16,
spans: im::Vector<Span>,
document: V,
}
impl<V: CrdtCollection> SmallVectorImpl<V> {
pub fn new(local_author: u16) -> Self {
Self::with_data(V::... |
use crate::buf::{Buf, Channels, ChannelsMut, ExactSizeBuf};
use crate::channel::{Channel, ChannelMut};
use crate::io::ReadBuf;
/// The tail of a buffer.
///
/// See [Buf::tail].
pub struct Tail<B> {
buf: B,
n: usize,
}
impl<B> Tail<B> {
/// Construct a new buffer tail.
pub(crate) fn new(buf: B, n: usi... |
use std::collections::HashMap;
fn has_ajacent_equal_characters(string: &String) -> bool {
let digits: Vec<_> = string.chars().map(|n| n.to_digit(10).unwrap()).collect();
// Check never decreases
for i in 1..digits.len() {
if &digits[i] < &digits[i-1] { return false; }
}
// Check... |
use super::*;
use crate::{TableIndex, TypeReader};
#[derive(Copy, Clone)]
pub struct Param {
pub reader: &'static TypeReader,
pub row: Row,
}
impl Param {
pub fn flags(&self) -> ParamFlags {
ParamFlags(self.reader.u32(self.row, 0))
}
pub fn sequence(&self) -> u32 {
self.reader.u32... |
use std::fs;
fn read_file(filename: &str) -> Vec<Vec<u8>> {
let mut file_string = fs::read_to_string(filename).expect("I could not read this file");
let mut matrix = Vec::new();
for line in file_string.lines() {
let mut row: Vec<u8> = Vec::new();
for ch in line.chars() {
row.pu... |
extern crate ctrlc;
extern crate tuxdroid;
use crate::tuxdroid::tuxdroid::TuxDroid;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::thread;
use std::time::Duration;
fn main() -> () {
let fux = tuxdroid::fux::Fux::new().expect("Failed to create Fux");
fux.get_status().unwrap();
... |
// Copyright 2014 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 ... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct AUDIO_ENDPOINT_SHARED_CREATE_PARAMS {
pub u32Size: u32,
pub u32TSSessionId: u32,
pub targetEn... |
use std::ops::BitXor;
#[allow(dead_code)]
fn single_number(nums: Vec<i32>) -> i32 {
nums.into_iter().fold(0, i32::bitxor)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_single_number() {
assert_eq!(single_number(vec![2, 2, 1]), 1);
assert_eq!(single_number(vec![4, 1, 2, 1, 2... |
mod graph;
mod hashfunc;
use graph::Edges;
use graph::LabelMatrix;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use std::thread;
use std::sync::mpsc::channel;
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Node {
value: String,
index: (usize, usize),
}
impl Node {
pub fn new(v: Stri... |
mod parse;
use std::env;
use std::error::Error;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use serde::Serialize;
use std::fs::File;
use std::io::Write;
use url::Url;
use walkdir::{DirEntry, WalkDir};
#[derive(Debug, Serialize, Eq, PartialEq)]
enum Record {
Login(Login),
CreditCard(Cr... |
use quote;
use syn::Ident;
use crate::attr::Config;
pub fn open_directory_module(config: &Config, tokens: &mut quote::Tokens) -> String {
// get the leaf directory name
let dirname = config.directory.rsplit('/').next().unwrap();
// create identifier
let dirname = sanitize_ident(dirname);
let dirn... |
//! Future-aware single-threaded synchronization
//!
//! This module contains similar abstractions to `sync`, for communications
//! between tasks on the same thread only.
pub mod mpsc;
pub mod oneshot;
|
mod parser;
fn main() {
println!("Hello, world!");
use std::f64::consts::*;
println!("acos(2)={}",(PI/3.0).cos());
}
|
pub use VkAttachmentStoreOp::*;
#[repr(u32)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum VkAttachmentStoreOp {
VK_ATTACHMENT_STORE_OP_STORE = 0,
VK_ATTACHMENT_STORE_OP_DONT_CARE = 1,
}
|
use derivative::Derivative;
use js_sys as js;
use std::cell::{Cell, RefCell};
use std::rc::Rc;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen::UnwrapThrowExt;
use web_sys as web;
pub type Send<Message> = Rc<dyn Fn(Message)>;
pub trait Subscription {
type Message;
fn subscribe(self, ... |
use crate::entities::Item;
use crate::game_event::GameEventType;
use crate::room::Room;
use crate::EventQueue;
use crate::{Action, ActionHandled, State};
// Second room room, locked per default, lever needs to be pulled.
#[derive(Debug)]
pub struct SlushLobbyRoom {
pub visited: bool,
}
impl SlushLobbyRoom {
p... |
#![allow(dead_code, non_camel_case_types)]
use crate::base::logic::bit::{I, O};
use core::panic;
use std::{
fmt::{self, Formatter},
ops::Index,
write,
};
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum bit {
O,
I,
}
impl fmt::Display for bit {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Res... |
mod title;
mod level;
use core::mem::ManuallyDrop;
use crate::framebuffer::Framebuffer;
use crate::controller::Buttons;
pub struct GameState {
pub buttons: Buttons,
pub id: GameStateId,
pub data: GameStateData
}
pub enum GameStateId {
Init,
Title,
Level
}
pub union GameStateData {
init: ... |
#[cfg(test)]
mod tests {
use cdl::{Data_new, Data_free};
#[test]
fn test_struct() {
let s = unsafe { Box::from_raw(Data_new()) };
Data_free(Box::into_raw(s));
}
} |
use ash::{
self,
version::{DeviceV1_0, FunctionPointers},
vk,
};
use device::{CommandBuffer, CommandQueue, Device};
use fence;
impl From<fence::FenceCreateFlags> for vk::FenceCreateFlags {
fn from(flags: fence::FenceCreateFlags) -> Self {
Self::from_flags(flags.bits()).expect("Unsupported flag... |
// Copyright (c) 2013, 2014 Michael Woerister
//
// 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, modify, merge... |
use std::io;
// C to F: F = C*(9/5) + 32
// F to C: C = (F-32)*(5/9)
/**********Converts between Fahrenheit and Celsius*********/
fn main() -> () {
println!("Do you want to convert to Celsius or Fahrenheit? Input C or F");
let mut convert_type = String::new();
io::stdin()
.read_line(&mut convert... |
use task::Task;
use worker;
use crossbeam_deque::Injector;
use futures::task::AtomicTask;
use futures::{Async, Future, Poll};
use std::sync::{Arc, Mutex};
/// Future that resolves when the thread pool is shutdown.
///
/// A `ThreadPool` is shutdown once all the worker have drained their queues and
/// shutdown their... |
#![recursion_limit = "128"]
use inflector::Inflector;
use quote::quote;
use syn::export::{Span, TokenStream2};
use syn::spanned::Spanned;
use syn::{Error, FnArg, Ident, ItemTrait, LitByteStr, LitStr, Pat, TraitItem};
pub fn process_trait(t: &ItemTrait, mod_name: Option<String>) -> syn::Result<TokenStream2> {
let m... |
#![allow(clippy::all)]
use std::collections::{HashMap, HashSet};
type Cave<'a> = &'a str;
type CaveMap<'a> = HashMap<Cave<'a>, Vec<Cave<'a>>>;
type SmallCaveSet<'a> = HashSet<Cave<'a>>;
pub fn part1(input: String) {
let (mut cave_map, mut small_caves) = parse_input(&input);
let mut all_paths = 0;
let mut... |
use proconio::input;
fn main() {
input! {
n: usize,
h: u32,
x: u32,
p: [u32; n],
};
for i in 0..n {
if h + p[i] >= x {
println!("{}", i + 1);
return;
}
}
unreachable!();
}
|
use std::{
io,
net::{ToSocketAddrs, TcpListener, TcpStream, SocketAddr},
thread,
sync::{mpsc, Arc, Mutex},
};
pub fn listen<A, F, H>(addr: A, factory: F) -> io::Result<()>
where
A: ToSocketAddrs,
F: FnMut() -> H,
F: Send + Sync + 'static,
H: Handler
{
Builder::new().bind(addr)?.b... |
#![allow(non_snake_case)]
use std::fmt;
use std::mem;
use std::slice;
use num;
use approx;
use channel::{PosFreeChannel, FreeChannelScalar, AngularChannel, AngularChannelScalar,
ChannelFormatCast, ChannelCast, ColorChannel};
use angle::{Deg, Angle, FromAngle, IntoAngle, Turns, Rad};
use angle;
use color:... |
//! A fantastically advanced mathematical librarie
/// Double a value
pub fn add_two(n: i64) -> i64 {
n + 2
}
#[test]
fn smoketest() {
assert_eq!(add_two(2), 4);
}
|
#[cfg(all(not(target_arch = "wasm32"), test))]
mod test;
use liblumen_alloc::erts::exception;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::Term;
/// `*/2` infix operator
#[native_implemented::function(erlang:*/2)]
pub fn result(process: &Process, multiplier: Term, multiplicand:... |
use super::Span;
use std::num::ParseFloatError;
use unit::Unit;
#[derive(Debug, Clone)]
pub struct Expression {
pub span: Span,
pub expression: ExpressionEnum,
}
impl PartialEq for Expression {
fn eq(&self, other: &Expression) -> bool {
self.expression == other.expression
}
}
#[derive(Debug, ... |
use actix_web::Json;
use actix_web::State;
use actix_web::{http::StatusCode, HttpResponse};
use auth::user::User;
use bigneon_db::models::*;
use bigneon_db::utils::errors::Optional;
use db::Connection;
use errors::BigNeonError;
use helpers::application;
use itertools::Itertools;
use payments::PaymentProcessor;
use serv... |
use cql_bindgen::CassLogMessage;
#[repr(C)]
pub enum CassLogLevel {
DISABLED = 0,
CRITICAL = 1,
ERROR = 2,
WARN = 3,
INFO = 4,
DEBUG = 5,
TRACE = 6,
LAST_ENTRY = 7,
}
pub type CassLogCallback =
::std::option::Option<extern "C" fn (
message: *const CassLogMessage,
da... |
// spell-checker:ignore compresslevel
pub(crate) use _bz2::make_module;
#[pymodule]
mod _bz2 {
use crate::common::lock::PyMutex;
use crate::vm::{
builtins::{PyBytesRef, PyTypeRef},
function::{ArgBytesLike, OptionalArg},
object::{PyPayload, PyResult},
types::Constructor,
... |
//==============================================================================
// Notes
//==============================================================================
// mcu::mod.rs
//==============================================================================
// Crates and Mods
//========================... |
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::SICR {
#[doc = r"Writes to the register"]
#[inline(always)]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{
self.register.set(
f(&mut W {
bits: Self::r... |
use byteorder::ReadBytesExt;
use core::mem;
use num_derive::FromPrimitive;
use std::io::{Cursor, Write};
use wayk_proto::{
container::Vec16,
error::*,
message::connection_sequence::InputActionCode,
serialization::{Decode, Encode},
};
#[derive(Encode, Decode, FromPrimitive, Debug, PartialEq, Clone, Copy... |
use crate::{Config, RequireIdentityForPorts, SkipByPort};
pub use futures::prelude::*;
use linkerd_app_core::{
config,
dns::Suffix,
drain, exp_backoff, metrics,
proxy::{
http::{h1, h2},
tap,
},
transport::{BindTcp, Keepalive, ListenAddr},
NameMatch, ProxyRuntime,
};
pub use l... |
use super::double::{double_escape_sequence, interpolated_character_sequence};
use crate::ast::Literal;
use crate::lexer::*;
use crate::parsers::comment::line_content;
use crate::parsers::program::{line_terminator, source_character, whitespace};
use crate::parsers::token::identifier::identifier_character;
// TODO: ensu... |
use std::fs::File;
use std::io::{BufRead, BufReader};
#[derive(Debug)]
struct Claim {
id: i32,
top: i32,
left: i32,
height: i32,
width: i32,
}
impl Claim {
fn parse(line: String) -> Claim {
let (offset, id) = find_value(&line, "#", Some(" "), 0);
let (offset, top) = find_value(... |
use num::ToPrimitive;
use num::Zero;
use num::{BigUint, Integer};
use projecteuler::factorial;
fn main() {
dbg!(solve(100));
dbg!(solve(10));
}
fn solve(n: usize) -> usize {
let mut sum = 0;
let mut prod: BigUint = factorial::factorial(n);
dbg!(&prod);
while prod > BigUint::zero() {
l... |
use rayon::prelude::*;
use std::io::prelude::*;
fn main() {
let start = std::time::Instant::now();
let mut output = std::path::PathBuf::from(reader::workspace_dir());
output.push("src/Windows");
let _ = std::fs::remove_dir_all(&output);
output.pop();
let reader = reader::TypeReader::get_mut();... |
extern crate libc;
use self::libc::{c_int, c_uint, uint16_t, uint8_t};
pub mod gpio;
pub mod spio;
#[link(name = "bcm2835")]
extern "C" {
fn bcm2835_init() -> c_int; // returns 1 if successful 0 if not
fn bcm2835_delay(delay_time: c_uint);
fn bcm2835_gpio_write(pin: uint8_t, value: uint8_t);
fn bcm2... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
pub struct CoreUserActivityManager {}
impl CoreUserActivityManager {
pub fn CreateUserActivitySessionInBackground<'a, Param0: ::windows::core::IntoParam<'a, super::UserActivity>>(activity... |
#![deny(
unused_import_braces,
unused_imports,
unused_comparisons,
unused_must_use,
unused_variables,
non_shorthand_field_patterns,
unreachable_code
)]
use bigint::{Address, H256, M256, U256};
use block::{Account, Transaction};
use evm::errors::{PreExecutionError, RequireError};
use evm::{
... |
use amethyst::{GameData, SimpleState, SimpleTrans, StateData, StateEvent, Trans};
use amethyst::core::ecs::{Entity, WorldExt};
use amethyst::input::{is_close_requested, is_key_down, is_mouse_button_down, VirtualKeyCode};
use amethyst::renderer::rendy::wsi::winit::MouseButton;
use amethyst::ui::UiCreator;
use crate::au... |
//! WASM ABI supported by the contracts module.
use oasis_contract_sdk_types::{message::Reply, ExecutionOk};
use oasis_runtime_sdk::{
context::Context,
types::{address::Address, token},
};
use super::{types, Error, Parameters};
pub mod gas;
pub mod oasis;
/// Trait for any WASM ABI to implement.
pub trait AB... |
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use bevy::prelude::*;
use rand::prelude::*;
use crate::populations::HerdSize;
#[readonly::make]
#[derive(Debug, Clone, Copy)]
pub struct DiseaseParameters {
/// Infection rate
infection_rate: f64,
/// Recovery rate
recovery_rate: f64,... |
use winapi::um::winuser::{WS_VISIBLE, WS_DISABLED, WS_BORDER, WS_CHILD, WS_CLIPCHILDREN, WS_EX_CONTROLPARENT};
use crate::win32::window_helper as wh;
use crate::win32::base_helper::check_hwnd;
use crate::NwgError;
use super::{ControlBase, ControlHandle};
const NOT_BOUND: &'static str = "Frame is not yet bound to a win... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.