text
stringlengths
8
4.13M
use std::f64::consts::PI; use std::sync::{Arc, Mutex}; use std::thread; use std::time::{Duration, SystemTime}; const TARGET: u32 = 10; const GUESS: u32 = 100; struct Leibniz { x: f64, d: f64, ticks: u32, tocks: u32, } fn computer(state: Arc<Mutex<Leibniz>>) { loop { let mut s = state.lock...
#[doc = "Reader of register EM23PERNORETAINCTRL"] pub type R = crate::R<u32, super::EM23PERNORETAINCTRL>; #[doc = "Writer for register EM23PERNORETAINCTRL"] pub type W = crate::W<u32, super::EM23PERNORETAINCTRL>; #[doc = "Register EM23PERNORETAINCTRL `reset()`'s with value 0"] impl crate::ResetValue for super::EM23PERN...
pub struct Solution; impl Solution { pub fn reverse_words(s: String) -> String { let mut res = String::new(); for word in s.split_whitespace().rev() { res.push_str(word); res.push(' '); } res.pop(); res } } #[test] fn test0151() { struct Case...
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // 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 ...
use super::super::request::*; #[derive(Debug, Clone)] pub struct Request { } impl KafkaSerializable for Request { fn serialize<W: Write>(&self, _: &mut W)-> Result<()> { Ok(()) } } impl KafkaRequest for Request { type Response = Response; fn api_key() -> i16 { 16 } fn api_ve...
/// /// /// pub struct Str16([u16]); impl Str16 { /// Converts a UCS-2 (no need to be valid UTF-16) slice into a string #[inline] pub fn from_slice(s: &[u16]) -> &Str16 { // SAFE: Same represenaton as &[u16] unsafe { ::core::mem::transmute(s) } } /// UNSAFE: Indexes input until NUL, lifetime inferred #...
extern crate math; use math::round; use std::cmp::Ordering; use std::mem; // courtesy of https://stackoverflow.com/a/28294764 fn swap<T>(x: &mut Vec<T>, i: usize, j: usize) { let (lo, hi) = match i.cmp(&j) { // no swapping necessary Ordering::Equal => return, // get the smallest and large...
use itertools::Itertools; use regex::Regex; use std::fs; use std::str; #[test] fn validate_6_2() { assert_eq!(algorithm("src/day_6/input_test.txt"), 6); } fn algorithm(file_location: &str) -> usize { let content = fs::read_to_string(file_location).unwrap(); let delimiter = Regex::new("\n\\s+\n").unwrap();...
use super::*; #[derive(PartialEq)] pub enum PlayerPose { Normal, Crouching, Sliding, Hurt, } pub struct Player { p_meter: i32, p_speed: bool, slide_timer: i32, idle_timer: i32, pose: PlayerPose, invuln_timer: i32, } impl Player { pub fn init(&mut self) { self.p_mete...
use std::fmt; /// The error used when managing connections with `deadpool`. #[derive(Debug)] pub enum Error { /// An error occurred establishing the connection ConnectionError(diesel::ConnectionError), /// An error occurred pinging the database QueryError(diesel::result::Error), } impl fmt::Display f...
pub mod str { use std::io::{Write, Result}; pub trait SliceChars { fn slice_chars_alt(&self, begin: usize, end: usize) -> &str; } impl SliceChars for str { fn slice_chars_alt(&self, begin: usize, end: usize) -> &str { assert!(begin <= end); let mut count = 0; ...
use std::collections::{HashMap, HashSet}; fn main() { let operations: Result<Vec<Operation>,_> = include_str!("input").lines().filter(|x| !x.starts_with("inp")).map(str::parse).collect(); let operations = operations.unwrap(); let chunks: Vec<_> = operations.chunks(17).collect(); let mut input_states: V...
use client; use maps; use key::MultiKey; use key::parse::parse; use state_machine::StateMachine; pub struct Vixi { machine: StateMachine<MultiKey>, } impl Vixi { pub fn new(client: Box<client::Client>) -> Self { Vixi { machine: StateMachine::new( client, map...
use std::fmt::{Display, Formatter, Result as FmtResult}; use std::path::{Path, PathBuf}; use std::str::FromStr; use serde::de::{self, Deserialize, Deserializer}; use serde::ser::{Serialize, Serializer}; use super::FilesystemId; use crate::hash::Hash; #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub ...
//! Control streams //! //! This module exposes a `controlstream(AsyncRead)` method //! which //! 1. frames the TNC control port socket; and //! 2. splits the output into events and command responses, //! and accepts Commands for transmission to the socket use std::collections::vec_deque::VecDeque; use std::io; use...
use proptest::strategy::{Just, Strategy}; use liblumen_alloc::atom; use liblumen_alloc::erts::term::prelude::*; use crate::erlang::unique_integer_1::result; use crate::test::strategy; use crate::test::with_process; #[test] fn without_proper_list_of_options_errors_badargs() { run!( |arc_process| { ...
//! A simple language. #![allow(clippy::drop_copy)] #![allow(clippy::drop_ref)] #![allow(clippy::new_without_default)] #![allow(clippy::while_let_on_iterator)] pub mod lang; pub mod pass; mod literal; pub mod reporting;
use crate::structures::basic::ValType; pub struct Value { pub value: ValType, } pub struct Labels { pub arity: usize, pub continuation: usize, } pub struct ModuleInstance; pub struct Frames { pub arity: usize, pub locals: Vec<ValType>, pub module: ModuleInstance, } /// The stack contains th...
use libloading::Library; use std::sync::Arc; use std::{ffi::OsStr, fmt}; use std; use crate::PluginRegistrar; use crate::PsistatsPlugin; pub struct PluginLoader { plugin_dir: String } #[derive(Debug, Clone)] pub enum Error { DeclError(String), LibError(String), Other(String) } impl fmt::Display for Error {...
use digest::{generic_array::typenum::consts::U32 as TU32, Digest, Output}; use ethers_core::types::U256; use std::collections::BTreeMap; use crate::*; #[derive(Default, Clone, Debug)] pub struct SimpleAccumulator<D> where D: Digest<OutputSize = TU32> + Clone + Default, { k: U256, s: BTreeMap<usize, Output...
use crate::demo_camera_plugin::Page; use bevy::prelude::*; /// Tags the main text. struct TitleText; /// Tags the subtitle text. struct SubtitleText; /// Text visible only on a certain page. struct BodyText(isize); pub struct DemoUiPlugin; impl Plugin for DemoUiPlugin { fn build(&self, app: &mut AppBuilder) { ...
use actix_web::{HttpResponse, ResponseError}; use thiserror::Error; #[derive(Error, Debug)] pub enum ServerError { #[error("read config filed error ")] ConfigReadFile(String), #[error("io: {0}")] Io(#[from] std::io::Error), #[error("sqlx error: {0}")] SqlxError(#[from] sqlx::Error), } pub typ...
mod plugin; mod resources; mod systems; pub use plugin::*; pub use resources::*; pub use systems::*;
#[macro_use] extern crate criterion; extern crate eosio_numstr; use criterion::{black_box, Criterion}; fn name_from_bytes(c: &mut Criterion) { c.bench_function_over_inputs( "name_from_bytes", |b, input| { b.iter(|| eosio_numstr::name_from_bytes(black_box(input.bytes()))) }, ...
use crate::{ Future, Result, error::QuicksilverError, }; use futures::Async; /// A structure to manage the loading and use of a future pub struct Asset<T>(AssetData<T>); enum AssetData<T> { Loading(Box<dyn Future<Item = T, Error = QuicksilverError>>), Loaded(T) } impl<T> Asset<T> { /// Create a n...
#![cfg(target_arch = "wasm32")] use proxy_wasm as wasm; use proxy_wasm::traits::{Context, HttpContext}; use proxy_wasm::types::{Action, LogLevel}; #[no_mangle] pub fn _start() { wasm::set_log_level(LogLevel::Trace); // Note: there are also RootContext and StreamContext that provide different callbacks wa...
pub const HEADER_PARTS_SEPARATOR: &[u8] = b":"; pub const LINE_SEPARATOR: &[u8] = b"\n"; pub const TERMINATOR: &[u8] = b"\x00"; pub const EMPTY: [u8; 0] = [];
#![deny(warnings)] mod argparser; mod commands; mod compiler; mod diagnostics; mod interner; mod output; mod parser; pub(crate) mod task; use std::ffi::OsString; use std::path::PathBuf; use std::sync::Arc; use anyhow::anyhow; use clap::crate_version; use firefly_session::{CodegenOptions, DebuggingOptions, OptionGrou...
#[cfg(feature = "datetime")] fn run() -> gdal::errors::Result<()> { use chrono::Duration; use gdal::vector::{Defn, Feature, FieldDefn, FieldValue}; use gdal::{Dataset, Driver}; use std::ops::Add; use std::path::Path; println!("gdal crate was build with datetime support"); let dataset_a = D...
use std::path::Path; fn main() { let dir = Path::new("/tmp/passwd"); assert!(dir.ends_with("passwd")); }
mod app_env; mod auth; mod config; mod datastore; mod graphql; mod mail; mod projects; mod scalars; mod stories; mod users; use actix_cors::Cors; use actix_web::{middleware, web, App, HttpServer}; use app_env::get_env; use std::{env, io, sync::Mutex}; pub struct AppData { graphql_schema: graphql::Schema, data...
use crate::query_tests::setups::SETUPS; use data_types::ColumnType; use futures::FutureExt; use observability_deps::tracing::*; use std::{collections::HashMap, sync::Arc}; use test_helpers_end_to_end::{maybe_skip_integration, MiniCluster, Step, StepTest, StepTestState}; #[tokio::test] async fn list_all() { Arc::ne...
pub mod esp826601s; pub mod tcp; use crate::io::Result; use heapless::String; pub enum Status { Cnnected, Disconnect, } pub struct IfInfo { pub inet4: String<15>, pub netmask: String<15>, pub gateway: String<15>, pub ether: String<17>, } pub trait TcpStream: Sized { fn connect(addr: (&st...
use bytes::{Buf, Bytes}; use crate::error::Error; use crate::mssql::io::MssqlBufExt; use crate::mssql::protocol::pre_login::Version; #[allow(dead_code)] #[derive(Debug)] pub(crate) struct LoginAck { pub(crate) interface: u8, pub(crate) tds_version: u32, pub(crate) program_name: String, pub(crate) prog...
use eosio::{AccountName, Asset}; use structopt::StructOpt; /// Transfer tokens from account to account #[derive(StructOpt, Debug)] pub struct Transfer { /// The account sending tokens pub sender: AccountName, /// The account receiving tokens pub recipient: AccountName, /// The amount of tokens to s...
extern crate maat_graphics; extern crate maat_input_handler; extern crate rand; extern crate parking_lot; extern crate rand_pcg; pub use maat_graphics::winit; pub use maat_graphics::cgmath; mod modules; use crate::modules::scenes::Scene; use crate::modules::scenes::LoadScreen; use maat_graphics::graphics::CoreRende...
use bigneon_db::dev::TestProject; use bigneon_db::models::{EventInterest, User}; use bigneon_db::utils::clamp; use rand::prelude::*; use uuid::Uuid; #[test] fn create() { let project = TestProject::new(); let user = project.create_user().finish(); let event = project.create_event().finish(); let event...
#[path = "float_to_list_2/with_float.rs"] pub mod with_float; // `without_float_errors_badarg` in unit tests
#[doc = "Reader of register D3CR"] pub type R = crate::R<u32, super::D3CR>; #[doc = "Writer for register D3CR"] pub type W = crate::W<u32, super::D3CR>; #[doc = "Register D3CR `reset()`'s with value 0x4000"] impl crate::ResetValue for super::D3CR { type Type = u32; #[inline(always)] fn reset_value() -> Self...
// See LICENSE file for copyright and license details. use serialize::{Decodable, json}; use error_context; use core::misc::read_file; pub struct Config { json: json::JsonObject, } fn decode<A: Decodable<json::Decoder, json::DecoderError>>(json_obj: json::Json) -> A { let mut decoder = json::Decoder::new(jso...
use std::io::prelude::*; use std::fs::File; use std::collections::BTreeMap; use std::iter::FromIterator; pub fn handler(filename: &String) -> String{ let mut f: File = File::open(filename).expect("file not found"); let mut contents = String::new(); f.read_to_string(&mut contents).expect("file cannot be r...
mod chip8; use crate::chip8::Chip8; use std::fs::read; use std::{thread, time}; use sdl2::audio::{AudioCallback, AudioSpecDesired, AudioStatus}; use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::pixels::Color; use sdl2::rect::Rect; use clap::{crate_authors, crate_name, crate_version, App, Arg}; struct ...
pub(crate) mod node { tonic::include_proto!("node"); } mod vm_handler; pub mod vmm_service;
#![feature(io)] use std::error::FromError; use std::str::Utf8Error; use std::string::FromUtf8Error; use std::old_io::{Reader, BufReader, IoError}; use std::old_io::net::ip::IpAddr; #[derive(Debug)] pub enum Error { Io(IoError), FormatError(FormatError) } #[derive(Debug, Copy)] pub enum FormatError { Un...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] pub const ALLOW_PARTIAL_READS: u32 = 5u32; #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] pub struct ALTERNATE_INTERFACE { pub InterfaceNumber: u16, pub Al...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)]...
#[cfg(unix)] use nix::libc; use std::{sync, thread}; /// Get an identifier for the thread; uses gettid on linux; pthread_threadid_np on mac; GetCurrentThreadId on windows. #[inline] pub fn gettid() -> u64 { #[cfg(any(target_os = "android", target_os = "linux"))] { use nix::unistd; Into::<libc::pid_t>::into(unist...
use bevy::{ asset::{AssetLoader, LoadedAsset}, prelude::*, reflect::TypeUuid, }; pub use pyxel; use pyxel::Pyxel; use serde::Deserialize; #[derive(Debug, Deserialize, TypeUuid)] #[uuid = "9da4b419-2d5f-4def-a63b-bcc1f43254d4"] pub struct PyxelFile { /// The file's name pub file_name: String, //...
use std::cmp::Ordering; use std::collections::BinaryHeap; use std::usize; #[derive(Copy, Clone, Eq, PartialEq)] struct State { cost: usize, position: usize, pre_node: usize, } impl Ord for State { fn cmp(&self, other: &State) -> Ordering { other .cost .cmp(&self.cost) ...
use opengl_graphics::shader_utils::{Shader, DynamicAttribute, compile_shader}; use opengl_graphics::gl::types::GLuint; use opengl_graphics::{gl, GlGraphics}; use opengl_graphics::GLSL; use graphics::BACK_END_MAX_VERTEX_COUNT; use opengl_graphics::shader_uniforms::{ShaderUniform, SUMat4x4, SUVec3, SUVec4}; use cgmath::{...
#[doc = "Reader of register PPSCTRL"] pub type R = crate::R<u32, super::PPSCTRL>; #[doc = "Writer for register PPSCTRL"] pub type W = crate::W<u32, super::PPSCTRL>; #[doc = "Register PPSCTRL `reset()`'s with value 0"] impl crate::ResetValue for super::PPSCTRL { type Type = u32; #[inline(always)] fn reset_va...
#[doc = "Reader of register ECR"] pub type R = crate::R<u32, super::ECR>; #[doc = "Writer for register ECR"] pub type W = crate::W<u32, super::ECR>; #[doc = "Register ECR `reset()`'s with value 0"] impl crate::ResetValue for super::ECR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { ...
// mengakses array dengan `index` fn main() { let number = [1,2,3]; println!("{}", number[0]); }
#![feature(proc_macro_hygiene, decl_macro)] // Nightly-only language features needed by rocket // Macros from rocket #[macro_use] extern crate rocket; use std::collections::HashMap; use oauth2::token::{AccessToken, Scope, TokenType}; use oauth2::user::{User, UserId}; struct Server { user_list: Vec<User>, ...
use std::io; use std::io::prelude::*; use std::net::TcpStream; use std::num; use std::sync::mpsc; use message; #[derive(Debug)] pub enum ClientError { Io(io::Error), ClientId(num::ParseIntError), Other, } pub struct Client<W: Write> { pub id: u64, out: W, events: mpsc::Receiver<message::Mess...
use crate::{Attribute, Listener, Mailbox, Property}; use derivative::Derivative; use std::rc::Rc; use web_sys as web; #[derive(Derivative)] #[derivative(Debug(bound = ""))] pub enum Aspect<Message> { Attribute(Attribute), Property(Property), Listener(Listener<Message>), } impl<Message: 'static> Aspect<Mes...
test_stdout!( with_small_integer_divisor_returns_small_integer, "true\n1024\n" ); test_stdout!(with_big_integer_divisor_returns_zero, "false\n0\n");
pub struct Solution; impl Solution { pub fn eval_rpn(tokens: Vec<String>) -> i32 { use std::str::FromStr; let mut stack = Vec::new(); for token in tokens { if let Ok(n) = i32::from_str(&token) { stack.push(n); } else if token == "+" { ...
mod render_buffer; pub use render_buffer::RenderBuffer; mod image_buffer; pub use image_buffer::Image; mod instance_buffer; pub use instance_buffer::InstanceBuffer;
// ByteArray, IntArray and LongArray serialization use coruscant_nbt::as_nbt_array; use serde::Serialize; #[derive(Serialize)] struct Wrap<'a> { list_of_bytes: &'a [i8], // no attributes, do it as ListTag of bytes . #[serde(serialize_with = "as_nbt_array")] // special attribute used, regard ...
pub mod contour; pub mod rstar;
//! xshell is a swiss-army knife for writing cross-platform "bash" scripts in //! Rust. //! //! It doesn't use the shell directly, but rather re-implements parts of //! scripting environment in Rust. The intended use-case is various bits of glue //! code, which could be written in bash or python. The original motivatio...
// Copyright 2018 Grove Enterprises 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 ...
use super::Topic; use super::FirstUpper; pub struct ListStrings; impl FirstUpper for String { fn first_upper(&self) -> String { let (first, last) = self.split_at(1); first.to_uppercase() + last } } impl Topic for ListStrings { fn run_example(&self, n: u8) { println!("Topic: {...
use utilities::prelude::*; use super::pipeline::PipelineType; use crate::prelude::*; use crate::impl_vk_handle; use std::sync::{Arc, Mutex}; pub struct QueryEnable { pub query_flags: VkQueryControlFlagBits, pub pipeline_statistics: VkQueryPipelineStatisticFlagBits, } pub struct CommandBufferBuilder { b...
use crate::gl_wrapper::vao::VAO; use crate::gl_wrapper::vbo::{VBO, VertexAttribute}; use std::collections::HashMap; use crate::gl_wrapper::{EBO, BufferUpdateFrequency}; pub struct PredefinedShapes { pub shapes: HashMap<&'static str, VAO>, } impl Default for PredefinedShapes { fn default() -> Self { le...
use std::io::BufRead; use std::ops::RangeInclusive; pub fn run(input: impl BufRead) { let pairs = read_assignment_pairs(input); println!("* Part 1: {}", count_containing(&pairs)); println!("* Part 2: {}", count_overlapping(&pairs)); } fn read_assignment_pairs(input: impl BufRead) -> Vec<AssignmentPair> { ...
//! Som misc shared functionality pub mod fs; use std::path::Path; use std::path::PathBuf; fn is_rust_src(file_path: &Path) -> bool { match std::env::var("RUST_SRC_PATH") { Err(_) => false, Ok(p) => file_path.starts_with(p), } } fn cargo_dir() -> PathBuf { let mut cargo_dir = dirs::home_di...
table! { posts (id) { id -> Integer, title -> Varchar, slug -> Varchar, body -> Text, introduction -> Nullable<Text>, tags -> Array<Varchar>, published -> Bool, created_at -> Timestamp, updated_at -> Timestamp, published_at -> Nullable<...
use crate::{app, db, graphql::ctx::GraphContext}; use chrono::{DateTime, NaiveDateTime, Utc}; use juniper::{FieldError, FieldResult}; pub struct PadsQueryRoot; graphql_object!(PadsQueryRoot: GraphContext |&self| { field all(&executor, req: ApiReqPadsQueryAll) -> FieldResult<ApiRespPadsQueryAll> { query_al...
//! Tests auto-converted from "sass-spec/spec/selector-functions" //! version 0f59164a, 2019-02-01 17:21:13 -0800. //! See <https://github.com/sass/sass-spec> for source material.\n //! The following tests are excluded from conversion: //! ["extend/nested", "extend/simple", "is_superselector", "parse", "replace", "unif...
use crate::context::Context; use crate::position::lsp_range_to_kakoune; use crate::types::{EditorMeta, EditorParams, PositionParams}; use crate::util::{editor_quote, get_file_contents, get_lsp_position, short_file_path}; use itertools::Itertools; use lsp_types::request::{GotoDefinition, GotoImplementation, GotoTypeDefi...
use std::any::type_name; use std::cmp::Ordering; use itertools::Itertools; pub use regex::Regex; #[cfg(feature = "use_serde")] use serde::{Deserialize, Serialize}; pub use agg::AggregationMethod; pub use column::{ColumnDefinition, SimpleColumn}; pub use datatype::ClickhouseDataType; use h3ron::H3_MAX_RESOLUTION; use ...
use std::{ error::Error, fs::File, io::{ self, prelude::*, }, net::TcpStream, }; use clipboard::{ ClipboardContext, ClipboardProvider, }; use crate::app; pub struct Cmd { file: Option<String>, clip: bool, remote: String, } impl Cmd { pub fn from_args() -> Self { let m = app::new().get_matches(); ...
//! Query AST models pub mod identifier; pub use self::identifier::Identifier; pub mod statement; pub use self::statement::Statement; pub mod expression; pub use self::expression::Expression; pub mod call_expression; pub use self::call_expression::CallExpression; pub mod member_expression; pub use self::member_express...
//! # Monotron API //! //! This crate contains the Userspace to Kernel API for the Monotron. //! //! It is pulled in by the Kernel (github.com/thejpster/monotron) and the //! various user-space example applications //! (github.com/thejpster/monotron-apps). //! //! The API in here is modelled after both the UNIX/POSIX A...
// The database connection, the parameters for creating one, and authenticaton. mod am_conn_core; mod authentication; mod connection_core; mod initial_request; mod params; mod session_state; mod tcp_client; pub use am_conn_core::AmConnCore; use authentication::AuthenticationResult; pub use connection_core::Connectio...
use diesel::sqlite::SqliteConnection; use iron::typemap::Key; use iron::{Plugin, Request}; use persistent::Write; use r2d2::{Pool, PooledConnection}; use r2d2_diesel::ConnectionManager; use errors::*; /// Struct to attach a database connection pool to an iron request. pub struct ConnectionPool; impl ConnectionPool {...
use std::net::TcpStream; use anyhow::Result; use std::io::{Write, BufReader}; use std::iter; use std::time::Duration; use std::io::BufRead; use crate::ircclient::message::IrcMessage; pub mod message; const DEFAULT_IRC_PORT:isize = 6667; pub struct IrcClient { config:Config, socket:Option<TcpStream> } pub struct I...
/* Part 1 Calculate the spreadsheet's checksum. For each row, determine the difference between the largest value and the smallest value; the checksum is the sum of all of these differences. For example, given the following spreadsheet: 5 1 9 5 7 5 3 2 4 6 8 The first row's largest and smallest values are 9 and 1...
mod erlang; mod golang; mod rust; mod viml; pub use erlang::Erlang; pub use golang::Golang; pub use rust::Rust; pub use viml::Viml; pub trait KeywordPriority { /// Definition/Decleration keywords. const DEFINITION: &'static [&'static str]; /// Dummy reference keywords. const REFERENCE: &'static [&'st...
#[doc = "Reader of register HSSR"] pub type R = crate::R<u32, super::HSSR>; #[doc = "Writer for register HSSR"] pub type W = crate::W<u32, super::HSSR>; #[doc = "Register HSSR `reset()`'s with value 0"] impl crate::ResetValue for super::HSSR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Typ...
use eosio_cdt::eos; use eosio_cdt::{check, expect, print, require_auth, Table, TableIterator}; #[derive(eos::Serialize, eos::Deserialize)] pub struct UserAge { user: eos::Name, age: u16, } impl Table for UserAge { fn new(code: eos::Name, scope: eos::Name) -> TableIterator<UserAge> { TableIterator:...
#[macro_use] extern crate conrod; extern crate find_folder; extern crate piston_window; extern crate netlion; use std::thread; use std::sync::{Arc, Mutex}; use piston_window::{EventLoop, PistonWindow, UpdateEvent, WindowSettings}; use netlion::*; // Generate the ID for the Button COUNTER. widget_ids! { struct Id...
use chrono::{Duration, Utc}; use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation}; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, convert::Infallible, sync::Arc}; use tokio::sync::Mutex; use warp::{http::Response, http::StatusCode, Filter, Rejection, Reply}; type Resul...
use std::{ cmp, collections::{HashMap, hash_map::Entry}, fs::{File, OpenOptions}, io, os::unix::fs::OpenOptionsExt, rc::Rc, }; use syscall::{error::*, flag::O_NONBLOCK, Error, Map, SchemeMut, Result}; #[derive(Default)] pub struct ShmHandle { buffer: Option<Box<[u8]>>, refs: usize } pub...
use crate::prelude::*; use std::ptr; #[repr(C)] #[derive(Debug, Clone)] pub struct VkDescriptorSetLayoutBinding { pub binding: u32, pub descriptorType: VkDescriptorType, pub descriptorCount: u32, pub stageFlagBits: VkShaderStageFlagBits, pub pImmutableSamplers: *const VkSampler, } impl VkDescript...
#[doc = "Reader of register DMACTL0"] pub type R = crate::R<u16, super::DMACTL0>; #[doc = "Writer for register DMACTL0"] pub type W = crate::W<u16, super::DMACTL0>; #[doc = "Register DMACTL0 `reset()`'s with value 0"] impl crate::ResetValue for super::DMACTL0 { type Type = u16; #[inline(always)] fn reset_va...
// Wiggle Subsequence // https://leetcode.com/explore/challenge/card/march-leetcoding-challenge-2021/590/week-3-march-15th-march-21st/3676/ pub struct Solution; impl Solution { #[cfg(disable)] pub fn wiggle_max_length(nums: Vec<i32>) -> i32 { enum State { Any(i32), Min(i32), ...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[link(name = "windows")] extern "system" { #[cfg(feature = "Win32_Foundation")] pub fn BuildCommDCBA(lpdef: super::super::Foundation::PSTR, lpdcb: *mut DCB) -> super::super::Foundation::BOOL; ...
use crate::sig::HasWrite; use nom::{ multi::count, number::complete::{le_f32, le_u16}, IResult, }; use std::fmt; #[derive(Debug)] // Поля публичные, добавить интерфейс pub struct Opening { pub num_points: u16, //Количество точек отверстия pub x_vec: Vec<f32>, //Последовательность х координат всех т...
// 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 LICENSE file. use crate::scenic::types::ScreenshotDataDef; use failure::{Error, ResultExt}; use fidl_fuchsia_ui_app::{ViewConfig, ViewMarker, ViewProviderMarker}; use fi...
macro_rules! bigint { ( $t:ident, $body:item ) => { #[cfg(feature="inclramp")] mod ramp { #[allow(dead_code)] type $t = ::RampBigInteger; $body } #[cfg(feature="inclgmp")] mod gmp { #[allow(dead_code)] type $t = :...
use sdl2::messagebox::*; use json; use std::fs::File; use std::io::Read; use std::io::Write; fn once_introduced() { let mut file = match File::open("./meta.json") { Err(err) => panic!("'meta.json' file is unable to be read. {}", err), Ok(file) => file, }; let mut buffer = Str...
// Following https://bodil.lol/parser-combinators/ // From the above: 'nom' is the state of the art in Rust parsers, 'pom' is like the following file, 'combine' is also popular. #![allow(dead_code)] // We will parse the following xml-subset: // <parent-element> // <single-element attribute="value" /> // </parent-el...
// Author: Artyom Liu use clap::{Arg, App}; mod http; // parse/deliver the http packet mod config; // parse the given config file in TOML form mod mthread; // thread pool for multi-thread use crate::config::Config; use crate::mthread::ThreadPool; use std::process::exit; use std::sync::Mutex; use lazy_static:...
use chars::human_names; use proptest::prelude::*; use std::fmt::Write; fn diagnostics(ch: char, query: &str) -> String { format!( "char: {:?} / {}, query: {:?}", ch, ch.escape_unicode(), query ) } proptest! { #![proptest_config(ProptestConfig::with_cases(100_000))] #[...
#[doc = "Reader of register LPMCNTRL"] pub type R = crate::R<u8, super::LPMCNTRL>; #[doc = "Reader of field `TXLPM`"] pub type TXLPM_R = crate::R<bool, bool>; #[doc = "Reader of field `RES`"] pub type RES_R = crate::R<bool, bool>; #[doc = "LPM Enable\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] #[rep...
use super::{ ifaces::RwLockIface, ttas::{TTas, TTasGuard}, }; use std::cell::UnsafeCell; use std::{ fmt, time::{Duration, Instant}, }; use std::{ marker::PhantomData as marker, ops::{Deref, DerefMut}, }; use std::{thread, thread::ThreadId}; const READ_OPTIMIZED_ALLOC: usize = 50_usize; struct ...
use amethyst::core::Time; use amethyst::core::ecs::{WriteStorage, System, Read, WriteExpect, World}; use amethyst::ui::UiText; use crate::timer::TimerText; use amethyst::prelude::SystemDesc; use amethyst::core::ecs::shred::SystemData; use crate::state::Pause; pub struct TimerSystem; impl<'a, 'b> SystemDesc<'a, 'b, Ti...