text
stringlengths
8
4.13M
pub use glyph_brush::HorizontalAlign as HAlign; pub use glyph_brush::VerticalAlign as VAlign; /// Defines an object's alignment. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Alignment { pub horizontal: HAlign, pub vertical: VAlign, } impl From<HAlign> for Alignment { #[inline] fn from...
use crate::core::alloc; use crate::core::bigarray; use crate::core::mlvalues; use crate::core::mlvalues::empty_list; use crate::error::Error; use crate::tag::Tag; use std::marker::PhantomData; use std::{mem, ptr, slice}; use crate::value::{Size, Value}; /// OCaml Tuple type pub struct Tuple(Value, Size); impl From<...
use std::{ collections::HashMap, env::consts::OS, time::{Duration, Instant}, }; use bytes::Bytes; use futures_util::{future::IntoStream, FutureExt}; use governor::{ clock::MonotonicClock, middleware::NoOpMiddleware, state::InMemoryState, Quota, RateLimiter, }; use http::{header::HeaderValue, Uri}; use ...
#[cfg(test)] mod tests { use lib::factorial; #[test] fn test_factorial() { let value: u32 = 4; let expected_result: u32 = 24; assert_eq!( expected_result, factorial(value), ); } }
use crate::typing::Type; use std::{ collections::{BTreeMap, BTreeSet}, fmt, }; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct AttrSetType { pub attrs: BTreeMap<String, Type>, pub rest: Box<Type>, } impl fmt::Display for AttrSetType { fn fmt(&self, f: &mut fmt::Formatter<'_>) ->...
use crate::rl::prelude::*; use crate::rl::trainers::q_learning::QFunction; use ndarray::prelude::*; use ndarray_stats::QuantileExt; use std::collections::HashMap; #[derive(Clone)] pub struct QTableAgent { action_space: usize, q_table: HashMap<Vec<i32>, Array1<Reward>>, } impl QTableAgent { pub fn new(acti...
use derive_more::{AsRef, Deref, DerefMut, Display, From, Into}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::str::FromStr; use url::Url; #[derive(Debug, Clone, From, Into, PartialEq, Eq, Deref, DerefMut, Display, AsRef)] pub struct UrlWrapper(pub Url); impl FromStr for UrlWrapper { type...
use super::{Pages, Pagination}; use crate::{commands::osu::MedalType, embeds::MedalsMissingEmbed, BotResult}; use rosu_v2::model::user::User; use twilight_model::channel::Message; pub struct MedalsMissingPagination { msg: Message, pages: Pages, user: User, medals: Vec<MedalType>, medal_count: (us...
//! Logger that prints messages like `[WARN] Lorem ipsum`. use atty; use log::{self, Log, Level, Metadata, Record}; use std::io::Write; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; struct Logger { level: Level, use_color: bool, } impl Log for Logger { fn enabled(&self, meta...
use proconio::input; use proconio::marker::*; use std::cmp::*; fn main() { input! { n: u32, s: Bytes, t: Bytes, } for i in 0..n{ print!("{}{}", s[i as usize] as char, t[i as usize] as char ); } println!(); }
use rust_decimal::Decimal; use serde::{Deserialize, Serialize}; /// This calls ::Default for types that use the serde /// deserialize_with attribute fn decimal_default_if_empy<'de, D, T>(de: D) -> Result<T, D::Error> where D: serde::Deserializer<'de>, T: serde::Deserialize<'de> + Default, { Option::<T>::de...
// https://www.codewars.com/kata/58712dfa5c538b6fc7000569/train/rust fn count_red_beads(n: u32) -> u32 { if n < 2 { return 0 } (n * 2) - 2 } #[cfg(test)] mod tests { use super::*; #[test] fn test_count_red_beads() { assert_eq!(count_red_beads(0), 0); assert_eq!(count_red_beads(1)...
//! GoodReads work schemas and record processing. use serde::Deserialize; use crate::arrow::*; use crate::parsing::*; use crate::prelude::*; const OUT_FILE: &'static str = "gr-author-info.parquet"; /// Author records as parsed from JSON. #[derive(Deserialize)] pub struct RawAuthor { pub author_id: String, pu...
#[doc = "Reader of register EFUSE_RDATA_L"] pub type R = crate::R<u32, super::EFUSE_RDATA_L>; #[doc = "Reader of field `DATA`"] pub type DATA_R = crate::R<u32, u32>; impl R { #[doc = "Bits 0:31 - This register has the read value from the Efuse macro, fuse bits\\[31:0\\]"] #[inline(always)] pub fn data(&self...
pub use self::{ circle::*, fill::*, group::*, padding::*, paint::*, path::*, rect::*, rounding::*, stroke::*, text::*, translate::*, }; use crate::{Real, Transform}; pub mod circle; pub mod fill; pub mod group; pub mod padding; pub mod paint; pub mod path; pub mod rect; pub mod rounding; pub mod stroke; pub mod te...
struct Foo { bar: bool, } impl Foo { fn abc(&mut self) {} fn xyz(mut self) { loop { self.bar = false; // Panic trigger requires both statements let _ = self.abc(); } } } fn main() {} /* thread 'rustc' panicked at 'Adding a write root node to an existing tre...
#![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 CertificateVerificationDescription { #[serde(default, skip_serializing_if = "Option::is_none")] pub certifi...
#[doc = "Register `ISR` reader"] pub type R = crate::R<ISR_SPEC>; #[doc = "Register `ISR` writer"] pub type W = crate::W<ISR_SPEC>; #[doc = "Field `ALRAWF` reader - Alarm A write flag"] pub type ALRAWF_R = crate::BitReader; #[doc = "Field `ALRBWF` reader - Alarm B write flag"] pub type ALRBWF_R = crate::BitReader; #[do...
extern crate rust_project; use rust_project::project::{string_to_integer,integer_to_string}; #[test] fn public_test_to_int() { assert_eq!(132, string_to_integer("one three two")); assert_eq!(62, string_to_integer("six two")); } #[test] fn public_test_to_string() { assert_eq!("one three two", integer_to_s...
use exonum::{ crypto::PublicKey, }; use std::collections::HashMap; use super::proto; #[derive(Clone, Debug, ProtobufConvert)] #[exonum(pb = "proto::Contract", serde_pb_convert)] pub struct Contract { pub pub_key: PublicKey, pub code: String, pub state: HashMap<String, String>, } impl Contract { ...
//! Provides a representation for one or many ready to use compute devices. use std::any::{Any, TypeId}; use super::error::Result; use super::memory::Memory; use super::tensor::TensorShape; /// An device capable of processing data. /// /// A compute device can be a single device, or multiple devices treated as a sin...
#[derive(Debug)] struct User { email: String, username: String, active: bool, sign_in_count: u32, } struct Color(i32, i32, i32); fn build_user(email: String, username: String) -> User { User { email, username, active: true, sign_in_count: 0, } } fn main() { ...
//! Extra utilities for spawning tasks mod spawn_pinned; pub use spawn_pinned::LocalPoolHandle;
use crate::register::Register; use liblog::storage; use std::sync::Arc; use warp::Filter; // TODO: make AsyncWAL and LogWriter a type arguments. pub async fn main<LW: storage::LogWriter<u64> + Sync + Send + 'static>( log_writer: LW, ) -> Result<(), LW::Error> { let reg = Arc::new(Register::new(0, log_writer));...
use crate::common::LmdbInstance; use holochain_json_api::json::JsonString; use holochain_persistence_api::{ cas::{ content::{Address, AddressableContent, Content}, storage::ContentAddressableStorage, }, error::{PersistenceError, PersistenceResult}, reporting::{ReportStorage, StorageRepor...
use crate::nes::cartridge::cartridge::Cartridge; use super::register; use crate::ppu::register::{PpuStatus, PpuCtrl, PpuStatusTrait, PpuCtrlTrait}; use crate::ppu::nametable; use crate::ppu::nametable::NametableMemory; const PATTERN_TABLE_SIZE: usize = 0x1000; const SCANLINE_PRE_RENDER: u16 = 261; const SCANLINE_VISI...
extern crate my_rc; use my_rc::MyRc; use std::cell::Cell; use std::rc::Rc; macro_rules! assert_expected_eq_actual { ($a:expr, $b:expr) => ({ let (a, b) = (&$a, &$b); assert!(*a == *b, "\nExpected `{:?}` is not equal to Actual `{:?}`\nAssertion: `assert_expected_eq_actual!({...
use num_bigint::{BigUint, ToBigUint}; use num_integer::Integer; use num_traits::{ToPrimitive, Zero}; use std::sync::mpsc::*; use std::thread; use std::time::Instant; use std::io::BufWriter; use std::io::prelude::*; use std::fs::OpenOptions; fn main() { let num_threads: u64 = num_cpus::get() as u64; let (tx, rx...
use shorthand::ShortHand; use std::collections::BTreeMap; #[derive(ShortHand, Default)] #[shorthand(enable(collection_magic))] struct Example { collection: BTreeMap<&'static str, usize>, irrelevant_field: usize, } fn main() { let _: &mut Example = Example::default().insert_collection("value", 0_usize); }
use std::sync::{Arc, Mutex, MutexGuard}; use crate::kv::StatefulKV; use svm_hash::{Blake3Hasher, Hasher}; use svm_types::{Address, State}; /// An Account-aware (and `State`-aware) key-value store interface responsible of /// mapping `u32` input keys (given as a 4 byte-length slice) to global keys under a raw key-val...
use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::ast::CellPath; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::Category; use nu_protocol::Spanned; use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value}; use std::sync::Arc; struct Argument...
use clap::{App, Arg}; use ebnf_tools::*; use std::fs; fn main() { let matches = App::new("generate") .arg( Arg::with_name("file") .value_name("file") .takes_value(true) .required(true), ) .get_matches(); let opts = matches.valu...
// Reported as issue #126, child leaks the string. use std; import std::task; fn child2(-s: str) { } fn main() { let x = task::spawn(bind child2("hi")); }
#![feature(nll, underscore_imports)] extern crate cgmath; extern crate pbrt; use std::sync::{ Arc, Mutex }; use cgmath::{ Deg, Matrix4 }; use pbrt::prelude::*; use pbrt::camera::PerspectiveCamera; use pbrt::film::Film; use pbrt::filter::TriangleFilter; use pbrt::integrator::{ Integrator, DirectLightingIntegrator, W...
use std::io::Write; use termcolor:: { Color, ColorChoice, ColorSpec, StandardStream, WriteColor }; pub trait Printer { fn print_single_banner_line( &mut self, banner_text : &str, banner_color : Color, path : &str); fn print( &mut self, text : &str); fn error( ...
pub mod opiterator; pub mod query; pub use memstore::storage_manager::StorageManager;
extern crate common; extern crate day2; use std::env::args; use std::fs::File; use std::io::BufReader; use std::process::exit; fn main() { let ar: Vec<String> = args().collect(); if ar.len() != 2 { eprintln!("Usage: {} <INPUT>", &ar[0]); exit(-1); } let input_file = File::open(&ar[1])...
pub mod display; pub mod mesh; pub mod shader;
//! # 830. 较大分组的位置 //! https://leetcode-cn.com/problems/positions-of-large-groups/ //! # 思路 //! 一次遍历,记录上一次的字符 pub struct Solution; impl Solution { pub fn large_group_positions(s: String) -> Vec<Vec<i32>> { if s.len() < 3 { return vec![]; } let bytes = s.as_bytes(); let m...
use message_parsing; pub trait AiInterface { fn update_game_state(&self, state: &GameState) -> String; fn get_bot_name(&self) -> String; } #[derive(Default, Debug)] pub struct GameState { pub player_direction: message_parsing::Direction, pub opponent_direction: message_parsing::Direction, pub deck...
use mobc_postgres::{tokio_postgres, PgConnectionManager}; use std::time::Duration; use std::env; use crate::{DbConnectionPool, DbConnection}; use super::errors::ErrorVariant; const DB_POOL_MAX_OPEN: u64 = 32; const DB_POOL_MAX_IDLE: u64 = 8; const DB_POOL_TIMEOUT_SECONDS: u64 = 15; pub fn create_pool() -> std::resul...
// 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 ...
#![allow(dead_code)] use std::ops::Add; use std::ops::Sub; use std::ops::Div; struct Calculator<T> { x: T, y: T } impl<T> Calculator<T> where T: Add<Output = T> + Copy + Sub<Output = T> + Div<Output = T> { pub fn add(&self) -> T { self.x + self.y } pub fn sub(&self) -> T { self.x -...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Data Register"] pub data: DATA, #[doc = "0x04 - Data enable register"] pub data_en: DATA_EN, #[doc = "0x08 - Direction control register"] pub dir: DIR, #[doc = "0x0c - Up and down control register"] pub pull...
//! Definition of `Handler`. use { crate::{ error::Error, future::TryFuture, util::Chain, // }, std::{rc::Rc, sync::Arc}, }; /// A trait representing the handler associated with the specified endpoint. pub trait Handler { type Output; type Error: Into<Error>; type Handl...
use serde::{Deserialize, Serialize}; use crate::protocol::{LogStreamSource, ProcessInfo, ProcessSpec, ProcessStatus}; /// A response to list information and metrics about managed processes. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct ListResponse { pub name: String, pub pid: Opti...
// RGB Rust Library // Written in 2019 by // Dr. Maxim Orlovsky <dr.orlovsky@gmail.com> // basing on ideas from the original RGB rust library by // Alekos Filini <alekos.filini@gmail.com> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to ...
//! # 316. 去除重复字母 //! https://leetcode-cn.com/problems/remove-duplicate-letters/ /// 给你一个字符串 s ,请你去除字符串中重复的字母,使得每个字母只出现一次。需保证 返回结果的字典序最小(要求不能打乱其他字符的相对位置)。 ///! # 解题思路 ///! 计算每个字符出现的次数,利用递增栈 pub struct Solution; impl Solution { pub fn remove_duplicate_letters(s: String) -> String { let mut letters = [(0, f...
use crate::compiler::Compiler; use crate::ast; use crate::parser; use std::fs; use std::path::PathBuf; #[derive(thiserror::Error)] #[derive(Debug)] pub enum Error { #[error("module {0}/{1} not found")] NotFound(String, String), #[error("I/O error")] Io(#[from] std::io::Error), #[error("parsing mo...
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ //! This crate wraps raw `u64` syscall arguments in stronger Rust types. This //! has a number of u...
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::channel_transaction_info::ChannelTransactionInfo; use crate::proof::ChannelTransactionAccumulatorProof; use libra_types::proof::SparseMerkleProof; /// The complete proof used to authenticate the state of an account. This...
//! Names for punctuation characters. /// Returns the name of the given character, or None if it is unknown. pub fn get_opt(c: char) -> Option<&'static str> { let ret = match c { '_' => "Underscore", '-' => "Minus", ',' => "Comma", ';' => "Semicolon", ':' => "Colon", '!' => "Bang", '?' =>...
pub fn pretty_print(request: Vec<u8>) -> String { let vec: Vec<u8> = request; format!( r#" ######################################################## {} ######################################################## "#, String::from_utf8_lossy(&vec) ) }
use rodio::Sink; use std::env; mod note; use note::model::{Note, Playable}; use std::{fs}; /// /// The main function, called /// when we execute: /// /// `cargo run [song file]` /// /// ... in the command line. /// fn main() { // We get the arguments passed to the cargo run command... let args : Vec<Stri...
use crate::grammar::ast::StringLit; use crate::grammar::testing::TestingContext; use crate::grammar::tracing::input::OptionallyTraceable; fn do_test(s: &'static str, r: &'static str, o: &'static str) { let tcx = TestingContext::with(&[s]); let fr = tcx.get_fragment(0); let (rem, out) = StringLit::parse(fr)...
use crc32fast::Hasher; /* Outputed file data structure bytes 0..31 = bitmask of used bytes in the original file bytes 32..36 = crc32 hash of the original file bytes 37..end = crc32 hashed data in 4 byte segments */ pub fn compress(block_size: usize, input_vector: &mut Vec<u8>) -> Vec<u32> { //pad end w...
use std::io::{self, Cursor, Read, Write}; use super::common::SyncBackend; use super::error::{MogError, MogResult}; use time::{self, Tm}; use url::Url; pub use self::iron::StorageHandler; pub use self::range::RangeMiddleware; pub mod iron; pub mod range; #[derive(Clone, Debug)] pub struct Storage { pub base_url: ...
/// Module that adds fasterxml annotations to generated classes. use backend::*; use codeviz::java::*; use super::models as m; use super::processor::*; pub struct Module { override_: ClassType, creator: ClassType, value: ClassType, property: ClassType, sub_types: ClassType, type_info: ClassType...
//! Provides utility functions for generating data sequences use euclid::Modulus; use std::f64::consts; use std::iter::Take; /// Generates a base 10 log spaced vector of the given length between the /// specified decade exponents (inclusive). Equivalent to MATLAB logspace /// /// # Examples /// /// ``` /// use statrs...
use std::{collections::HashMap, io, num::ParseIntError, str::FromStr}; use problem::{solve, Problem, ProblemInput}; #[derive(Clone)] enum Rule { Literal(char), Sequence(Vec<usize>), Alternate(Vec<usize>, Vec<usize>), } impl Rule { fn matches<'a>(&self, rules: &HashMap<usize, Rule>, s: &'a str) -> Vec<...
mod lib; pub use lib::*;
/// Converts the borrowed value of `Boo` to owned. See `Boo::into_owned_with` for details. pub trait BooToOwned<TBorrowed: ?Sized, TOwned> { /// Converts the borrowed value of `Boo` to owned. fn convert_to_owned(borrowed: &TBorrowed) -> TOwned; }
use std::io; use std::str::FromStr; #[allow(dead_code)] fn read_line() -> String { let mut buffer = String::new(); io::stdin() .read_line(&mut buffer) .expect("failed to read line"); buffer } #[allow(dead_code)] fn read<T : FromStr>() -> Result<T, T::Err>{ read_line().trim().parse::<...
mod common; pub use common::*; use crate::{qjs, Map}; #[derive(qjs::FromJs)] pub struct ExecArg { pub cmd: String, #[quickjs(default)] pub args: Option<Vec<String>>, #[quickjs(default)] pub envs: Option<Map<String, String>>, #[quickjs(default)] pub cwd: Option<String>, #[quickjs(defaul...
#[doc = "Register `BDMUPR` reader"] pub type R = crate::R<BDMUPR_SPEC>; #[doc = "Register `BDMUPR` writer"] pub type W = crate::W<BDMUPR_SPEC>; #[doc = "Field `MCR` reader - MCR"] pub type MCR_R = crate::BitReader<MCR_A>; #[doc = "MCR\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum MCR_A { ...
use crate::{PingResult, Target}; use core::cmp; use std::collections::HashMap; fn print_columns(indent: usize, header: Vec<String>, columns: Vec<Vec<String>>) { let mut lens: Vec<usize> = columns.clone() .into_iter() .map(...
#![allow(unused)] use std::cell::RefCell; use std::time::Duration; use std::collections::HashMap; use std::cmp::Ordering; use std::thread; use priority_queue::PriorityQueue; use rand::IsaacRng; use rand::prelude::RngCore; use xcg::model::*; use xcg::bot::KillerBot; use xcg::utils::Trim; use xcg::bot::common::{P, a_st...
extern crate curl; use std::fs::{self, File}; use std::io::Write; use std::path::Path; use std::str; use self::curl::easy::Easy; use utils::errors::LeanpubResult; pub trait HttpClient { fn get(&self, uri: &str) -> LeanpubResult<String>; fn download(&self, uri: &str, path: &Path) -> LeanpubResult<()>; } pub ...
fn main() { let mut txt = String::from("first"); converter(txt); } fn converter(mut s: String) { let vowels = ['a', 'i', 'u', 'e', 'o']; let mut hay = String::from("-hay"); let head = &s.chars().nth(0).unwrap(); if vowels.contains(&head) == false { hay = format!("-{}ay", head); } ...
use std::net::TcpListener; pub fn server() { let listener = TcpListener::bind("0.0.0.0:8080").unwrap(); for stream in listener.incoming() { println!("coonection",); let _stream = stream.unwrap(); } }
#[doc = "Register `PUPDR` reader"] pub type R = crate::R<PUPDR_SPEC>; #[doc = "Register `PUPDR` writer"] pub type W = crate::W<PUPDR_SPEC>; #[doc = "Field `PUPDR0` reader - Port x configuration bits (y = 0..15)"] pub type PUPDR0_R = crate::FieldReader; #[doc = "Field `PUPDR0` writer - Port x configuration bits (y = 0.....
fn main() { let t = (12, "eggs"); let b = Box::new(t); println!("{:?} is tuple\n{:?} is boxed struct now", t, b) }
use gl::types::{GLint, GLuint}; use glm::Vec3; pub struct Vertex { pos: Vec3, } impl Vertex { pub fn new(pos: Vec3) -> Self { Self { pos } } } const NUM_BUFFERS: usize = 1; // number of variants on enum below, it should be a macro enum VertexArrayBuffer { PositionVB = 0, } pub struct Mesh { ...
use super::Register; use crate::util::*; mod branch; mod condition; mod data; mod multiply; mod shifter; mod swap; pub use condition::ConditionCode; pub use shifter::{ShiftOperand, ShiftOperation, ShifterOperand}; #[derive(Copy, Clone, Eq, PartialEq, Debug)] pub enum DecodeError { InvalidShifterOperand(u16), } ...
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::metadata::Metadata; use crate::module::pubsub::event_subscription_actor::ChainNotifyHandlerActor; use crate::module::pubsub::notify::SubscriberNotifyActor; use actix::Addr; use futures::channel::mpsc; use jsonrpc_core::Re...
use super::lexer::{tokens, Lexer}; const DEBUG: bool = false; #[derive(Debug)] pub enum Result { Ok, Error(String), } #[derive(Debug)] pub struct Parser { /// Lexer lexer: Lexer, /// Active token lookahead_token: Option<tokens::Token>, } impl Parser { pub fn new(input: String) -> Parser ...
use serde::{Serialize, Deserialize}; #[derive(Copy, Clone, Eq, PartialEq, Default, Debug, Serialize, Deserialize)] pub struct Point { pub x: i32, pub y: i32, } impl Point { pub fn new(x: i32, y: i32) -> Point { Point { x, y } } pub fn nearest(x: f32, y: f32) -> Point { Point { ...
//! A crate containing my practice implementation of a variable size thread pool //! for executing functions in parallel. Spawns a specified number of worker //! threads, but will panic if any of them panic. //! //! After creating the [`ThreadPool`], give it work by passing boxed closures to //! [`schedule()`]. If y...
//! [`Router`](crate::Router) is a lightweight high performance HTTP request router. //! //! This router supports variables in the routing pattern and matches against //! the request method. It also scales better. //! //! The router is optimized for high performance and a small memory footprint. //! It scales well even...
// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd. // Copyright (C) 2021 Subspace Labs, Inc. // 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 // ...
use std::fs; use crate::prelude::*; use crate::{ git::GitClient, poc::{Metadata, PeerMetadata, PocMap, TargetMetadata}, }; use anyhow::bail; use askama::Template; use duct::cmd; use semver::Version; use structopt::StructOpt; use tempdir::TempDir; use toml::value::Datetime; #[derive(Debug, StructOpt)] pub enu...
use dioxus::prelude::*; pub(crate) fn home(cx: Scope) -> Element { cx.render(rsx! ( h1 { "Home" } p { "These are all the strange things made with Dioxus." } )) }
use rusqlite::Connection; use bincode::SizeLimit; use bincode::rustc_serialize::{encode, decode}; use rustc_serialize::{Encodable}; #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug, Clone)] pub struct Log { pub hash: String, // Log Hash pub state: String, // Hash of the state ...
use bevy::prelude::*; pub struct CreditsEvent {} pub struct CreditsDelay(pub Timer); pub fn setup_credits( mut commands: Commands, mut windows: ResMut<Windows>, asset_server: Res<AssetServer>, ) { commands.spawn_bundle(UiCameraBundle::default()); commands.insert_resource(ClearColor(Color::hex(crat...
pub use crate::error::{Error, ErrorExt, ResultExt}; pub use crate::ext::{EventHandlerExt, JSObjectExt, JsonStreamReadExt, JsonStreamWriteExt}; pub use neon::prelude::*; pub use tokio::prelude::*; pub use tokio::stream::StreamExt;
use std::env; use std::fs; fn main(){ let args : Vec<String> = env::args().collect(); if args.len() < 2 { return; } let lines = fs::read_to_string(&args[1]).unwrap(); let mut disks = Vec::<(i32, i32)>::new(); for line in lines.split('\n') { if line == "" { continue...
#[derive(derive_more::From, collections_fromstr::FromStr, PartialEq)] #[item_separator = ","] struct NewVec(std::vec::Vec<std::string::String>); fn main(){ use assert2::assert; use std::str::FromStr; static VALUES: &str = "Apple🍎,Banana🍌,Carrot🥕"; assert!(NewVec::from_str(VALUES).unwrap() == NewVec...
#[no_mangle] pub extern fn physics_single_chain_ufjc_lennard_jones_thermodynamics_isotensional_asymptotic_end_to_end_length(number_of_links: u8, link_length: f64, link_stiffness: f64, force: f64, temperature: f64) -> f64 { super::end_to_end_length(&number_of_links, &link_length, &link_stiffness, &force, &tempera...
/// A Telegram chat. #[derive(Debug,Deserialize)] pub struct Chat { /// Unique identifier for this chat. pub id: i64, /// Type of chat, can be either "private", "group", "supergroup" or /// "channel". #[serde(rename = "type")] pub kind: String, /// Title for supergroups, channels and group c...
use crate::{ fold::{HirFoldable, HirFolder, HirVisitor}, ids::{ AscriptionExpr, Assignment, BlockExpr, CallExpr, Expression, FieldExpr, Identifier, IfExpr, Literal, MatchExpr, Pattern, RecordExpr, Statement, Type, }, }; use either::Either; use valis_ds::{Intern, Untern}; use valis_ds_macros:...
use crate::grammar::model::Fragment; use crate::grammar::parsers::whitespace; use crate::grammar::parsers::whitespace::{multiline_comment, token_delimiter}; use crate::grammar::testing::TestingContext; use crate::grammar::tracing::input::OptionallyTraceable; use codespan::{FileId, Files}; fn setup(src: &str) -> (Files...
use super::*; #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] #[repr(transparent)] pub struct KeyInterruptControl(u16); impl KeyInterruptControl { const_new!(); bitfield_bool!(u16; 0, a, with_a, set_a); bitfield_bool!(u16; 1, b, with_b, set_b); bitfield_bool!(u16; 2, select, with_select, set_select); b...
//! Defines definitions for a [`Symlink`]. use serde::{Deserialize, Serialize}; use std::path::PathBuf; /// A symlink to be created during the deployment. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct Symlink { /// Absolute path of the link source. pub source_path: PathBuf, /// Absolut...
use super::DateTime; use crate::utils::f64_from_string; use serde::{Deserialize, Serialize}; use uuid::Uuid; // Public #[derive(Serialize, Deserialize, Debug)] pub struct Time { pub iso: String, pub epoch: f64, } #[derive(Serialize, Deserialize, Debug)] pub struct CurrencyDetails { #[serde(rename = "type...
use futures::try_ready; use tokio::net::tcp::{self, TcpStream}; #[cfg(unix)] use tokio::net::unix::{self, UnixStream}; use tokio::prelude::*; use tower_grpc::codegen::server::tower::Service; use std::{io, net::SocketAddr}; #[cfg(unix)] use std::path::{Path, PathBuf}; /// Specifies the connection details of a remote ...
#[doc = "Register `I2C_TIMINGR` reader"] pub type R = crate::R<I2C_TIMINGR_SPEC>; #[doc = "Register `I2C_TIMINGR` writer"] pub type W = crate::W<I2C_TIMINGR_SPEC>; #[doc = "Field `SCLL` reader - SCLL"] pub type SCLL_R = crate::FieldReader; #[doc = "Field `SCLL` writer - SCLL"] pub type SCLL_W<'a, REG, const O: u8> = cr...
/* * x is defined as an immutable variable, then defined again later (shadowed?) * redefining a variable like this lets you change the type. */ fn main() { let x = 5; println!("The value of x is: {}", x); let x = 6; println!("The value of x is: {}", x); }
#[doc = "Register `FMC_HWCFGR1` reader"] pub type R = crate::R<FMC_HWCFGR1_SPEC>; #[doc = "Field `NAND_SEL` reader - NAND_SEL"] pub type NAND_SEL_R = crate::BitReader; #[doc = "Field `NAND_ECC` reader - NAND_ECC"] pub type NAND_ECC_R = crate::BitReader; #[doc = "Field `SDRAM_SEL` reader - SDRAM_SEL"] pub type SDRAM_SEL...
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. use arena_collections::list::List; use arena_trait::TrivialDrop; use ocamlrep::slab::OwnedSlab; use ocamlrep_derive::{FromOcamlRepIn, To...
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4) // from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70) // DO NOT EDIT use OutputStream; use Seekable; use ffi; use glib; use glib::object::Downcast; use glib::object::IsA; use glib::signal::SignalHandlerId; use glib::signal::connect...