text stringlengths 3.09k 13.9k |
|---|
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use channel;
use futures::{compat::Future01CompatExt, Future, FutureExt, SinkExt, TryFutureExt};
use logger::prelude::*;
use std::{
pin::Pin,
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
};
use tokio::{executor::Executor,... |
use num::Complex;
use rand::Rng;
use indicatif::{ProgressBar, ProgressStyle};
use crate::colour::ColourFunctionArgs;
fn in_mandelbrot_set(c: &Complex<f64>) -> bool {
(c.re > -1.2 && c.re <= -1.1 && c.im > -0.1 && c.im < 0.1)
|| (c.re > -1.1 && c.re <= -0.9 && c.im > -0.2 && c.im < 0.2)
|| (c.re > -0... |
use crate::simple::{AutocompleteType, SearchIndex, SearchType};
use std::clone::Clone;
use std::cmp::Ord;
use std::collections::{BTreeMap, BTreeSet};
// -----------------------------------------------------------------------------
//
/// The [builder pattern](https://doc.rust-lang.org/1.0.0/style/ownership/builders.ht... |
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, StdResult};
use cw2::set_contract_version;
use sg1::checked_fair_burn;
use sg_std::{Response, StargazeMsgWrapper};
use crate::ContractError;
use cw721::ContractInfoResponse;
us... |
// A simple UDP echo server using Tokio to multiplex reads and writes.
// This is an alternate implementation that uses separate "reader" and
// "writer" futures connected by an MPSC queue.
extern crate futures;
#[macro_use]
extern crate tokio_core;
use std::io;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use futur... |
use anyhow::{format_err, Error};
use futures::future::try_join_all;
use rusoto_core::Region;
use rusoto_route53::{
Change, ChangeBatch, ChangeResourceRecordSetsRequest, HostedZone, ListHostedZonesRequest,
ListResourceRecordSetsRequest, ResourceRecordSet, Route53, Route53Client,
};
use std::{fmt, net::Ipv4Addr};... |
/*******************************************************************************
*
* Copyright (c) 2020 Gnarwhal
*
* -----------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associa... |
#[cfg(feature = "malloc")]
use std::alloc::System;
#[cfg(feature = "malloc")]
#[cfg_attr(feature = "malloc", global_allocator)]
static A: System = System;
use gifski;
#[macro_use] extern crate clap;
#[macro_use] extern crate error_chain;
#[cfg(feature = "video")]
extern crate ffmpeg;
use natord;
use wild;
#[cfg(fe... |
use std::cmp::Ordering;
use tui::buffer::Buffer;
use tui::layout::{Constraint, Rect};
use tui::text::{Span, Spans};
use tui::widgets::{Block, Borders, Cell, Row, StatefulWidget, Table, TableState, Widget};
use crate::colorscheme::theme::Theme;
use crate::metric::command::CmdStat;
use crate::metric::Metric;
use crate:... |
//! Helper functions for evaluating an expression syntax tree.
//!
//! Most functions here panic instead of returning Result because at this point
//! any errors should have been caught earlier during initial parsing.
use crate::grammar::{Pair, Rule};
/// Evaluate an Expression. Panics if the expression tree is inval... |
extern crate log;
use actix_web::{web, App, HttpServer};
use stigadigi_backend::GameData;
mod api {
// use actix_web::dev::HttpResponseBuilder;
// use actix_web::http::StatusCode;
use actix_web::{get, post, put, web, HttpRequest, HttpResponse};
// use cloudevents_sdk_actix_web::HttpRequestExt;
... |
use std::{
collections::HashMap,
fmt::{self, Debug},
hash::Hash,
marker::PhantomData,
sync::{Arc, Mutex},
};
use crate::throttle::{Interval, Throttle, ThrottleBuilder};
#[cfg(feature = "retrying")]
use crate::retrying;
/// A [`Throttle`] pool to restrict the resource access speed for multiple res... |
//! # rustwtxt
//!
//! This is a library intended to make working with `twtxt` timelines
//! a bit easier.
use std::collections::BTreeMap;
use std::str::FromStr;
use failure::format_err;
use regex::Regex;
use ureq;
pub mod parse;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
pub type TweetMap... |
//! Utility functions for computing in-gamut regions for CIELuv color space.
use crate::{FloatComponent, LuvHue};
#[allow(unused)]
use num_traits::Float;
use num_traits::{Pow, ToPrimitive};
/// Boundary line in the u-v plane of the Luv color space.
struct BoundaryLine {
slope: f64,
intercept: f64,
}
impl Boun... |
// 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 ark_ff::{One, Zero};
use zkp_curve::Curve;
use zkp_r1cs::Index;
use crate::Vec;
// ~eq(x, rx)
pub fn eval_eq<G: Curve>(rx: &Vec<G::Fr>) -> Vec<G::Fr> {
let base: usize = 2;
let rlen = rx.len();
let pow_len = base.pow(rlen as u32);
let mut evals: Vec<G::Fr> = vec![G::Fr::one(); pow_len];
let m... |
use std::{
path::PathBuf,
process::{Child, Command, Stdio},
sync::Arc,
};
use crate::mode::{fuzzy_matches, FilterEntry};
pub mod git;
pub mod hg;
pub mod plastic;
pub type BackendResult<T> = std::result::Result<T, String>;
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum FileStatus {
Modifi... |
use image::{self, GenericImage, ImageBuffer};
use pbr::ProgressBar;
use std::path::{PathBuf, Path};
use ::Direction;
use ::errors::{ErrorKind, Result, ResultExt};
fn generage_subimage_coords(bounds: (u32, u32, u32, u32),
index: u32,
direction: Direction)
... |
use std::sync::Arc;
use fxhash::FxHashMap;
use hecs::Entity;
use rand::rngs::SmallRng;
use rand::{Rng, SeedableRng};
use tracing::{error_span, info, trace};
use common::{
graph::{Graph, NodeId},
math,
proto::{self, ClientHello, Command, Component, FreshNode, Position, Spawns, StateDelta},
sanitize_mot... |
use super::create_tx_header;
use godcoin::{
blockchain::{GenesisBlockInfo, ReindexOpts},
prelude::*,
tx::CreateAccountTx,
};
use godcoin_server::{client::*, prelude::*, ServerData};
use sodiumoxide::randombytes;
use std::{
env, fs,
io::Cursor,
net::SocketAddr,
path::{Path, PathBuf},
sync... |
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
fuchsia_async as fasync,
fuchsia_cobalt::{CobaltConnector, CobaltSender, ConnectionType},
time_metrics_registry::{
RealTimeClockE... |
use crate::{
interchange::Interchange,
test_utils::{pubkey, DEFAULT_GENESIS_VALIDATORS_ROOT},
SigningRoot, SlashingDatabase,
};
use serde_derive::{Deserialize, Serialize};
use tempfile::tempdir;
use types::{Epoch, Hash256, PublicKey, Slot};
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MultiTe... |
use num_bigint::BigInt;
use num_integer::Integer;
use num_traits::{One, Zero};
use std::fmt;
#[derive(Debug, Clone, PartialEq, PartialOrd)]
struct Rational {
nominator: BigInt,
denominator: BigInt,
}
impl Rational {
fn new(n: &BigInt, d: &BigInt) -> Rational {
assert!(!d.is_zero(), "denominator ca... |
use std::io::Write;
use std::os::unix::fs::PermissionsExt;
use std::process::{Command as StdCommand, ExitStatus, Stdio};
const VSOCK_AGENT_PATH: &str = "/opt/ic/bin/vsock_agent";
#[derive(Clone, Debug)]
pub enum UtilityCommandError {
IoError(String),
Failed(String, ExitStatus),
}
impl std::fmt::Display for U... |
use aoc_runner_derive::{aoc, aoc_generator};
use regex::Regex;
use std::collections::HashMap;
use std::error::Error;
#[aoc_generator(day4)]
fn parse_input(input: &str) -> Result<Vec<HashMap<String, String>>, Box<dyn Error>> {
Ok(input
.split("\n\n")
.map(|p| {
p.split_whitespace()
... |
// Copyright (c) 2017 The vulkano 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 co... |
use db::{Database, QueryUtils};
use errors::*;
use experiments::{CapLints, CrateSelect, Experiment, GitHubIssue, Mode, Status};
use server::github::Issue;
use server::messages::{Label, Message};
use server::routes::webhooks::args::{AbortArgs, EditArgs, RetryReportArgs, RunArgs};
use server::Data;
pub fn ping(data: &Da... |
use std::collections::BTreeSet;
fn parse_map(s: &str) -> Vec<Vec<u32>> {
s.lines()
.map(|line| {
line.chars()
.map(|c| c.to_digit(10).unwrap())
.collect::<Vec<u32>>()
})
.collect()
}
fn find_low_point(map: &Vec<Vec<u32>>) -> Vec<u32> {
let ma... |
//! Simplified cargo structures.
//!
//! These are used to avoid pulling in cargo as a dependency, but
//! they may not be exactly consistent with what cargo does.
use std::{
env,
fs::File,
io::Read,
path::{Path, PathBuf},
};
use anyhow::{anyhow, Result};
use serde_derive::Deserialize;
use toml;
/// F... |
// Copyright 2019 Parity Technologies (UK) Ltd.
//
// 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, mer... |
use crate::payout_curve::Error;
use ndarray::prelude::*;
use ndarray::s;
use std::cmp::Ordering;
use std::f64::consts::PI;
pub fn bisect_left(arr: &Array1<f64>, val: &f64, mut hi: usize) -> usize {
let mut lo: usize = 0;
while lo < hi {
let mid = (lo + hi) / 2;
if arr[mid] < *val {
... |
// This file is part of Substrate.
// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// 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 F... |
#![no_std]
#![no_main]
#![feature(naked_functions)]
#![feature(asm)]
#![feature(generator_trait)]
#![feature(default_alloc_error_handler)]
mod peripheral;
mod hart_csr_utils;
mod runtime;
mod execute;
mod feature;
extern crate alloc;
use core::panic::PanicInfo;
use buddy_system_allocator::LockedHeap;
use rustsbi::p... |
extern crate wasm_bindgen;
mod fractal;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern {
#[allow(dead_code)]
fn log(s: &str);
#[allow(dead_code)]
fn error(e: &str);
}
#[allow(unused_macros)]
macro_rules! log {
($($t:tt)*) => (log(&format_args!($($t)*).to_string()))
}
#[allow(unused_macros... |
#[macro_use]
extern crate actix_web;
extern crate clap;
extern crate memcache;
const APPNAME: &'static str = "memproxy";
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
const DEF_CFG_FN: &'static str = "cfg-memproxy.json";
const DEF_BIND_ADDR: &'static str = "127.0.0.1";
const DEF_BIND_PORT: &'static str = "8... |
/*
MIT License
Copyright (c) 2021 <NAME>
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, publish, distrib... |
use ethabi::LogParam;
use web3::types::*;
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EthereumBlock {
pub block: Block<Transaction>,
pub transaction_receipts: Vec<TransactionReceipt>,
}
impl EthereumBlock {
pub fn transaction_for_log(&self, log: &Log) -> Option<Transaction> {
log.tr... |
use alloc::vec::Vec;
#[derive(Debug)]
pub enum Error {
InvalidEmailKey,
InvalidUidKey,
InvalidRoleKey,
InvalidEmailValue,
InvalidUidValue,
InvalidRoleValue,
KeyNotFound,
}
const AMP_KEY: u8 = 0x26; // '&'
const EQ_KEY: u8 = 0x3d; // '='
fn find_key(buf: &[u8], key: u8) -> Result<usize, Er... |
//! To-do tasks (iCal `VTODO` item)
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use chrono::{DateTime, Utc};
use ical::property::Property;
use url::Url;
use crate::item::SyncStatus;
use crate::utils::random_url;
/// RFC5545 defines the completion as several optional fields, yet some combinations make no sen... |
// Copyright 2019 Parity Technologies (UK) Ltd.
//
// 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, mer... |
#![deny(warnings)]
#![feature(global_asm)]
#![feature(proc_macro_hygiene)]
#![no_std]
use riscv::{asm, csr};
#[cfg(debug_assertions)]
use semihosting::hio;
#[cfg(debug_assertions)]
use ufmt::uwriteln;
#[cfg(debug_assertions)]
use ufmt_utils::{consts, Ignore, LineBuffered};
// NOTE `csrci mstatus, 8` = disables inte... |
use super::{
action_button::{ActionButton, ActionMsg, ActionType}, constants::IMAGE_PATH, styles::CustomButton,
};
use libkoompi::session::PowerManager;
use num_traits::FromPrimitive;
use std::path::PathBuf;
use std::ops::SubAssign;
use std::time::{Duration, Instant};
use iced::{
button, Align, Application, But... |
use iter::Bytes;
pub unsafe fn parse_uri_batch_16(bytes: &mut Bytes) {
while bytes.as_ref().len() >= 16 {
let advance = match_url_char_16_sse(bytes.as_ref());
bytes.advance(advance);
if advance != 16 {
break;
}
}
}
#[target_feature(enable = "sse4.2")]
#[allow(non_s... |
// Rust JSON-RPC Library
// Written in 2015 by
// <NAME> <<EMAIL>>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
//
// You should have re... |
use std::io::Write;
use blake2b_simd::{Hash as Blake2bHash, Params, State};
use byteorder::{LittleEndian, WriteBytesExt};
use crate::transaction::{
components::transparent::{self, TxOut},
sighash::{
SignableInput, TransparentInput, SIGHASH_ANYONECANPAY, SIGHASH_MASK, SIGHASH_NONE,
SIGHASH_SING... |
use core::cmp::Ordering;
use core::convert::From;
use core::time::Duration;
use bitflags::bitflags;
use generic_array::ArrayLength;
use gregor::{DayOfTheWeek, UnixTimestamp};
use heapless::binary_heap::{BinaryHeap, Min};
use crate::uhr::Uhr;
bitflags! {
/// A bit packed structure representing days of the week
... |
use glam::{Mat4, Quat, Vec3};
use pica::error::Error;
use pica::math;
use pica::pica_window::{Window, WindowAttributes};
use pica::utils;
use pica::wgpu_renderer::Vertex;
use pica::wgpu_renderer::{camera::Camera, Instance, InstanceRaw, WGPURenderer};
use std::borrow::Cow;
pub fn cube_positions() -> Vec<[i8; 3]> {
... |
use druid::kurbo::{Point, RoundedRect, Size};
use druid::theme;
use druid::widget::Label;
use druid::{
Affine, BoxConstraints, Color, Env, Event, EventCtx, Insets, LayoutCtx, LifeCycle, LifeCycleCtx, LinearGradient,
MouseEvent, PaintCtx, Rect, RenderContext, Selector, UnitPoint, UpdateCtx, Widget,
};
// TODO: Make t... |
use std::{fmt, ops::Range};
use crate::bnf;
/// An integer used to identify a terminal or a nonterminal symbol.
///
/// It easily maps into a symbol table index, see ``.
pub type SymbolID = usize;
/// An integer used to identify a production.
pub type ProductionID = usize;
#[derive(Default, Debug)]
pub struct Produc... |
use csv;
use serde::{Serialize, Deserialize, de, Deserializer};
use csv::{ReaderBuilder, Writer, Reader};
use std::str::FromStr;
pub fn read_csv() -> Result<(), csv::Error> {
let csv = "year,make,model,description
1948,Porsche,356,Luxury sports car
1967,Ford,Mustang fastback 1967,American car";
let mut reader = cs... |
//! An ADSR envelope filter.
use num::traits::Float;
use oxcable::types::{SAMPLE_RATE, AudioDevice, MessageReceiver, Sample, Time};
/// Defines the messages that the ADSR supports.
#[derive(Clone, Copy, Debug)]
pub enum Message {
/// Triggers an attack.
NoteDown,
/// Triggers a release.
NoteUp,
/... |
#[doc = "PWM Channel Mode Register (ch_num = 0)\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2ru... |
use anchor_lang::prelude::Pubkey;
use bytemuck::{Pod, PodCastError, Zeroable};
use std::mem::size_of;
#[derive(Copy, Clone, Debug)]
#[repr(u64)]
pub enum AccountFlag {
Initialized = 1u64 << 0,
Market = 1u64 << 1,
OpenOrders = 1u64 << 2,
RequestQueue = 1u64 << 3,
EventQueue = 1u64 << 4,
Bids = 1... |
#![cfg_attr(not(feature = "std"), no_std)]
use sp_std::{prelude::*, vec::Vec, if_std};
use frame_support::{
decl_module, decl_event, decl_storage, decl_error,
ensure, dispatch,
traits::EnsureOrigin
};
use frame_system::{self as system, ensure_signed, RawOrigin};
/// Configure the pallet by specifying the parameter... |
use data_encoding::{Encoding, Specification};
fn advance<'a>(x: &mut &'a [u8], n: usize) -> Option<&'a [u8]> {
if x.len() < n {
return None;
}
let r = &x[.. n];
*x = &x[n ..];
Some(r)
}
fn encode_slice(input: &[u8], output: &mut Vec<u8>) {
assert!(input.len() < 256);
output.push(in... |
use anyhow::{anyhow, Result};
use futures_util::stream::{repeat, Stream};
use futures_util::{StreamExt, TryFutureExt, TryStreamExt};
use parking_lot::RwLock;
use rustls::internal::pemfile::{certs, rsa_private_keys};
use rustls::{NoClientAuth, ServerConfig};
use std::future::Future;
use std::sync::Arc;
use tokio::io::{A... |
/*!
Library for loading [Audio Scene Description Format (ASDF)][ASDF] files,
written in Rust.
[ASDF]: https://AudioSceneDescriptionFormat.readthedocs.io/
# Requirements
* Rust compiler, Cargo (<https://rustup.rs/>)
The required Rust packages (a.k.a. "crates") are listed in the file
`Cargo.toml`.
# API Documentatio... |
#![deny(missing_docs)]
//! # Closure Calculus
//! An implementation of Closure Calculus
//!
//! Based on paper by <NAME>: https://dl.acm.org/doi/pdf/10.1145/3294032.3294085
use Expr::*;
/// Stores expressions for Closure Calculus.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Expr {
/// Zero.
J,
/// Su... |
use std::io::{BufReader, Read};
use crate::convert_path_buf;
use crate::{Error, Result};
use std::collections::BTreeMap;
use std::path::PathBuf;
use std::str::FromStr;
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq)]
struct Coordinate {
y: usize,
x: usize,
}
#[derive(Debug)]
enum Land {
Open,
Tree,
}... |
use crate::widget::tree::{self, Tree};
use crate::{Element, Widget};
use iced_native::event::{self, Event};
use iced_native::layout::{self, Layout};
use iced_native::mouse;
use iced_native::renderer;
use iced_native::text;
use iced_native::widget::text_input;
use iced_native::{Clipboard, Length, Padding, Point, Rectan... |
//! Protocol for sending messages to remote actors
use erased_serde::{Deserializer, Serializer};
use futures::future::FutureObj;
use serde::de::Error as SerdeDeError;
use std::cell::RefCell;
use crate::types::{ActorId, Message, MessageBox};
/// A bunch of actors and functions used for theaters to communicate between... |
//! Events emitted by the [SemanticEventExtractor] which are then constructed into the Semantic Model
use std::collections::VecDeque;
use rome_js_syntax::{JsLanguage, JsSyntaxNode, TextRange, TextSize};
use rome_rowan::syntax::Preorder;
/// Events emitted by the [SemanticEventExtractor]. These events are later
/// m... |
// Copyright (c) 2018 <NAME>, RWTH Aachen University
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed exc... |
use crate::game_state::GameState;
use bevy::prelude::*;
use bevy_mod_picking::PickingCameraBundle;
use leafwing_input_manager::{
plugin::InputManagerPlugin, prelude::ActionState, InputManagerBundle,
};
use leafwing_input_manager::{prelude::InputMap, Actionlike};
use smooth_bevy_cameras::{LookTransform, LookTransfor... |
/*
* Copyright (c) 2021 Works Applications Co., Ltd.
*
* 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 ... |
//!Multipart support
use bytes::Bytes;
use mime::Mime;
use mime_guess;
use std::path;
use std::fs;
use std::io;
use std::io::Write;
use crate::header::{ContentDisposition, Filename};
use crate::utils::BytesWriter;
const DEFAULT_BOUNDARY: &'static str = "yuki";
///Multipart Form.
///
///Default boundary is `yuki`.
... |
#[macro_use]
extern crate magic_crypt;
extern crate passwords;
use magic_crypt::MagicCryptTrait;
use passwords::analyzer;
use passwords::scorer;
use passwords::PasswordGenerator;
use std::collections::HashMap;
use std::fs;
use std::io::Write;
/// Function to load data from the file saved as 'db.json' in current direct... |
use crate::U256;
use std::prelude::v1::*;
#[cfg(feature = "std")]
use std::{fmt, format};
impl U256 {
// Can not use Self inside the macro
#[allow(clippy::use_self)]
pub fn from_decimal_str(s: &str) -> Result<Self, ParseError> {
// ceil(2^256 / 10)
let max10: Self = Self::from_limbs([
... |
pub const TILE_DIM_BITS: u32 = 4;
pub const TILE_DIM: u32 = 1 << TILE_DIM_BITS;
pub const TILE_PIXELS_BITS: u32 = TILE_DIM_BITS * 2;
pub const TILE_PIXELS: u32 = 1 << TILE_PIXELS_BITS;
pub const TILE_PIXELS_WORDS_BITS: u32 = TILE_PIXELS_BITS - 2;
// TODO: Move
pub const SYSTEM_BUS_ADDR_BITS: u32 = 24;
pub const TEX_WO... |
/*
src/funcs.rs
Copyright (c) 2019, 2020 <NAME> All rights reserved.
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... |
/*******************************************************************************
* (c) 2021 Zondax 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/lic... |
use itertools::Itertools;
use crate::input;
use std::collections::HashMap;
pub fn run() {
let notes = input::get_lines("day08");
let part1 = count_unique_digits(¬es);
println!("part1: {:?}", part1);
let part2 = get_sum_of_outputs(¬es);
println!("part2: {:?}", part2);
}
fn count_unique_... |
use byteorder::{BigEndian, ReadBytesExt};
use message::defines::*;
use mio::{Evented, Poll, PollOpt, Ready, Token};
use mio::tcp::TcpStream;
use serde_json;
use std::io::{Error, ErrorKind, Read, Write};
use std::io::Result as STDResult;
use std::net::{Shutdown, SocketAddr};
use std::mem::transmute;
use std::str;
pub ... |
use itertools::{iproduct, Itertools};
use rand::Rng;
use rayon_adaptive::Policy;
use rayon_adaptive::{
adaptive_sort_no_copy_with_policies, adaptive_sort_raw_with_policies,
adaptive_sort_raw_with_policies_swap_blocks, adaptive_sort_with_policies,
};
use std::fs::File;
use std::io::prelude::*;
use std::iter::{on... |
// Copyright 2016 OpenMarket Ltd
// Copyright 2021 The Matrix.org Foundation C.I.C.
//
// 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
//... |
use nix::sys::ptrace;
use nix::sys::signal;
use nix::sys::wait::{waitpid, WaitPidFlag, WaitStatus};
use nix::unistd::Pid;
use std::process::Child;
use std::os::unix::process::CommandExt;
use std::process::Command;
use crate::dwarf_data::{DwarfData, Error as DwarfError};
use std::collections::HashMap;
pub enum Status ... |
// File: day_6.rs
// Author: <NAME>
// Date: December 2020
/*
Copyright 2020 <NAME>
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 azure_core::error::{ErrorKind, ResultExt};
use azure_core::{headers::*, Context, Policy, PolicyResult, Request};
use http::header::AUTHORIZATION;
use http::Method;
use std::borrow::Cow;
use std::sync::Arc;
use url::Url;
use crate::clients::{ServiceType, StorageCredentials};
const STORAGE_TOKEN_SCOPE: &str = "http... |
//! The crate provides macros, which measure the time in ms until end of scope
//!
//! This is done by creating an object, which measures the time. The time is printed when the object is dropped.
//!
//! The logging behaviour is the same as other log macros like info!(..)
//!
//! ### Examples
//!
//! ```rust
//! use me... |
use std::net::{IpAddr, Ipv4Addr};
use std::time::{Duration, Instant};
use log::debug;
type PacketCount = usize;
#[derive(Clone, Copy)]
struct ThrottlerRecord {
ip: IpAddr,
packets: PacketCount,
expiration: Instant,
creation_time: Instant,
}
impl Default for ThrottlerRecord {
fn default() -> Self... |
use std::time::Duration;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use cozy_chess::Board;
const POSITIONS: &[&str] = &[
"Q7/5Q2/8/8/3k4/6P1/6BP/7K b - - 0 67",
"r4rk1/p4ppp/1q2p3/2n1P3/2p5/3bRNP1/1P3PBP/R2Q2K1 b - - 0 24",
"r1bq1rk1/pp3ppp/2nbpn2/3p4/3P4/1PN1PN2/1BP1BPPP/R2Q1... |
#[allow(non_snake_case)]
#[macro_use]
extern crate glium;
extern crate nalgebra_glm as glm;
use openfile;
use random_color::{Luminosity, RandomColor};
use regex::Regex;
mod graphics;
mod pop;
use crate::pop::PopCreator;
use std::collections::HashMap;
use std::error::Error;
#[macro_use]
use serde;
mod provinces;
mod u... |
use rand::{thread_rng, Rng};
use piston_window::*;
use piston_window::types::Color;
use crate::food::Food;
use crate::playground::Playground;
use crate::snake::{Snake};
use crate::draw::{Position, Direction, draw_rectangle, draw_text};
const GAMEOVER_COLOR: Color = [0.0, 0.0, 0.0, 0.90];
const WHITE_COLOR: Color = [1... |
use std::slice;
/*
Four actions with unsafe rust:
1) Dereference a raw pointer
2) Call an unsafe function or method
3) Access or modify a mutable static variable
4) Implement an unsafe trait
Unsafe doesn’t turn off the borrow checker or disable any other of Rust’s safety
checks: if you use a reference in unsafe code... |
//! Heph, derived from [Hephaestus], is the Greek god of blacksmiths,
//! metalworking, carpenters, craftsmen, artisans, sculptors, metallurgy, fire,
//! and volcanoes. Well this crate has very little to do with Greek gods, but I
//! needed a name.
//!
//! [Hephaestus]: https://en.wikipedia.org/wiki/Hephaestus
//!
//! ... |
use crate::scheduler::Scheduler;
use crate::timer::Timer;
use alloc::boxed::Box;
use alloc::vec::Vec;
use log::*;
use spin::{Mutex, MutexGuard};
struct Thread {
status: Status,
status_after_stop: Status,
waiter: Option<Tid>,
context: Option<Box<Context>>,
}
pub type Tid = usize;
type ExitCode = usize;... |
//! Decoding and Encoding of TIFF Images
//!
//! TIFF (Tagged Image File Format) is a versatile image format that supports
//! lossless and lossy compression.
//!
//! # Related Links
//! * <http://partners.adobe.com/public/developer/tiff/index.html> - The TIFF specification
extern crate tiff;
use std::convert::TryFro... |
use crate::buffer::{BytePacketBuffer, Deserialize, Result, Serialize};
/// Representation of a DNS message header.
///
/// [RFC 1035 - DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION](https://tools.ietf.org/html/rfc1035)
///
/// [RFC 4035 - Protocol Modifications for the DNS Security Extensions](https://tools.ietf.org... |
// (C) Copyright 2019 Hewlett Packard Enterprise Development LP
use std::cell::RefCell;
use std::rc::{Rc, Weak};
use std::sync::Arc;
use crate::config::Config;
use crate::filter::Filter;
use crate::renderer::types::*;
use super::log::LogState;
use super::bar::BarState;
use super::filter_bar::FilterBarState;
use supe... |
#[cfg(all(
not(feature = "std"),
any(feature = "parse-comments", feature = "string-value")
))]
use alloc::string::String;
#[derive(Debug)]
pub(crate) enum ParseResult<G, E> {
Input(E),
Parsing(crate::Error),
Ok(G),
}
impl<O, E> From<core::result::Result<O, E>> for ParseResult<O, E> {
fn from(f:... |
/*
Copyright 2018 Google LLC
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
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
dis... |
// Copyright 2020 <NAME>
//
// 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::{
path::Path,
path::PathBuf,
sync::Arc,
};
use eyre::{eyre, Result};
use fritz_jingle_db::{jingle::Jingle, JinglesDb};
use futures::{stream, StreamExt};
use indicatif::{MultiProgress, ProgressStyle};
use reqwest::{self, header, Client, Url};
use select::{
document::Document,
node::Node,
... |
use bincode;
use crate::config::*;
use crate::host::Host;
use crate::message::*;
use crate::params::*;
use sha2::digest::FixedOutput;
use sha2::Digest;
use std::collections::HashSet;
pub struct PbftState {
config: Config,
local_index: usize,
next_nonce: u64, // only used if the current node is primary
... |
use crate::{
bind_merge::BindGroupBuilder,
datatypes::{Camera, CameraProjection, DirectionalLight, DirectionalLightHandle},
registry::ResourceRegistry,
renderer::{camera::CameraManager, INTERNAL_SHADOW_DEPTH_FORMAT, SHADOW_DIMENSIONS},
};
use glam::{Mat4, Vec3};
use std::{mem::size_of, num::NonZeroU32, ... |
///////////////////////////////////////////////////////////////////////////////
//
// Copyright 2018-2021 <NAME> <<EMAIL>>
//
// 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
//
// h... |
#[macro_use]
extern crate log;
use std::env;
use std::path;
use ggez::{self, *};
mod components;
mod input;
mod level_configuration;
mod lighting;
mod resources;
mod scenes;
mod systems;
mod types;
mod util;
mod world;
const DESIRED_FPS: u32 = 60;
const DIMENSIONS: (f32, f32) = (1920.0, 1080.0);
const GAME_ID: &str ... |
use std::sync::Arc;
use chrono::{DateTime, Local};
use enum_primitive_derive::Primitive;
use peace_constants::{GameMode, PlayMods};
use peace_objects::beatmaps::Beatmap;
use tokio::sync::RwLock;
use crate::objects::{Channel, Player};
#[derive(Debug, Clone, Copy, Eq, PartialEq, Primitive)]
#[repr(u8)]
pub enum MatchS... |
use std::collections::HashMap;
fn bucket_calc(d: &mut HashMap<usize, (usize, usize)>, v: &Vec<usize>) -> () {
//{{{
let mut p = v[0];
let mut q = v[0];
let mut z = 0;
for c in v.iter() {
let i = match d.get(c) {Some(x) => (*x).1 + 1, None => 1};
d.insert(*c, (0, i));
if *... |
use std::fs::{create_dir, read_to_string, remove_file, File};
use std::io::prelude::*;
use std::path::Path;
use hyper::Request;
use once_cell::sync::OnceCell;
use serde_json::{json, Value};
use tokio::time::{sleep, Duration};
use webbrowser;
use crate::dialoguer as dlg;
use crate::http::CLIENT;
const CODE_URL: &'sta... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.