text
stringlengths
8
4.13M
// unihernandez22 // https://atcoder.jp/contests/abc153/tasks/abc153_a // math use std::io::stdin; fn main() { let mut s = String::new(); stdin().read_line(&mut s).unwrap(); let words: Vec<i64> = s .split_whitespace() .map(|x| x.parse().unwrap()) .collect(); let h = words[0];...
#![allow(dead_code, unused)] #![feature(arc_unwrap_or_clone)] mod bgp_type; pub mod config; mod connection; mod error; mod event; mod event_queue; mod packets; mod path_attribute; pub mod peer; pub mod routing; mod state;
fn string_compression(s: &str) -> String { // let mut a = 0; let mut s1 = String::new(); let mut prev = s.chars().next().unwrap(); for c in s.chars() { // if c == prev { a += 1; } else { s1.push_str(&*format!("{}{}", prev, a)); a = 1; ...
use std::io; use std::error::Error; // fn main() -> Result<(), Box<dyn Error>> { //Option<T> let result = Some(5); // some method value let fail = None; let result = do_something(result); println!("{}", result.unwrap_or_else(|| 666)); println!("{}", fail.unwrap_or_else(|| 666)); // fail....
use http_muncher::ParserHandler; use std::mem; use std::str; use std::collections::HashMap; pub struct Request { pub method: Option<String>, pub path: Option<String>, pub headers: HashMap<String, String>, pub body: Option<String>, last_header_field: Option<String> } impl Request { pub fn new(...
use byteorder::{BigEndian, LittleEndian}; use crate::{ Endianness, errors::*, pcap::Packet, pcap::PcapHeader, peek_reader::PeekReader }; use std::io::Read; /// Wraps another reader and uses it to read a Pcap formated stream. /// /// It implements the Iterator trait in order to read one packet at...
// This file is part of Substrate. // Copyright (C) 2019-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 anyhow::{anyhow, bail, Result}; use serde::de::{self, DeserializeOwned, Visitor}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::convert::TryInto; use std::hash::{Hash, Hasher}; use std::{fs, fmt}; use std::io::{Seek, SeekFrom, Write}; use std::marker::PhantomData; pub struct BinaryConfig<...
use assembly_fdb::mem::{Database, Tables}; use mapr::Mmap; use std::{fs::File, path::PathBuf, time::Instant}; use structopt::StructOpt; #[derive(Debug, StructOpt)] /// Prints the names of all tables and their columns struct Options { /// The FDB file file: PathBuf, } fn main() -> color_eyre::Result<()> { ...
mod cut_and_paste; mod kv; pub mod pkcs7;
use super::conn_pipe::*; use super::*; #[tokio::test] async fn test_pipe() -> Result<()> { let (c1, c2) = pipe(); let mut b1 = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let n = c1.send(&b1).await?; assert_eq!(n, 10); let mut b2 = vec![133; 100]; let n = c2.recv(&mut b2).await?; assert_eq!(n, 10...
fn main() { // let a: [f64; 4] = [32., 45., -10., 69.]; // for x in a.iter() { // println!("{}", farenheit_to_celsius(*x)); // } // for n in 0..10 { // println!("{}", fibonacci(n)); // } tweleve_days(); } // fn farenheit_to_celsius(x: f64) -> f64 { // (x - 32.) * (5. / 9.)...
use std::cmp::Ordering; fn main() { let s = [10, 12, 13, 14, 18, 20, 25, 27, 30, 35, 40, 45, 47]; println!("{:?}", binary_search(&s, 18)); } fn binary_search(s: &[i32], x: i32) -> Option<usize> { location(s, x, 0, s.len()) } fn location(s: &[i32], x: i32, low: usize, high: usize) -> Option<usize> { ...
#[macro_use] pub mod macros; pub mod error; pub mod varint; pub mod byte; pub mod comparator; pub mod slice;
use rand::prelude::*; // Not too much revolutionary here in the definition of reference types #[derive(Debug, PartialEq)] // deriveable traits struct Building { name: String, number: u32, owner: String, location: String, valdermort_controlled: bool } // you can seperate out your impl - Convention ...
mod initialize; mod runtime; use { data::semantics::Semantics, proc_macro2::{Span, TokenStream}, quote::{quote, quote_spanned}, }; impl Semantics { pub fn runtime() -> TokenStream { let header = Self::header(); let runtime_register_functions = Self::runtime_register_functions(); let runtime_render_functions...
#![cfg_attr(feature = "unstable", feature(test))] // Launch program : cargo run --release < input/input.txt // Launch benchmark : cargo +nightly bench --features "unstable" /* Benchmark results: running 5 tests test tests::test_part_1 ... ignored test tests::test_part_2 ... ignored test bench::bench_...
use crate::common::{delay_for, factories::prelude::*}; use common::futures_util::stream::StreamExt; use common::log::Level; use common::rsip::{self, prelude::*}; use models::transport::TransportMsg; use sip_server::transport::processor::Processor as TransportProcessor; use std::any::Any; use std::convert::{TryFrom, Try...
///// chapter 3 "using functions and control structures" ///// program section: // fn increment_power(power: i32) -> i32 { println!("my power is going to increase:"); if power < 100 { 999 } else { 0 } } fn main() { ///// function is called // let power = increment_power(1); println!("my power l...
use std::fmt; use crate::{ error::{cuda_error, CudaResult}, sys, Cuda, }; /// A CUDA device or API version #[derive(Clone, Copy, Debug)] pub struct CudaVersion { pub major: u32, pub minor: u32, } impl From<u32> for CudaVersion { fn from(version: u32) -> Self { CudaVersion { ma...
pub mod thick_2_ofn; pub mod util; pub mod ofn_typing; pub mod ofn_labeling; pub mod ldtab_2_ofn; pub mod ofn_2_man; pub mod ofn_2_ldtab; pub mod ofn_2_rdfa; pub mod ofn_2_thick; pub mod owl;
#[derive(Debug)] pub struct FitHeader { pub size: u8, pub protocol_version: u8, pub profile_version: u16, pub data_size: u32, pub fit_str: String, pub crc: u16 } impl Default for FitHeader { fn default() -> FitHeader { return FitHeader{ fit_str: String::new(), ...
#![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; mod web; mod data; mod demo; mod leet_code; fn main() { //力扣 leet_code::main(); //测试demo demo::main(); //init web service web::main(); }
use proconio::input; #[allow(unused_imports)] use proconio::source::auto::AutoSource; #[allow(unused_imports)] use proconio::marker::{Chars, Bytes}; #[allow(unused_imports)] use num::integer::{sqrt, gcd, lcm}; #[allow(unused_imports)] use std::cmp::{max, min, Reverse}; fn main() { // let source = AutoSource::from(...
#![allow(dead_code)] use std::io; use std::error::Error; use std::result::Result; use std::iter::{Iterator, IntoIterator}; use std::collections::HashMap; use std::collections::hash_map; use std::vec::Vec; use std::vec; use std::cmp::{Eq, PartialEq}; use std::hash::{Hash, Hasher}; use std::convert::From; use std::slice;...
pub fn a() {} #[cfg(test)] mod tests { use crate::a; #[test] fn it_works() { a(); } }
//! This module contains a configuration of a [`Border`] or a [`Table`] to set its borders color via [`Color`]. //! //! [`Border`]: crate::settings::Border //! [`Table`]: crate::Table use std::{borrow::Cow, ops::BitOr}; use crate::{ grid::{ color::{AnsiColor, StaticColor}, config::{ColoredConfig, ...
/// An enum to represent all characters in the Osmanya block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum Osmanya { /// \u{10480}: '𐒀' LetterAlef, /// \u{10481}: '𐒁' LetterBa, /// \u{10482}: '𐒂' LetterTa, /// \u{10483}: '𐒃' LetterJa, /// \u{10484}: '𐒄' Lette...
#[derive(Default, Debug, Clone, PartialEq, serde_derive::Serialize, serde_derive::Deserialize)] #[serde(rename_all = "camelCase")] pub struct Root { pub id: String, pub sector_tree: SectorTree, pub content: Content, } #[derive(Default, Debug, Clone, PartialEq, serde_derive::Serialize, serde_derive::Deseria...
use amethyst::ecs::prelude::{Component, VecStorage}; /// A physics-affected entity need to have either friction, air resistance or both, /// otherwise it won't move. #[derive(Debug, Default, Clone)] pub struct PhysicalProperties { /// The weight of the entity itself, like a car's empty mass. pub mass: f32, ...
use cid::Cid; use sp_std::{ self, collections::btree_map::BTreeMap, vec::Vec, }; #[derive(Clone, PartialEq)] pub enum Ipld { /// Represents the absence of a value or the value undefined. Null, /// Represents a boolean value. Bool(bool), /// Represents an integer. Integer(i128), /// Represents a flo...
mod call_stack; use std::iter; use datum::Datum; use spell::Instruction; use spell::Local; use spell::SpellId; pub use self::call_stack::*; /// Interpret a single instruction and return what should happen to the call /// stack. #[inline(always)] pub fn interpret_instruction<'a>( program_counter: ProgramCounter<...
fn main() { // Line comments /* Block Comments */ // println!("Rust or Go?") /* public static void main(String[] args) { System.out.print.ln("Hello, World!"); } */ println!("Hello World!"); println!("I'm Rustacean!\nAre you?"); let x = 5 + /* 90 + */ 5; ...
fn down_heap<T: Ord>(a: &mut [T], i: usize, n: usize) { let mut p = i; loop { let q = p; let left = (q << 1) + 1; if left < n && a[p] < a[left] { p = left } let right = (q << 1) + 2; if right < n && a[p] < a[right] { p = right } a.swap(q, p); if q == p { br...
use std::collections::HashMap; use std::iter::empty; use std::time::Instant; use hymns::vector2::Point2; const INPUT: &str = include_str!("../input.txt"); fn make_point(coord: &str) -> Point2<i32> { let mut coords = coord.split(',').map(|c| c.parse().unwrap()); let x: i32 = coords.next().unwrap(); let y:...
extern crate proc_macro; mod debug_with; #[proc_macro_derive(DebugWith)] pub fn derive_debug_with(input: proc_macro::TokenStream) -> proc_macro::TokenStream { // Parse the input tokens into a syntax tree. let input = syn::parse_macro_input!(input as syn::DeriveInput); // Used in the quasi-quotation below...
use crate::config::rule::Modifier; use crate::error::MatcherError; use log::*; use tornado_common_api::Value; pub mod lowercase; pub mod replace; pub mod trim; #[derive(Debug, PartialEq)] pub enum ValueModifier { Lowercase, ReplaceAll { find: String, replace: String }, Trim, } impl ValueModifier { pu...
#[doc = "Register `APB1RSTR1` reader"] pub type R = crate::R<APB1RSTR1_SPEC>; #[doc = "Register `APB1RSTR1` writer"] pub type W = crate::W<APB1RSTR1_SPEC>; #[doc = "Field `TIM2RST` reader - TIM2 timer reset"] pub type TIM2RST_R = crate::BitReader<TIM2RST_A>; #[doc = "TIM2 timer reset\n\nValue on reset: 0"] #[derive(Clo...
use super::constants::*; use crate::constants::*; use crate::engine::{ input::GameInput, ui::{view, UIComponent, ViewAttr::*, ViewBuilder}, }; use sdl2::{keyboard::Keycode, render::Canvas, video::Window}; use std::{collections::HashMap, path::Path}; const game_dir: &str = "~/personal/rust/game/"; const game_co...
use log::info; use std::time::Duration; use tokio::sync::mpsc::Sender; use tokio::timer::Interval; use crate::fetcher; use crate::{Configuration, Messages}; pub async fn run_iterations(config: Configuration, sender: Sender<Messages>) { let mut iteration: usize = 0; let mut interval = Interval::new_interval(Du...
use super::identifier::*; use super::MatrixErrorBody; use actix_web::{ get, post, web::{HttpResponse, Json}, Responder, }; use serde::{Deserialize, Serialize}; /// Represents the list of login flows returned by the serve_login_types endpoint #[derive(Serialize)] struct LoginFlow<'a> { flows: [LoginTyp...
extern crate ctest; use std::env; use std::path::PathBuf; fn main() { let root = PathBuf::from(env::var_os("DEP_JEMALLOC_ROOT").unwrap()); let mut cfg = ctest::TestGenerator::new(); cfg.header("jemalloc/jemalloc.h") .include(root.join("include")) .fn_cname(|rust, link_name| link_name.unwrap...
use libc::{c_int, c_longlong, c_uint, c_ulonglong, c_void, size_t}; pub type herr_t = c_int; pub type htri_t = c_int; pub type hsize_t = c_ulonglong; pub type hssize_t = c_longlong; pub type hbool_t = c_uint; #[cfg(target_pointer_width = "32")] pub type haddr_t = u32; #[cfg(target_pointer_width = "64")] pub type hadd...
use async_metronome::{assert_tick, await_tick}; use futures::{channel::mpsc, SinkExt, StreamExt}; #[async_metronome::test] async fn test_send_receive() { let (mut sender, mut receiver) = mpsc::channel::<usize>(1); let sender = async move { assert_tick!(0); sender.send(42).await.unwrap(); ...
use std::env; use std::fs::File; use std::io::{self, BufRead, BufReader, BufWriter, Write}; use glob::{ GlobResult, glob }; mod graph; use graph::*; fn main() -> Result<(), Box<dyn std::error::Error>>{ let mut args = env::args(); args.next().unwrap(); let output_path = args.next().unwrap(); let mut...
//! Executable for working with .sdc files. extern crate docopt; extern crate rustc_serialize; extern crate sdc; use std::process::exit; use docopt::Docopt; use sdc::{Reader, Version}; const USAGE: &'static str = " Work with .sdc files. Usage: sdc info <infile> [--brief] \ sdc...
use crate::preset; use crate::layer; use crate::output; use std::io::prelude::*; use std::net::TcpStream; use std::{thread,time}; #[derive(Debug)] enum Command { DiVentix(String), DelayMS(u64), } #[derive(Debug)] pub struct Cmd { cmds: Vec<Command>, } impl Cmd { pub fn new() -> Cmd { Cmd { ...
//! ## Data for the [`Pet Control` component](https://docs.lu-dev.net/en/latest/components/034-pet-control.html) use serde::{Deserialize, Serialize}; /// Data for the [`Pet Control` component](https://docs.lu-dev.net/en/latest/components/034-pet-control.html) #[derive(Default, Debug, PartialEq, Deserialize, Serialize...
#![deny(warnings)] #[macro_use] extern crate warp; use warp::Filter; fn main() { let route_home = warp::filters::path::end() .map(|| "home"); let route_info = warp::path("info") .map(|| "info"); let cors = warp::cors() .allow_any_origin() .allow_method("post") ...
use crossterm::event::{self, Event as CEvent, KeyEvent}; use std::{convert::TryInto, io::{Stdout}, sync::mpsc::Sender, thread, time::{Duration, Instant}}; use tui::{Frame, backend::CrosstermBackend, layout::{Constraint, Direction, Layout}, style::{Color, Modifier, Style}, widgets::{Block, Borders, List, ListItem}}; ...
/* * Copyright 2020 Damian Peckett <damian@pecke.tt> * * 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 applica...
use fake::{Dummy, Fake}; use serde::{Deserialize, Serialize}; pub mod api; pub mod db; #[derive(Debug, Dummy, Clone, PartialEq, Serialize, Deserialize)] pub struct Entry { pub id: Option<i32>, pub start: String, pub stop: String, pub week_day: String, pub code: String, pub memo: String, } #[d...
#[doc = "Register `PDCRD` reader"] pub type R = crate::R<PDCRD_SPEC>; #[doc = "Register `PDCRD` writer"] pub type W = crate::W<PDCRD_SPEC>; #[doc = "Field `PD0` reader - Port D pull-down bit i (i = 3 to 0) Setting PDi bit while the APC bit of the PWR_CR3 register is set activates a pull-down device on the PD\\[i\\] I/O...
// Copyright 2021 Datafuse Labs. // // 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 agre...
/// gives a feature to generic operations that most types except enum cannot be used with the operations. pub(crate) trait EnumSpecific {}
#[doc = "Register `CIER` reader"] pub type R = crate::R<CIER_SPEC>; #[doc = "Register `CIER` writer"] pub type W = crate::W<CIER_SPEC>; #[doc = "Field `LSIRDYIE` reader - LSI ready interrupt enable"] pub type LSIRDYIE_R = crate::BitReader; #[doc = "Field `LSIRDYIE` writer - LSI ready interrupt enable"] pub type LSIRDYI...
use {SystrayError}; pub struct Window { } impl Window { pub fn new() -> Result<Window, SystrayError> { Err(SystrayError::NotImplementedError) } }
use crossbeam::crossbeam_channel::*; #[derive(Debug)] pub struct VM { pub memory: Vec<isize>, ip: usize, sp: usize, pub input: Sender<isize>, reader: Receiver<isize>, pub output: Receiver<isize>, writer: Sender<isize>, } #[derive(PartialEq, Debug, Copy, Clone)] pub enum Address { Position(isize), Im...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Profile control"] pub ctl: CTL, #[doc = "0x04 - Profile status"] pub status: STATUS, _reserved2: [u8; 8usize], #[doc = "0x10 - Profile command"] pub cmd: CMD, _reserved3: [u8; 1964usize], #[doc = "0x7c0 ...
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_lambda::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS Region in...
extern crate diesel_demo; extern crate diesel; use self::diesel_demo::*; use std::io::stdin; fn main() { let connection = establish_connection(); println!("Title:"); let mut title = String::new(); stdin().read_line(&mut title).unwrap(); let title = &title[..(title.len() - 1)]; // Drop the newli...
//! # Pcf8523 //! //! `Pcf8523` is a crate which abstracts away managing a PCF8523 device on an //! I2C bus. You can read the time and write the time, and someday in the future //! do other configuration tasks as well. use chrono::prelude::*; use i2cdev::core::*; use i2cdev::linux::LinuxI2CDevice; #[cfg(test)] mod te...
//! [balena] **c**onfiguration **dsl** //! //! A crate that provides facilities to: //! //! * transform configuration DSL into the JSON Schema & UI Object Schema with custom extensions //! * parse configuration DSL //! //! # Versioning //! //! This crate is being actively developed and it does NOT follow [Semantic Vers...
#[cfg(test)] mod hash_test { #![feature(map_first_last)] use std::collections::BTreeMap; use std::{ fs::File, io::{BufRead, BufReader}, u64, }; use crypto::digest::Digest; use crypto::md5::Md5; use hash::{Bkdr, Crc32, Hash}; use std::ops::Bound::Included; #...
use super::{Allocator, Layout}; use core::{ffi::c_void, ptr::NonNull}; use win32::kernel32; #[derive(Clone, Copy, Default)] pub struct Win32HeapAllocator; impl Allocator for Win32HeapAllocator { unsafe fn alloc(&mut self, layout: Layout) -> Option<NonNull<c_void>> { let ptr = kernel32::HeapAlloc(kern...
use std::sync::{Arc, Mutex, atomic::{AtomicUsize, Ordering}}; use crate::{LobbyEvent, LobbyManager, MatchLogEvent, LobbyData, StrippedPlayer}; use futures::{StreamExt, future}; use futures::FutureExt; use mozaic_core::Token; use serde::{Serialize, Deserialize}; use tokio::sync::mpsc; use tokio_stream::wrappers::Unboun...
use crate::ret_none_if; use crate::name::NamePtr; use crate::expr::{ Expr, ExprsPtr, ExprPtr, Expr::* }; use crate::level::LevelsPtr; use crate::env::{ Declar, Declar::* }; use crate::utils::{ List::*, Tc, IsCtx }; use crate::tc::eq::ShortCircuit::*; use crate::tc::infer::InferFlag::*; impl<'t, '...
//! This example demonstrates how [`CompactTable`] is limited to single //! line rows. //! //! * Note how the multiline data is accepted, but then truncated in the display. use tabled::{settings::Style, tables::CompactTable}; fn main() { let data = [ ["De\nbi\nan", "1.1.1.1", "true"], ["Arch", "12...
extern crate mio; use std::net::{SocketAddr}; use std::collections::HashMap; use mio::{Events, Poll, Ready, PollOpt, Token}; use mio::net::{TcpListener, TcpStream}; struct WebSocketServer { socket: TcpListener, clients: HashMap<Token, TcpStream>, token_counter: usize } // Setup some tokens to allow us t...
use reqwest::header::CONTENT_TYPE; use std::fmt::Debug; use telegram_types::bot::methods::{ChatTarget, GetUpdates, Method, SendDocument, TelegramResult}; use telegram_types::bot::types::{FileToSend, InputFile, Message, Update}; async fn make_request<T: Method + Debug>(data: &T) -> TelegramResult<T::Item> { let tok...
use std::sync::Arc; use async_graphql::{Context, EmptySubscription, Object, Result, Schema}; use crate::{domains::counter::Counter, port::CounterRepository}; pub struct QueryRoot; #[Object] impl QueryRoot { async fn find_counter(&self, ctx: &Context<'_>, name: String) -> Result<CounterResolver> { let co...
#[macro_use] extern crate lazy_static; use std::num::NonZeroU32; use std::convert::TryInto; #[derive(Eq, PartialEq, Hash, Copy, Clone, Debug)] pub enum Encoding { Unicode, AdobeStandard, AdobeExpert, AdobeSymbol, AdobeZdingbat, WinAnsiEncoding, } pub enum Transcoder { Id, Forward(&'sta...
use super::*; #[test] fn select_1() { assert_eq!( Query::select() .columns(vec![Char::Character, Char::SizeW, Char::SizeH]) .from(Char::Table) .limit(10) .offset(100) .to_string(PostgresQueryBuilder), r#"SELECT "character", "size_w", "size...
use std::mem::size_of; use std::thread::sleep; use libc::c_uchar; use libc::{c_int, c_void}; #[repr(C)] #[warn(improper_ctypes)] struct VideoParam { width: u32, height: u32, fps: u32, file_or_stream_flag: u32, file_or_stream_url: String, } #[repr(C)] #[warn(improper_ctypes)] struct Video; extern...
use axum::{ http::{header, HeaderValue, Request}, middleware::Next, response::IntoResponse, }; use blake3::Hasher; /// Functions related to caching and cache busting. use cached::proc_macro::cached; use std::{fs::File, io}; /// Generate the blake3 hash of the file at the given path. /// Returns the hash as...
use std::collections::HashMap; use std::thread; use std::str; use std::ops::Deref; use std::sync::{mpsc, Arc, Mutex}; use websocket::{self, server, stream, sender, Sender, Receiver, Message}; use rustc_serialize::json; const WS_ADDR: &'static str = "0.0.0.0:1981"; #[derive(Debug, Clone)] #[derive(RustcDecodable, Rust...
use math::*; use ray::Ray; use super::geometry::Geometry; use super::intersection::Intersection; pub struct Sphere { pub position: Vector3, pub radius: f32, } impl Geometry for Sphere { fn intersect(&self, ray: &Ray) -> Option<Intersection> { let po = ray.origin - self.position; let b = ray.direction.do...
use std::cmp::*; use std::collections::*; use std::io::*; use std::str::FromStr; fn read<T: FromStr>() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) ...
use crate::enums::{Event, Font, FrameType, Key, Mode, Shortcut}; use crate::prelude::*; use crate::utils::FlString; use crate::window::Window; use fltk_sys::fl; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use std::{ any, cmp, ffi::{CStr, CString}, marker, mem, os::raw, ...
#[doc = "Reader of register RCC_MP_APB3ENCLRR"] pub type R = crate::R<u32, super::RCC_MP_APB3ENCLRR>; #[doc = "Writer for register RCC_MP_APB3ENCLRR"] pub type W = crate::W<u32, super::RCC_MP_APB3ENCLRR>; #[doc = "Register RCC_MP_APB3ENCLRR `reset()`'s with value 0"] impl crate::ResetValue for super::RCC_MP_APB3ENCLRR ...
use wasm_bindgen::prelude::*; use super::Object3D; #[wasm_bindgen(module = "three")] extern "C" { #[wasm_bindgen(extends = Object3D)] pub type Camera; #[wasm_bindgen(constructor)] pub fn new() -> Camera; } #[wasm_bindgen(module = "three")] extern "C" { #[wasm_bindgen(extends = Camera)] pub t...
use super::Point; use super::Translate; /// Standard pixel size pub const SIZE: u32 = 10; /// A simple text object #[derive(Debug, Clone, PartialEq, Hash)] pub struct Text { /// Position of the text pub point: Point, /// The actual text string pub text: String, /// The font size, pub size: u3...
#![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 ErrorResponse { #[serde(default, skip_serializing_if = "Option::is_none")] pub error: Option<ErrorResponseB...
use ast; use ast::AstExpressionNode; use ast::Block; use ast::PointerType; use ast::Expression; use ast::Function; use ast::FunctionCall; use ast::Program; use ast::Statement; use ast::VarType; use code_block::CodeBlock; use std::collections::VecDeque; use std::collections::HashMap; // This function checks that the ...
#![allow(non_snake_case)] #![allow(unused_assignments)] #![allow(dead_code)] use libc::{c_int,c_uint, c_void}; use super::encode::{UTF82UCS2,UCS2TOUTF8}; use super::types::{MSG}; pub type DWnd = * const c_void; extern "stdcall"{ //Window Text pub fn GetWindowTextLengthW(hWnd:DWnd)->c_int; pub fn GetWindowTextW...
mod triangle; mod wall; use wall::Wall; fn main() { let wall = Wall::new(String::from("input.txt")); println!("Number possible triangles on wall: {}", wall.possible_triangles_count()); }
use std::iter::FromIterator; use std::collections::HashSet; //was to lazy to implement my own data structure so I just used one from cargo //Didn't reuse the dfs implementation from day12 extern crate disjoint_set; use disjoint_set::DisjointSet; #[allow(dead_code)] const TEST_INPUT: &str = "flqrgnkx"; const GRID_ROW_...
use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet}; use std::error; use std::fmt; use std::io; use std::iter::FromIterator; use crate::disk::chain::ChainIterator; use crate::disk::error::DiskError; use crate::disk::file::FileOps; use crate::disk::format::DiskFormat; use crate::disk::Direct...
use crate::{buffer::Span, Cell, Merge, Settings}; pub use direction::Direction; pub use fragment::Fragment; pub use fragment_span::FragmentSpan; pub use fragment_tree::FragmentTree; use itertools::Itertools; use std::{ collections::BTreeMap, fmt::Write, ops::{Deref, DerefMut}, }; pub mod direction; pub mod...
#[derive(Default)] struct PizzaConfig { wants_cheese: bool, number_of_olives: i32, special_message: String, crust_type: CrustType } enum CrustType { Thin, Thick } impl Default for CrustType { fn default() -> CrustType { CrustType::Thin } } fn main() { let foo: i32 = Defau...
//! These callbacks should be registered in order to be used by the Lua libraries. //! Only one struct can be used by each interface, but the interfaces can share //! as many structs as they want. It's recommended you have one struct per //! interface, though you can just use one struct if you wish. // Callback module...
#[doc = "Register `CSR` reader"] pub type R = crate::R<CSR_SPEC>; #[doc = "Register `CSR` writer"] pub type W = crate::W<CSR_SPEC>; #[doc = "Field `LSION` reader - LSI oscillator enable"] pub type LSION_R = crate::BitReader<LSION_A>; #[doc = "LSI oscillator enable\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, Par...
use log::{debug, info, warn}; use proxy_wasm::traits::{Context, HttpContext}; use proxy_wasm::types::*; #[no_mangle] pub fn _start() { proxy_wasm::set_log_level(LogLevel::Trace); proxy_wasm::set_http_context(|_, _| -> Box<dyn HttpContext> { Box::new(TestStream) }); } struct TestStream; impl Context for TestS...
trait Monster { fn attack(&self); } struct OrcBerzerker { strength: int } impl Monster for OrcBerzerker { fn attack(&self) { println!("The Orc berserker slashes his axe at your head for {:d}.", self.strength) } } struct SkavenPlagueMonk { strength: int } impl Monster for SkavenPlagueMonk...
#[no_mangle] pub extern fn physics_single_chain_efjc_thermodynamics_isotensional_asymptotic_legendre_helmholtz_free_energy(number_of_links: u8, link_length: f64, hinge_mass: f64, link_stiffness: f64, force: f64, temperature: f64) -> f64 { super::helmholtz_free_energy(&number_of_links, &link_length, &hinge_mass, ...
use crate::cpu::{ioregister, Cpu, Instruction, Reg}; use crate::mem::{self, Memory}; use crate::peripherals::sound; use std::io::{self, Write}; use crate::gebemula::GBMode; struct BreakCommand { break_addr: Option<u16>, break_reg: Option<Reg>, break_ioreg: Option<u16>, break_reg_value: u16, break_d...
// Opcodes are fundamental operations to the CPU, LC-3 only has 16 opcodes. // Each instruction is 16 bits long, with first 4 bits storing the Opcode, // the rest is reserved for the parameter. use super::vm::VM; use std::io; use std::io::Read; use std::io::Write; use std::process; #[derive(Debug)] pub enum OpCode { ...
//! Futures and other types that allow asynchronous interaction with channels. use std::{ future::Future, pin::Pin, task::{Context, Poll}, }; use crate::*; use futures::{Stream, stream::FusedStream, future::FusedFuture}; impl<T> Receiver<T> { #[inline] fn poll(&self, cx: &mut Context<'_>) -> Poll<...
fn main() { let man = env!("CARGO_MANIFEST_DIR").replace('\\', "/"); let protos_dir = format!("{}/../../protos", man); println!("cargo:rerun-if-changed={}", protos_dir); let protos = std::fs::read_dir(protos_dir.as_str()) .expect("Failed to read protos directory") .filter(|path| { ...
//! `FromCast` and `IntoCast` implementations for portable 16-bit wide vectors #![rustfmt::skip] use crate::*; impl_from_cast!( i8x2[test_v16]: u8x2, m8x2, i16x2, u16x2, m16x2, i32x2, u32x2, f32x2, m32x2, i64x2, u64x2, f64x2, m64x2, i128x2, u128x2, m128x2, isizex2, usizex2, msizex2 ); impl_from_cast!( u8x...