text
stringlengths
8
4.13M
use friday_error::{FridayError, propagate, frierr}; use serde_json; use serde::Serialize; use serde::de::DeserializeOwned; pub mod core; pub mod server; pub mod webgui; pub mod path; pub mod endpoint; pub mod vendor; mod impl_tiny_http; mod tests; pub fn get_name( r: &mut dyn core::FridayRequest, endpoin...
use std::io::{self, Read, Write}; use std::net::{self, Shutdown, SocketAddr, ToSocketAddrs}; #[cfg(feature = "io_timeout")] use std::time::Duration; use crate::io as io_impl; use crate::io::net as net_impl; use crate::io::split_io::{SplitIo, SplitReader, SplitWriter}; #[cfg(unix)] use crate::io::sys::mod_socket; #[cfg...
#[cfg(feature = "normalize")] extern crate nalgebra; extern crate serial; #[cfg(feature = "normalize")] use nalgebra::*; use std::fs::{File, OpenOptions}; use std::str::FromStr; use std::error::Error; use std::fmt; use std::io::{BufRead, BufReader, Lines}; #[macro_use] mod calculus; use calculus::*; mod circbuf; ...
//! Generic vector with two components. use std::{cmp::Ord, ops::*}; /// Generic vector with two components. /// /// It implements multiple operators (for each combination of owned and borrowed /// args), namely addition, subtraction, element-wise multiplication, /// element-wise division and multiplication & divisio...
use super::button::Button; use serde::ser::{Serialize, Serializer, SerializeStruct}; use serde_json::Value; pub trait Card: Send + Sync { fn to_json(&self) -> Value; fn typed(&self) -> &'static str ; } #[derive(Clone)] pub struct DefaultAction { status: &'static str, url: String, //title: String, ...
use necsim_core_bond::{NonNegativeF64, PositiveF64}; use crate::{ cogs::{Habitat, LineageReference, LineageStore, RngCore}, landscape::{IndexedLocation, Location}, simulation::partial::emigration_exit::PartialSimulation, }; #[allow( clippy::inline_always, clippy::inline_fn_without_body, clippy...
extern crate chrono; extern crate dirs; mod routine; mod story; use routine::Routine; use story::Story; use std::fs::File; use std::fs; use chrono::prelude::*; fn main() { // load existing -> all in home directory // states -> empty, some let mut story = get_story().expect("Error in story"); let test_routine ...
/* Copyright 2021 Volt 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 Unless required by applicable la...
use winapi_safe::constants::*; use winapi_safe::*; const THRESH: i32 = 40; // Enumerate Windows Handler fn enum_handler(m_hwnd: HWND, o_hwnd: HWND, mut m_rect: RECT) -> i32 { // Ignore minimized windows. if let Ok(ret) = is_window_minimized(o_hwnd) { if ret == true { return 1; } ...
use crate::commands::osu::ProfileSize; use rosu_v2::prelude::{GameMode, Username}; use smallstr::SmallString; use smallvec::SmallVec; pub type Prefix = SmallString<[u8; 2]>; pub type Prefixes = SmallVec<[Prefix; 5]>; pub type Authorities = SmallVec<[u64; 4]>; #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[repr(u8)] ...
use sys; use bullet_vector3::BulletVector3; use collision::collision_shapes::Shape; use mint::{Vector3, Vector4}; #[repr(u8)] pub enum ActivationState { /// Means active so that the object having the state could be moved in a step simulation. /// This is the "normal" state for an object to be in. /// Use b...
use std::io; use std::fs; use std::cmp::Ordering; use std::collections::HashMap; use nom::bytes::complete::tag; use nom::character::complete::{digit1, space1, alpha1}; use nom::combinator::map; use nom::sequence::pair; use nom::multi::separated_nonempty_list; use nom::IResult; #[derive(Debug, Default, Clone)] struct I...
#![allow(clippy::needless_doctest_main)] //! This crate provides an easy way to extract data from HTML. //! //! [`HtmlExtractor`] is neither a parser nor a deserializer. //! It picks up only the desired data from HTML. //! //! [`html_extractor!`](macro.html_extractor.html) will help to implement [`HtmlExtractor`]. //! ...
//! Main optimization struct use std::cmp::Ordering; use crate::{ acquisition::ExpectedImprovement, kernels::RBF, lbfgs_opt::minimize, posterior::Laplace, DataPreferences, DataSamples, }; use anyhow::Result; use dialoguer::{theme::ColorfulTheme, Select}; use itertools::Itertools; use nalgebra::{Cholesky, DMat...
use crate::{ error::Error, graph::{remove_node_id, DepGraph, DependencyMap}, }; use crossbeam_channel::{Receiver, Sender}; use rayon::iter::{ plumbing::{bridge, Consumer, Producer, ProducerCallback, UnindexedConsumer}, IndexedParallelIterator, IntoParallelIterator, ParallelIterator, }; use std::cmp; u...
fn main() { let add_one = |n| n + 1; println!("{}", add_one(2)); }
use proconio::{fastout, input}; fn main() { input! { n: usize, m: usize, k: i64, a_vec: [i64; n], b_vec: [i64; m], } let mut a_acc_vec: Vec<i64> = Vec::new(); a_acc_vec.push(0); a_vec.iter().enumerate().for_each(|(i, a)| { a_acc_vec.push(a + a_acc_vec...
//! libsdp is a small utility library for parsing the sdp protocol. //! Mostly Intended for SIP user agents. extern crate nom; mod lines; pub use self::lines::{ SdpVersion, parse_version, parse_version_line, SdpSessionName, parse_session_name, parse_session_name_line, SdpOrigin, parse_origin, parse_origin...
#![doc = "generated by AutoRust 0.1.0"] #![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Account { #[serde(flatten)] pub tracked_resource: TrackedResource, #[serde(default, skip_serializing_if...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - DDRCTRL master register 0"] pub ddrctrl_mstr: DDRCTRL_MSTR, #[doc = "0x04 - DDRCTRL operating mode status register"] pub ddrctrl_stat: DDRCTRL_STAT, _reserved2: [u8; 8usize], #[doc = "0x10 - Mode Register Read/Write...
#![allow(clippy::let_unit_value)] mod auth; mod database; mod meal_plan; mod recipe; mod shopping_list; use async_trait::async_trait; use oikos_api::{models::*, server::OikosApi}; #[derive(Debug, thiserror::Error)] pub enum ServerError { #[error("recipe error")] RecipeError(#[from] recipe::RecipeError), ...
struct Solution; const CHAR_A_U8: u8 = 'a' as u8; impl Solution { pub fn partition_labels(s: String) -> Vec<i32> { let mut ans = Vec::new(); // 每个字母最后出现的位置。 let last_pos = s.chars().enumerate().fold([0; 26], |mut acc, (idx, c)| { acc[(c as u8 - CHAR_A_U8) as usize] = idx; ...
use std::sync::Arc; #[derive(Clone)] pub struct SharedVecSlice { pub data: Arc<Vec<u8>>, pub start: usize, pub len: usize, } impl SharedVecSlice { pub fn empty() -> SharedVecSlice { SharedVecSlice::new(Arc::new(Vec::new())) } pub fn new(data: Arc<Vec<u8>>) -> SharedVecSlice { ...
#[macro_use] extern crate quick_error; use intcode::Intcode; use std::borrow::Cow; use std::env; use std::io; use std::num::ParseIntError; quick_error! { #[derive(Debug)] pub enum SuperError { IoError(err: io::Error) { from() } ParseIntError(err: ParseIntError) { from() } } } fn main() -...
use wasm_bindgen::prelude::*; type DocumentId = u32; /// Modify the active Document in the editor state store #[wasm_bindgen] pub fn set_active_document(document_id: DocumentId) { todo!("set_active_document {}", document_id) } /// Query the name of a specific document #[wasm_bindgen] pub fn get_document_name(docume...
fn main(){ println!("Hello Rust!"); let x = 6; let y = 9; println!("x is {}, y is {}", x ,y); println!("x is {valx}, y is {fred}", valx=x , fred=y); // passing values println!("Debug {:?}", (3,4)); //Debug show what is in variable println!("y is {1}, x is {0}", x, y);// using index on variab...
use std::fmt; // possible boolean values #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct BoolDomain { pub tt: bool, pub ff: bool, } impl fmt::Display for BoolDomain { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match (self.tt, self.ff) { (true, t...
use anyhow::{anyhow, Result}; use byteorder::{ByteOrder, LittleEndian}; use secstr::SecUtf8; use std::ffi::OsStr; use std::iter::once; use std::mem::MaybeUninit; use std::os::windows::ffi::OsStrExt; use std::slice; use std::str; use winapi::shared::minwindef::FILETIME; use winapi::um::wincred::{ CredDeleteW, CredFree...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Interrupt mask register (EXTI_IMR)"] pub imr: IMR, #[doc = "0x04 - Event mask register (EXTI_EMR)"] pub emr: EMR, #[doc = "0x08 - Rising Trigger selection register (EXTI_RTSR)"] pub rtsr: RTSR, #[doc = "0x0c - F...
// Copyright 2019-2020 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) a...
use crate::*; use std::ops::Deref; use std::ops::{Index, IndexMut, Range}; const ARG_ARRAY_SIZE: usize = 8; #[derive(Debug, Clone)] pub struct Args { pub block: Option<MethodRef>, pub kw_arg: Option<Value>, elems: ArgsArray, } impl Args { pub fn new(len: usize) -> Self { Args { bl...
//! STM32L0x1 Clocks //! //! This module contains types representing the various clocks on the STM32L0x1, both internal and //! external. Each clock's type implements a `configure` method (not a trait impl) that configures //! the clock in the RCC peripheral. use crate::power; use crate::rcc; use crate::time::Hertz; ...
pub fn run() { let _arr1 = [1, 2, 3]; let _arr2 = _arr1; let vec1 = vec![1, 2, 3]; let vec2 = &vec1; println!("Values: {:?}", (&vec1, vec2)) }
use irc::client::Client; use irc::client::data::user::AccessLevel; use irc::proto::{Command, Message}; use std::str; use std::fs::File; use std::io::{BufRead, BufReader}; use std::collections::HashMap; use std::sync::Arc; use tokio::process; use async_recursion::async_recursion; use once_cell::sync::Lazy; use regex::Re...
/// CreateGPGKeyOption options create user GPG key #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct CreateGpgKeyOption { /// An armored GPG key to add pub armored_public_key: String, } impl CreateGpgKeyOption { /// Create a builder for this object. #[inline] pub fn builder() -> ...
use futures::{Async, Poll, Stream}; use std::clone::Clone; use std::sync::Arc; use std::sync::Mutex; use std::sync::MutexGuard; use crate::structs::EveError; pub struct StreamCopy<T, S: Stream<Item=T, Error=EveError>> { input: S, buffers: Vec<Vec<T>>, idx: usize, } pub struct StreamCopyMutex<T, S: Stream...
/// An enum to represent all characters in the BlockElements block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum BlockElements { /// \u{2580}: '▀' UpperHalfBlock, /// \u{2581}: '▁' LowerOneEighthBlock, /// \u{2582}: '▂' LowerOneQuarterBlock, /// \u{2583}: '▃' LowerThreeEi...
use std::os::raw::c_char; use std::slice; pub fn c_char_to_unsigned(slice: &[c_char]) -> &[u8] { let ptr = slice.as_ptr().cast::<u8>(); let len = slice.len(); unsafe { slice::from_raw_parts(ptr, len) } } pub fn unsigned_to_c_char(slice: &[u8]) -> &[c_char] { let ptr = slice.as_ptr().cast::<c_char>(); ...
use rayon::iter::plumbing::{ bridge_producer_consumer, Folder, Producer, ProducerCallback, Reducer, UnindexedConsumer, }; use rayon::prelude::*; pub struct ByBlocks<I, S> { pub(super) sizes: S, pub(super) base: I, } struct BlocksCallback<S, C> { sizes: S, consumer: C, len: usize, } impl<T, S,...
use serde::Deserialize; use serde::Serialize; use std::collections::HashMap; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum Asset { None, Signature { #[serde(rename = "publicKey")] public_key: String, }, Delegate { username...
use crate::geometry::{Rect, Size}; use num_traits::{AsPrimitive, Float, NumCast, PrimInt}; use std::ops; /// Defines a position in 2D cartesian coordinates. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] #[repr(C)] pub struct Point<T> { /// Distance from the left edge. pub x: T, /// Distance f...
use std::marker::PhantomData; pub trait Key { type Value; } pub struct RankKey<K>(PhantomData<K>); impl<K> Key for RankKey<K> { type Value = mpi::topology::Rank; }
pub mod window; pub mod renderer; pub mod widgets;
fn main() { let parsed: i32 = "5".parse().unwrap(); println!("parsed {:?}", parsed); }
pub fn problem_009() -> u64 { let n = 1000; for i in 0..n { for j in i..((n - 1) / 2) { let k = n - i - j; if i * i + j * j == k * k { return i * j * k; } } } 0 } #[cfg(test)] mod test { use super::*; use test::Bencher; ...
//tuples are collection of values that are different types pub fn tuple_fn(){ //tuple let city : (&str,i32,&str) = ("Belgrade",2000000,"Serbia"); println!("I live in {0} it is the capital of {2}, and {0} has {1} people living",city.0,city.1,city.2); }
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. pub fn serialize_structure_add_layer_version_permission_input( object: &mut smithy_json::serialize::JsonObjectWriter, input: &crate::input::AddLayerVersionPermissionInput, ) { if let Some(var_1) = &input.statement_id { ...
use std::option::Option; use crate::n_peekable::NPeekable; struct Scanner<'a> { line: i32, cur_lexeme: String, char_iter: NPeekable<'a> } impl<'a> Scanner<'a> { fn new(source: &'a str) -> Scanner { Scanner { line: 0, cur_lexeme: String::new(), char_iter: NPeekable::new(source) } } fn ...
pub enum ShellAction { // 退出命令行 Exit(i32), // 清屏 ClearHost, // 更换当前所在目录 ChangePath(String), // 输出一些内容 OutputResult(String), }
use crate::set::Set; use core::{iter::FromIterator, option}; #[derive(Debug, Clone, PartialEq, Eq)] pub enum SmallSet<A> { Singleton(A), Empty, } impl<A> Default for SmallSet<A> { fn default() -> Self { SmallSet::Empty } } impl<A> SmallSet<A> { pub fn into_option(self) -> Option<A> { ...
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use super::SstPartitionerResult; use crocksdb_ffi::{ self, DBSstPartitioner, DBSstPartitionerContext, DBSstPartitionerFactory, DBSstPartitionerRequest, }; use libc::{c_char, c_uchar, c_void, size_t}; use std::{ffi::CString, ptr, slice}; #[deri...
//! numbers and statistics types and methods use crate::qtable::Filter; use num::Float; use std::cmp::Ordering; use std::f64::NAN; /// f64 extensions trait pub trait F64Ext<T> { fn frmtf64(&self, sig: usize, nan: &str) -> String; fn frmtint(&self, nan: &str) -> String; } impl F64Ext<f64> for f64 { fn frm...
mod cli; mod tool; mod update; pub use tool::Tool; pub use cli::CommandLineInterface; fn main() { let tool = Tool::new() .name("e+") .help("Positron Project CLI") .tool(crate::update::tool()); CommandLineInterface::main(tool) }
use std::fmt::Debug; use crate::interaction::SurfaceInteraction; use super::Texture; #[derive(Debug)] pub struct ConstantTexture<T: Clone + Debug> { value: T, } impl<T: Clone + Debug> ConstantTexture<T> { pub fn new(value: impl Into<T>) -> Self { Self { value: value.into(), } ...
mod cli; mod help; use std::{ ffi::{CStr, CString, OsString}, fs::{File, Permissions}, io::{self, Read, Seek, Write}, os::unix::prelude::{MetadataExt, OsStringExt, PermissionsExt}, path::{Path, PathBuf}, process::Command, }; use crate::{ sudoers::Sudoers, system::{ can_execute,...
use std::{ collections::{HashMap, HashSet}, future::Future, sync::{Arc, Weak}, time::Duration, }; use bson::oid::ObjectId; use futures_util::{ stream::{FuturesUnordered, StreamExt}, FutureExt, }; use tokio::sync::{ mpsc::{self, UnboundedReceiver, UnboundedSender}, watch::{self, Ref}, };...
use std::env; use std::process; use common::load_file; use multiarray::Array2D; use std::collections::{HashMap, HashSet}; #[derive(Debug)] struct Coord { x: i32, y: i32, } impl Coord { fn dist(&self, other: Coord) -> i32 { (self.x - other.x).abs() + (self.y - other.y).abs() } } fn main() { ...
fn main() { // no i++ ++i // std::num::wrapping for overflow }
extern crate clap; use crate::build::BuildSystemBase; use clap::{App, Arg}; /// Entry point to generating Android.mk /// Creates a Androidmk struct from input which then allows you.. /// to read architectures supported, .so libraries and more pub fn read_input() -> BuildSystemBase { let matches = App::new("Generat...
use derive_more::Display; use diesel::result::{DatabaseErrorKind, Error as DBError}; use graphql_depth_limit::ExceedMaxDepth; use juniper::graphql_value; use std::convert::From; use validator::ValidationErrors; #[derive(Debug)] pub struct DuplicateErrorInfo { pub origin: String, pub info: String, } #[allow(de...
use serde::{Deserialize, Serialize}; use topology::provider; #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct MixProviderPresence { pub location: String, pub client_listener: String, pub mixnet_listener: String, pub pub_key: String, pub registered_client...
#[macro_use] extern crate log; #[macro_use] extern crate diesel; #[macro_use] extern crate validator_derive; #[macro_use] extern crate strum_macros; use diesel::pg::PgConnection; use diesel::r2d2::{ConnectionManager, Pool, PooledConnection}; use once_cell::sync::OnceCell; use warp::{self, http::Method, path, Filter...
use diesel::pg::PgConnection; use diesel::prelude::*; use dotenv::dotenv; use std::env; pub fn connection_without_transaction() -> PgConnection { dotenv().ok(); let connection_url = env::var("TEST_DATABASE_URL").expect("No test database url set"); PgConnection::establish(&connection_url).unwrap() } pub ...
// Licensed under the 2-Clause BSD license <LICENSE or // https://opensource.org/licenses/BSD-2-Clause>. This // file may not be copied, modified, or distributed // except according to those terms. use Operation; #[allow(missing_docs)] #[derive(Clone, Copy, Debug, PartialEq, PartialOrd)] #[repr(i32)] pub enum Instruc...
pub mod opa;
extern crate rustbox; use std::io::{BufReader, BufRead, Write, Error, ErrorKind, Result}; use std::net::TcpStream; use std::process::exit; use rustbox::{Color, RustBox, Event, Key}; struct Constraint { search_type: String, search_term: String, } impl Constraint { pub fn new(metadata_type: char ) -> Opti...
use std::fmt::{Display, Debug}; fn printer<T: Display>(t: T) { println!("{}", t); } struct S<T: Display>(T); trait HasArea { fn area(&self) -> f64; } #[derive(Debug)] struct Rectangle { length: f64, height: f64, } impl HasArea for Rectangle { fn area(&self) -> f64 { self.length * self....
/* * Slack Web API * * One way to interact with the Slack platform is its HTTP RPC-based Web API, a collection of methods requiring OAuth 2.0-based user, bot, or workspace tokens blessed with related OAuth scopes. * * The version of the OpenAPI document: 1.7.0 * * Generated by: https://openapi-generator.tech *...
// Copyright 2022 The Tari Project // SPDX-License-Identifier: BSD-3-Clause //! The robotic innards of a Diffie-Hellman key exchange (DHKE) producing a shared secret. //! Even though the result of a DHKE is the same type as a public key, it is typically treated as a secret value. //! To make this work more safely, we ...
extern crate serde_json; #[macro_use] extern crate serde_derive; use std::env; use std::fs; use std::io::{Write, Result}; use std::path::Path; #[derive(Deserialize, Debug)] struct ChromeDbgEvent { name: String, description: Option<String>, parameters: Option<Vec<ChromeDbgTypeDecl>>, experimental: Opt...
use optimized_square_free; #[no_mangle] pub extern "C" fn is_square_free(base: i32, exponent: i32, sub: i32) -> i32 { if optimized_square_free::is_square_free(optimized_square_free::convert_input(base, exponent, sub)) { 1_i32 } else { 0_i32 } } #[cfg(test)] mod tests { use super::is_squ...
// Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
//! Convenience re-export of common members //! //! Like the standard library's prelude, this module simplifies importing of //! common items such as traits. Unlike the standard prelude, the contents of //! this module must be imported manually. //! //! # Examples //! ```rust //! use chbs::{config::BasicConfig, prelude...
/// EditGitHookOption options when modifying one Git hook #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct EditGitHookOption { pub content: Option<String>, } impl EditGitHookOption { /// Create a builder for this object. #[inline] pub fn builder() -> EditGitHookOptionBuilder { ...
pub mod font; pub mod fullscreen_scroller; pub mod vertical_scroller; use ssd1963::{Bounds, Display}; use self::{font::MonoFont, fullscreen_scroller::FullscreenVerticalScroller, vertical_scroller::Scroller}; use core::{ convert::{TryFrom, TryInto}, ops::RangeBounds, }; // pub fn text_to_pixels<'a, 'font: 'a,...
use std::fs::File; use std::io::{BufRead, BufReader}; use std::io::prelude::*; // typedef struct { // char idlength; // char colourmaptype; // char datatypecode; // 2 // short int colourmaporigin; // short int colourmaplength; // char colourmapdepth; // short int x_origin; ...
fn main() { let i = 3;// lifetime starts { let borrow1 = &i;// starts borrow1 println!("borrow1: {}", borrow1); }// ends borrow1 { let borrow2 = &i;// starts borrow2 println!("borrow2: {}", borrow2); }// ends borrow2 }// lifetime ends
#[doc = "Register `DMASBMR` reader"] pub type R = crate::R<DMASBMR_SPEC>; #[doc = "Register `DMASBMR` writer"] pub type W = crate::W<DMASBMR_SPEC>; #[doc = "Field `FB` reader - Fixed Burst Length When this bit is set to 1, the AHB master will initiate burst transfers of specified length (INCRx or SINGLE). When this bit...
use crate::AtomicWaker; use std::cell::RefCell; use std::io::{Error, ErrorKind, Result}; use std::sync::atomic::{AtomicU8, AtomicUsize, Ordering}; use std::task::{Context, Poll}; use crate::ResponseData; use ds::RingSlice; use protocol::{Request, RequestId}; #[repr(u8)] #[derive(Clone, Copy)] pub enum ItemStatus { ...
use std; use rustc; // -*- rust -*- import core::{option, str, vec, result}; import result::{ok, err}; import std::{io, getopts}; import io::writer_util; import option::{some, none}; import getopts::{opt_present}; import rustc::driver::driver::*; import rustc::syntax::codemap; import rustc::driver::diagnostic; fn ver...
#![doc = "generated by AutoRust 0.1.0"] #![allow(unused_mut)] #![allow(unused_variables)] #![allow(unused_imports)] use super::{models, API_VERSION}; #[non_exhaustive] #[derive(Debug, thiserror :: Error)] #[allow(non_camel_case_types)] pub enum Error { #[error(transparent)] FileSystem_Mkdirs(#[from] file_system...
//! # 376. 摆动序列 //!https://leetcode-cn.com/problems/wiggle-subsequence/ //!如果连续数字之间的差严格地在正数和负数之间交替,则数字序列称为摆动序列。第一个差(如果存在的话)可能是正数或负数。少于两个元素的序列也是摆动序列。 //!例如, [1,7,4,9,2,5] 是一个摆动序列,因为差值 (6,-3,5,-7,3) 是正负交替出现的。相反, [1,4,7,2,5] 和 [1,7,4,5,5] 不是摆动序列,第一个序列是因为它的前两个差值都是正数,第二个序列是因为它的最后一个差值为零。 //!给定一个整数序列,返回作为摆动序列的最长子序列的长度。 通过从原始序...
pub mod random; pub mod metrics; pub mod cli;
mod repository; mod statistics; pub use repository::*; pub use statistics::*; use common::model::StringId; use common::result::Result; pub type PublicationId = StringId; use crate::domain::user::User; #[derive(Debug, Clone)] pub struct Publication { id: PublicationId, author: User, statistics: Statistic...
//! A simple Driver for the [Waveshare](https://github.com/waveshare/e-Paper) E-Ink Displays via SPI //! //! - Built using [`embedded-hal`] traits. //! - Graphics support is added through [`embedded-graphics`] //! //! [`embedded-graphics`]: https://docs.rs/embedded-graphics/ //! [`embedded-hal`]: https://docs.rs/embedd...
use itertools::Itertools; use std::collections::HashMap; use std::str::FromStr; fn main() -> std::io::Result<()> { let input = std::fs::read_to_string("examples/14/input.txt")?; let lines = input.lines().map(|line| line.parse::<Line>().unwrap()); let mut mask = vec![]; let mut memory: HashMap<usize, u64...
#![feature(panic_info_message)] #![feature(int_to_from_bytes)] extern crate chacha; extern crate rand; #[macro_use] extern crate serde_derive; extern crate serde; extern crate sha3; extern crate toml; pub mod config; pub mod connector; pub mod encryption; pub mod keyboard_and_clicks; pub mod keyboard_reset; pub mod m...
#![doc = "generated by AutoRust 0.1.0"] #![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Error { #[serde(default, skip_serializing_if = "Option::is_none")] pub code: Option<String>, #[serde(de...
use op; use regex; pub trait OpTransform { fn transform(&self, op: op::Op) -> op::Op; } pub struct NsFilterTransform { allowed_pattern: regex::Regex, } impl NsFilterTransform { pub fn new(patten: regex::Regex) -> NsFilterTransform { NsFilterTransform { allowed_pattern: patten } } } impl OpTr...
extern crate parallel_iterator; use parallel_iterator::ParallelIterator; fn do_some_work(i: u32) -> u32 { i + 1 // let's pretend this is a heavy calculation } fn main() { for i in ParallelIterator::new(|| (0u32..100), || do_some_work) { println!("Got a number: {}!", i); } }
use crate::glsl::{Glsl, GlslFragment, GlslLine}; use std::{ collections::HashMap, convert::{TryFrom, TryInto}, }; use syn::{spanned::Spanned, Block, Error, ExprBlock, Result}; use crate::{ yasl_ident::YaslIdent, yasl_stmt::YaslStmt, yasl_type::{Typed, YaslType}, }; #[derive(Debug)] pub struct Yasl...
use ::libc; use std::convert::TryInto; extern "C" { #[no_mangle] fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; #[no_mangle] fn memmove(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; } pub type uint8_t = _...
use cocoa::base::{id, nil}; use cocoa::foundation::NSUInteger; use sys::MTLRenderPassDescriptor; use {FromRaw, IntoRaw, RenderPassColorAttachmentDescriptor, RenderPassColorAttachmentDescriptorArray, RenderPassDepthAttachmentDescriptor, RenderPassStencilAttachmentDescriptor}; pub struct RenderPassDescriptor(i...
extern crate vulkano; extern crate vulkano_shaders; extern crate vulkano_win; extern crate winit; use clap::App; use clap::Arg; use kikansha::engine::State; use kikansha::figure::FigureMutation; use kikansha::figure::FigureSet; use kikansha::figure::RenderableMesh; use kikansha::scene::camera::StickyRotatingCamera; us...
use derive_more::{Deref, AsRef, From, Into}; use lazy_static::lazy_static; use regex::Regex; use serde::{Serialize, Deserialize}; use validator::Validate; use validator_derive::Validate; lazy_static! { pub static ref USERNAME_REGEX: Regex = Regex::new(r"(?i)^[a-z\d_-]*$").unwrap(); pub static ref PASSWORD_REGE...
mod patch; mod repo; mod tree; use std::path::Path; pub use repo::{GitCommit, GitRepo}; pub use tree::Tree; pub fn run_stat<P,F,S>( path: P, verbose: bool, commit_filter: F, mut stat: S, ) where P: AsRef<Path>, F: Fn(&GitCommit) -> bool, S: FnMut(&GitRepo, &GitCommit, &Tree, usize, usiz...
use super::*; pub fn fill(board: &mut Board, sudoku_content: String) { let sudoku_lines: Vec<_> = sudoku_content.lines().collect(); for x in 0..BOARD_WIDTH as usize { let row_text = sudoku_lines.get(x).unwrap_or(&""); let numbers: Vec<_> = row_text.split_whitespace().collect(); for y ...
use std::rc::Rc; use std::cell::RefCell; use super::curio::Curio; use super::hall::Hall; pub struct Room { pub name: String, pub contents: Vec<Curio>, pub halls: Vec<Rc<Hall>>, pub wumpus: bool, } impl PartialEq for Room { fn eq(&self, other: &Self) -> bool { self.name == other.name }...
use std::time::Duration; use crate::{ bson::{doc, Bson}, cmap::StreamDescription, coll::{options::DistinctOptions, Namespace}, error::ErrorKind, operation::{ test::{self, handle_response_test}, Distinct, Operation, }, }; #[test] fn build() { let field_name = "field_...
use async_trait::async_trait; use uuid::Uuid; use common::cache::Cache; use common::error::Error; use common::infrastructure::cache::InMemCache; use common::result::Result; use crate::domain::category::{Category, CategoryId, CategoryRepository}; use crate::mocks; pub struct InMemCategoryRepository { cache: InMem...