text stringlengths 3.09k 13.9k |
|---|
use std::{
convert::TryInto,
error::Error,
fmt,
fs::File,
io::{BufRead, BufReader},
path::PathBuf,
str::FromStr,
};
use num_enum::{IntoPrimitive, TryFromPrimitive};
#[derive(Debug)]
struct ParseError(&'static str);
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatte... |
//! Context needed when validating instructions and constructing our `Instr` IR.
use crate::error::{ErrorKind, Result};
use crate::ir::{BlockKind, Instr, InstrLocId, InstrSeq, InstrSeqId, InstrSeqType};
use crate::module::functions::{FunctionId, LocalFunction};
use crate::module::Module;
use crate::parse::IndicesToIds... |
//! Steffensen's method.
//!
//! [Steffensen's](https://en.wikipedia.org/wiki/Steffensen%27s_method) method
//! is a technique similar to Newton's method, but without using derivatives.
//!
//! **Important:** Only one-dimensional systems are supported.
//!
//! # References
//!
//! \[1\] [Wikipedia](https://en.wikipedia... |
use grid;
use pancurses;
use pancurses::{Window, Attribute, Attributes, ColorPair, ToChtype};
use memory;
use sprite;
use sprite::{Sprite, Color};
use geometry::*;
use util::{self, pick};
use world::World;
use log::Log;
use item::Inventory;
use tile::Tile;
fn color(color: Color) -> Attributes {
match color {
... |
mod layers;
mod level_png;
mod model_obj;
use std::{
fs::{read as fs_read, File},
io::BufWriter,
path::PathBuf,
};
pub fn save_tiff(path: &PathBuf, layers: layers::LevelLayers) {
let images = [
tiff::Image {
width: layers.size.0 as u32,
height: layers.size.1 as u32,
... |
use futures::future;
use futures::future::FutureExt;
use futures::future::TryFutureExt;
use futures::stream;
use futures::stream::Stream;
use futures::stream::StreamExt;
use futures::stream::TryStreamExt;
use crate::futures_grpc::*;
use crate::error::Error;
use crate::proto::metadata::Metadata;
use crate::result;
us... |
//! A battle server.
use crate::battle::{Battle, BattleController, BattleRules, EventCallback};
use crate::error::{WeaselError, WeaselResult};
use crate::event::{
ClientEventPrototype, EventProcessor, EventPrototype, EventQueue, EventReceiver, EventRights,
EventServer, EventWrapper, MultiClientSink, MultiClien... |
//! A Roguelike game using bracket-lib and legion ecs.
mod components;
mod map;
mod schedule;
mod spawner;
mod systems;
mod ui;
/// Grouping of imports and globals for convienience.
mod prelude {
pub use bracket_lib::prelude::*;
pub use legion::systems::CommandBuffer;
pub use legion::world::SubWorld;
... |
use crate::code_writer;
use crate::graph;
use std::io::{Result, Write};
pub struct NodeDecl {
pub net_type: NetType,
pub name: String,
pub bit_width: u32,
}
impl NodeDecl {
pub fn write<W: Write>(&self, w: &mut code_writer::CodeWriter<W>) -> Result<()> {
w.append_indent()?;
self.net_t... |
use crate::github::{PullRequest, PullRequestEvent};
use crate::handlers::Context;
use crate::config::{RepoConfig, LabelConfig};
use crate::git::{Git, GitCredential};
use std::sync::Arc;
use std::collections::HashMap;
use std::convert::TryFrom;
use std::{env, fs, writeln};
use std::path::Path;
use std::fmt::Write as Fmt... |
// SPDX-FileCopyrightText: 2020 <NAME> <<EMAIL>>
// SPDX-License-Identifier: Apache-2.0 or MIT
//! Utilities for text wrapping.
use std::mem;
use crate::style;
use crate::Context;
use crate::Mm;
/// Combines a sequence of styled words into lines with a maximum width.
///
/// If a word does not fit into a line, the ... |
use std::{
fmt::{self, Debug},
str::FromStr,
};
use nom::{
bytes::complete::{take, take_while},
character::complete::char,
combinator::{map, map_res, rest},
sequence::{preceded, tuple},
IResult,
};
use nom_supreme::final_parser::{final_parser, Location};
use crate::md5::MD5Sum;
/*
fn from... |
use std::cmp::Reverse;
use std::collections::{BinaryHeap, HashSet, VecDeque};
use std::error::Error;
use std::io::{self, BufRead};
use std::iter::{FromIterator, Iterator};
type Pos = (usize, usize);
pub struct NeighborIterator {
pos: Pos,
upper_bounds: Pos,
state: u8,
}
impl NeighborIterator {
pub fn... |
use std::sync::Arc;
use async_trait::async_trait;
use color_eyre::{eyre::ensure, Result};
use ethers::{signers::Signer, types::Address};
use futures_util::future::select_all;
use prometheus::IntCounter;
use tokio::task::JoinHandle;
use tracing::{info, instrument::Instrumented, Instrument};
use crate::{
produce::U... |
use std::convert::TryFrom;
/// Tokens are high-level identifiers used by the parser to generate ASTs
#[derive(Debug, Clone, PartialEq)]
pub enum Token {
/// Variables, types and other
Identifier(String),
/// Reserved keywords such as types and instructions (return, break etc)
Reserved(ReservedKind),
... |
use super::email::Email;
use super::git::Git;
use super::gitlab::Gitlab;
use super::ical::Ical;
use super::redmine::Redmine;
use crate::config::Config;
use chrono::prelude::*;
use rayon::prelude::*;
use std::collections::HashMap;
use std::error::Error;
use std::fmt;
use std::time::Instant;
#[derive(PartialEq, Copy, Cl... |
use crate::{
assembly::{AssemblyInstruction, AssemblyInstructionBuilder, Disassemble},
operations::Operation,
state::State,
system::{Cartridge, Flags, WideRegister},
};
/// Indicates what condition should trigger a relative jump command.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum JumpRelativeFlag ... |
use crate::{
game::tile::Letter,
util::fsm::{Fsm, FsmSequence, StateId},
};
use std::{collections::HashMap, hash::Hash};
/// Represents a state in a finite state machine. `is_terminal` determines
/// whether it is an acceptance state.
#[derive(Debug, Default)]
pub struct State {
pub(super) is_terminal: boo... |
use anyhow::Context;
use closure::closure;
use libpulse_binding as pulse;
use pulse::context::ext_device_manager::DeviceManager;
use pulse::context::Context as Ctx;
use pulse::mainloop::standard::{IterateResult, Mainloop};
use pulse::operation::Operation;
use pulse::proplist::Proplist;
use std::cell::RefCell;
use std... |
//! PA8 button.
//! red: PC13<X>, green: PA1<Y>, blue: PA2<Z>
#![no_std]
#![no_main]
#![feature(asm)]
use panic_halt as _;
use core::fmt::Write;
use longan_nano_playground::ByteMutWriter;
use embedded_graphics::fonts::{Font8x16, Text};
use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::prelude::*;
us... |
use std::{f32::consts::PI, ops::Mul};
use cgmath::{perspective, Matrix4, Point3, Rad, SquareMatrix, Vector3};
use glium::{
backend::Facade,
implement_vertex,
index::{NoIndices, PrimitiveType},
uniform, Frame, Program, Surface, VertexBuffer,
};
use crate::{cube::Cube, step::FaceId};
#[derive(Copy, Clo... |
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... |
extern crate rustyline;
extern crate mio;
extern crate flate2;
extern crate getopts;
use mio::*;
use mio::net::*;
use std::io::prelude::*;
use std::process::{exit};
use std::env;
use rustyline::error::ReadlineError;
use rustyline::config::Builder;
use rustyline::Editor;
use flate2::Compression;
use flate2::write::Zli... |
use std::ffi::{CStr, CString};
use std::os::raw::{c_char, c_int};
use std::path::PathBuf;
use std::ptr::null_mut;
use fontconfig::{Fontconfig, Pattern};
use fontconfig_sys::fontconfig::{
FcChar8, FcPattern, FcPatternAddInteger, FcPatternAddString, FcPatternCreate, FcPatternDestroy,
FcPatternGetInteger, FcPatte... |
use std::collections::HashMap;
use std::fmt::{Debug, Formatter, Result as FormatterResult};
use std::marker::PhantomData;
use std::str;
use chrono::{DateTime, Utc};
use serde;
use serde::de::{Deserialize, DeserializeOwned, Deserializer, MapAccess, Visitor};
use serde::ser::SerializeMap;
use serde::{Serialize, Serializ... |
use std::{convert::TryInto, pin::Pin};
use camino::Utf8PathBuf;
use rkyv::{archived_root, archived_root_mut};
use self_cell::self_cell;
use sled::{IVec, Iter};
use super::{
storage::{InnerDb, InnerTree},
types::{
ArchivedLruDataData, ArchivedLruTimestampData, LruDataData, LruDataKey, LruTimestampData,... |
use common::{DebugLineStrOffset, DebugStrOffset, DebugStrOffsetsBase, DebugStrOffsetsIndex};
use endianity::Endianity;
use read::{EndianSlice, Reader, ReaderOffset, Result, Section};
use Format;
/// The `DebugStr` struct represents the DWARF strings
/// found in the `.debug_str` section.
#[derive(Debug, Default, Clone... |
//! A utility crate for bootstrapping emf modules.
#![feature(c_unwind)]
#![allow(dead_code)]
#![warn(
missing_docs,
rust_2018_idioms,
missing_debug_implementations,
rustdoc::broken_intra_doc_links
)]
use emf_core_base_rs::module::{Loader, Module, ModuleAPI};
use emf_core_base_rs::ownership::BorrowMutab... |
use super::*;
use crate::TypeReader;
#[derive(Copy, Clone)]
pub struct Attribute {
pub reader: &'static TypeReader,
pub row: Row,
}
impl Attribute {
pub fn constructor(&self) -> AttributeType {
self.reader.decode(self.row, 1)
}
pub fn name(&self) -> (&'static str, &'static str) {
... |
use core::fmt::{self, Write};
use crate::parser::{LlmlParser as Parser, Rule};
use pest::iterators::Pair;
/// A syntax tree node.
#[derive(Clone)]
pub enum Node {
Root(Vec<Node>),
MacroCall(String, Vec<Node>),
Element(String, Vec<Node>),
Wrapper(Vec<Node>),
Attribute(String, String),
Literal(S... |
use async_trait::async_trait;
use thiserror::Error;
use url::Url;
use crate::XaynetClient;
use xaynet_core::{
common::RoundParameters,
crypto::{ByteObject, PublicSigningKey},
mask::Model,
SumDict,
UpdateSeedDict,
};
/// Error returned upon failing to build a new [`Client`]
#[derive(Debug, Error)]
... |
use std::io::prelude::*;
use std::clone::Clone;
use std::collections::HashMap;
use std::io;
use std::io::{BufReader, Error, ErrorKind};
use std::net::{Shutdown, SocketAddr, TcpStream, ToSocketAddrs};
use nom::IResult;
use crate::parsers::{sam_hello, sam_naming_reply, sam_session_status, sam_stream_status};
pub stat... |
// Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Validate or convert TEE app configuration files.
#![deny(unsafe_op_in_unsafe_fn)]
use std::collections::BTreeSet as Set;
use std::convert::TryFro... |
//! Packet parsing and serialization.
//!
//! As it turns out, the extremely simple format used by `bincode` is perfect for reading and
//! writing simple, fixed structures, so we make use of it here.
/* We piggyback information if audio data blocks are stored in SHM on the seek mode */
/*
#define PA_FLAG_SHMDATA ... |
use std;
use crate::errors::{ ErrorKind, Result };
use std::io::Write;
pub const OFS_DELTA: u8 = 6;
pub const REF_DELTA: u8 = 7;
#[derive(Debug)]
struct CopyState {
offset: usize,
extent: usize
}
#[derive(Debug)]
struct InsertState {
extent: usize
}
#[derive(Debug)]
enum DeltaDecoderState {
NextCom... |
use std::collections::HashMap;
use std::ffi::{c_void, CStr, CString};
use std::path::Path;
use std::ptr;
use anyhow::{anyhow, bail, Result};
use libbpf_sys;
#[allow(dead_code)]
pub struct BPFLink {
ptr: *mut libbpf_sys::bpf_link,
}
pub struct BPFObj {
ptr: *mut libbpf_sys::bpf_object,
progs: Vec<BPFProg>... |
// Copyright 2021 <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 crate::error::{LayoutError, Error};
use crate::font::MathFont;
use crate::dimensions::*;
use crate::layout::{LayoutNode, LayoutVariant, Alignment, Style, LayoutSettings, Layout, Grid};
use crate::parser::{color::RGBA};
pub struct Renderer {
pub debug: bool,
}
#[derive(Copy, Clone, Default)]
pub struct Cursor ... |
//! Buffer Management.
//!
//! This module is mainly intended for use cases when the amount of space that
//! can be consumed by buffers needs to be defined at compile time. For most
//! users, the [`DefaultBuffers`] alias should be suitable.
//!
//! For most end users it is probably simpler to determine a "good enough... |
use camino::Utf8PathBuf;
use serde::{Deserialize, Serialize};
use std::sync::Mutex;
use tower_lsp::jsonrpc::*;
use tower_lsp::lsp_types::*;
use tower_lsp::{Client, LanguageServer, LspService, Server};
mod queries;
mod vfs;
mod workspace;
use workspace::VSCodeWorkspaces;
#[derive(Debug, Deserialize, Serialize)]
struc... |
#![doc(html_root_url = "https://dtolnay.github.io/syn")]
#![cfg_attr(feature = "cargo-clippy", allow(large_enum_variant))]
#[cfg(feature = "printing")]
extern crate quote;
#[cfg(feature = "parsing")]
extern crate unicode_xid;
#[cfg(feature = "parsing")]
#[macro_use]
extern crate synom;
#[cfg(feature = "aster")]
pu... |
//! Node handle.
use std::fmt;
use crate::{
low::v7400::AttributeValue,
tree::v7400::{NodeData, NodeId, NodeNameSym, Tree},
};
/// Node handle.
#[derive(Debug, Clone, Copy)]
pub struct NodeHandle<'a> {
/// The tree the node belongs to.
tree: &'a Tree,
/// Node ID.
node_id: NodeId,
}
impl<'a>... |
/***********************************************************************************************************************
* Copyright (c) 2020 by the authors
*
* Thanks to the help of https://users.rust-lang.org/u/krishnasannasi/summary at this post:
* https://users.rust-lang.org/t/request-feedback-on-an-implementat... |
mod contraint_size;
use std::cmp::Ordering;
pub use contraint_size::{SizeConstraint, WidgetExt};
use druid::{im::Vector, kurbo::Line, widget::prelude::*, WidgetPod};
type DynWidget<T> = WidgetPod<T, Box<dyn Widget<T>>>;
type WidgetMake<T> = Box<dyn Fn() -> DynWidget<T>>;
pub struct Table<T> {
cols: Vec<(Widget... |
extern crate env_logger;
use std::rc::Rc;
use super::*;
use term_color::*;
use rule::*;
#[derive(Debug,Clone)]
struct LayeredColors {
colors: Rc<Colors>,
back: Option<Box<LayeredColors>>,
}
impl LayeredColors {
fn new() -> LayeredColors {
LayeredColors {
colors: Rc::new(NO_COLORS.clo... |
//! Unary integers, to represent indices and lengths of lists.
//!
//! These are typelevel integers whose representation (in the type system)
//! can be thought of as just a bunch of tally lines:
//!
//! * `P0 = Zero`
//! * `P1 = Succ(Zero)`
//! * `P2 = Succ(Succ(Zero))`
//! * `P3 = Succ(Succ(Succ(Zero)))`
//! * `P4 = ... |
//! Generates remote Swift bindings for a given Flipper module.
//!
//! This mod makes use of the `handlebars` rust crate. There's
//! a `templates/swift.hbs` file which describes the layout of a
//! Swift module. To populate the template, we create serializable
//! representations of all the parameters and functions i... |
use crate::hal;
use hal::prelude::*;
use hal::pac;
use hal::pwr;
use hal::rcc;
use hal::time::Hertz;
use hal::time::MegaHertz;
// - constants ----------------------------------------------------------------
// SAI clock uses pll3
const PLL3_P: Hertz = Hertz(48_000 * 256);
// - types -------------------------------... |
use std::sync::{Arc};
use crate::{Id};
pub type Symbol = string_cache::DefaultAtom;
pub type Tuple = Arc<[Value]>;
macro_rules! impl_from {
($to:ty, $from:ty, $via:expr) => {
impl From<$from> for $to {
fn from(value: $from) -> $to { ($via)(value) }
}
}
}
#[derive(Debug, Clone, C... |
use crate::bba::idstring::*;
use crate::bels::*;
use crate::database::*;
use std::collections::{BTreeMap, BTreeSet, HashMap};
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Debug)]
pub enum BranchSide {
Left,
Right,
}
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Debug)]
pub enum Neighbour {
... |
/* Copyright 2020-2021 <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 ... |
use crate::*;
use near_sdk::Gas;
use near_sdk::utils::{is_promise_success};
/// Callback gas
pub const CALLBACK: Gas = Gas(25_000_000_000_000);
// This function supposedly be in internal.rs, but we're not using
// it anywhere so let's just put it here.
/// Converts royalty percentage and amount to pay into payout.... |
use std;
use std::ffi::CString;
use gl;
use gl::types::{GLint, GLuint};
use super::vertex::Attrib;
/// Encapsulates an OpenGL shader.
///
/// The shader may be a vertex or fragment shader.
pub struct Shader {
pub id: GLuint
}
impl Drop for Shader {
/// Deletes the shader (`glDeleteShader()`)
fn drop(&mut s... |
/**
* Copyright 2019-2020, <NAME> and the zenith contributors
*/
use serde_derive::{Deserialize, Serialize};
use std::borrow::Cow;
use std::collections::HashMap;
use std::fs;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::time::{Duration, SystemTime};
const ONE_WEEK: u64 = 60 * 60 * 24 * 7;
const DB_ER... |
//
// https://aomedia.org/av1-bitstream-and-decoding-process-specification/
//
use obu;
use obu::NUM_REF_FRAMES;
pub const INTRA_FRAME: usize = 0;
pub const LAST_FRAME: usize = 1;
pub const LAST2_FRAME: usize = 2;
pub const LAST3_FRAME: usize = 3;
pub const GOLDEN_FRAME: usize = 4;
pub const BWDREF_FRAME: usize = 5;
... |
use std::env;
use std::fs::File;
use std::str::FromStr;
use num::Complex;
use image::ColorType;
use image::png::PNGEncoder;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() != 5 {
eprintln!("Usage: {} FILE PIXELS UPPERLEFT LOWERRIGHT",
args[0]);
eprin... |
use core::intrinsics::size_of;
use crate::memory::{Frame, page_round_down, PAGE_SIZE, PHYSICAL_MEMORY, PhysicalAddress, VirtualAddress};
use crate::memory::layout::MAX_VA;
use crate::memory::page_table::{Level1, Level2, Level3, PageEntry, PageEntryFlags, PageTable};
pub struct Page {
number: usize,
}
impl Page {... |
//! A REPL (read–eval–print–loop) for an artichoke interpreter exposed by
//! the [`artichoke-backend`](artichoke_backend) crate.
//!
//! The REPL is readline enabled, but does not save history. The REPL supports
//! multi-line Ruby expressions, CTRL-C to break out of an expression, and can
//! inspect return values an... |
//! Aligned memory buffers for Direct IO.
use std::rt::heap;
use std::ptr;
use std::slice;
use buf::{RdBuf, WrBuf};
/// Allocate and manage buffers with fixed memory alignment.
///
/// This is intended to be used with Directio, which has such
/// requirements. The buffer has two sizes associated with it: the
/// actu... |
mod intcode;
use advent::prelude::*;
use intcode::{parse_program, State};
fn default_input() -> Vec<i64> {
parse_program(include_str!("input/07.txt"))
}
#[derive(Debug)]
struct Computer {
mem: Vec<i64>,
ptr: usize,
}
fn cast(num: i64) -> usize {
usize::try_from(num).unwrap()
}
impl Computer {
f... |
use crate::prelude::{ContextExtensions, HttpRequestExtensions};
use crate::privileges::repo_visibility::RepoVisibility;
use crate::user::WebUser;
use crate::{err, render_template};
use std::fmt::{Display, Formatter, Result as FmtResult};
use actix_web::{HttpRequest, Responder, web};
use anyhow::Result;
use derive_mor... |
use crate::collision::Collided;
use macroquad::prelude::*;
use serde::de::{self, Deserializer, MapAccess, Visitor};
use serde::ser::{SerializeStruct, Serializer};
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Debug)]
pub struct Bullet {
pos: Vec2,
vel: Vec2,
shot_at: f64,
size: f32,
c... |
use cfg::ast::AST;
use cfg::ast_search::ASTSearch;
use cfg::lang::Lang;
use serde_json::Value;
use std::fmt;
pub struct NounClause {
pub noun: String,
count: Option<String>,
pub adjective: Option<String>,
}
impl NounClause {
pub fn new(
noun: String,
count: Option<String>,
adje... |
//! System Controller driver.
use kernel::common::cells::OptionalCell;
use kernel::common::registers::{register_structs, ReadWrite};
use kernel::common::StaticRef;
use kernel::hil::time;
use kernel::hil::time::{Ticks, Ticks64, Time};
use kernel::ReturnCode;
/// 100Hz `Frequency`
#[derive(Debug)]
pub struct Freq100Hz;... |
use log::{trace, debug, info, warn, error}; // trace, debug, info, warn, error
use crate::util::RetType;
#[allow(dead_code)]
fn _get_rid_of_log_unused_import_warnings() {
trace!("Example trace.");
debug!("Example debug.");
info!("Example info.");
warn!("Example warn.");
error!("Example error.");
}
... |
mod ser_bots;
mod ser_resources;
mod ser_structures;
mod util;
mod world_events;
use caolo_sim::{
components::RoomComponent,
prelude::{Axial, Hexagon, TerrainComponent, World},
};
use std::collections::HashMap;
use std::sync::Arc;
use tokio::sync::{
broadcast::{error::RecvError, Sender},
mpsc,
};
use t... |
use std::collections::HashSet;
use std::process::{Command, Stdio};
use anyhow::{Context, Result};
use git2::{BranchType, Config, Reference, Repository};
use log::*;
use crate::config::get_remote;
use crate::remote_ref::get_fetch_remote_ref;
fn git(repo: &Repository, args: &[&str]) -> Result<()> {
let workdir = r... |
use wasm_bindgen::prelude::*;
use rand::*;
use std::collections::{BTreeSet, HashMap};
macro_rules! log {
( $( $t:tt)* ) => {
web_sys::console::log_1(&format!( $( $t )* ).into());
}
}
#[wasm_bindgen]
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Direction {
Up,
Down,
... |
use crate::env::Env;
use crate::error::RuntimeError;
use crate::val::{Callee, Object, Val};
use js_sys::{Function as JsFunction, Object as JsObject};
use std::any::Any;
use std::collections::VecDeque;
use std::fmt;
use wasm_bindgen::JsValue;
fn dq_to_jv(dq: &VecDeque<Val>, env: &Env) -> JsValue {
let all_chars = d... |
// Copyright 2020 <NAME>. See the LICENSE-MIT and
// LICENSE-APACHE files at the top-level directory of this
// distribution.
//
// 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>, ... |
use priority_queue::PriorityQueue;
use revord::RevOrd;
use std::collections::{btree_map, BTreeMap};
use std::usize;
use text_io::{scan, try_scan};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, Hash)]
struct Coord {
x: usize,
y: usize,
}
impl Coord {
fn new(x: usize, y: usize) -> Se... |
use std::cmp;
use utils::InputType;
fn main() {
let (grid, folds) = read_input(InputType::Input);
println!("Day13 part a = {}", part_a(&grid, &folds)); // 847
println!("Day13 part b = {}", part_b(&grid, &folds)); // BCZRCEAB
}
fn part_a(grid: &Vec<Vec<bool>>, folds: &Vec<Fold>) -> usize {
assert!(fold... |
// Copyright 2017 <NAME>. See the COPYRIGHT
// directory of this distribution.
//
// 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. This file may not be copied,... |
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
chained_bft::{
block_storage::BlockStore,
epoch_manager::EpochManager,
network::{NetworkReceivers, NetworkTask},
network_interface::{ConsensusNetworkEvents, ConsensusNetworkSender},
... |
//! PKCS#8 encoding/decoding support
use super::{SecretKey, SecretValue};
use crate::{
sec1::{self, UncompressedPointSize, UntaggedPointSize, ValidatePublicKey},
weierstrass, AlgorithmParameters, FieldBytes, Result, ALGORITHM_OID,
};
use core::ops::Add;
use generic_array::{typenum::U1, ArrayLength};
use pkcs8:... |
#[macro_use]
extern crate nom;
use std::cell::Cell;
use std::collections::HashMap;
use std::fs;
use nom::{
bytes::complete::tag,
character::complete::{alpha1, digit1},
combinator::map_res,
IResult,
};
#[derive(Debug, Eq, PartialEq)]
enum Input {
Value(u16),
Wire(String),
}
impl Input {
f... |
//! A web service for interactively exploring a state machine.
//!
//! 
//!
//! API summary:
//! - `GET /` returns a web browser UI as HTML.
//! - `GET /.states` returns available initial states and fingerprint... |
use crate::{app::HttpsClient, config::Builder, expression::*, prelude::*};
use futures::{future::*, Future};
use http::{
header::{HeaderMap, HeaderName, HeaderValue},
request::Builder as RequestBuilder,
Method, Request, Response, StatusCode,
};
use hyper::Body;
use serde::{Deserialize, Serialize};
use std::... |
use crate::mem_info::{MAX_SZ, MAX_SZ_IDX};
/// Contains information on the size of each block, the size of super block containing the blocks, the number of blocks in the superblock,
/// and the cache block number
pub struct SizeClassData {
pub block_size: u32,
pub sb_size: u32,
pub block_num: u32,
pub ... |
#![allow(proc_macro_derive_resolution_fallback)]
extern crate actix;
extern crate actix_net;
extern crate actix_web;
extern crate askama;
extern crate base64;
extern crate byteorder;
extern crate chrono;
#[macro_use] extern crate diesel;
#[macro_use] extern crate diesel_migrations;
extern crate env_logger;
#[macro_use... |
use hyper::{
body::to_bytes,
service::{make_service_fn, service_fn},
Body, Request, Server,
};
use route_recognizer::Params;
use router::Router;
use std::sync::Arc;
use hyper::server::conn::AddrStream;
use std::thread;
use std::time;
use std::env;
use drop_root::set_user_group;
//Globals ------------------... |
use float::Float;
#[cfg(not(feature = "std"))]
use num_traits::float::FloatCore;
use {Blend, ComponentWise};
use blend::{BlendFunction, PreAlpha};
///A pair of blending equations and corresponding parameters.
///
///The `Equations` type is similar to how blending works in OpenGL, where a
///blend function has can be ... |
// 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 ... |
//! Adds support for the IMAP IDLE command specificed in [RFC2177](https://tools.ietf.org/html/rfc2177).
use std::fmt;
use std::pin::Pin;
use std::time::Duration;
use async_std::io::{self, Read, Write};
use async_std::prelude::*;
use async_std::stream::Stream;
use futures::task::{Context, Poll};
use imap_proto::{Requ... |
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use prettytable::{cell, row, table, Table};
use wonnx::{
onnx::{GraphProto, ModelProto, NodeProto},
utils::{ScalarType, Shape},
WonnxError,
};
use crate::utils::ValueInfoProtoUtil;
fn dimensions_infos(graph_proto: &GraphProto) -> Result<HashMa... |
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::collections::HashSet;
use std::collections::HashMap;
struct Case {
test_pats: Vec<HashSet<char>>,
out_pats: Vec<HashSet<char>>,
}
impl Case {
fn solve(&self) -> isize {
// We have ten unique input patterns
// 1, 7, 4, and 8 have ... |
use std::collections::BTreeSet;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use std::time::Instant;
use futures::future;
use futures::task::SpawnExt;
use tracing_facade::trace_scoped;
fn progress_bar_style(task_count: usize) -> indicatif::ProgressStyle {
let task_count_digits = tas... |
/*
* Copyright (c) 2016 <NAME> <<EMAIL>>
*
* 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, pu... |
// Copyright 2022. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// di... |
use crate::common::Result;
use crate::table::format::BlockHandle;
use crate::table::InternalIterator;
#[derive(Default, Debug, Clone)]
pub struct TableProperties {
pub data_size: u64,
// the size of index block.
pub index_size: u64,
// Total number of index partitions if kTwoLevelIndexSearch is used
... |
use std::collections::LinkedList;
use ggez::{ GameResult, Context, graphics };
use super::food::Food;
use super::miscellaneous::{ Segment, GridPosition, Direction };
/// Here we define an enum of the possible things that the snake could have "eaten"
/// during an update of the game. It could have either eaten a piece ... |
use {
crate::error::*,
color_quant::NeuQuant,
image::{
imageops::{colorops, FilterType},
DynamicImage, GenericImageView, ImageBuffer, Pixel, Rgb,
},
libc::{
c_void, ioctl, poll, pollfd, read, tcgetattr, tcsetattr, termios, winsize, ECHO, ICANON,
POLLIN, STDIN_FILENO, ... |
// Copyright 2021 <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 writ... |
extern crate dynet;
extern crate rand;
use std::cmp::min;
use std::collections::HashMap;
use std::fs::File;
use std::io::{self, stdout, BufRead, BufReader, Write};
use std::path::Path;
use dynet::*;
use rand::{seq::SliceRandom, thread_rng};
#[derive(Debug)]
pub struct RNNLanguageModel<B> {
p_c: LookupParameter,
... |
use ark_ec::AffineCurve;
use ark_ff::Zero;
use bandersnatch::{EdwardsAffine, EdwardsProjective, Fr};
use crate::committer::Committer;
#[derive(Debug, Clone)]
pub struct PrecomputeLagrange {
inner: Vec<LagrangeTablePoints>,
num_points: usize,
}
impl<'a> Committer for &'a PrecomputeLagrange {
// If compute... |
mod page;
pub use self::page::Page;
use std::collections::BTreeMap;
use std::default::Default;
use std::env;
use std::str::FromStr;
use std::time::Duration;
use html5ever::tokenizer::BufferQueue;
use html5ever::tokenizer::Tokenizer;
use reqwest::header::{CONTENT_TYPE, USER_AGENT};
use reqwest::Client as HttpClient;
u... |
use crate::frame::select::Selection;
use crate::prelude::*;
use arrow::datatypes::SchemaRef;
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Clone, Debug)]
pub enum ScalarValue {
Null,
/// A binary true or false.
Boolean(bool),
/// A UTF8 encoded string type.
Utf8(String),
/// An unsigned 8-b... |
//! Structs representing the components within Zcash transactions.
use std::io::{self, Read, Write};
use super::{amount::Amount, GROTH_PROOF_SIZE};
// π_A + π_A' + π_B + π_B' + π_C + π_C' + π_K + π_H
const PHGR_PROOF_SIZE: usize = 33 + 33 + 65 + 33 + 33 + 33 + 33 + 33;
const ZC_NUM_JS_INPUTS: usize = 2;
const ZC_NU... |
use std::collections::{HashMap, HashSet};
use crate::{
api::{Context, Id, err::{ApiResult, invalid_input}},
db::types::Key,
prelude::*,
};
use super::{Realm, RealmOrder};
impl Realm {
pub(crate) async fn add(realm: NewRealm, context: &Context) -> ApiResult<Realm> {
let db = context.db(context... |
// Copyright 2019 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 anyhow::Error;
use carnelian::{
color::Color,
drawing::{load_font, measure_text_width, FontFace},
input::{self},
make_message,
scen... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.