text stringlengths 3.09k 13.9k |
|---|
use itertools::Itertools;
use crate::input;
pub fn run() {
let lines = input::get_lines("day11");
let part1 = flashes(&lines, 100);
println!("part1: {:?}", part1);
let part2 = first_simultaneous(&lines);
println!("part2: {:?}", part2);
}
fn flashes(lines: &[String], steps: u32) -> u32 {
l... |
use super::{AnimBuilder, Animation, TargetAction};
use crate::appearance::SetOpacity;
use crate::arena::{Arena, Id, Index, Object};
use crate::scene::Resource;
/// Types of commands available. Vector of `TimedCommand` constructs the
/// sequence of motion generated by the `Scene`.
#[derive(Debug, PartialEq)]
pub enum ... |
use anyhow::{anyhow, Result};
use js_sys::ArrayBuffer;
use std::future::Future;
use wasm_bindgen::{
closure::WasmClosure, closure::WasmClosureFnOnce, prelude::Closure, JsCast, JsValue,
};
use wasm_bindgen_futures::JsFuture;
use web_sys::{
CanvasRenderingContext2d, Document, Element, HtmlCanvasElement, HtmlElem... |
use std::fs::{self, File};
use std::str::FromStr;
use std::io::{Read, Seek};
use std::path::PathBuf;
use std::time::Instant;
use vach::prelude::{ArchiveConfig, Archive, InternalError};
use vach::rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use vach::crypto_utils;
use indicatif::{ProgressBar, ProgressStyle... |
#[derive(Debug)]
pub struct Templates {
// We expect to have multiple templates later. We can give this a better name
// when we know better the distinction between different templates. If we end
// up with only one template though, that won't be the end of the world.
pub t1: stbhw::Template,
// Dit... |
//! Everything related to authentication.
use std::fmt::Debug;
use branca::Branca;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use warp::{filters::BoxedFilter, Filter};
use crate::reject;
const TOKEN_TTL_SECONDS: u32 = 60 * 60 * 6; // 6 hours.
/// Generate a signed token from an encrypti... |
#[macro_use]
extern crate quote;
extern crate proc_macro;
use itertools::Itertools;
use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use syn::{Field, Ident, PathArguments, Type};
const GRAPHQL_LOAD_META: &'static str = "graphql_load";
fn graphql_load_meta(field: &Field) -> Option<(&Field, I... |
//! Describes symmetries of a 2x2x2 cube puzzle.
use crate::cube::corner::{Corner, CornerOrient, CornerPerm, CornerPos};
use crate::puzzle::PuzzlePerm;
/// A symmetry permutation, excluding reflections.
///
/// This is built from 3 components:
///
/// - `urf_rot`: 120 degree clockwise rotation about the axis through ... |
use crate::commands::WholeStreamCommand;
use crate::prelude::*;
use nu_errors::ShellError;
use nu_protocol::{Primitive, ReturnSuccess, Signature, TaggedDictBuilder, UntaggedValue, Value};
pub struct FromXML;
impl WholeStreamCommand for FromXML {
fn name(&self) -> &str {
"from-xml"
}
fn signature(... |
//! Reactor core.
//!
//! Any long running instance of the node application uses an event-dispatch pattern: Events are
//! generated and stored on an event queue, then processed one-by-one. This process happens inside
//! the reactor*, which also exclusively holds the state of the application besides pending events:
//... |
//! Machinery for hygienic macros, inspired by the MTWT[1] paper.
//!
//! [1] <NAME>, <NAME>, <NAME>, and <NAME>.
//! 2012. *Macros that work together: Compile-time bindings, partial expansion,
//! and definition contexts*. J. Funct. Program. 22, 2 (March 2012), 181-216.
//! DOI=10.1017/S0956796812000093 http://dx.doi.... |
use crate::core::Target;
use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::{Config, StableHasher};
use anyhow::{bail, Context as _};
use serde::Serialize;
use std::collections::BTreeSet;
use std::fs;
use std::hash::{Hash, Hasher};
use std::path::Path;
/// Indicator for ... |
// Copyright 2017 The Grin 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 agree... |
//! # base64 reader module
use std::io;
use std::io::prelude::*;
use crate::util::is_base64_token;
/// Reads base64 values from a given byte input, stops once it detects the first non base64 char.
#[derive(Debug)]
pub struct Base64Reader<R> {
inner: R,
}
impl<R: Read + Seek> Base64Reader<R> {
/// Creates a ... |
use std::sync::Arc;
use crate::{client_server::SESSION_ID_LENGTH, utils, Error, Result};
use ruma::{
api::client::{
error::ErrorKind,
r0::uiaa::{
IncomingAuthData, IncomingPassword, IncomingUserIdentifier::MatrixId, UiaaInfo,
},
},
signatures::CanonicalJsonValue,
Dev... |
//! Warning: This example is outdated. It worked with yup-oauth2 version 1. To use the new
//! asynchronous yup-oauth2, take a look at: https://github.com/dermesser/async-google-apis.
//!
//! Demonstrates the use of service accounts and the Google Cloud Pubsub API.
//!
//! Run this binary as .../service_account pub 'yo... |
use std::ffi::OsString;
use std::default::Default;
use anyhow::Context;
use async_std::path::{Path, PathBuf};
use async_std::stream::StreamExt;
use async_std::fs;
use async_std::io::{self, Write, prelude::WriteExt};
use edgedb_protocol::client_message::{ClientMessage, Dump};
use edgedb_protocol::server_message::Serve... |
use std::str::FromStr;
use structopt;
/// Command line arguments.
///
/// This type represents everything the user can specify via CLI args. The main
/// method is [`from_args`][Arguments::from_args] which reads the global
/// `std::env::args()` and parses them into this type.
///
/// The CLI is very similar to the o... |
use crate::player::{Choice, Player};
use contracts::*;
use fastrand::Rng;
use fnv::FnvHashMap;
use indicatif::{ProgressBar, ProgressIterator, ProgressStyle};
use itertools::Itertools;
use std::convert::TryFrom;
pub type StrategySignature = Box<dyn Fn(&[Choice], &[Choice], &mut Rng) -> Choice>;
pub struct Tournament {... |
use std::net;
use std::path::PathBuf;
use diesel::prelude::*;
use http::{HeaderMap, HeaderValue};
use serde::{Deserialize, Serialize};
use syntect::dumps;
use syntect::highlighting::ThemeSet;
use syntect::parsing::SyntaxSet;
#[cfg(feature = "frontend")]
use handlebars::Handlebars;
use crate::db::models::Author;
use ... |
use std::collections::HashMap;
use std::cmp::{max, Ordering};
#[derive(Hash, Eq, PartialEq, Debug)]
pub struct Bigram {pub left: u32, pub right: u32,}
impl Ord for Bigram {
fn cmp(&self, other: &Self) -> Ordering {
return max(self.left, self.right).cmp(&max(other.left, other.right));
}
}
impl Partial... |
// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors
//
// 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
//
// Unl... |
use crate::counter::Counter;
use crate::error::{invalid_state, PolarResult};
use crate::events::QueryEvent;
use crate::runnable::Runnable;
use crate::terms::{Operation, Operator, Pattern, Symbol, Term, Value};
use std::collections::HashSet;
fn path(x: &Term) -> Vec<Term> {
match x.value() {
Value::Express... |
#[allow(dead_code)]
#[allow(unused_imports)]
#[allow(unused_variables)]
#[allow(unused_must_use)]
// Import libraries
use std::fmt::Debug;
use std::ops::{Add, AddAssign, Neg}; // add 'addition' from the operation module for Rust
// TRAITS
// A trait is a group of methods that can be applied to a structure
// define... |
use anyhow::{anyhow, Result};
use async_std::prelude::*;
use async_std::sync::{channel, Arc, Receiver, Sender};
use log::error;
use threshold::sig::Scheme;
use time::{Duration, OffsetDateTime};
use crate::dkg;
use crate::key;
use super::beacon::{self, Beacon, PartialBeacon, Round};
const DB_BEACON_STORE: &[u8] = b"b... |
use crate::PlatformTag;
use anyhow::{format_err, Context, Result};
use pyproject_toml::PyProjectToml as ProjectToml;
use serde::{Deserialize, Serialize};
use std::fs;
use std::path::{Path, PathBuf};
/// The `[tool]` section of a pyproject.toml
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab... |
use futures::sink::Send;
use futures::stream::Stream;
use futures::{Async, Future, Poll, Sink};
use futures_state_stream::{StateStream, StreamEvent};
use native_tls::TlsConnector;
use std::io;
use std::net::ToSocketAddrs;
use tokio::net::tcp::{ConnectFuture, TcpStream};
use tokio_codec::Decoder;
use tokio_tls::{self... |
/// A parser for the `LS_COLORS` environment variable.
use std::collections::HashMap;
use ansi_term::{Style, Colour};
/// Maps file extensions to ANSI colors / styles.
pub type ExtensionStyles = HashMap<String, Style>;
/// Maps filenames to ANSI colors / styles.
pub type FilenameStyles = HashMap<String, Style>;
con... |
use bitflags;
use libc::if_nametoindex;
use std::{ffi::CString, io, os::unix::io::RawFd};
use thiserror::Error;
use crate::{
generated::{
bpf_attach_type::BPF_XDP, bpf_prog_type::BPF_PROG_TYPE_XDP, XDP_FLAGS_DRV_MODE,
XDP_FLAGS_HW_MODE, XDP_FLAGS_REPLACE, XDP_FLAGS_SKB_MODE, XDP_FLAGS_UPDATE_IF_NOE... |
// Copyright 2020-2022 <NAME>
// SPDX-License-Identifier: Apache-2.0
use std::{any::TypeId, convert::Infallible};
use async_trait::async_trait;
use bee_message::{milestone::MilestoneIndex, MessageId};
use bee_runtime::{node::Node, shutdown_stream::ShutdownStream, worker::Worker};
use bee_tangle::{metadata::IndexId, s... |
// Copyright © 2018 <NAME>
// [This program is licensed under the "MIT License"]
// Please see the file LICENSE in the source
// distribution of this software for license terms.
extern crate rustalgo;
use rustalgo::points::*;
use rustalgo::convexhull::*;
use rustalgo::convexhull::Algorithm::*;
use rustalgo::inputset::... |
use std::collections::{HashMap, HashSet};
use std::fmt::Debug;
use std::io::Write;
use colored::*;
use lazy_static::*;
use regex::Regex;
use serde::{Deserialize, Serialize};
use crate::commands::tracker::StatusContext;
use crate::commands::validate::{OutputFormatType, Reporter};
use crate::commands::validate::common:... |
// Copyright 2019-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Author: <NAME> <<EMAIL>>
// Author: <NAME> <<EMAIL>>
//! ***NitroSecureModule multithread test for Rust API***
//! # Overview
//! This module implements a aggresive run-time test for the
//! NSM Ru... |
use std::collections::HashMap;
mod resolver;
pub use resolver::BiblioResolver;
use super::{Entry, FieldQuery, QuotedString, Resolver};
/// An intermediate representation of a bibliography which is not tied to a specific end format.
#[derive(Debug, Default, PartialEq)]
#[cfg_attr(test, derive(Clone))]
pub struct Bib... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Version ID Register"]
pub verid: VERID,
#[doc = "0x04 - Parameter Register"]
pub param: PARAM,
#[doc = "0x08 - Comparator Control Register 0"]
pub ccr0: CCR0,
#[doc = "0x0c - Comparator Control Register 1"]
pub ccr1: CCR1,
... |
use super::constants::{BOUNDED_WORD_REGEX, STOP_WORDS};
use regex::Captures;
use std::borrow::Cow;
/// pre-processing pipeline wrapper that removes punctuation, normalizes word case (utf-8 included)
/// to lowercase, and remove stop words
pub(super) fn preprocess(text: &str) -> Vec<String> {
let text = remove_punc... |
//! This module provides a websocket endpoint.
//!
//! ### Example
//! ```
//! use futures::StreamExt;
//! use roa::router::{Router, RouterError};
//! use roa::websocket::Websocket;
//! use roa::{App, Context};
//! use roa::http::Method;
//!
//! # fn main() -> Result<(), RouterError> {
//! let router = Router::new().on... |
//! bgzip-rs
//! ========
//! [](https://travis-ci.org/informationsea/bgzip-rs)
//! [](https://ci.appveyor.com/project/information... |
use crate::console_log;
use crate::raft::{self, client::Client, Raft, RaftStateDump};
use crate::raft_init::{self, RaftProps};
use futures::channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender};
use futures::StreamExt;
use serde::{Deserialize, Serialize};
use wasm_bindgen_futures::spawn_local;
use web_sys::win... |
/*
* Copyright 2020 Fluence Labs Limited
*
* 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 a... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - MODE."]
pub mode: crate::Reg<mode::MODE_SPEC>,
#[doc = "0x04 - INT_SOURCE."]
pub int_source: crate::Reg<int_source::INT_SOURCE_SPEC>,
#[doc = "0x08 - INT_MASK."]
pub int_mask: crate::Reg<int_mask::INT_MASK_SPEC>,
... |
use std::{marker::PhantomData, path::Path, time::Duration};
use crate::{
dut_definition::{DefinitionSource, DutDefinition},
tests::{
stepping::test_stepping, test_flashing, test_hw_breakpoints, test_memory_access,
test_register_access,
},
};
use anyhow::{Context, Result};
use colored::Color... |
use std::fs::File;
use std::io::{BufRead, BufReader};
// TODO:
// Find if there is a way to find the solution if the bus ids are not relatively prime to each other
type BusNumber = u32;
type Time = u64;
// ---------------- Bus ----------------
struct Bus {
id : Option<BusNumber>,
}
impl Bus {
pub fn new(id ... |
//! A Rust implementation of [TURN][RFC 5766] server and client.
//!
//! # Examples
//!
//! ```
//! # extern crate fibers_global;
//! # extern crate futures;
//! # extern crate rustun;
//! # extern crate rusturn;
//! # extern crate stun_codec;
//! # extern crate trackable;
//! use futures::Future;
//! use rustun::messa... |
use crate::mesh::SimplePolygon;
use crate::utils;
use crate::Config;
use cgmath::prelude::*;
use cgmath::{Vector2, Vector3};
#[allow(unused_imports)]
use test::Bencher;
/// Barycentric coordinates of a point are represented from points of triangle
/// itself For example: Given triangle with A, B, C, we can have a poi... |
use httpmock::{
Method::{GET, POST},
MockRef, MockServer,
};
use serial_test::serial;
mod common;
use goose::prelude::*;
use goose::GooseConfiguration;
// Paths used in load tests performed during these tests.
const INDEX_PATH: &str = "/";
const SETUP_PATH: &str = "/setup";
const TEARDOWN_PATH: &str = "/tear... |
use bytes::{Buf, Bytes};
use std::num::Wrapping;
use crate::routing::Token;
#[allow(clippy::upper_case_acronyms)]
#[derive(Clone, PartialEq, Debug)]
pub(crate) enum PartitionerName {
Murmur3,
CDC,
}
impl Default for PartitionerName {
fn default() -> Self {
PartitionerName::Murmur3
}
}
pub tr... |
extern crate vst3;
use flexi_logger::{DeferredNow, Logger, Record};
use log::info;
use once_cell::sync::Lazy;
use std::{cell::Cell, f64::consts::PI, rc::Rc};
use uuid::Uuid;
use vst3::{
audio_processor::{AudioProcessor, ProcessInput, ProcessOutput},
edit_controller::EditController,
plugin::{read_parameter_... |
use crate::os::process::can_run_services_as_svc_user;
use nix::unistd::{setgid,
setuid,
Gid,
Uid};
use std::{ffi::OsStr,
io,
os::unix::process::CommandExt,
process::{Command,
Stdio},
result};
/// Prepare a... |
#![no_std]
#![no_main]
use panic_halt as _;
use cortex_m;
use cortex_m_rt::entry;
use stm32f3xx_hal::prelude::*;
use stm32f3xx_hal::{self, delay, pac, i2c, stm32};
const LCD_ADDRESS: u8 = 0x27;
const En: u8 = 0x04;
const Backlight: u8 = 0x08;
// A low effort and not really accurate
// delay for n milliseconds func... |
pub mod channel;
pub mod connection;
mod message;
use async_std::sync::{Arc, RwLock};
use log::{error, info};
use tokio::signal::unix::{signal, SignalKind};
use tokio_stream::StreamExt;
use futures::future::select_all;
use futures::future::FutureExt;
use lapin::options::{BasicCancelOptions, BasicConsumeOptions, Ba... |
// Copyright 2014 Google Inc. All rights reserved.
//
// 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... |
use std::time::Duration;
use arci::{
gamepad::{Axis, Button, GamepadEvent},
JointTrajectoryClient, Speaker,
};
use async_trait::async_trait;
use parking_lot::Mutex;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use super::control_node::ControlNode;
const AXIS_GAIN: f64 = 2.0;
const JOINT_POS... |
// 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 self::dir::{Dir, Op};
use std::ops::{AddAssign, SubAssign};
type Input = Dir;
type Pos = (isize, isize);
register!(
"input/day12.txt";
(input: input!(parse Input)) -> usize {
Ship1::run(input.iter().copied());
Ship2::run(input);
}
);
trait Ship: Default + Into<Pos> {
fn apply(&mut... |
//! Tools for reading data types of arbitrary bit length and might not be byte-aligned in the source data
//!
//! The main way of handling with the binary data is to first create a [`BitReadBuffer`]
//! ,wrap it into a [`BitReadStream`] and then read from the stream.
//!
//! Once you have a BitStream, there are 2 diffe... |
use crate::SantaConfig;
use std::{
collections::{hash_map::Entry, HashMap, HashSet},
fs,
path::{Path, PathBuf},
};
// extern crate yaml_rust;
use log::{debug, error, info, trace, warn};
use serde::{Deserialize, Serialize};
use serde_enum_str::{Deserialize_enum_str, Serialize_enum_str};
// use yaml_rust::{Y... |
// Copyright 2020-2022 <NAME>
// SPDX-License-Identifier: Apache-2.0
//! A module that provides JSON Web Token utilities.
use std::time::{SystemTime, UNIX_EPOCH};
pub use jsonwebtoken::TokenData;
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation};
use serde::{Deserialize, Serialize};
us... |
use item::*;
use print_config::*;
use style::*;
use std::io;
struct Indent {
pub regular_prefix: String,
pub child_prefix: String,
pub last_regular_prefix: String,
pub last_child_prefix: String,
}
impl Indent {
pub fn from_config(config: &PrintConfig) -> Indent {
Self::from_characters_and... |
use gfx_hal as hal;
use hal::format as f;
use hal::image as i;
use crate::gx_object::{TriIndexData, TriIndices, VertexData, Vertices};
pub const COLOR_RANGE: i::SubresourceRange = i::SubresourceRange {
aspects: f::Aspects::COLOR,
levels: 0..1,
layers: 0..1,
};
pub fn triangle_vertices() -> Box<[VertexDat... |
use crate::ckb_types::{
core::{BlockNumber, BlockView},
h256, packed,
prelude::*,
};
use crate::entry;
use ckb_testkit::Node;
use std::cmp::max;
use std::time::Duration;
const BLOCK_CONFIRMATION: BlockNumber = 10;
pub struct ChainCrawler {
node: Node,
query_sender: crossbeam::channel::Sender<Strin... |
#![feature(unsized_locals)]
use irc::client::prelude::*;
use irc::error::IrcError;
use rustyknife::*;
use std::fs;
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(name = "basic")]
struct Options {
#[structopt(name = "FILE", parse(from_os_str))]
story_file: PathBuf,
... |
//! [`Path`] for filling and stroking.
use crate::models::{Arc, Cubic, Ellipse, Line, Quad};
use crate::point::Point;
#[derive(Debug, Clone)]
pub enum PathItem {
Line(Line),
Arc(Arc),
Ellipse(Ellipse),
Quad(Quad),
Cubic(Cubic),
CloseAndJump,
Jump,
}
impl PathItem {
pub fn flip(&self) ... |
//! The [glutin] windowing implementation for [luminance-windowing].
//!
//! [glutin]: https://crates.io/crates/glutin
//! [luminance-windowing]: https://crates.io/crates/luminance-windowing
#![deny(missing_docs)]
use gl;
use glutin::{
event_loop::EventLoop, window::WindowBuilder, Api, ContextBuilder, ContextError,... |
extern crate firecracker_rust_sdk;
use crate::network;
use firecracker_rust_sdk::models::{
boot_source, drive, logger, machine, machine_configuration, network_interface,
};
use node::{Status, VmConfig};
use std::convert::TryFrom;
use std::process::Stdio;
use std::sync::Arc;
use anyhow::{anyhow, Result};
use tok... |
use crate::*;
use std::str::FromStr;
#[test]
fn loglevels() {
macro_rules! test_conv {
($level:ident, $str1:literal, $str2:literal, $str3:literal) => {
assert_eq!(Ok(LogLevel::$level), LogLevel::from_str($str1));
assert_eq!(Ok(LogLevel::$level), LogLevel::from_str($str2));
... |
/*! Blocklists.
Contains basic filtering code and constructors.
Filtering methods can be used on [Url]s.
!*/
use std::{
collections::HashSet,
fs::File,
io::{BufRead, BufReader},
path::{Path, PathBuf},
};
use url::{Position, Url};
use crate::error::Ut1Error as Error;
/// Blocklist instantiation/det... |
//! Noise components.
use super::audionode::*;
use super::math::*;
use super::signal::*;
use super::*;
use numeric_array::*;
/// Maximum length sequences (MLS) are pseudorandom, spectrally flat,
/// binary white noise sequences with interesting properties.
/// We have pre-baked sequences with state space sizes from 1... |
use super::error::{ErrorKind, Result};
use serde::de::{Deserialize, Deserializer, Error as SerdeDeError};
use std::borrow::Borrow;
use std::fmt;
use std::fmt::Debug;
use std::fmt::Display;
use std::ops::Deref;
use std::result::Result as StdResult;
use std::str::{self, FromStr};
#[derive(Clone, Copy, PartialEq, Partial... |
use crate::blocks::{Block, BlockDirection, BlockFace, BlockPos};
use crate::plot::Plot;
// Redstone wires are extremely inefficient.
// Here we are updating many blocks which don't
// need to be updated. A lot of the time we even
// updating the same redstone wire twice. In the
// future we can use the algorithm creat... |
// <NAME> licenses this file to you 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 writ... |
extern crate chrono;
extern crate clap;
extern crate rpmpkg;
use chrono::NaiveDateTime;
use clap::{App, Arg, SubCommand};
use std::fs;
use std::io;
use std::time::{SystemTime, UNIX_EPOCH};
// ========================================================================= //
fn main() {
let matches = App::new("rpminfo"... |
use std::ptr;
use crate::{
display::Display,
keybindings::keybinding::Keybinding,
system::DisplayId,
system::Rectangle,
system::SystemResult,
system::WindowId,
system::{api, SystemError},
task_bar::Taskbar,
util,
};
use log::{debug, error};
use regex::Regex;
use winapi::{
shared... |
#[allow(non_camel_case_types)]
mod tls;
use std::{ mem, io, ptr };
use std::os::unix::io::AsRawFd;
use byteorder::{ ByteOrder, NetworkEndian };
pub use self::tls::*;
pub const TCP_ULP: libc::c_int = 31;
pub const SOL_TCP: libc::c_int = 6;
pub const SOL_TLS: libc::c_int = 282;
pub const TLS_1_2_VERSION: libc::c_uint ... |
use std::{cmp::Reverse, collections::BinaryHeap, sync::Arc, thread::ThreadId, time};
use parking_lot::{Condvar, Mutex};
pub trait Delayed: Ord {
fn delayed(&self) -> i64;
}
#[derive(Default)]
pub struct DelayQueue<T: Delayed> {
queue: Arc<Mutex<DelayQueueInner<T>>>,
available: Arc<Condvar>,
}
impl<T: De... |
use regex::Regex;
use std::collections::HashMap;
use crate::config;
use crate::line::Line;
use crate::link::reference::Reference;
use crate::spec::Spec;
use crate::util;
pub fn transform_data_blocks(doc: &mut Spec, lines: &[Line]) -> Vec<Line> {
lazy_static! {
// regex for begin tag
static ref BEG... |
// MIT License
//
// Copyright (c) 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, copy, modify, merg... |
use std::str;
use std::str::FromStr;
use std::fmt;
use std::borrow::Cow;
use assert_types::*;
use bytes::Bytes;
/// A convenience struct representing a part of a header (either the name or the value).
pub struct HeaderPart(Bytes);
impl fmt::Debug for HeaderPart {
fn fmt(&self, fmt: &mut fmt::Formatter) -> Resul... |
extern crate proc_macro;
use core::{fmt::Display, ops::RangeInclusive, str::FromStr};
use proc_macro::TokenStream;
use std::collections::BTreeMap;
use proc_macro2::Span;
use quote::quote;
use syn::{
braced,
parse::{self, Parse, ParseStream},
parse_macro_input,
punctuated::Punctuated,
token, Ident,... |
use std::str::FromStr;
#[derive(Debug, PartialEq, Clone)]
pub struct Atom {
pub name: String,
pub charge: f64,
pub pos: Vec<f64>,
pub fpos: Vec<f64>,
}
impl Atom {
pub fn new(name: String, charge: f64, pos: Vec<f64>, fpos: Vec<f64>) -> Self {
Atom {
name,
cha... |
//! WIP. Please ignore.
//!
//! This file is just a playground exploring how traits might work that can power a proc macro.
//!
//! ```rust,ignore
//! #[derive(Versions)]
//! #[versions(strategy = Pot)]
//! enum Versions {
//! #[versions(strategy = Bincode)]
//! V0(UserV0),
//! // implied strategy Pot
//! ... |
use proc_macro2::Span;
use regex::Regex;
use lazy_static::lazy_static;
use proc_macro_error::abort;
use syn::spanned::Spanned;
lazy_static! {
pub static ref COW_TYPE: Regex = Regex::new(r"Cow<'[a-z]+,str>").unwrap();
}
static CUSTOM_ARG_LIFETIME: &str = "v_a";
static CUSTOM_ARG_ALLOWED_COPY_TYPES: [&str; 14] = ... |
use std::fs::{self, File};
use std::io::Read;
use std::path::Path;
use std::str::FromStr;
use crate::dic::grammar::Grammar;
use crate::dic::header::Header;
use crate::dic::lexicon::Lexicon;
use crate::lattice::node::Node;
use crate::lattice::Lattice;
use crate::morpheme::Morpheme;
use crate::prelude::*;
/// Able to t... |
use {
crate::game::{
game_map::GameMap,
polygon::Polygon,
raycast::{raycast, Ray},
},
ggez::nalgebra::{distance, Point2, Unit, Vector2},
std::{cmp::Ordering, f32},
};
pub trait FieldOfView {
fn get_visible_area(&self) -> Option<&Polygon>;
fn recalculate(
&mut sel... |
//! ndarray_init
//!
//! Initializer of ndarray
use super::super::util::*;
use ndarray::prelude::*;
use ndarray_rand::rand_distr::*;
use std::fmt::Display;
/// Enum of distributions generating random values
#[derive(Clone, Debug)]
pub enum DistributionEnum {
Bernoulli = 0,
Beta = 1,
Binomial... |
extern crate yaml_rust;
use yaml_rust::scanner::ScanError;
use yaml_rust::Yaml;
use yaml_rust::YamlLoader;
// TODO: Look for a different solution other than .clone() for creating a Parser
/// A parser for reading metadata information about *Arcanum* packages
pub struct MetadataParser {
doc: Yaml,
}
/// A parser... |
use csv::{Reader, Writer};
use hash_hasher::{HashBuildHasher, HashedSet};
use rev_query_utils::{
error::{Error, Result},
resumeinfo::ResumeInfo,
};
use std::{
collections::hash_map::DefaultHasher,
fs::File,
hash::{Hash, Hasher},
iter::FromIterator,
path::Path,
};
use steam_review_api::conven... |
// Copyright 2019 The Exonum Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
use dice::Roll;
use crate::{
character::Character,
fact,
item::{
weapon::{CombatProperties, DamageType, WeaponItem},
AnyItem,
},
rules::Rule,
status::StatusType,
utils::get_armor,
world::World,
};
use crate::{timeline::get_modifier, utils::get_active_weapon};
use super:... |
//! Most of this module is copied from my deathframe crate.
use super::*;
/// Just a plain `Axis` enum with `X` and `Y` variants.
#[derive(Clone, Debug, PartialEq)]
pub(super) enum Axis {
X,
Y,
}
impl Axis {
/// This iterator-like method simply executes the passed closure with
/// the `X` variant and... |
extern crate proc_macro;
use proc_macro::{TokenStream, TokenTree};
use std::fs;
use std::io::{self, Write};
use std::iter;
use std::process::{Command, Stdio};
use std::env;
use tempdir::TempDir;
// Crates provided as part of the runtime
const UNICODE_XID_RLIB: &[u8] = include_bytes!(concat!(
env!("OUT_DIR"),
... |
/*
* picker_stash_sys returns the potential entity and stashes it in EntityPicker
* the stashing makes it simpler to run systems that expect it
* however, it's up to downstream to clear that value each tick
* (or call picker_clear_stash_sys)
*
* Note that picking itself isn't the absolute most ideal method
* y... |
/*
MIT License
Copyright (c) 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, copy, modify,... |
//! Solutions for day 17.
use std::collections::HashSet;
use std::fs;
/// A set of points representing the state of the game.
type Points = HashSet<Vec<i32>>;
#[doc(hidden)]
fn main() {
// Read input
let data: Vec<Vec<char>> = fs::read_to_string("input/17.txt")
.expect("Can't read input")
.lin... |
/*!
# Platform-agnostic driver for 3X4 numeric keypads
Provides a driver for reading from standard 3X4 keypads
## Example
```rust
let rows = (
gpiob.pb15.into_pull_up_input(&mut gpiob.crh),
gpioa.pa7.into_pull_up_input(&mut gpioa.crl),
gpiob.pb6.into_pull_up_input(&mut gpiob.crl),
gpioa.pa9.into_pull... |
use std::io::Result as IoResult;
use std::io::ErrorKind;
use std::process::{Command, ExitStatus};
use std::path::{Path, PathBuf};
use std::fs::{
DirBuilder, read_dir, remove_dir, rename,
remove_file,
};
use std::ffi::OsStr;
use std::os::unix::process::ExitStatusExt;
use std::os::unix::ffi::OsStrExt;
use std::fmt::W... |
use super::{MapBuilder, Map,
TileType, Position, spawner, SHOW_MAPGEN_VISUALIZER};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
use std::collections::HashMap;
pub struct CellularAutomataBuilder {
map : Map,
starting_position : Position,
depth: i32,
history: Vec<Map>,
noise_areas : Ha... |
use super::address_space::{IA32eAddrT, IA32eVirtual};
use super::CR3_MASK;
use crate::{Error, RekallProfile, Result};
use crate::{BLINK, EPROCESS, FLINK, LIST_ENTRY, PTR_SZ};
use log::debug;
use async_std::sync::{self, Receiver, Sender};
use async_std::task::{self, JoinHandle};
use std::collections::HashSet;
use std... |
use codegen::data_analyzer::{PointerSource, PointerSourceAggregateType};
use codegen::values::remap_type;
use codegen::{build_context_function, surface, util, BuilderContext, LifecycleFunc, ObjectCache};
use inkwell::context::Context;
use inkwell::module::{Linkage, Module};
use inkwell::types::BasicType;
use inkwell::v... |
use super::super::tools::*;
use super::super::style::*;
use super::super::model::*;
use flo_ui::*;
use flo_binding::*;
use flo_animation::*;
use std::sync::*;
///
/// The toolbox controller allows the user to pick which tool they
/// are using to edit the canvas
///
pub struct ToolboxController<Anim: Animation> {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.