text
stringlengths
8
4.13M
use std::{path::PathBuf}; use bevy::{ // math::vec2, prelude::*, render::{ mesh::Indices, pipeline::DynamicBinding, pipeline::PipelineDescriptor, pipeline::PipelineSpecialization, pipeline::RenderPipeline, render_graph::base, render_graph::AssetRender...
#[path = "../lib/intcode.rs"] mod intcode; use anyhow::Context; use intcode::{IntCodeComputer, MemoryValue}; use itertools::Itertools; use std::io::BufRead; const INPUT: &str = include_str!("input.txt"); fn run(memory: &mut [MemoryValue]) -> anyhow::Result<()> { let stdin = std::io::stdin(); let mut istream ...
use std::cell::RefCell; use std::collections::BTreeMap; use std::fmt; use serde::{Deserialize, Serialize}; use super::fmt::FmtGuard; use super::variable::{Keywords, Value}; pub type Outs = BTreeMap<String, Out>; #[derive(Clone, PartialEq, Serialize, Deserialize)] pub struct OutDim { pub out: Out, pub dim: u...
#![allow(dead_code)] #[derive(Default)] pub struct Triangle { pub v: [glm::Vec3; 3], pub color: [glm::Vec3; 3], pub tex_coords: [glm::Vec3; 3], pub normal: [glm::Vec3; 3], pub position: [glm::Vec3; 3], pub perp_pos: [glm::Vec4; 3], } impl Triangle { pub fn new() -> Triangle{ Triang...
#[allow(unused_imports)] use proconio::{marker::*, *}; #[allow(unused_imports)] use std::{cmp::Ordering, convert::TryInto}; #[fastout] fn main() { input! { n: i32, s: String, // s: Chars, } } pub trait CumlativeSum { /// 累積和を取る /// 返り値の先頭要素は番兵の 0 である。 fn cumlative_sum(&sel...
use gl::types::*; use std::ffi::CString; use std::fs::File; use std::io::Read; use std::ptr; use std::str; #[allow(non_snake_case)] pub struct Shader { pub ID: u32, } #[allow(non_snake_case)] impl Shader { pub fn new(vertex_path: &str, fragment_path: &str) -> Self { let mut shader = Self { ID: 0 }; ...
//! # Transient Storage Adapters //! //! A collection of adapters on top of the substrate storage API. //! //! Currently implements a bounded priority queue in the `priority_queue` module. //! Implements a ringbuffer queue in the `ringbuffer` module. pub mod priority_queue; pub mod bounded_deque; pub use priority_que...
use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, Debug, Deserialize, Serialize, Default, Eq, PartialEq, Ord, PartialOrd)] pub struct PlayCount(pub i32); impl PlayCount { pub fn new(count: i32) -> PlayCount { PlayCount(count) } } impl fmt::Display for PlayCount { fn fmt(&self, f:...
extern crate serde; mod test_utils; use flexi_logger::LoggerHandle; use hdbconnect_async::{Connection, HdbResult}; use log::{debug, info}; // cargo test test_036_bool -- --nocapture #[tokio::test] async fn test_036_bool() -> HdbResult<()> { let mut log_handle = test_utils::init_logger(); let start = std::tim...
use crate::ConnectParams; use std::net::TcpStream; #[derive(Debug)] pub struct SyncPlainTcpClient { params: ConnectParams, reader: std::io::BufReader<TcpStream>, writer: std::io::BufWriter<TcpStream>, } impl SyncPlainTcpClient { // Returns an initialized plain tcp connection pub fn try_new(params:...
mod segment_tree; pub use segment_tree::SegmentTree; mod lazy_segment_tree; pub use lazy_segment_tree::LazySegmentTree; mod union_find_tree; pub use union_find_tree::UnionFindTree; mod vector_as_number_collection; pub use vector_as_number_collection::VectorAsNumberCollection;
// 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::{ mod_manager::ModManager, story_context_store::StoryContextStore, story_module::StoryModuleService, }, failure::{...
#![cfg(any(unix, target_os = "redox"))] // FIXME: Remove once we test everything #![allow(dead_code)] /// SharedMimeInfo allows to look up the MIME type associated to a file name /// or to the contents of a file, using the [Freedesktop.org Shared MIME /// database specification][xdg-mime]. /// /// Alongside the MIME ...
use iostream::io::*; use std::fs::remove_file; fn remove_file_s() { let _r = remove_file("1.txt"); let _r = remove_file("2.txt"); let _r = remove_file("3.txt"); } #[test] fn test_create() { { let r = FileStream::new("1.txt", FileMode::Create, FileAccess::ReadWrite); if let Err(i) = r {...
use crate::arrow2::error::Result; use crate::arrow2::ffi::{FFIArrowChunk, FFIArrowSchema, FFIArrowTable}; use arrow2::array::Array; use arrow2::chunk::Chunk; use arrow2::io::ipc::write::{StreamWriter as IPCStreamWriter, WriteOptions as IPCWriteOptions}; use arrow2::io::parquet::read::{ infer_schema, read_metadata a...
use std::borrow::Cow; use std::ops::Deref; use std::{cmp, mem}; use alacritty_terminal::ansi::{Color, CursorShape, NamedColor}; use alacritty_terminal::event::EventListener; use alacritty_terminal::grid::Indexed; use alacritty_terminal::index::{Column, Line, Point}; use alacritty_terminal::selection::SelectionRange; u...
#[cfg(not(target_os = "linux"))] compile_error!("PidFd is only supported on Linux >= 5.3"); use fd_reactor::{Interest, REACTOR}; use std::{ convert::TryInto, future::Future, io, mem::MaybeUninit, os::unix::{ io::{AsRawFd, RawFd}, process::ExitStatusExt, }, pin::Pin, pro...
use std::{ future::Future, pin::Pin, task::{Context, Poll}, time::Duration, }; use pin_project_lite::pin_project; use crate::{ actor::Actor, clock::{sleep, Sleep}, fut::ActorFuture, }; pin_project! { /// Future for the [`timeout`](super::ActorFutureExt::timeout) combinator, interrupts...
use bitfield::bitfield; #[allow(dead_code)] #[derive(Debug, Copy, Clone, PartialEq)] pub enum Register { LeftInputVol = 0x00, RightInputVol = 0x01, Lout1Vol = 0x02, Rout1Vol = 0x03, Clocking = 0x04, Ctr1 = 0x05, Ctr2 = 0x06, AudioIface = 0x07, Clocking2 = 0x08, AudioIface2 = 0x0...
#![crate_name = "uu_link"] /* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; #[macro_use] extern crate uucore; us...
fn main() { let pair = (-2, 0); println!("Katakan padaku tentang {:?}", pair); match pair { (0, y) => println!("Pertama `0` dan `y` adalah `{:?}`", y), (x, 0) => println!("`x` adalah `{:?}` dan terakhir adalah `0`", x), _ => println!("Tidak masallah apa mereka itu"), } }
const MAX_PORT:u64 = 10000; fn main() { let a = 1; let b = 2; let mut ab = 1; println!("hello world{}", a); println!("hello world{}", ab); println!("hello world{}", b); println!("Hello, world!"); ab = 44; println!("{}", ab); let b: f32 = 2.22; println!("b = {}", b); pr...
use libc; extern "C" { pub type __sFILEX; #[no_mangle] fn strerror(_: libc::c_int) -> *mut libc::c_char; #[no_mangle] static mut __stdinp: *mut FILE; #[no_mangle] static mut __stdoutp: *mut FILE; #[no_mangle] static mut __stderrp: *mut FILE; #[no_mangle] fn fclose(_: *mut FIL...
// Copyright 2022 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 agreed to ...
//! File holding the FormHashMap type accepting variable parameters from a Rocket request //! exposing a simplified Map type interface to access them //! //! Author: [Boris](mailto:boris@humanenginuity.com) //! Version: 2.0 //! //! ## Release notes //! - v2.0 : refactored using serde_json Map & Value //! - v1.1 : impl...
//! Intrinsics are instructions Falcon cannot model. use crate::il::*; use serde::{Deserialize, Serialize}; use std::fmt; /// An Instrinsic is a lifted instruction Falcon cannot model. #[derive(Clone, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub struct Intrinsic { mnemonic: String, ...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtWidgets/qcolumnview.h // dst-file: /src/widgets/qcolumnview.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block be...
use std::{unimplemented, vec}; use utils::Vector2; // #[test] pub fn run() { let input = read_input(include_str!("input/day12.txt")); // println!("{:?}", input); println!("{}", exercise_1(&input)); println!("{}", exercise_2(&input)); } pub fn read_input(input: &str) -> Vec<(char, isize)> { input ...
use super::{Fence, Op, Pctr, RawProgram, ValueDecoder}; use crate::index::*; use crate::memory::{Loc, LocArray, Val}; use std::hash::Hash; pub enum Step<P: State> { Return { val: P::Value, }, Ignore, Fence { kind: Fence, next: P, }, Read { loc: Loc, is_ac...
use std::ops; /// A bounded integer. /// /// This has two value parameter, respectively representing an upper and a lower bound. pub struct BoundedInt<const lower: usize, const upper: usize> // Compile time constraints. where lower <= upper { /// The inner runtime value. n: usize, } // To see how this...
use wasm_bindgen::prelude::*; #[wasm_bindgen] pub fn hello() -> String { "Hello wasm".to_owned() }
use crate::utils::*; // choose #[inline(always)] fn ch(x: u32, y: u32, z: u32) -> u32 { ((x) & (y)) ^ (!(x) & (z)) } // majority #[inline(always)] fn maj(x: u32, y: u32, z: u32) -> u32 { ((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)) } #[inline(always)] fn ep0(x: u32) -> u32 { u32::rotate_right(u32::rotate_righ...
#![no_std] extern crate alloc; use alloc::{borrow::ToOwned, string::String}; use hgg::HggLite; use space::{Knn, MetricPoint, Neighbor}; pub struct Dictionary { hgg: HggLite<Word, ()>, lookup_quality: usize, } impl Dictionary { pub fn new() -> Self { Self { hgg: HggLite::new().exclude...
use byteorder::{ByteOrder, LittleEndian as LE}; use custom_error::custom_error; custom_error!{pub Error IncompleteCode{index: usize} = "premature end of code stream at {index}", IncompleteData{index: usize} = "premature end of data stream at {index}" } #[derive(Debug)] pub enum Op { Literal(u8), CopyBytes { count...
extern crate rand; use core::cmp; use std::collections::HashMap; use rand::Rng; use rand::XorShiftRng; use rand::SeedableRng; use utils::ipoint::IPoint; use utils::irange::IRange; use utils::pointrng::PointRng; use state::world::World; use state::level::Level; use objects::wall::Wall; use objects::floor::Floor; #[der...
use bound_int::*; bound_int_types!(Foo, 1, 3); fn main() { println!("1 + 2 + 1 = {}", bound_int_eval!(Foo_1 + Foo_2 + Foo_1).value()); }
use std::io; use std::rand; fn main() { println!("Guess the number!"); let secret_number = (rand::random::<uint>() % 100u) + 1u; loop { print!("Please input your guess (1-100): "); let input = io::stdin().read_line() .ok() .expe...
use error::Error; use serde::{Serialize, Serializer, Deserialize, Deserializer}; use serde::de::{self, Visitor, MapAccess, IntoDeserializer}; use std::fmt::{self, Debug}; use std::str::FromStr; pub const TOKEN: &'static str = "$serde_edn::private::SymbolHack"; pub const FIELD: &'static str = "$__serde_edn_private_sym...
fn main() { use text_grid::*; struct RowData { a: f64, b: f64, } impl CellsSource for RowData { fn fmt(f: &mut CellsFormatter<&Self>) { f.column("a", |&s| cell!("{:.2}", s.a).right()); f.column("b", |&s| cell!("{:.3}", s.b).right()); } } l...
use std::{ sync::{ atomic::{AtomicUsize, Ordering}, Arc, }, time::Duration, }; use metric::DurationCounter; use observability_deps::tracing::*; use parking_lot::Mutex; use tokio::{ sync::Semaphore, task::JoinHandle, time::{Instant, Interval, MissedTickBehavior}, }; use crate::i...
use crate::buf::Buf; use crate::sample::Sample; /// Trait implemented for buffers that can be resized. pub trait ResizableBuf: Buf { /// Resize the number of per-channel frames in the buffer. /// /// # Examples /// /// ```rust /// use audio::{ResizableBuf, ExactSizeBuf as _, Channels as _}; ...
macro_rules! binary_op { ( $inst:ident, $op:tt ) => {{ let a = &$inst.pop(); let b = &$inst.pop(); &$inst.push(b $op a); }} } const STACK_SIZE: usize = 1000; enum Opcode { LITERAL, ADD, SUBSTRACT, MULTIPLY, DIVIDE, PRINT, } impl Opcode { fn from_byte(byte: ...
use std::io; use std::process::{Command, Child}; use x86::cpuid::VendorInfo; use x86::msr::MSR_PKG_POWER_LIMIT; use crate::bitfields::TurboRatioLimitsBitfield; use crate::structures::TurboRatioLimits; use crate::util::byte_slice_to_u64; pub mod util; pub mod structures; pub mod ffi; pub mod bitfields; fn rdmsr(reg...
use af; use af::Array; use utils; use error::HALError; /// Return a vector form of the l2 error /// (y - x) * (y - x) pub fn l2_vec(pred: &Array, target: &Array) -> Array{ let diff = af::sub(pred, target, false); af::mul(&diff, &diff, false) } /// Return a vector form of the mean squared error /// 0.5 * (y - x) ...
use std::process; use std::env; use std::path::{PathBuf}; use clap::{Arg, App, ArgMatches}; use fstree::Options; /* This is a simple command line tool to print the content of a directory as a * string. * arguments: * dir : The name of the dir to tree-ify; * * TODO: *** Print nodes as a tree (This is the goal)...
//! Contains connection components. //! //! # Example //! //! ``` //! use dbus_tokio::connection; //! use dbus::nonblock::Proxy; //! use std::time::Duration; //! //! #[tokio::main] //! pub async fn main() -> Result<(), Box<dyn std::error::Error>> { //! //! // Connect to the D-Bus session bus (this is blocking, unfo...
use crate::config::Config; use crate::errors::*; use crate::messages::*; use crate::pool::*; use crate::stream::*; use crate::types::*; use std::sync::Arc; use tokio::sync::Mutex; /// Abstracts a cypher query that is sent to neo4j server. #[derive(Clone)] pub struct Query { query: String, params: BoltMap, } i...
use pyo3::prelude::*; mod pa { pub use pathfinder_canvas::{ Canvas, CanvasRenderingContext2D, Path2D, FillStyle, FillRule, CanvasFontContext, TextAlign, TextBaseline, }; pub use pathfinder_geometry::{ vector::Vector2F, rect::RectF, transform2d::Transform2F ...
use std::collections::BTreeMap; use std::collections::{HashMap, HashSet}; use std::sync::Arc; use anyhow::anyhow; use firefly_diagnostics::*; use firefly_syntax_base::*; use firefly_util::emit::Emit; use super::*; /// Represents expressions valid at the top level of a module body #[derive(Debug, Clone, PartialEq, S...
#![allow(dead_code)] use std::fs::File; use std::io; use std::io::prelude::*; use std::panic; use std::path::{Path, PathBuf}; use std::process::{Command, Output, Stdio}; use std::str; use tempdir::TempDir; pub fn test_write_file(path: &Path, content: &[u8], file_name: &str) -> PathBuf { let mut file = File::crea...
pub enum Error { Codegen(cranelift_module::ModuleError), } impl From<cranelift_module::ModuleError> for Error { fn from(src: cranelift_module::ModuleError) -> Error { Error::Codegen(src) } } impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { ...
use crate::bulb::LB110; use crate::error::Result; use crate::plug::HS100; use crate::{proto, Bulb, Plug}; use serde_json::{json, Value}; use std::collections::HashMap; use std::net::IpAddr; use std::time::Duration; /// Types of TP-Link Wi-Fi Smart Home Devices. pub enum DeviceKind { /// TP-Link Smart Wi-Fi Plug. ...
#![allow(warnings)] use crate::target::{Concrete, Endpoint, EndpointFromMetadata}; use futures::{future, prelude::*, stream}; use linkerd_app_core::{ discovery_rejected, is_discovery_rejected, proxy::{ api_resolve::Metadata, core::{Resolve, ResolveService, Update}, discover::{self, Buff...
/// A 2D compositor pub struct Compositor2D {}
use num_enum::{IntoPrimitive, TryFromPrimitive}; /// A network domain. #[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)] #[repr(i32)] pub enum Domain { Ipv4 = libc::AF_INET, Unix = libc::AF_LOCAL, } #[cfg(test)] mod tests { use super::*; use std::convert::TryFrom; #[te...
#[derive(Debug)] struct Point { x: i32, y: i32, } impl Point { fn new(x_t: i32, y_t: i32) -> Self { Point { x: x_t, y: y_t } } fn double(&mut self) { self.x *= 2; self.y *= 2; } fn len(x_pos: Point, y_pos: Point) -> f64 { let x_bet = (x_pos.x - y_pos.x) as f64...
/* origin: FreeBSD /usr/src/lib/msun/src/s_fmaf.c */ /*- * Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of ...
/* * hurl (https://hurl.dev) * Copyright (C) 2020 Orange * * 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 ...
use std::env; use std::str; mod puzzle_logic; mod error; fn parse_input(args: Vec<String>) -> [[u32; 9]; 9] { let mut puzzle: [[u32; 9]; 9] = [[0; 9]; 9]; let mut x: usize; for y in 1..10 { x = 0; if args[y].len() != 9 { error::print_usage_error(2); } ...
use std::collections::HashSet; use std::io::{self, BufRead}; fn get_input() -> Vec<String> { let stdin = io::stdin(); let stdin = stdin.lock(); let result = stdin.lines().collect::<Result<_, _>>().expect("Could not read input"); result } struct Passphrase<'a> { words: Vec<&'a str>, } impl <'a> Pa...
use log::{error}; use quantum_core::*; fn main() { simple_logger::init().unwrap(); let mut core = Quantum::new(); match core.load_plugin("plugin") { Ok(name) => println!("{}", name), Err(err) => error!("{}", err), } }
//! //! The layer map tracks what layers exist for all the relishes in a timeline. //! //! When the timeline is first accessed, the server lists of all layer files //! in the timelines/<timelineid> directory, and populates this map with //! ImageLayer and DeltaLayer structs corresponding to each file. When new WAL //! ...
//#![no_std] pub mod attribute; pub mod attribute_parser; pub mod data_set_parser; pub mod encoding; pub mod handler; pub mod meta_information; pub mod p10; pub mod p10_parser; pub mod prefix; pub mod tag; pub mod test; pub mod value_parser; pub mod vr;
pub mod io; pub mod cartridge; pub mod memory_bus; pub mod work_ram; pub mod registers;
use std::io; fn main() { loop { println!("\nInput a temperature (e.g. 1°C or 2.3°K):"); let mut input = String::new(); io::stdin().read_line(&mut input).expect("Couldn't read user input!"); // check if user wants to exit if input.contains("q") { println!("Thank...
use crate::ui::common::table::Table; use crate::ui::Refresh; use gtk::prelude::*; use sysinfo::{ProcessExt, SystemExt}; pub struct Processes { pub table: Table, } impl Processes { pub fn new() -> Self { let column_names = [ "PID", "User ID", "Status", "C...
extern crate pest; #[macro_use] extern crate pest_derive; use pest::Parser; use pest::iterators::Pairs; use std::io::{self, Write}; #[cfg(debug_assertions)] const _GRAMMAR: &'static str = include_str!("bvh.pest"); #[derive(Parser)] #[grammar = "bvh.pest"] struct BvhParser; #[derive(Debug)] pub struct Bvh { pub...
use crate::actor::{telegram_receiver::TbReceiverActor, telegram_sender::TbSenderActor}; use crate::clients::create_telegram_client; use crate::controllers::push_event::register_push_event; use actix::prelude::*; use actix::Addr; use actix_rt::System; use actix_web::{middleware, web, App, HttpResponse, HttpServer}; use...
use std::io; use std::io::prelude::*; use std::io::BufReader; use std::fs::File; use std::collections::HashMap; #[derive(Debug)] pub enum ParseError { Io(io::Error), Format(String), } impl From<io::Error> for ParseError { fn from(err: io::Error) -> ParseError { ParseError::Io(err) } } impl Fr...
use super::fetch_data::FetchResponse; use crate::Error; use rskafka_proto::{ apis::{ fetch::{FetchRequestV4, IsolationLevel, PartitionFetch, TopicFetch}, metadata::TopicMetadata, offset_fetch::TopicOffsets, }, BrokerId, ErrorCode, RecordBatch, }; use rskafka_wire_format::WireFormatBo...
#[macro_export] macro_rules! remote_type { // // Service // ( $(#[$meta:meta])* service $service: ident { properties: { $( { $( $property: tt)+ } )* } methods: { $( { $( $method: tt)+ } )* } } ) =...
use std::fmt::{Debug, Display}; use async_trait::async_trait; use data_types::{Namespace, NamespaceId, NamespaceSchema}; pub mod catalog; pub mod mock; #[async_trait] pub trait NamespacesSource: Debug + Display + Send + Sync { /// Get Namespace for a given namespace /// /// This method performs retries. ...
// Copyright © 2017-2023 Trust Wallet. // // This file is part of Trust. The full Trust copyright notice, including // terms governing use, modification, and redistribution, is contained in the // file LICENSE at the root of the source code distribution tree. use std::ffi::CString; use tw_encoding::ffi::{decode_base58...
//! GDAL Raster Data mod rasterband; mod types; mod warp; pub use rasterband::{Buffer, ByteBuffer, ColorInterpretation, RasterBand, ResampleAlg}; pub use types::{GDALDataType, GdalType}; pub use warp::reproject; #[derive(Debug)] pub struct RasterCreationOption<'a> { pub key: &'a str, pub value: &'a str, } #...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtWidgets/qprogressdialog.h // dst-file: /src/widgets/qprogressdialog.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main ...
use poem::{web::Json, IntoResponse, Response}; /// Response for `async_graphql::Request`. pub struct GraphQLResponse(pub async_graphql::Response); impl From<async_graphql::Response> for GraphQLResponse { fn from(resp: async_graphql::Response) -> Self { Self(resp) } } impl IntoResponse for GraphQLResp...
use std::cmp; use std::f64; use std::time; #[derive(Debug, Clone)] struct LogBuffer<T> where T: Clone, { head: usize, size: usize, samples: usize, contents: Vec<T>, } impl<T> LogBuffer<T> where T: Clone + Copy, { fn new(size: usize, init_val: T) -> LogBuffer<T> { LogBuffer { ...
use crate::prelude::*; use std::os::raw::c_void; use std::ptr; #[repr(C)] #[derive(Debug)] pub struct VkPhysicalDevicePushDescriptorPropertiesKHR { pub sType: VkStructureType, pub pNext: *const c_void, pub maxPushDescriptors: u32, } impl VkPhysicalDevicePushDescriptorPropertiesKHR { pub fn new(max_pu...
mod news_controller; mod photo_controller; mod user_controller; mod video_controller; use rocket::Route; pub fn routes() -> Vec<Route> { let routes_list = vec![ news_controller::news_routes(), photo_controller::photo_routes(), video_controller::video_routes(), user_controller::user...
use fyrox::{ core::{ algebra::{UnitQuaternion, Vector3}, pool::Handle, }, engine::{resource_manager::ResourceManager, Engine, EngineInitParams, SerializationContext}, event::{DeviceEvent, ElementState, Event, VirtualKeyCode, WindowEvent}, event_loop::{ControlFlow, EventLoop}, res...
use minifb::Window; const SCREEN_WIDTH: u16 = 64; const SCREEN_HEIGHT: u16 = 32; pub const SCREEN_SIZE: usize = SCREEN_WIDTH as usize * SCREEN_HEIGHT as usize; // sprites pub const BYTES_PER_CHARACTER: u8 = 5; pub const NUM_FONT_CHARACTERS: u8 = 16; pub const FONT_ARRAY_SIZE: usize = (BYTES_PER_CHARACTER * NUM_FONT_C...
//! An example of an escrow program, inspired by PaulX tutorial seen here //! https://paulx.dev/blog/2021/01/14/programming-on-solana-an-introduction/ //! This example has some changes to implementation, but more or less should be the same overall //! Also gives examples on how to use some newer anchor features and CPI...
use std::{time::Duration, thread}; use chrono::{DateTime, Local}; #[derive(Copy, Clone)] struct Column { pub rows: [bool; 4], } impl Column { fn new() -> Column { Column { rows: [false; 4] } } fn update(&mut self, mut digit: i32) { for i in 0..4 { let ...
/*BEGIN*/fn main() { // ^^^^^^^^^WARN(no-trans) function is never used // ^^^^^^^^^NOTE(no-trans) #[warn(dead_code)] // 1.24 nightly has changed how these no-trans messages are displayed (instead // of encompassing the entire function). }/*END*/ // ~NOTE(check) here is a function named 'main'
use crate::postgres::stream::PgStream; use crate::url::Url; #[cfg_attr(not(feature = "tls"), allow(unused_variables))] pub(crate) async fn request_if_needed(stream: &mut PgStream, url: &Url) -> crate::Result<()> { // https://www.postgresql.org/docs/12/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS match url.param...
use { flate2::{write::GzEncoder, Compression}, futures::{ compat::Future01CompatExt, future::{FutureExt, TryFutureExt}, }, futures_util::{compat::Stream01CompatExt, TryStreamExt}, hyper::{ header::{HeaderMap, HeaderValue}, service::service_fn, Body, Method, Re...
//! CLI math tool extern crate arithmancy; extern crate getopts; use std::process; use std::env::args; // Show short CLI spec fn usage(brief : &str, opts : &getopts::Options) { println!("{}", (*opts).usage(brief)); } // CLI entry point fn main() { let arguments : Vec<String> = args() .collect(); le...
/*! An application that load different interfaces using the partial feature. Partials can be used to split large GUI application into smaller bits. Requires the following features: `cargo run --example partials_d --features "listbox frame combobox flexbox"` */ extern crate native_windows_gui as nwg; exter...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[cfg(feature = "ApplicationModel_Calls_Background")] pub mod Background; #[cfg(feature = "ApplicationModel_Calls_Provider")] pub mod Provider; #[link(name = "windows")] extern "system" {} pub type CallAns...
#![allow(clippy::comparison_chain)] #![allow(clippy::collapsible_if)] use std::cmp::Reverse; use std::cmp::{max, min}; use std::collections::{BTreeSet, HashMap, HashSet}; use std::fmt::Debug; use itertools::{sorted, Itertools}; use whiteread::parse_line; const ten97: usize = 1000_000_007; /// 2の逆元 mod ten97.割りたいときに使...
fn check_slope(ski_map : &Vec<Vec<char>>, dx : usize, dy : usize) -> u32 { let mut x = 0; let mut y = 0; let mut tree_count = 0; while y < ski_map.len() { if ski_map[y][x] == '#' { tree_count += 1; } x = (x + dx) % (ski_map[0].len()); y += dy; } retur...
use actix_web::{middleware, web, App, HttpRequest, HttpResponse, HttpServer, Responder}; use env_logger; mod routing; use dotenv; use serde::Serialize; use sqlx::postgres::PgPoolOptions; mod auth; #[derive(Serialize)] struct ErrorResp<'a> { message: &'a str, } pub async fn resp_not_found() -> HttpResponse { H...
extern crate aoc; use std::cmp; use std::fs::File; use std::io::prelude::*; use std::io::{self, BufReader}; #[derive(Debug)] struct Claim { id: u32, left: u32, top: u32, width: u32, height: u32, } fn to_claim(line: String) -> Result<Claim, io::Error> { let index_at = line .find('@') ...
use candy_frontend::id::CountableId; use candy_vm::fiber::FiberId; use extension_trait::extension_trait; #[extension_trait] pub impl FiberIdThreadIdConversion for FiberId { fn from_thread_id(id: usize) -> Self { Self::from_usize(id) } fn to_thread_id(self) -> usize { self.to_usize() } ...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtCore/qsysinfo.h // dst-file: /src/core/qsysinfo.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin => // <=...
use std::collections::{HashMap, HashSet}; use std::iter; use std::slice::{Iter, IterMut}; use interpreter::{Action, Condition, Output}; use interpreter::{Empty, True}; pub type StateID = Vec<usize>; pub type StateLabel = String; pub trait Node { fn id(&self) -> &StateID; fn label(&self) -> &StateLabel; ...
use regex::Regex; pub fn regex_em() { let re = Regex::new(r"[a-z]+(?:([0-9]+)|([A-Z]+))").unwrap(); let caps = re.captures("abc123").unwrap(); let text1 = caps.get(1).map_or("", |m| m.as_str()); let text2 = caps.get(2).map_or("", |m| m.as_str()); assert_eq!(text1, "123"); assert_eq!(text2, ""...
extern crate actix_web; use actix_web::{server, App, HttpRequest, HttpResponse, http, Json}; #[macro_use] extern crate serde_derive; #[derive(Debug, Deserialize, Serialize)] struct UserLogin { username: String, password: String } #[derive(Debug, Deserialize, Serialize)] struct User { username: String, ...
#[derive(Debug)] pub enum WardenError { KAUTH_REGISTRATION, }
use std::collections::HashMap; #[derive(Debug)] pub struct RedisAccessorError { pub err_type: RedisAccessorErrorType } #[derive(Debug)] pub enum RedisAccessorErrorType { ConnNotOpen, OpenConnError, AuthError, GetContentError, GetKeyNotExist, SetContentError } pub trait RedisAccessor { }