text
stringlengths
3.09k
13.9k
use std::collections::HashMap; use std::iter; use std::path::Path; use anyhow::Context; use anyhow::Result; use itertools::Itertools; use rust_htslib::bcf; use rust_htslib::bcf::Read; pub fn split<P: AsRef<Path>>(input_bcf: P, output_bcfs: &[P]) -> Result<()> { let info = BcfInfo::new(&input_bcf).context("error r...
// Generated from definition io.k8s.api.certificates.v1beta1.CertificateSigningRequestSpec /// This information is immutable after the request is created. Only the Request and Usages fields can be set on creation, other fields are derived by Kubernetes and cannot be modified by users. #[derive(Clone, Debug, Default, P...
// // Copyright (C) 2018 Kubos Corporation // // 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...
pub mod authorize; pub mod error; pub mod framework; pub mod helpers; pub mod migrations; pub mod resources; pub mod services; use self::{framework::middleware::authentication_middleware, resources::{authenticate::Authenticate, channels::Channels, ext::Ext, ...
use std::io::{self, prelude::Write}; use std::time::Duration; use super::OutputFormatter; use crate::{ console::{ConsoleTestState, OutputLocation}, test_result::TestResult, time, types::{TestDesc, TestType}, }; pub struct JunitFormatter<T> { out: OutputLocation<T>, results: Vec<(TestDesc, Test...
use crate::model::WeightLine; use crate::model::PlotType; use chrono::{Duration, NaiveDate, NaiveDateTime, Datelike}; use plotters::prelude::*; use std::f32; pub fn plot( data :&Vec<&WeightLine>, path :&str, title :&str, plot_type :PlotType) -> Result<(), Box<dyn std::error::Error>> { ...
#![allow(clippy::too_many_arguments)] //! Instruction types #[cfg(target_arch = "bpf")] use solana_sdk::program::invoke_signed; use solana_sdk::{ instruction::{AccountMeta, Instruction}, program_error::ProgramError, pubkey::Pubkey, }; use std::mem::size_of; /// fee rate as a ratio #[repr(C)] #[derive(Clo...
#![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; use alloc::vec::Vec; use core::fmt::Debug; use codec::{Decode, Encode}; use sp_core::U256; #[cfg(feature = "enable_serde")] use serde::{Deserialize, Serialize}; #[cfg(feature = "pruntime")] pub mod pruntime; // Messages: Phase Wallet #[derive(Encode, D...
// Copyright 2020-2021 The Datafuse Authors. // // SPDX-License-Identifier: Apache-2.0. use std::ops::Sub; use std::time::Duration; use common_exception::ErrorCode; use common_runtime::tokio; use common_tracing::init_tracing_with_file; use fuse_query::api::HttpService; use fuse_query::api::RpcService; use fuse_query:...
//! This module implements a SMB2 negotiate response. //! The SMB2 NEGOTIATE Response packet is sent by the server to notify the client of the preferred common dialect. //! This response is composed of an SMB2 header, followed by this response structure. use crate::smb2::helper_functions::{fields::SecurityMode, negoti...
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. // NOTE to all: use **cached** prepared statements when interfacing with SQLite. use deno_core::error::AnyError; use deno_core::include_js_files; use deno_core::op_sync; use deno_core::Extension; use deno_core::OpState; use rusqlite::params; u...
use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet, VecDeque}; const DIRECTIONS: &[(i32, i32); 4] = &[(0, 1), (0, -1), (-1, 0), (1, 0)]; struct Maze { cols: usize, array: Vec<u8>, portals: HashMap<(i32, i32), ((i32, i32), i32)>, start_location: (i32, i32), end_location:...
use anyhow::{bail, Context, Result}; use flate2::write::GzEncoder; use std::fs::{read_link, symlink_metadata}; use std::io::{self, empty, BufWriter, Write}; use std::path::Path; use tar::{Builder, Header}; use walkdir::WalkDir; use xz2::write::XzEncoder; use crate::util::*; actor! { #[derive(Debug)] pub struc...
// The RDATA of the NSEC RR is as shown below: // // 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // / Next Domain Name / // +-+-+-+-+-+-+-+...
// Copyright 2018 Developers of the Rand project. // Copyright 2016-2017 The Rust Project Developers. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your // option. Thi...
//! Misc HTML templates //! //! Various templates that do not belong to any of the other modules or //! are "top-level" such as the index and static route. //! //! Template contain the state of the page they relate to and are returned //! by a handler since they can be rendered to HTML. use crate::models::User; use cr...
#![allow(dead_code)] use std::fmt; use crate::{parse::Stmt, selector::Selector}; #[derive(Debug, Clone)] pub(crate) struct MediaRule { pub super_selector: Selector, pub query: String, pub body: Vec<Stmt>, } #[derive(Clone, Debug, Eq, PartialEq, Hash)] pub(crate) struct MediaQuery { /// The modifier, ...
// 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 anyhow::{format_err, Result}; use bitfield::bitfield; use fidl::encoding::Decodable; use fidl_fuchsia_media::*; use std::{convert::TryInto, fs, io, path...
use std::{ fmt::{self, Display, Write}, rc::Rc, }; use gc::{Finalize, Gc, GcCell}; use crate::{ast::Lambda, util::ShowSlice, vm::Env}; // Note that currently, this type is designed to be two machine words on a // 64-bit architecture. The size should be one machine word on both 32-bit and // 64-bit architectu...
use boolinator::Boolinator; use iter_enum::Iterator; use or_iterator::OrIterator; use serde::Serialize; use std::fmt::Debug; use std::iter::once; use std::rc::Rc; use thiserror::Error as ThisError; use sqlparser::ast::{Ident, Join as AstJoin, JoinConstraint, JoinOperator}; use super::context::{BlendContext, FilterCon...
use std::io::BufRead; use std::str::FromStr; fn main() { println!("{}", find_max_y_for_probe(std::io::stdin().lock())); println!("SIMULATIONS={}", unsafe { SIMULATIONS }); } fn find_max_y_for_probe(buffer: impl BufRead) -> i64 { let line = buffer.lines().next().unwrap().unwrap(); let (x_area_str, y_ar...
// 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_inspect::{Node, NumericProperty as _, Property as _, UintProperty}, fuchsia_inspect_contrib::inspectable::InspectableU64, std::co...
pub mod lir_unary; pub mod mir; pub mod mir_quant; pub mod mir_quant_unary; pub mod mir_unary; pub mod pack; use crate::internal::*; use tract_itertools::Itertools; use tract_linalg::mmm::FusedSpec; use tract_ndarray::prelude::*; pub use self::mir::MatMul; pub use self::mir_quant::{MatMulQParams, QMatMul}; pub use se...
// Copyright 2020 Google and The HuggingFace Inc. team. // 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 r...
use super::*; use std::sync::atomic::{AtomicU64, Ordering}; /// A Kompact lifecycle event /// /// Lifecycle events are produced by the Kompact system in response to certain API calls, /// such as [start](KompactSystem::start), for example. /// /// Lifecyle events are handled in a [ControlPort](ControlPort) handler, w...
use crate::fields::Scanner; use regex::Regex; use std::collections::HashMap; use std::collections::HashSet; use std::iter::FromIterator; //tag::create_bingo_boards[] pub fn create_scanners(data: &Vec<String>) -> std::io::Result<Vec<Scanner>> { let l = data.len(); let re = Regex::new(r"^---\sscanner\s\d+...
//! Unstable non-standard Wasmer-specific API that contains more WASI //! API. use super::super::{ externals::wasm_extern_t, module::wasm_module_t, store::wasm_store_t, types::wasm_name_t, wasi::wasi_env_t, }; use crate::error::CApiError; use wasmer::Extern; use wasmer_wasi::{generate_import_object_from_env, g...
use std::thread; use std::sync::mpsc; // library of matrix and vector functions // a 3 component vector pub struct Vec3{ pub x: f32, pub y: f32, pub z: f32 } // associated functions of Vec3 impl Vec3{ // used for constructing Vec3 nicely pub fn new(x:f32,y:f32,z:f32) -> Vec3 { Vec3{x: x, y...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Control"] pub ctrl: CTRL, _reserved1: [u8; 3usize], #[doc = "0x04 - Channel"] pub channel: CHANNEL, #[doc = "0x08 - User Multiplexer"] pub user: USER, _reserved3: [u8; 2usize], #[doc = "0x0c - Channel St...
use crate::{components::icons::*, router::Auth}; use yew::prelude::*; #[derive(Debug, Default, Clone)] struct MusicIndex { catalog: String, track_number: u8, } #[derive(Debug, Clone)] struct Playlist(Vec<MusicIndex>); impl Playlist { fn get(&self, index: usize) -> Option<MusicIndex> { if index >=...
use bars_duration_ticks; use conrod_core::{self as conrod, widget, Colorable, Positionable}; use ruler; use std; use time_calc as time; use track; /// A track used for drawing the #[derive(WidgetCommon)] pub struct Ruler<'a> { #[conrod(common_builder)] common: widget::CommonBuilder, ruler: ruler::Ruler, ...
use std::collections::HashMap; use std::str::FromStr; use std::marker::PhantomData; #[derive(Debug, Fail)] pub enum VirusError { #[fail(display = "Failure to parse cluster: {}", _0)] ParseError(String), } #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum Infection { Clean, Weakened, Infected, Flagged, } #[...
// 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::message_stream::{MessageStream, TransitionToRead}; use crate::messages; use crate::messages::*; use crate::options::*; use anyhow::*; use std::fs::File; use std::io::{Read, Write}; use std::net::{TcpListener, TcpStream}; use std::os::unix::fs::PermissionsExt; use std::process::{Child, Command, Stdio}; use st...
use crate::{peeking_take_while::PeekableExt, Error}; use proc_macro::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; use std::{ iter::Peekable, str::{Chars, FromStr}, }; /// Simulate a const block, ensuring that the value will be computed at compile-time. pub(crate) fn const_block(valu...
use crate::{Error, Result}; use libc::{c_char, c_void, free, malloc, memset}; use std::{ ffi::{CStr, CString}, mem, ptr::NonNull, }; /// A helper to read C string pub struct StringReader { buf: Vec<i8>, } impl StringReader { /// Create a new reader /// /// # Arguments /// /// * max...
use super::{expression::*, helpers::*, parse::*, types::*}; use crate::{ ast::{expr::*, stmt::*}, expect, expect_one, match_then_consume, match_then_consume_stmt, peek_matches, token::*, }; use std::vec; #[inline(always)] pub fn print_statement(tokens: ParserIter) -> Result<Option<Stmt>, ParseError> { let st...
use std::{ cell::RefCell, future::Future, mem::{self}, pin::Pin, rc::{Rc, Weak}, sync::atomic::{AtomicUsize, Ordering}, }; use anyhow::{anyhow, Context as _}; use api::{Api, StartWsApi, StartWsError, StartWsRequest, WsResult}; use futures::{ stream::{SplitSink, SplitStream, TakeUntil}, ...
use std::io; use std::path::PathBuf; use std::sync::Arc; use itertools::Itertools; use filemap::{FileMap, FileName}; use index::{ByteIndex, ByteOffset, RawIndex}; #[derive(Clone, Debug, Default)] #[cfg_attr(feature = "serialization", derive(Deserialize, Serialize))] pub struct CodeMap { files: Vec<Arc<FileMap>>,...
// Copyright (c) Calibra Research // SPDX-License-Identifier: Apache-2.0 use std::{ cmp::{max, min}, collections::hash_map::DefaultHasher, hash::{Hash, Hasher}, }; use super::*; use record_store::*; #[cfg(test)] #[path = "unit_tests/pacemaker_tests.rs"] mod pacemaker_tests; // -- BEGIN FILE pacemaker_up...
use crate::{ TARGET, db_impl_serializable, db::traits::KvcWriteable, node_state_db::NodeStateDb, traits::Serializable, types::{BlockHandle, BlockMeta} }; use adnl::common::{add_object_to_map, add_object_to_map_with_update}; use std::{io::Cursor, sync::{Arc, Weak}}; use ton_block::BlockIdExt; use ton_types::{er...
//---------------------------------------------------------------------------// // Copyright (c) 2017-2019 <NAME>. All rights reserved. // // This file is part of the Rusted PackFile Manager (RPFM) project, // which can be found here: https://github.com/Frodo45127/rpfm. // // This file is licensed under the MIT licen...
use std::cell::RefCell; use std::f64; use std::fmt; use std::rc::Rc; use std::str::FromStr; use crate::object::Object; #[derive(Clone)] pub enum JSValue { Boolean(bool), Number(f64), String(String), Object(Rc<RefCell<Object>>), NativeFunction(fn(JSValue, &[JSValue]) -> JSValue), Undefined, ...
use crate::games_enum::SupportedGames; use crate::platform::Platform; use crate::profile::SensProfile; use crate::steam_folder::SteamFolders; use serde::{Deserialize, Serialize}; use std::fs; use std::fs::File; use std::io; use std::io::{Read, Write}; use std::path::Path; extern crate dirs; #[derive(Serialize, Deseri...
use std::fs::File; use std::io::BufReader; use anyhow::Result; const DAY: &str = "xx"; fn main() -> Result<()> { println!("----- Advent of Code -- Day {} -----", DAY); println!("--------------------------------------"); println!(); let input_file = File::open("input.txt")?; let buf_reader = Bu...
// Copyright 2021 Cargill Incorporated // // 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 agre...
use crate::database::{ entity::{self, prelude::*}, repo_queries::{RepoParam, RepoQueries}, DbResult, PostgresDatabase, }; use async_trait::async_trait; use sea_orm::{entity::*, query::*}; use std::collections::BTreeMap; use tracing::info; use tracing_attributes::instrument; pub mod models { use crate::...
//! Decorate content and apply alignment. use crate::alignment::{self, Alignment}; use crate::event::{self, Event}; use crate::layout; use crate::mouse; use crate::overlay; use crate::renderer; use crate::{ Background, Clipboard, Color, Element, Layout, Length, Padding, Point, Rectangle, Shell, Widget, }; use ...
use std::ops::{Add,Sub,Mul}; use std::io; use std::io::Write; use std::fs::File; use crate::maths; #[derive(Debug,Clone,Copy)] pub struct Colour { pub red: f64, pub green: f64, pub blue: f64, } pub struct Canvas { width: usize, height: usize, pixels: Vec<Colour>, } impl PartialEq for Colour {...
// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 // // Contains modifications by MobileCoin. /*! `ServiceMetrics` is a metric [`Collector`](prometheus::core::Collector) to capture key metrics about a gRPC server. For each method, the counters that are captured are: - num_req: number...
use csv::Reader; fn build_table_header(reader: &mut Reader<&[u8]>) -> Result<Node, csv::Error> { let mut thead = Node::from("thead"); let mut title_row = Node::from("tr"); // Task 1: // - iterate csv headers // - create cells for the html table header with <td> // - set the csv ...
//! This module implements a serial port based tty. //! This is a bit different from the other implementations in that //! we cannot explicitly spawn a process into the serial connection, //! so we can only use a `CommandBuilder::new_default_prog` with the //! `openpty` method. //! On most (all?) systems, attempting to...
use std::fs; fn main() { let filename = "input.txt"; let contents = fs::read_to_string(filename).expect(&format!("could not read {}", filename)); let lines: Vec<&str> = contents.lines().collect(); println!("part1 is {}", part1(&lines)); println!("part2 is {}", part2(&lines)); } fn part1(lines: &[&...
// FIXME: Remove this attribute once false positive is resolved. #![allow(unused_parens)] // conditionally allow deprecated items to allow using the // "deprecated" table! macro #![cfg_attr( any(feature = "huge-tables", feature = "large-tables"), allow(deprecated) )] use super::backend::{FailedToLookupTypeErro...
/******************************************************************************* * (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 std::fmt; use crate::{atom, Data, Tag}; /// A list of standard genre codes and values found in the `gnre` atom. The codes are equivalent to /// the ID3v1 genre codes plus 1. pub const STANDARD_GENRES: [&str; 80] = [ "Blues", "Classic rock", "Country", "Dance", "Disco", "Funk", "Grunge"...
// @author :: <NAME>-Stosur-Bassett <http://stosur.info> // @date :: December 8, 2017 // @description :: This file takes pinyin with tone numbers and returns pinyin with tone marks //! ### About //! Turn pinyin written with tone numbers and turn it into pinyin with node marks. prettify_pinyin accepts in...
// light use std::fmt; use rand::Rng; use super::*; use super::algebra::*; use super::geometry::*; use super::optics::*; use super::physics::*; use super::surface::*; pub type Flux = Flt; #[derive(Debug, Clone, Copy, PartialEq)] pub enum Light { PointLight { color: Color, flux: Flux, pos: Position3 ...
mod identifier; mod illegal; mod number; mod operator; mod punctuation; mod reserved; mod string; use crate::token::*; use identifier::*; use illegal::*; use nom::branch::alt; use nom::character::complete::multispace0; use nom::combinator::into; use nom::sequence::delimited; use nom::IResult; use number::*; use operat...
use anyhow::{format_err, Context, Result}; use lazy_static::lazy_static; use log::{debug, error}; use std::{convert::TryFrom, env, path::PathBuf, str::FromStr}; const CLIENT_PATH: &str = "CLIENT_PATH"; const STATIC_PATH: &str = "STATIC_PATH"; lazy_static! { pub(crate) static ref FAVICON: String = file_from_env_or...
extern crate bitstream_io; use bitstream_io::huffman::{compile_read_tree, compile_write_tree, HuffmanTreeError}; #[tokio::test] async fn test_huffman_errors() { use bitstream_io::BE; let empty: Vec<(i32, Vec<u8>)> = Vec::new(); assert!(if let Err(err) = compile_read_tree::<BE, i32>(empty) { err ==...
use chrono::{Duration, Local, TimeZone}; use std::fs; pub struct VoltcraftData { raw_data: Vec<u8>, } #[derive(Debug, Copy, Clone)] pub struct PowerEvent { pub timestamp: chrono::DateTime<Local>, // timestamp pub voltage: f64, // volts pub current: f64, // am...
use libc::c_uint; use llvm::LLVMRealPredicate; use llvm::core::{ LLVMBuildAdd, LLVMBuildBr, LLVMBuildCall, LLVMBuildCondBr, LLVMBuildFAdd, LLVMBuildFCmp, LLVMBuildFMul, LLVMBuildFSub, LLVMBuildMul, LLVMBuildPhi, LLVMBuildRet, LLVMBuildRetVoid, LLVMBuildSub, LLVMB...
use std::future::Future; use std::mem; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use std::time::Instant; use bytes::Bytes; use futures::Stream; use std::result::Result as StdResult; use thiserror::Error; use tokio::sync::mpsc; use super::errors::QueryError; use crate::cql_to_rust::{FromRo...
// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{adapter::Adapter, FileHandle}; use anyhow::{bail, Result}; use async_trait::async_trait; use bytes::{Bytes, BytesMut}; use futures::{stream, stream::TryStreamExt}; use libra_crypto::HashValue; use libra_types::{account_stat...
use anyhow::{anyhow, Result}; use glib::{object_subclass, wrapper}; use gtk::{prelude::*, subclass::prelude::*}; use std::{cell::RefCell, str::FromStr}; use yuck::value::NumWithUnit; use crate::error_handling_ctx; wrapper! { pub struct Transform(ObjectSubclass<TransformPriv>) @extends gtk::Bin, gtk::Container...
#[allow(unused_imports)] use crate::winapi::*; use crate::utils::*; use std::io; use std::mem::{self, MaybeUninit}; use std::ffi::OsString; use std::os::windows::ffi::OsStringExt; pub type ProcessHandle = HANDLE; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Process { pub pid: u32, pub name: String, ...
use crate::imp::structs::var_type::VarType; use crate::imp::structs::rust_value::RustMemberType; use crate::imp::structs::list_value::ListDefValue; use crate::imp::structs::list_def_obj::ListDefObj; use crate::imp::structs::root_obj::RootObject; use crate::imp::structs::root_value::RootValue; use crate::imp::intf::tabl...
// Copyright (c) 2018-2022 Ministerio de Fomento // Instituto de Ciencias de la Construcción Eduardo Torroja (IETcc-CSIC) // 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 ...
use crate::camera::Camera; use crate::context::Context; use gfx_hal::Backend; use gfx_hal::Device; use gfx_hal::Instance; use vek::geom::FrustumPlanes; use vek::mat::Mat4; use vek::vec::Vec3; use winit::VirtualKeyCode; use crate::allocator::GpuAllocator; /// This camera implements the Camera trait. This camera needs t...
use crate::errors::Error; use crate::expr::ToExpr; use crate::instance::ToInstance; use crate::loc::attr_from_loc; use crate::loc::{Bel, BelReg, ExprCoord, Loc}; use crate::param::Param; use crate::port::{ConnectionMap, DefaultPort, Port, WidthMap}; use crate::{create_literal, inst_name_try_from_instr, vec_expr_try_fro...
//! # GEDCOM X //! GEDCOM X defines an open data model and an open serialization format for //! exchanging the genealogical data essential to the genealogical research //! process. Examples of these data include information about persons, the //! relationships between persons, and the records that support that //! info...
pub struct Token { pub tipo: TokenType, pub data: String, } impl Token { pub fn new(tipo: TokenType, data: String) -> Token { Token { tipo, data } } } pub enum TokenType { Cond, Exp, Var, Default, } pub struct Parser {} impl Parser { pub fn evaluar_numeros(string: &mut S...
use std::sync::Arc; use futures::lock::Mutex; use log::debug; use serde_json::json; use crate::{ accessory::HapAccessory, characteristic::Perm, pointer, transport::http::{ReadResponseObject, Status, WriteObject, WriteResponseObject}, Error, Result, }; /// `AccessoryDatabase` is a wrapper type...
use chrono::{NaiveDate, Datelike, Weekday}; use computus; fn easter_ordinal(y: i32) -> u32 { let easter = computus::gregorian(y).expect("computus error"); NaiveDate::from_ymd(y, easter.month, easter.day).ordinal() } pub fn is_bankholiday<T: Datelike>(date: &T) -> bool { let day = date.weekday(); let ...
//! Nitro containers. //! //! A Nitro container holds... well, subcontainers, but inside of _those_ are //! the model, texture, or animation files. A Nitro container is recognized by //! an identifying stamp: eg. b"BMD0". The subcontainers also contain a stamp //! eg. b"MDL0". An MDL0 contains models, a TEX0 contains t...
use cargo::core::{ PackageSet, PackageId, registry::PackageRegistry, resolver::{EncodableResolve, Method, Resolve}, Workspace }; use cargo::ops; use cargo::util::{errors::CargoResult, important_paths::find_root_manifest_for_wd, toml}; use cargo::Config; use core::Session; use nameres::RUST_SRC_PATH; use std::co...
// Copyright 2021 <NAME> <<EMAIL>> // // This file is part of lcpc-brakedown-pc, which is part of lcpc. // // Licensed under the Apache License, Version 2.0 (see // LICENSE or https://www.apache.org/licenses/LICENSE-2.0). // This file may not be copied, modified, or distributed // except according to those terms. /*! ...
use std::vec; use std::num::ParseIntError; use std::collections::HashMap; use anyhow::{Result, anyhow, bail, Context}; use crate::puzzle::Puzzle; #[derive(Clone, Default)] struct MessageRules { max_rule_idx: u16, term: HashMap<u16, Vec<char>>, one: HashMap<u16, Vec<u16>>, two: HashMap<u16, Vec<(u16, ...
// Adapted from jsdom/whatwg-mimetype: // // - https://github.com/hyperium/mime/blob/8b04bcac22bb687b57704a7121b8c2765ed2dcaa/src/parse.rs // - https://github.com/jsdom/whatwg-mimetype/blob/98408de520084336b4b17ec196a311e71d53e8e4/lib/parser.js use omnom::prelude::*; use std::collections::HashMap; use std::io::prelude...
use core::nonzero::NonZero; use std::mem::transmute; use std::ptr::Unique; use intrusive_collections::{IntrusivePointer, RBTree, UnsafeRef, Bound}; use util::{Uninitialized, Initializable, Foam, Span, AllocSat}; use layout::Markmap; use arena::ArenaAllocator; use descriptor::{Descriptor, MSBlock, LargeObjRope, FreeRop...
use dominator::{Dom, EventOptions, clone, html}; use super::super::menu::{dom as MenuDom, state::State as MenuState}; use super::{actions, state::*}; use crate::edit::sidebar::state::State as SidebarState; use components::module::_common::thumbnail::ModuleThumbnail; use futures_signals::signal::SignalExt; use shared::...
pub(super) fn run() -> Result<(), super::Error> { let (graph, shiny_gold_node_index) = parse(super::read_input_lines::<String>("day7")?)?; { let result = part1(&graph, shiny_gold_node_index); println!("7a: {}", result); assert_eq!(result, 164); } { let result = part2(&graph, shiny_gold_node_index); p...
use chrono::NaiveDateTime; use crate::model::{ common::{SelfId, SelfIdString, Validator}, errors::ResError, }; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct User { pub id: u32, pub username: String, pub email: String, pub hashed_password: String, pub avatar_url: String, pu...
use std::collections::HashMap; use std::error; use std::fs::File; use std::io::Read; type Result<T> = std::result::Result<T, Box<dyn error::Error>>; fn main() -> Result<()> { let contents = get_contents("input"); let contents = contents.trim(); let mut inputs = vec![2]; dbg!(run_program(contents, &mu...
use test_case::test_case; use std::sync::Arc; use super::{Graph, Node, Node::*, StartEdge, Edge}; fn s(string: &str) -> String { String::from(string) } fn a<T>(value: T) -> Arc<T> { Arc::new(value) } fn are_equail_unordered<T: Eq>(actual: &[T], expected: &[T]) -> bool { actual.len() == expected.len() && actual...
use btleplug::{ api::{ bleuuid::uuid_from_u16, Central, CentralEvent, Manager as _, Peripheral as _, ScanFilter, WriteType, }, platform::Manager, }; use color_thief::get_palette; use dxgcap::DXGIManager; use futures::stream::StreamExt; use glam::*; use image::{ imageops::FilterType, DynamicImage::{se...
//! Display an interactive selector of a single value from a range of values. use crate::widget::tree::{self, Tree}; use crate::{Element, Widget}; use iced_native::event::{self, Event}; use iced_native::layout; use iced_native::mouse; use iced_native::renderer; use iced_native::widget::slider; use iced_native::{Clipbo...
use math::FractalPoint; use palette::{Hsv, rgb::Srgb}; pub trait ColorTransformation { fn determine_color_hsv(&self, point: &FractalPoint, max_iters: usize) -> (f32, f32, f32); fn determine_color(&self, point: &FractalPoint, max_iters: usize) -> (u8, u8, u8) { return hsv_to_rgb(self.determine_color_h...
use crate::{ commands::Command, error::Error, types::{Address, HeatingDuration, HeatingPower, Measurement, Precision, SensorData}, }; use core::marker::PhantomData; use embedded_hal::blocking::{ delay::DelayMs, i2c::{Read, Write, WriteRead}, }; use sensirion_i2c::i2c; const RESPONSE_LEN: usize = 6;...
/*! Gory decoder details. */ use super::CharSet; use super::super::Chunk; use ::core::ops; //---------------------------------------------------------------- // Iterate over chunks by value #[derive(Clone, Debug, Eq, PartialEq)] pub struct ChunkVal { chars: [char; 4], len: u32, } impl Chunk for ChunkVal { fn len...
use super::*; use core::ptr::{NonNull, drop_in_place}; /// A chunked doubly-linked list. Efficient for the following operations: /// /// * In-order chunked traversal and consumption /// * Append (at tail) /// * Pop (at tail) /// /// Allows you to plug in your own allocator via closures so you can /// use a custom a...
use std::path::PathBuf; use std::time::SystemTime; use std::fs; use std::sync::{Arc, Mutex}; use async_trait::async_trait; use bytes::Bytes; use reqwest::Client; use indicatif::{ProgressBar, ProgressStyle}; use super::Environment; use super::super::types::ErrBox; // use a macro here so the expression provided is only...
use andiskaz::{ color::{BasicColor, Color, Color2}, coord::{Coord, Vec2}, emergency_restore, error::Error, event::{Event, Key, KeyEvent, ResizeEvent}, screen::{Screen, Tile}, string::{TermGrapheme, TermString}, style::Style, terminal, terminal::Terminal, tstring, }; use std::...
use crate::{ rite::{contents, render_error, ContentGetError, Document}, State, }; use http_types::{mime, StatusCode}; use indexmap::IndexMap; use serde::Deserialize; use sqlx::{query::QueryAs, sqlite::SqliteArguments, Sqlite}; use tide::{Redirect, Request, Response}; use tide_tera::{context, TideTeraExt}; use u...
use serde_json; use cabot::{RequestBuilder, Client}; use url::form_urlencoded::Serializer as URLSerializer; use super::super::results::{BearerResult, BearerError}; use super::super::config::{Tokens, ClientRef}; #[derive(Deserialize)] pub struct JsonToken { pub access_token: String, pub expires_in: Option<us...
use std::collections::{HashMap, HashSet}; // Given various subsequences of an array of unique integers, reconstruct the original array: // // Example: [1, 3, 5], [1, 3, 9], [9, 5] // Output : [1, 3, 9, 5] // // There may be multiple valid reconstructions of the original array. Return a valid reconstruction. // // Exam...
use crate::config::{BrainConfig, Config}; use crate::stats::Stats; use markov::Markov; use hashbrown::HashMap; use indicatif::{ProgressBar, ProgressStyle}; use tokio::{fs::File, io::BufReader}; use {futures::prelude::*, tokio::prelude::*}; use std::path::{Path, PathBuf}; use std::sync::mpsc::Receiver; use std::time::...
use ctap_hid_fido2; use ctap_hid_fido2::public_key_credential_descriptor::PublicKeyCredentialDescriptor; use ctap_hid_fido2::public_key_credential_user_entity::PublicKeyCredentialUserEntity; use ctap_hid_fido2::util; use ctap_hid_fido2::Key; use ctap_hid_fido2::InfoParam; extern crate clap; use clap::{App, Arg}; fn me...
#[derive(Debug)] pub(crate) struct Logs { interfaces: std::collections::BTreeSet<String>, inner: [Option<Log>; 10], // Index of the newest log. Moves backwards as new logs are pushed. head: usize, previous_digest: Option<String>, } impl Logs { pub(crate) fn new(interfaces: impl IntoIterator<Item = String>) ->...