text
stringlengths
8
4.13M
#![feature(concat_idents)] #![feature(type_ascription)] extern crate homotopy; extern crate underscore_args; extern crate vecmath; extern crate image; pub mod utils; use homotopy::*; use underscore_args::args; use utils::render::*; use utils::math::*; fn main() { let n = 10; for i in 0..n { let fx =...
use std::process::Command; use anyhow::{anyhow, Result}; use thiserror::Error; #[derive(Error, Debug)] pub enum ExecError { #[error("Cannot execute empty command.")] EmptyCommand, } pub fn exec(s: &str, proj_name: &str, proj_output: &str) -> Result<(), anyhow::Error> { let replaced = s .replace(c...
use std::iter; use std::marker::PhantomData; use tll::ternary::{Nat, Pred, NatPred, Triple, NatTriple, Zero, One, Two}; use iterator::{Iterator, NonEmpty}; pub struct Zip<L: Nat, I: Iterator<L>, J: Iterator<L>> { phantom: PhantomData<L>, first: I, second: J, } impl<L: Nat, I: Iterator<L>, J: Iterator<L...
#![no_main] #![no_std] #![feature(alloc)] #![feature(lang_items)] extern crate cortex_m; #[macro_use(block)] extern crate nb; extern crate cortex_m_rt as rt; extern crate panic_semihosting; extern crate stm32f103xx_hal as hal; extern crate nmea_slimline as nmea; extern crate cortex_m_semihosting; extern crate alloc_co...
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT // file 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>,...
pub fn sim() { let noodles = "noodles".to_string(); let oodles = &noodles[1..]; let poodles = "ಠ_ಠ"; println!("{}", noodles); println!("{}", oodles); println!("{}", poodles); println!("{}", "ಠ_ಠ".len()); println!("{}", "ಠ_ಠ".chars().count()); assert_eq!("ಠ_ಠ".len(), 7); assert_e...
//! Client for making HTTP requests. mod http_client; mod reqwest_http_client; #[cfg(test)] mod mock_http_client; pub use self::http_client::HttpClient; pub use self::reqwest_http_client::ReqwestHttpClient; #[cfg(test)] pub use self::mock_http_client::MockHttpClient;
/*! Standard Portable Intermediate Representation (SPIR-V) backend !*/ use super::{Instruction, LogicalLayout, PhysicalLayout, WriterFlags}; use spirv::Word; use std::{collections::hash_map::Entry, ops}; use thiserror::Error; const BITS_PER_BYTE: crate::Bytes = 8; #[derive(Clone, Debug, Error)] pub enum Error { #...
// Copyright (c) 2018-2020 Jeron Aldaron Lau // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0>, the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, or the ZLib // license <LICENSE-ZLIB or https://www.zlib.net/zlib_license.html> at ...
extern crate piston_window; extern crate rand; mod board; mod direction; mod food; mod snake; use board::Board; use direction::Direction; use food::Food; use snake::Snake; use piston_window::*; use std::time::Instant; const ONE_HUNDRED_MS: u32 = 100000000; static WHITE: [f32; 4] = [1.0, 1.0, 1.0, 1.0]; static RED: ...
use log::*; use super::*; use futures_util::future::*; use std::net::{TcpListener, TcpStream, SocketAddr, SocketAddrV6}; use std::sync::Arc; use socket2::{Socket, Domain, Type}; use stdio_override::{StdoutOverride, StdinOverride, StderrOverride}; use msg_bus::MsgBusHandle; use nix::pty::ptsname_r; use nix::pty::{posix_...
// This file is part of libfringe, a low-level green threading library. // Copyright (c) Nathan Zadoks <nathan@nathan7.eu>, // whitequark <whitequark@whitequark.org> // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE...
#[doc = "Writer for register INTC"] pub type W = crate::W<u32, super::INTC>; #[doc = "Register INTC `reset()`'s with value 0"] impl crate::ResetValue for super::INTC { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Write proxy for field `CKOKIC`"] pub struct C...
//! A component wrapping a `<button>` tag that changes the route. use crate::{ agent::{RouteAgentDispatcher, RouteRequest}, route::Route, Switch, }; use yew::prelude::*; use super::{Msg, Props}; use crate::RouterState; use yew::virtual_dom::VNode; /// Changes the route when clicked. #[derive(Debug)] pub s...
#[derive(Debug)] struct Person<'a> { name: &'a str, age: u8, } struct Nil; struct Pair(i32, f32); #[derive(Debug)] struct Point { x: f32, y: f32, } #[derive(Debug)] struct Rectangle { p1: Point, p2: Point, } fn rect_area(r: Rectangle) -> f32 { let Rectangle { p1, p2 } = r; let w = i...
use crate::block_hasher::{BlockHasher, HashProgress}; use crate::open_file; use crossbeam::channel::Sender; use digest::Digest; use std::io::{BufReader, Read}; use std::path::Path; pub struct FileHash<T: Digest> { reader: BufReader<std::fs::File>, hasher: T, buffer: Vec<u8>, buffer_size: usize, byt...
use std::path::PathBuf; use crate::{ config::Config, db, logger::create_logger, model::auth::{ InvalidRegisterRequest, LoginError, LoginRequest, LoginResponse, RegisterRequest, }, model::image::*, server, services::{auth, AuthService, DefaultImageService, ImageService}, util...
tonic::include_proto!("nc/nc");
use amethyst::utils::scene::BasicScenePrefab; use amethyst::renderer::PosNormTex; use amethyst::animation::AnimationSetPrefab; use amethyst::core::Transform; use std::vec::Vec; pub type myPrefabData = Option<BasicScenePrefab<Vec<PosNormTex>>>;
pub(crate) mod config; use std::path::{Path, PathBuf}; use std::str::FromStr; use structopt::StructOpt; use crate::cli::constants::*; #[derive(Debug, StructOpt)] #[structopt(about = "Download packages into a specified directory")] pub struct Download { #[structopt(required = true, help = "Packages to download")]...
use tilemap::Chunks; use tilemap::MapBuilder; pub struct Layer { pub chunks: Chunks, pub tint: [f32; 4], pub collision: bool, } impl Layer { pub fn build(b: &MapBuilder, layer: usize) -> Layer { let mut tint = [1.0; 4]; let mut collision = true; let chunks = Chunks::build(b, l...
use std::io; use std::path::PathBuf; use std::option::Option; use rexiv2; use crate::app_environment::*; #[derive(Clone)] pub struct AppState { pub camera: Option<String>, pub film: Option<String>, pub iso: Option<String>, pub author: Option<String>, pub comment: Option<String>, pub set_file_...
mod errors; mod utils; mod wikia; use argh::FromArgs; use inflector::Inflector; use crate::wikia::Shadow; #[derive(FromArgs)] /// Find shadow resistance/weakness information struct Opts { /// name of shadow #[argh(option, short = 's', default = "String::from(\"none\")")] shadow: String, /// persona s...
// Copyright 2017, 2018 Parity Technologies // // 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...
// struct Point { // x: f32, // y: f32, // } // struct Rectangle { // top_left: Point, // bottom_right: Point, // } #[derive(Debug)] struct Person<'a> { name: &'a str, age: u8, } fn main() { let name = "Edward"; let age = 27; let edward = Person { name, age }; println!("{:?}", edward); }
extern crate arrayfire; extern crate rand; extern crate rand_distr; extern crate csv; extern crate statistical; mod utils; mod layer; mod fc; use arrayfire::*; use utils::*; use layer::*; use fc::*; use csv::*; use statistical::standard_deviation as stddev; fn arrayfire_test() { println!("Backends: {}, Device. ...
// 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 Fuchsia_LICENSE file. // Code has been retrieved from the zerocopy crate. // https://fuchsia.googlesource.com/fuchsia/+/master/src/lib/zerocopy/src/byteorder.rs //! Byt...
//! MIPS CP0 Wired register register_rw!(6, 0);
#[doc = "Register `DBTP` reader"] pub type R = crate::R<DBTP_SPEC>; #[doc = "Register `DBTP` writer"] pub type W = crate::W<DBTP_SPEC>; #[doc = "Field `DSJW` reader - Synchronization jump width Must always be smaller than DTSEG2, valid values are 0 to 15. The value used by the hardware is the one programmed, incremente...
mod geometry { use inherent_pub::inherent_pub; pub trait Length { fn length(&self) -> f64; } pub struct Vector(pub f64, pub f64); #[inherent_pub] impl Length for Vector { pub fn length(&self) -> f64 { let Vector(x, y) = self; (x.powi(2) + y.powi(2)).sqr...
use std::ops::ControlFlow; use std::ops::FromResidual; use std::ops::Try; #[derive(Debug)] pub enum Control<T> { Continue(T), Finished, } impl<T> FromResidual<()> for Control<T> { fn from_residual(residual: ()) -> Self { Control::Finished } } impl<T> Try for Control<T> { type Output = T; ...
pub mod factions { pub fn process_command() { loop { println!("Please input an army command or help to see available commands or back to go back!"); let mut input = String::new(); std::io::stdin() .read_line(&mut input) .expect("Error pars...
#[doc = "Register `CR` reader"] pub type R = crate::R<CR_SPEC>; #[doc = "Register `CR` writer"] pub type W = crate::W<CR_SPEC>; #[doc = "Field `DBGSLEEP_CD` reader - Allow D1 domain debug in Sleep mode"] pub type DBGSLEEP_CD_R = crate::BitReader; #[doc = "Field `DBGSLEEP_CD` writer - Allow D1 domain debug in Sleep mode...
#[derive(Debug)] pub struct Matrix { pub(crate) data: Vec<Vec<f64>>, pub(crate) rows: usize, pub(crate) cols: usize, } use rand::prelude::*; impl Clone for Matrix { fn clone(&self) -> Matrix { Matrix { data: self.data.clone(), rows: self.rows, cols: self.cols...
use std::cell::RefCell; use std::rc::Rc; use crate::treenode::TreeNode; struct BSTIterator { current: Option<Rc<RefCell<TreeNode>>>, path: Vec<Rc<RefCell<TreeNode>>>, } impl BSTIterator { fn new(root: Option<Rc<RefCell<TreeNode>>>) -> Self { match root { Some(mut node) => { ...
#[doc = "Reader of register GICD_IIDR"] pub type R = crate::R<u32, super::GICD_IIDR>; #[doc = "Reader of field `IMPLEMENTER`"] pub type IMPLEMENTER_R = crate::R<u16, u16>; #[doc = "Reader of field `VARIANT`"] pub type VARIANT_R = crate::R<u8, u8>; #[doc = "Reader of field `REVISION`"] pub type REVISION_R = crate::R<u8,...
extern crate rust; // use self::rust::*; // use std::error::Error; use std::fs; use std::io; use std::process; fn read() -> Result<(), Box<dyn std::error::Error + 'static>> { let mut rdr = csv::Reader::from_reader(io::stdin()); for result in rdr.records() { let record = result?; let origin_fil...
use crate::{ commands::osu::CompareResult, embeds::attachment, util::{ datetime::sec_to_minsec, numbers::{with_comma_float, with_comma_int}, }, }; use chrono::{DateTime, Utc}; use rosu_v2::prelude::{GameMode, User, UserStatistics}; use std::{ cmp::Reverse, fmt::{Display, Write},...
//! Contains the `App` type, used to initialize and run a Limn application. use std::time::{Instant, Duration}; use std::rc::Rc; use std::cell::RefCell; use glutin::{self, dpi::LogicalSize}; use window::Window; use ui::Ui; use input::InputEvent; use widget::Widget; use event::{self, EventHandler}; use geometry::Size...
use async_trait::async_trait; use crate::result::Result; #[async_trait] pub trait Cache<K, V> { async fn get(&self, k: &K) -> Option<V>; async fn set(&self, k: K, v: V) -> Result<()>; async fn delete(&self, k: &K) -> Result<()>; }
use solana_program::{ program_pack::{IsInitialized, Pack, Sealed}, program_error::ProgramError, pubkey::Pubkey, msg, }; use arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs}; pub struct State { pub is_available: bool, pub previous_owner_pubkey: Pubkey, } impl Sealed for State {}...
//! This module contains definition of Markov Decision Process (MDP) model and related reinforcement //! learning logic. mod simulator; pub use self::simulator::*; mod strategies; pub use self::strategies::*; use crate::utils::{compare_floats, Random}; use hashbrown::HashMap; use std::cmp::Ordering; use std::hash::H...
use xi_core_lib::selection::InsertDrift; use xi_rope::{RopeDelta, Transformer}; use crate::{buffer::Buffer, state::Mode}; use std::cmp::{max, min}; #[derive(Clone, Copy, PartialEq, Debug)] pub enum ColPosition { FirstNonBlank, Start, End, Col(usize), } #[derive(Clone, Copy, PartialEq, Debug)] pub str...
use std::{ collections::HashSet, error::Error, fs::{self, File}, io::Write, process::Command, str::from_utf8, }; use std::time::SystemTime; use codegen::{Scope, Type}; use roxmltree::{Document, Node}; use serde::{Deserialize, Serialize}; fn is_power_of_two(x: u8) -> bool { (x & (x - 1)) =...
use actix_web_validator::{ JsonConfig, PathConfig, QueryConfig, Error, }; use crate::api::errors::ApiError; use std::sync::Arc; use multer::{ FieldConfig, MulterConfig, memory_storage::MemoryStorageBuilder, }; use crate::api::extractors::limit::RateLimit; use actix_web::web; use crate::api::app_...
#![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 SerialConsoleStatus { #[serde(default, skip_serializing_if = "Option::is_none")] pub disabled: Option<bool>...
use noria::consensus::ZookeeperAuthority; use noria::SyncControllerHandle; use slog::Drain; use slog::Logger; use slog_term::term_full; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{mpsc, Arc, Mutex}; use std::thread; #[macro_use] extern crate slog; pub struct NoriaBackend { pub handle: SyncControl...
// <p>The sequence of triangle numbers is generated by adding the natural numbers. So the $7$<sup>th</sup> triangle number would be $1 + 2 + 3 + 4 + 5 + 6 + 7 = 28$. The first ten terms would be: // $$1, 3, 6, 10, 15, 21, 28, 36, 45, 55, \dots$$</p> // <p>Let us list the factors of the first seven triangle numbers:</p>...
#[allow(unused_imports)] use super::prelude::*; type Input = Vec<u32>; pub fn input_generator(input: &str) -> Input { input.lines() .map(|l| l.parse::<u32>().expect("Input line is not a positive integer")) .collect() } pub fn part1(input: &Input) -> u32 { input.iter().map(|mass| (mass / 3).sat...
use eyre::WrapErr; use std::{ fs, io::{self, BufRead, BufReader, ErrorKind}, path::Path, process::Command, }; const TOML_DIRECTORY_PATH: &str = "../rsonpath-lib/tests/documents/toml"; const JSON_DIRECTORY_PATH: &str = "../rsonpath-lib/tests/documents/json"; const OUTPUT_FILE_PATH: &str = "../rsonpath-l...
use serde::Serialize; use serde::de::DeserializeOwned; use serde_json::{Value, Number, Map, to_value, from_value}; use std::iter::FromIterator; pub fn serde_interpolate<T: Serialize + DeserializeOwned + Clone>(from: &T, to: &T, amount: f32) -> T { let from_val = to_value(from).unwrap(); let to_val = to_value(t...
use crate::equity::Equity; pub enum Presult { ADDED, REMOVED, EXISTS, DNE, } pub struct PortList { pub portfolio_list: Vec<Portfolio>, } impl PortList { // Creates a new empty List of Portfolios pub fn empty_new() -> Self { PortList { portfolio_list: Vec::new(), ...
use std::collections::HashSet; /// Determine whether a sentence is a pangram. pub fn is_pangram(sentence: &str) -> bool { if sentence.len() == 0 { return false } let mut letters = HashSet::new(); for c in sentence.to_lowercase().chars() { if c.is_ascii_alphabetic() { lette...
use predicates::prelude::Predicate; use predicates::str::contains; use short::BIN_NAME; use test_utils::init; use test_utils::{PROJECT_CFG_FILE, PROJECT_ENV_DIR}; mod test_utils; #[test] fn cmd_dir() { let mut e = init("cmd_env_dir"); e.add_file( PROJECT_CFG_FILE, r#" setups: setup_1: f...
use super::utils::parse_string; use crate::ast::rules; #[test] fn test_label() { assert_eq!( parse_string(":: Label ::", rules::label), r#"[Single(Label(Id("Label")))]"# ); } #[test] fn test_goto() { assert_eq!( parse_string("goto Label", rules::stat), r#"[Single(Goto(Id("L...
//! Generation scheme module to define how to generate passphrases //! //! This module defines the [`Scheme`](Scheme) type, with a corresponding [build](SchemeBuilder) if //! that pattern is desired. //! //! As both provided and custom structures may produce a [`Scheme`](Scheme) for passphrase //! generation, the [`ToS...
use crate::muxer; use super::{Error, Result}; use super::destdev::{DestinationDevice}; use super::srcdev::{SourceDeviceSet, SourceDevice, Event, Modifier}; use muxer::Muxer; use std::{path::Path, rc::Rc}; use std::os::unix::io::RawFd; pub struct Evenger { muxer: Muxer, srcdevs: SourceDeviceSet, destdev: D...
#![allow(dead_code)] #![cfg(target_os = "linux")] // no ioctl support for osx yet // Simple tests to ensure macro generated fns compile ioctl!(bad do_bad with 0x1234); ioctl!(none do_none with 0, 0); ioctl!(read read_test with 0, 0; u32); ioctl!(write write_test with 0, 0; u64); ioctl!(readwrite readwrite_test with 0...
//! Provide operations over IPv6 addresses. use std::cmp::Ordering; use std::fmt; use std::io::IpAddr as StdIpAddr; use std::ops::*; use std::simd::u64x2; use std::str::FromStr; use super::IpAddrVersion::{self, Ipv6}; pub const MAX_PREFIXLEN: uint = 128; #[derive(Copy, Clone, Show, PartialEq, Eq, Hash, RustcEncodable...
#[doc = "Register `PUCRC` reader"] pub type R = crate::R<PUCRC_SPEC>; #[doc = "Register `PUCRC` writer"] pub type W = crate::W<PUCRC_SPEC>; #[doc = "Field `PU0` reader - PU0"] pub type PU0_R = crate::BitReader<PU0_A>; #[doc = "PU0\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum PU0_A { ...
//! Simple parser for a very simple key-values file format used by Cykas //! wallets. use std::io::{Buffer, IoResult, IoError, OtherIoError}; // There are only two tokens to worry about in Cykas' wallet file format: keys // and values, both Strings. #[deriving(PartialEq,Show)] enum Token { Key(String), Value(...
// generic_struct.rs struct GenericStruct<T>(T); struct Container<T>{ item: T } fn main() { //stuff }
use super::{ FlowProperties, FlowPropertyVal, OperatorCategory, OperatorConstraints, NULL_WRITE_FN, RANGE_0, }; /// > unbounded number of input streams of any type, unbounded number of output streams of any type. /// /// As a source, generates nothing. As a sink, absorbs anything with no effect. /// /// ```hydrofl...
pub struct Map { map_vec: Vec<Vec<char>>, height: usize, width: usize, // Total width t_width: usize, // Width of the original tile } impl Map { fn get_idx(&mut self, h: usize, w: usize) -> Option<char> { if h > self.height { return None; } while w >= self.wid...
// author: Erik Nordin // created: 07/14/2018 // updated: 08/04/2018 // version: 0.1.0 // contact: aeketn@gmail.com #![feature(test)] extern crate nordint; extern crate num_bigint; extern crate test; #[cfg(test)] mod biguint_benchmarks { use nordint::BigUint as LocalBigUint; use num_bigint::BigUint as Crate...
use http::Uri; use serde_json::Value; use songbird::input::Metadata; pub trait FromIceJson { fn from_ice_json(value: Value, uri: &str) -> Self; } impl FromIceJson for Metadata { fn from_ice_json(value: Value, query: &str) -> Self { let emptymeta = Metadata { title: None, artist...
#![allow(clippy::module_inception)] #![allow(clippy::too_many_arguments)] #![allow(clippy::ptr_arg)] #![allow(clippy::large_enum_variant)] #![doc = "generated by AutoRust 0.1.0"] #[cfg(feature = "package-preview-2021-09")] pub mod package_preview_2021_09; #[cfg(all(feature = "package-preview-2021-09", not(feature = "no...
use crate::card::Card; use crate::deck::Deck; use crate::traits::Representation; use std::fmt; #[derive(Debug, Default)] pub struct Turn { pub master_index: Option<usize>, cards: Deck, } impl Turn { #[must_use] pub fn take_cards_except_fool(self) -> Deck { Deck::new( self.cards ...
//! Collection of visitors that are fed from chunk iterator use std::io::Cursor; use byteorder::{LittleEndian, ReadBytesExt}; use failure::{bail, Error, ResultExt}; use log::warn; use crate::chunks::{ Chunk, ChunkLoaderStream, PackageWrapper, ResourceWrapper, StringTableWrapper, TableTypeWrapper, TypeSpecWrap...
/// A peek helper macro. macro_rules! peek { ($expr:expr) => { peek!($expr, false) }; ($expr:expr, $default:expr) => { match $expr { Some(value) => value, None => return $default, } }; }
use crate::ty::ID; use std::{collections::HashSet, hash::Hash}; #[derive(Default, Clone)] struct OrderedSet<T> { v: Vec<T>, s: HashSet<T>, } impl<T> OrderedSet<T> where T: Eq + Hash + Clone, { fn insert(&mut self, value: T) -> bool { if self.s.insert(value.clone()) { self.v.push(va...
use std::io; fn get_input() -> String { let mut input = String::new();; io::stdin().read_line(&mut input) .expect("Failed to read line"); return input; } fn main() { println!("Welcome to Cipher Machine!"); println!("You can choose beetwen 3 types of ciphers:"); println!("- Caesar ...
//! # for printing information about the mod song //! //! text_out contains utility functions for printing out information about mods. Primarily intended to be used for debugging and understanding the progress of the playback use super::Sample; use super::{Effect, Note, Song}; static NOTE_FREQUENCY_STRINGS: [(u32, &st...
use thiserror::Error; #[derive(Debug, Error)] pub enum Errors { #[error("hello ioerror")] Io(#[from] std::io::Error), #[error("hello parseerror")] Parse(#[from] std::string::ParseError), }
// Copyright (c) 2017 oic developers // // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT // license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. All files in the project carrying such notice may not be copied, // mo...
#[doc = "Register `DMA_HIFCR` writer"] pub type W = crate::W<DMA_HIFCR_SPEC>; #[doc = "Field `CFEIF4` writer - CFEIF4"] pub type CFEIF4_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>; #[doc = "Field `CDMEIF4` writer - CDMEIF4"] pub type CDMEIF4_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>; #[doc = "Fi...
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::serde::Deserialize; use deno_core::serde::Serialize; use deno_core::serde_json; use deno_core::serde_json::Value; use deno_core::ModuleSpecifier; use lsp::WorkspaceFolder; use lspower::lsp; use std...
// Copyright (C) 2017 1aim 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/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in wr...
impl Solution { pub fn num_subarrays_with_sum(nums: Vec<i32>, goal: i32) -> i32 { let (mut res,mut l1,mut l2) = (0,0,0); let n = nums.len(); let (mut s1,mut s2) = (0,0); for r in 0..n{ s1 += nums[r]; while l1 <= r && s1 > goal{ s1 -= nums[l1]; ...
//! A module which contains configuration of a [`CompactGrid`] which is responsible for grid configuration. //! //! [`CompactGrid`]: crate::grid::compact::CompactGrid use crate::color::StaticColor; use crate::config::{AlignmentHorizontal, Borders, Indent, Line, Sides}; /// This structure represents a settings of a g...
fn main() { let tweet = Tweet { username: String::from("lencx"), content: String::from("of course, as you probably already know, people"), reply: false, retweet: true, }; println!("I new tweet: \n[{}]", tweet.summarize()); let new_article = NewArticle { headline...
#![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 InitiateTransferRequest { #[serde(default, skip_serializing_if = "Option::is_none")] pub properties: Option...
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::SL6CFG { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mu...
use ferris_base; mod utils; #[test] fn moves_down() { let start = vec![ "............", "..🦀........", "............", "Fe==Mv......", ]; let inputs = vec![None]; let end = vec![ "............", "............", "..🦀........", "Fe==Mv......
#![feature(macro_rules)] #[macro_export] macro_rules! err_print( ($msg:expr) => ( match std::io::stderr().write(format!("{:s}", $msg).as_bytes()) { Ok(_) => { } Err(_) => { } } ); ($fmt:expr, $($xs:expr)*) => (err_print!(format!($fmt, $($xs)* ))); ) #[macro_export]...
/* * * Author: Austin Mullins * Copyright: Tangent * */ use tokio::net::TcpListener; use tokio::prelude::*; use super::super::log::*; use std::sync::{Arc, Mutex}; use std::collections::VecDeque; use super::parser; static INBOUND_PORT: &str = "7777"; pub async fn start_inbound_server(queue: Arc<Mutex<VecDeque<parser...
// Copyright 2018 Mohammad Rezaei. // // 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, modified, or distributed // except accordin...
//! Measuring the size of (de)serialized data. use serde::ser; use crate::error::{Error, Result}; /// Limits on the number of bytes that can be read or written. pub trait SizeLimit { fn add(&mut self, n: u64) -> Result<()>; fn limit(&self) -> Option<u64>; } /// A `SizeLimit` that restricts serialized or des...
/// _BigBang_ gang #[derive(Debug, Eq, PartialEq, Copy, Clone)] enum Name { Sheldon, Leonard, Penny, Rajesh, Howard, } /// Just to make code look a bit nicer type Names = Vec<Name>; /// Will return the `Name` of the person who will drink the `n`-th cola. fn who_is_next(names: &Names, n: usize) -> ...
#[doc = "Register `LTDC_L1CFBAR` reader"] pub type R = crate::R<LTDC_L1CFBAR_SPEC>; #[doc = "Register `LTDC_L1CFBAR` writer"] pub type W = crate::W<LTDC_L1CFBAR_SPEC>; #[doc = "Field `CFBADD` reader - CFBADD"] pub type CFBADD_R = crate::FieldReader<u32>; #[doc = "Field `CFBADD` writer - CFBADD"] pub type CFBADD_W<'a, R...
fn main() { let input = String::from_utf8(std::fs::read("input/day2").unwrap()).unwrap(); let input: Vec<_> = input .split_terminator('\n') .map(|s| { let mut split = s.split(": "); (split.next().unwrap(), split.next().unwrap()) }) .map(|(policy, password)...
use murmur3::murmurhash3_x86_32 as murmur3; use {Set, Transformer}; pub use self::modifiers::*; pub mod modifiers; pub struct Word { value: String, } impl Set for Word {} impl Transformer for Word { fn transform(&self, dimensions: u32) -> Option<Vec<u32>> { match dimensions { 0 => None, ...
//! A `ShadowExecutor` wraps an executor to have shadow observer that will not be considered by the feedbacks and the manager use crate::{ executors::{Executor, ExitKind, HasExecHooksTuple, HasObservers, HasObserversHooks}, inputs::Input, observers::ObserversTuple, Error, }; pub trait HasShadowObserve...
use futures::channel::oneshot; use libp2p::multiaddr::Protocol; use parity_scale_codec::{Decode, Encode}; use parking_lot::Mutex; use std::sync::Arc; use std::time::Duration; use subspace_networking::{Config, GenericRequest, GenericRequestHandler}; use tokio::time::sleep; #[derive(Encode, Decode)] struct ExampleReques...
#[doc = "Reader of register TCRC"] pub type R = crate::R<u32, super::TCRC>; #[doc = "Reader of field `TCR`"] pub type TCR_R = crate::R<u16, u16>; impl R { #[doc = "Bits 0:15 - Tx CRC register"] #[inline(always)] pub fn tcr(&self) -> TCR_R { TCR_R::new((self.bits & 0xffff) as u16) } }
use crate::crd::Echo; use kube::api::{Patch, PatchParams}; use kube::{Api, Client, Error}; use serde_json::{json, Value}; /// Adds a finalizer record into an `Echo` kind of resource. If the finalizer already exists, /// this action has no effect. /// /// # Arguments: /// - `client` - Kubernetes client to modify the `E...
use std::net::IpAddr; use sqlx::migrate::Migrator; use sqlx::types::Uuid; use sqlx::PgConnection; use sqlx::{Pool, Postgres}; use crate::common::SideType; use crate::database::models::{CountryCode, MapList, Match, Player, Server, Spectator, Team}; pub mod models; static MIGRATOR: Migrator = sqlx::migrate!(); pub a...
// Copyright 2017 rust-ipfs-api Developers // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except accord...
#[macro_use] extern crate lazy_static; extern crate alloc; mod api; pub mod basic_game; pub mod cameras; pub mod constants; pub mod core; pub mod js; pub mod lights; pub mod materials; pub mod math; pub mod prelude; pub mod shapes;
mod chip; mod cpu; mod app; extern crate piston; extern crate graphics; extern crate glutin_window; extern crate opengl_graphics; extern crate rand; use piston::window::WindowSettings; use piston::event_loop::*; use piston::input::*; use glutin_window::GlutinWindow as Window; use opengl_graphics::{ GlGraphics, OpenGL...