text
stringlengths
8
4.13M
use crate::rtb_type_strict; rtb_type_strict! { Topframe, UnfriendlyOrUnknown=0; Topframe = 1 }
//! How to extract subcommands' args into external structs. //! //! Running this example with --help prints this message: //! ----------------------------------------------------- //! classify 0.3.25 //! //! USAGE: //! enum_tuple <SUBCOMMAND> //! //! FLAGS: //! -h, --help Prints help information //! -...
enum BinaryTree { Data(Free), Root(Box<[BinaryTree; 2]>), } impl BinaryTree { /// Gets first element with free root and sets it to used pub fn get_first_free(&mut self, traverse_levels: usize) -> Option<usize> { match self { Self::Data(free) => { if traverse_levels ==...
fn main() { let mut s = String::from("Please add a dot"); append_dot(&mut s); println!("s with dot = {}", s); } fn append_dot(t : &mut String) { t.push('.'); }
//! Module with various macros to make code less verbose /// Macro for handling errors returned from the `rusqlite` crate /// /// The argument of this macro invoication should be a `Result<T, rusqlite::Error>` #[macro_export] macro_rules! unwrap_db_err { ($expression:expr) => { match $expression { ...
use std::borrow::Cow; use std::sync::Arc; use command_data_derive::CommandData; use discorsd::{async_trait, BotState}; use discorsd::commands::*; use discorsd::errors::BotError; use discorsd::http::ClientResult; use discorsd::model::ids::*; use discorsd::model::interaction_response::message; use crate::Bot; use crate...
pub mod karkkainen; pub trait Compute <T>{ fn compute(text: String, sa: Vec<T>) -> Result<pLcp<T>,Error>; }
#[doc = "Reader of register DDRCTRL_CRCPARSTAT"] pub type R = crate::R<u32, super::DDRCTRL_CRCPARSTAT>; #[doc = "Reader of field `DFI_ALERT_ERR_CNT`"] pub type DFI_ALERT_ERR_CNT_R = crate::R<u16, u16>; #[doc = "Reader of field `DFI_ALERT_ERR_INT`"] pub type DFI_ALERT_ERR_INT_R = crate::R<bool, bool>; impl R { #[doc...
#![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode}; use core::cmp; use frame_support::{ decl_error, decl_event, decl_module, decl_storage, ensure, traits::{Currency, ExistenceRequirement, Get, ReservableCurrency}, }; use frame_system::ensure_signed; use sp_runtime::{ traits::{ A...
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// ImageWidgetDefinition : The image widget allows you to embed an image on your dashboard. An image ca...
mod apply; mod bridge; mod checkpoint; mod connection; mod error; mod ip; mod profile; mod show; pub(crate) use apply::*; pub(crate) use checkpoint::*; pub(crate) use connection::nm_gen_conf; pub(crate) use show::*;
use crate::{Status, TypeMeta}; use serde::{Deserialize, Deserializer, Serialize}; use thiserror::Error; /// The `kind` field in [`TypeMeta`] pub const META_KIND: &str = "ConversionReview"; /// The `api_version` field in [`TypeMeta`] on the v1 version pub const META_API_VERSION_V1: &str = "apiextensions.k8s.io/v1"; #[...
extern crate cocoa; use self::cocoa::base::{id, nil, selector, NO}; use self::cocoa::foundation::{NSAutoreleasePool, NSPoint, NSRect, NSSize, NSString, NSUInteger}; use self::cocoa::appkit::{self, NSApp, NSApplication, NSMenu, NSMenuItem, NSRunningApplication, NSWindow}; use super::common; use super::super::pane::Pan...
#![allow(proc_macro_derive_resolution_fallback)] use diesel; use diesel::prelude::*; use crate::schema::posts; use crate::posts::Post; pub fn all(connection: &PgConnection) -> QueryResult<Vec<Post>> { posts::table.load::<Post>(&*connection) } pub fn get(id: i32, connection: &PgConnection) -> QueryResult<Post> { ...
mod school_member{ pub mod teacher{ pub fn get_salary(){ println!("Salary"); } } } fn main() { school_member::teacher::get_salary(); }
use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; use crate::models; use super::common::DBError; use super::engine; const GAME_DB_FILE_NAME: &'static str = "db/game.csv"; const MAP_DB_FILE_NAME: &'static str = "db/map.csv"; const TILES_DB_FILE_NAME: &'static str = "db/tiles.csv"; const CHARACTER_...
use wasm_bindgen::{prelude::*, JsCast}; use wasm_bindgen_futures::JsFuture; use web_sys::{console, Document, HtmlElement, MediaDeviceInfo, MediaStream, MediaStreamConstraints, Navigator, Window}; pub fn...
pub fn lib_function() { println!("featureA"); }
use std::rc::{Rc, Weak}; use std::cell::{RefCell}; use std::mem; use std::option::Option::{None, Some}; use std::fmt::{Display, Formatter, Debug}; use std::borrow::Borrow; #[derive(Debug,Default)] struct Node<E>{ value:E, pre:Option<Weak<RefCell<Node<E>>>>, next:Option<Rc<RefCell<Node<E>>>> } #[derive(Deb...
use crate::float::Float; use crate::matrix::{FloatMatrix, FromVectors, IntoVectors, Matrix, M4}; use crate::numeric::Numeric; use crate::vector::{Vector, V4}; use std::ops::{Add, Deref, DerefMut, Div, Mul, Sub}; impl<T> Deref for M4<T> where T: Numeric, { type Target = [[T; 4]; 4]; fn deref(&self) -> &Sel...
pub const DEBUG: bool = true; pub fn get_path_separator() -> String { if DEBUG { ";".to_string() } else { ":".to_string() } } pub fn get_project_root() -> String { "".to_string() } pub fn get_public_path() -> String { "".to_string() }
use rand::distributions::{Distribution, Uniform}; use crate::scorecard::{Scorecard, new_scorecard, get_score_by_index, YAHTZEE_BONUS, get_highest_scores, YAHTZEE, set_score_by_index}; use std::collections::HashSet; #[derive(Debug)] pub struct YahtzeeGame{ pub roll: Vec<u8>, pub scorecard: Scorecard, ...
pub mod traits;
//! Tests auto-converted from "sass-spec/spec/non_conformant/scss/media" #[allow(unused)] use super::rsass; // From "sass-spec/spec/non_conformant/scss/media/interpolated.hrx" #[test] fn interpolated() { assert_eq!( rsass( "// You can interpolate into a media type.\ \n@media bar#{12...
//! Gets temperature data via sysinfo. use super::{is_temp_filtered, temp_vec_sort, TempHarvest, TemperatureType}; use crate::app::Filter; pub async fn get_temperature_data( sys: &sysinfo::System, temp_type: &TemperatureType, actually_get: bool, filter: &Option<Filter>, ) -> crate::utils::error::Result<Option<Vec...
mod blog; #[cfg(test)] mod tests { use crate::blog::Post; fn sample_post(text: &str) -> Post { let mut post = Post::new(); post.add_text(text); post } #[test] fn test_flow() { let mut post = sample_post("salad"); assert_eq!("", post.content()); pos...
extern crate bigint; #[macro_use] extern crate failure; extern crate rlp; extern crate tiny_keccak; pub mod asm; pub mod errors; pub mod vm; #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } }
use std::sync::Arc; use crate::prelude::*; use crate::bxdf::TransportMode; use super::Primitive; use crate::interaction::SurfaceInteraction; use crate::light::Light; use crate::material::Material; use crate::math::AnimatedTransform; #[derive(Clone, Debug)] pub struct TransformedPrimitive { pub primitive: Arc<dyn P...
use std::io; use std::env::var_os as env_var; use super::{Vars, VarsError}; #[derive(Debug)] pub enum ExprInternalError { UnexpectedEof, UnknownExpressionType, UnknownEnv(String), } pub enum ExprError { Vars(VarsError), Input(io::Error), Output(io::Error), Internal(ExprInternalError), } ...
#![no_std] #![feature(maybe_uninit_uninit_array)] #![feature(maybe_uninit_slice)] mod device; pub mod events; mod gpio; mod timer; use core::cmp::Ordering; use core::mem::MaybeUninit; use device::TimerID; use gpio::InputPin; use gpio::OutputPin; use once_cell::unsync::OnceCell; use device::Pin; use device::Port; use...
#[doc = "Reader of register SPI_CTRLR0"] pub type R = crate::R<u32, super::SPI_CTRLR0>; #[doc = "Writer for register SPI_CTRLR0"] pub type W = crate::W<u32, super::SPI_CTRLR0>; #[doc = "Register SPI_CTRLR0 `reset()`'s with value 0x0300_0000"] impl crate::ResetValue for super::SPI_CTRLR0 { type Type = u32; #[inl...
// https://adventofcode.com/2017/day/15 fn main() { // First star let mut gen_a: u64 = 512; let mut gen_b: u64 = 191; let mut matches = 0; for _ in 0..40000000 { // Run generators gen_a = gen_a.wrapping_mul(16807) % 2147483647; gen_b = gen_b.wrapping_mul(48271) % 2147483647;...
mod string; pub use string::join;
use clap::{crate_version, App, Arg}; use nix::sched::{unshare, CloneFlags}; use nix::unistd::execvp; use std::ffi::{CStr, CString}; fn main() { let matches = App::new("unshare") .version(crate_version!()) .arg( Arg::with_name("ipc") .help("unshare IPC namespace") ...
#[funtime::timed] fn foo(y: i32) -> i32 { let mut x = 1; let d = 1_000; x += d; x += y; x } #[funtime::timed] fn main() { foo(23); }
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { _reserved0: [u8; 0x04], #[doc = "0x04..0x44 - Cluster CH%s, containing ?CR1, ?CR2, ?FRCR, ?SLOTR, ?IM, ?SR, ?CLRFR, ?DR"] pub ch: [CH; 2], #[doc = "0x44 - PDM control register"] pub pdmcr: PDMCR, #[doc = "0x48 - PDM delay register"...
// This file is part of Substrate. // Copyright (C) 2018-2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // 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 // // ht...
use std::error::Error; #[derive(Debug, Clone, Copy, PartialEq)] pub enum FileFormat { /// iNES INes, /// NES 2.0 Nes20, } #[derive(Debug, Clone, Copy, PartialEq)] pub enum Mirroring { Horizontal, Vertical, FourScreen, } #[derive(Debug, Clone, Copy, PartialEq)] pub struct Header { pub ...
#[macro_use] extern crate lazy_static; use rustyline::error::ReadlineError; use rustyline::Editor; use clap::{AppSettings, Clap}; use std::fs; #[derive(Clap, Debug)] #[clap( version = "1.0", author = "author - Tanay D. Pingalkar <tanaydpingalkar@gmail.com>", about = "a functional programming language" )]...
use crate::states::game::GameState; use oxygengine::prelude::*; #[derive(Default)] pub struct SplashState; impl State for SplashState { fn on_enter(&mut self, world: &mut World) { let token = world.read_resource::<AppLifeCycle>().current_state_token(); world .create_entity() ...
impl Default for Config { fn default() -> Config { let split_size = ReadableSize::mb(coprocessor::config::SPLIT_SIZE_MB); Config { sync_log: true, prevote: true, raftdb_path: String::new(), capacity: ReadableSize(0), raft_base_tick_interval...
use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::models::canister_id_store::CanisterIdStore; use crate::lib::root_key::fetch_root_key_if_needed; use crate::lib::waiter::waiter_with_exponential_backoff; use crate::util::clap::validators; use crate::util::print_idl_b...
use nu_engine::CallExt; use nu_protocol::{ ast::{Call, CellPath}, engine::{Command, EngineState, Stack}, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, }; #[derive(Clone)] pub struct SubCommand; impl Command for SubCommand { fn name(&self) -> &str { "into fil...
// Copyright 2015 Ted Mielczarek. See the COPYRIGHT // file at the top-level directory of this distribution. use std::env; use std::path::Path; use std::io::Write; extern crate minidump; use minidump::*; const USAGE : &'static str = "Usage: minidump_dump <minidump>"; fn print_minidump_dump(path : &Path) { matc...
#[doc = "Register `CMD` reader"] pub type R = crate::R<CMD_SPEC>; #[doc = "Register `CMD` writer"] pub type W = crate::W<CMD_SPEC>; #[doc = "Field `CMDINDEX` reader - Command index. This bit can only be written by firmware when CPSM is disabled (CPSMEN = 0). The command index is sent to the card as part of a command me...
use common::tokio::time::Instant; use std::time::Duration; use super::super::TIMER_L; #[derive(Debug)] pub struct Accepted { pub entered_at: Instant, } impl Accepted { pub fn should_terminate(&self) -> bool { self.entered_at.elapsed() > Duration::from_millis(TIMER_L) } } impl Default for Accepte...
extern crate proc_macro; use crate::proc_macro::TokenStream; use quote::quote; use syn::Data::Struct; use syn::Fields; use syn::Type::Path; fn impl_hello_macro(ast: &syn::DeriveInput) -> TokenStream { let name = &ast.ident; let data = &ast.data; // println!("{:#?}", data); let mut defenition = format!...
use std::collections::HashMap; // game_mode: 22 = role queue // win/loss = +- 20 MMR // Wins: 1061 Lose: 1125 = 2200 MMR #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { // steamid = "60374563" // dota // steamid = "76561198020640291" // steam let request_url = format!( "ht...
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 use anyhow::{ensure, Result}; use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use starcoin_accumulator::node::{AccumulatorStoreType, ACCUMULATOR_PLACEHOLDER_HASH}; use starcoin_accumulator::{Accumulator, MerkleAccumu...
use std::collections::HashMap; use std::fs; fn gen_graph(input: String) -> (Vec<Vec<usize>>, HashMap<String, usize>) { input .split("\n") .map(|s| { s.split(")") .map(|z| String::from(z)) .collect::<Vec<String>>() }) .fold( (Ve...
use valis_ds_macros::DebugWith; #[derive(Debug, DebugWith, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Binder<T>(T); impl<T> Binder<T> { pub fn bind(value: T) -> Self { Binder(value) } pub fn inner_ref(&self) -> &T { &self.0 } pub fn as_ref(&self) -> Binder<&T>...
use std::io::{self,Write}; use std::fs::File; use std::io::{BufRead, BufReader}; const MAP_ROW : usize = 40; const MAP_COL : usize = 28; fn print_board(board : &[u8], score : usize) -> (usize, usize) { let mut ball_pos = (0, 0); for c in 0..MAP_COL { for r in 0..MAP_ROW { let cc = ...
use super::PointDataType; use crate::base::PointWriter; use anyhow::{Context, Result}; use pasture_core::containers::{UntypedPoint, UntypedPointSlice}; use pasture_core::layout::{attributes, PointLayout}; use pasture_core::nalgebra::Vector3; // combined trait to handle the PointWriter trait aswell as the AsciiFormat tr...
use core::pin::Pin; use futures_core::ready; use futures_core::stream::{FusedStream, Stream, TryStream}; use futures_core::task::{Context, Poll}; use pin_project::{pin_project, project}; impl<S: ?Sized + TryStream> TryStreamExt for S {} /// An extension trait for Streams that provides a variety of convenient combinat...
#![feature(custom_attribute, plugin)] #![plugin(profile_ext)] #[profile] fn foo() { println!("foo"); } pub fn main() { println!("enter main function"); foo(); println!("exit main function"); }
use std::fmt::Debug; use std::path::PathBuf; use error::*; use source::Source; use data_backend::ReceivedAsset; #[derive(Debug, RustcDecodable, RustcEncodable)] pub struct Auth { pub name: String, pub key: String } #[derive(Debug, RustcDecodable, RustcEncodable)] pub struct ControlPayload { pub auth: Auth...
//! Implements Forsyth–Edwards Notation parsing. use regex::Regex; use board::*; use files::*; use ranks::*; /// Parses Forsyth–Edwards Notation (FEN). /// /// Returns a tuple with the following elements: `0`) a board /// instance, `1`) halfmove clock, `2`) fullmove number. /// /// # Forsyth–Edwards Notation /// ///...
#[derive(Serialize,Deserialize,Debug)] pub struct CharacterBuilder { name: Option<String>, race: Option<Race>, class: Option<Class>, base_abilities: Option<AbilityScores>, } #[derive(Serialize,Deserialize,Debug)] pub struct AbilityValues<T> { strength: T, dexterity: T, constitution: T, ...
//! Azure OAuth2 helper crate for the unofficial Microsoft Azure SDK for Rust. This crate is part of a collection of crates: for more information please refer to [https://github.com/azure/azure-sdk-for-rust](https://github.com/azure/azure-sdk-for-rust). //! This crate provides mechanisms for several ways to authentica...
extern crate liquid; use liquid::LiquidOptions; use liquid::Renderable; use liquid::Context; use liquid::parse; use std::default::Default; macro_rules! compare { ($input:expr, $output:expr) => { let input = $input.replace("…", " "); let expected = $output.replace("…", " "); let options: Li...
use std::collections::HashMap; #[allow(dead_code)] /// the `KvStore` using a hashmap to store value in the memory pub struct KvStore { map: HashMap<String, String>, } impl KvStore { /// This method used to create a KvStore /// /// # Example /// /// ```rust /// use kvs::KvStore; /// ...
#[doc = "Register `DMACRxCR` reader"] pub type R = crate::R<DMACRX_CR_SPEC>; #[doc = "Register `DMACRxCR` writer"] pub type W = crate::W<DMACRX_CR_SPEC>; #[doc = "Field `SR` reader - Start or Stop Receive Command"] pub type SR_R = crate::BitReader; #[doc = "Field `SR` writer - Start or Stop Receive Command"] pub type S...
// 使用pub修饰就可以消除未被使用的警告了 pub mod client; pub mod network; #[cfg(test)] mod tests { use super::client; #[test] fn it_works() { // 从跟模块开始 // ::client::connect(); // 或者直接使用super上移到当前模块的父模块 // super::client::connect(); // 或者直接使用use super::client client::connect()...
//! This is an implementaiton of the GFF3 spec. //! //! https://github.com/The-Sequence-Ontology/Specifications/blob/master/gff3.md // todo: This implementation doesn't implement any of the string excaping rules. // todo: If and when it's extended to support that, consider using a wrapper // around string to enforc...
use num_derive::FromPrimitive; use num_enum::IntoPrimitive; use num_traits::FromPrimitive; use bytes::{ Bytes, Buf, BytesMut, BufMut }; #[derive(FromPrimitive, IntoPrimitive, Debug, PartialEq, Copy, Clone)] #[repr(u8)] pub enum Status { LearnReady = 0x1, NodeFound = 0x2, AddingSlave = 0x3, ...
use std::{ env, process::{exit, Command}, }; fn main() { let mut args = env::args().peekable(); args.next(); let prog_name = match args.peek() { Some(opt) if opt == "--gui" => { args.next(); "nvim-qt" } _ => "nvim", }; let res = Command::new(p...
#![warn(clippy::all)] use actix_web::{App, HttpServer}; use dotenv::dotenv; use tracing::{error, info, Level}; use tracing_error::ErrorLayer; use tracing_subscriber::prelude::*; extern crate vaas_server; use std::env; use vaas_server::{db, server}; #[actix_rt::main] async fn main() -> std::io::Result<()> { dotenv...
//! Highest Response Ratio Next use keyed_priority_queue::KeyedPriorityQueue; use crate::scheduling::{Os, PId, Scheduler}; /// In this scheduling, processes with highest response ratio is scheduled. /// This algorithm avoids starvation. /// Mode: Non-Preemptive /// `Response Ratio = (Waiting Time + Burst time) / Burs...
// Copyright 2017 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. #![deny(warnings)] extern crate failure; extern crate fidl; extern crate fuchsia_app as component; extern crate fuchsia_async as async; extern crate fuchs...
use std::convert::TryInto; use sdl2::{pixels::Color, render::*, video::{self, WindowContext}, VideoSubsystem}; pub struct SdlContext { pub ttf_context: sdl2::ttf::Sdl2TtfContext, pub canvas: Canvas<video::Window>, pub event_pump: sdl2::EventPump, pub texture_creator: TextureCreator<WindowContext>, ...
use crate::client::cover_traffic_stream::LoopCoverTrafficStream; use crate::client::mix_traffic::{MixMessageReceiver, MixMessageSender, MixTrafficController}; use crate::client::provider_poller::{PolledMessagesReceiver, PolledMessagesSender}; use crate::client::received_buffer::{ ReceivedBufferRequestReceiver, Rece...
use std::str::FromStr; fn solve(input: &mut [isize], part_two: bool) { let mut line = 0isize; let mut steps = 0; loop { steps += 1; { let jump = &mut input[line as usize]; line += *jump; if part_two && *jump >= 3 { *jump -= 1; ...
use std::str::FromStr; pub fn day_1_input() -> Vec<i64> { include_str!("../resources/day01part01.txt") .lines() .map(|s| i64::from_str(&s).unwrap()) .collect() } pub fn day_2_input() -> Vec<String> { include_str!("../resources/day02part01.txt") .lines() .map(|s| s.to_ow...
use crate::schema::users; use crate::schema::papers; use chrono::NaiveDateTime; #[derive(Debug, Queryable)] pub struct Paper { pub paper_id: i32, pub paper_title: String, pub paper_author: String, pub paper_year: i32, pub user_id: i32, pub created_at: NaiveDateTime, pub updated_at: NaiveD...
use bson::{doc, Document, Timestamp}; use serde::Deserialize; use crate::{ client::ClusterTime, cmap::{RawCommandResponse, StreamDescription}, error::{Result, TRANSIENT_TRANSACTION_ERROR}, operation::{CommandErrorBody, CommandResponse, Operation}, options::{ReadPreference, SelectionCriteria}, }; p...
pub mod bitwarden; use std::error::Error; pub trait Authenticator { fn new(master_password: &str) -> Result<Self, Box<dyn Error>> where Self: Sized; fn get(&self, hostname: &str, user: &str) -> Result<&str, Box<dyn Error>>; }
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::error::AccountServiceError; use crate::{Wallet, WalletAccount}; use starcoin_types::account_address::AccountAddress; use starcoin_types::transaction::{RawUserTransaction, SignedUserTransaction}; pub type ServiceResult<T>...
use std::{io, num::ParseIntError}; use grid::Grid; use problem::{Problem, ProblemInput, solve}; #[derive(Clone, Copy, Debug)] struct Transform { rotation: u8, reflection: bool, } impl Transform { fn combine(&self, other: &Self) -> Self { if !self.reflection { Self { rot...
extern crate green; extern crate rustuv; use std::comm::{sync_channel, Receiver, Sender}; use tcp::{start_tcp_handler, WorkerProcSender}; use tcp::{TcpEvent, ConnCreat, Read, Write, ConnClose}; use std::collections::HashMap; use std::sync::{Arc, Mutex}; #[start] fn start(argc: int, argv: *const *const u8) -> int { ...
extern crate bindgen; use std::env; use std::path::{Path, PathBuf}; use std::process::Command; fn main() { let target = env::var("TARGET").unwrap(); let worker_package_dir = PathBuf::from(env::var("OUT_DIR").unwrap()).join("worker_sdk"); let package_name = if target.contains("windows") { "c-stat...
//! # Store //! //! A storage trait for Tendermock `Node`s. //! //! For now the only available storage is the `InMemoryStore`. //! As its name implies, this resides in volatile memory. However, implementations of //! persistent storage are possible without impacting the rest of the code base as it only relies //! on th...
// ==================================================== // Netlyser Copyright(C) 2019 Furkan Türkal // This program comes with ABSOLUTELY NO WARRANTY; This is free software, // and you are welcome to redistribute it under certain conditions; See // file LICENSE, which is part of this source code package, for details. /...
use std::env; use std::fs; use regex::{Regex}; fn main(){ let args : Vec<String> = env::args().collect(); if args.len() < 2 { return; } let lines = fs::read_to_string(&args[1]).unwrap(); const H : usize = 6; const W : usize = 50; let mut state = [[false; W]; H]; let re_rect = ...
use ipasir_sys::*; use std::ffi::{CStr, c_void}; mod ipasir_signature { use super::*; #[test] fn it_returns_the_name_and_version_of_the_sat_solver() { let c_buffer = unsafe { ipasir_signature() }; let c_string = unsafe { CStr::from_ptr(c_buffer) }; let signature = c_string.to_str()...
#[doc = "Register `GICD_ITARGETSR7` reader"] pub type R = crate::R<GICD_ITARGETSR7_SPEC>; #[doc = "Field `CPU_TARGETS0` reader - CPU_TARGETS0"] pub type CPU_TARGETS0_R = crate::FieldReader; #[doc = "Field `CPU_TARGETS1` reader - CPU_TARGETS1"] pub type CPU_TARGETS1_R = crate::FieldReader; #[doc = "Field `CPU_TARGETS2` ...
use std::sync::mpsc; use std::sync::{Arc, Barrier}; use std::thread; use crossbeam_channel; fn main() { let barrier = Arc::new(Barrier::new(3)); let (snd, rcv) = mpsc::channel::<i32>(); { let b = barrier.clone(); thread::spawn(move || { b.wait(); snd.send(4); ...
extern crate hello; use hello::ThreadPool; use std::fs; use std::io::prelude::*; use std::net::TcpStream; use std::net::TcpListener; use std::thread; use std::time::Duration; /* Cargo Process- cargo new --bin hello cd hello/ -> both html files in root -> src/lib.rs -> src/bin/main.rs cargo run -> open window go ...
//! Helper methods for composing widget layouts. use crate::geometry::{Bounds, BoundsMut, VAlign}; /// Bounds extension for placing widgets relative to others. pub trait Layout: BoundsMut { fn left_of<B: Bounds>(&mut self, other: &B, spacing: u32) -> &mut Self { let pos = self .get_position() ...
//给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 // //说明:你不能倾斜容器,且 n 的值至少为 2。 // // // //图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容器能够容纳水(表示为蓝色部分)的最大值为 49。 // //  // //示例: // //输入: [1,8,6,2,5,4,8,3,7] //输出: 49 use std::cmp::min; fn abs_i32(mu...
use crate::contract::Contract; use crate::deck::Deck; use crate::errors::TarotErrorKind; use crate::game::Game; use crate::game_started::GameStarted; use crate::options::Options; use crate::player::Player; use crate::player_in_game::PlayerInGame; use crate::role::Role; use crate::team::Team; use itertools::{Either, Ite...
mod avx; mod camera; mod fallback; mod hit_record; mod hittable; mod material; mod object; mod object_list; mod ray; mod sphere; mod vec3; use camera::Camera; use material::{Dielectric, Lambertian, Metal}; use object_list::ObjectList; use rand::Rng; use ray::Ray; use sphere::Sphere; use vec3::{Color, Vec3}; fn ray_co...
/// Cron represents a Cron task #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct Cron { pub exec_times: Option<i64>, pub name: Option<String>, pub next: Option<String>, pub prev: Option<String>, pub schedule: Option<String>, } impl Cron { /// Create a builder for this object...
use file; pub fn run() { let inputs = file::read_inputs("Day9.txt"); println!("{:?}", solve(&"{{{},{},{{}}}}")); println!("{:?}", solve(&"{<a>,<a>,<a>,<a>}")); println!("{:?}", solve(&"{{<ab>},{<ab>},{<ab>},{<ab>}}")); println!("{:?}", solve(&"{{<!!>},{<!!>},{<!!>},{<!!>}}")); println!("{:?}",...
use serde::{Deserialize, Serialize}; #[repr(u8)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Serialize, Deserialize)] pub enum OpCode { VOID = 0, PUSH = 1, LOOKUP = 2, IF = 3, JMP = 4, FUNC = 5, SCLOSURE = 6, ECLOSURE = 7, STRUCT = 8, POP = 9, BIND = 10, SDEF = 11, ...
use z80::Z80; /* ** SBC A, $xx|(HL)|register */ pub fn sbc(z80: &mut Z80, op: u8) { let sub = match op { 0xDE => { z80.r.pc += 1; z80.mmu.rb(z80.r.pc - 1) }, 0x9E => z80.mmu.rb(z80.r.get_hl()), 0x9F => z80.r.a, 0x98 => z80.r.b, 0x99 => z80.r.c,...
pub mod grid; pub mod board; pub mod game; pub use board::*; pub use game::*; #[test] fn it_works() { }
use crate::core::Client; use crate::queue::clients::QueueAccountClient; use crate::queue::PopReceipt; use crate::requests; use crate::HasStorageClient; use std::borrow::Cow; use std::fmt::Debug; #[derive(Debug, Clone)] pub struct QueueClient<C> where C: Client + Clone, { queue_account_client: QueueAccountClien...
// 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::Result, ffx_core::ffx_plugin, ffx_preflight_args::PreflightCommand}; #[ffx_plugin()] pub async fn preflight_cmd(_cmd: PreflightCommand) -> Re...
use std::collections::{HashMap, HashSet}; use std::ops::Range; fn main() -> std::io::Result<()> { let input = std::fs::read_to_string("examples/16/input.txt")?; let mut parts = input.split("\n\n"); let fields: Vec<_> = parts .next() .unwrap() .lines() .map(|line| Field::from(...
#![doc = "generated by AutoRust 0.1.0"] #![allow(unused_mut)] #![allow(unused_variables)] #![allow(unused_imports)] use crate::models::*; use reqwest::StatusCode; use snafu::{ResultExt, Snafu}; pub mod report_config { use crate::models::*; use reqwest::StatusCode; use snafu::{ResultExt, Snafu}; pub asyn...