text
stringlengths
8
4.13M
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - TIMx control register 1"] pub timx_cr1: TIMX_CR1, _reserved1: [u8; 2usize], #[doc = "0x04 - TIMx control register 2"] pub timx_cr2: TIMX_CR2, _reserved2: [u8; 2usize], #[doc = "0x08 - slave mode control register...
pub enum Keyword { Break, Case, Catch, Class, Const, Continue, Default, Delete, Do, Else, Enum, Export, Extends, Finally, For, Function, If, Import, In, Instanceof, Let, New, Return, Super, Switch, This, Throw, Try, Typeof, Var, Void, While, With } pub ...
#[cfg(test)] mod test; use bson::RawBsonRef; use serde::Deserialize; use crate::{ bson::{doc, Bson, Document}, cmap::{Command, RawCommandResponse, StreamDescription}, coll::{options::DistinctOptions, Namespace}, error::Result, operation::{append_options, OperationWithDefaults, Retryability}, s...
use crate::{AnyBin, AnyStr, BinSegment, Segment}; /// A segment; segments can be joined to create strings. See `StrBuilder`, /// `SegmentIterator` and `SegmentsSlice`. /// /// ```rust /// use abin::{NewStr, StrSegment, Str, StrBuilder}; /// /// let mut builder = NewStr::builder(); /// builder.push(StrSegment::Static("...
#[derive(Debug)] /// A joystick event. /// Joysticks are not supported for now pub enum JoystickEvent { /// A joystick has been connected JoystickConnected(), /// A joystick has been disconnected JoystickDisonnected(), /// A joystick moved JoystickMove(), /// A button has been pressed Jo...
#![allow(clippy::unwrap_used)] use std::fs::OpenOptions; use clap::Parser; use lspower::{LspService, Server}; use simplelog::{ CombinedLogger, Config, LevelFilter, SimpleLogger, WriteLogger, }; use tokio::net::{TcpListener, UnixListener}; use flux_lsp::LspServer; #[derive(Parser)] #[clap(author, version, about, ...
use super::truth_table::{hash_to_expr, TruthTable}; use itertools::Itertools; use simple_error::SimpleError; use std::cmp; use std::collections::HashSet; use std::convert::From; use std::fmt; use std::rc; use std::rc::Rc; #[derive(PartialEq, PartialOrd, Debug, Clone)] pub enum Expr { True, False, Var(Strin...
use crate::tx_confirm_stat::TxConfirmStat; use crate::FeeRate; use ckb_logger::debug; use ckb_types::packed::Byte32; use std::collections::HashMap; pub const MAX_CONFIRM_BLOCKS: usize = 1000; const MIN_BUCKET_FEERATE: f64 = 1000f64; const MAX_BUCKET_FEERATE: f64 = 1e7; const FEE_SPACING: f64 = 1.05f64; const MIN_ESTIM...
pub mod lex; pub mod parse; pub mod token; pub mod ast; pub mod eval; pub mod builtins;
pub struct Command { pub position: (f32, f32), pub quadrant: (u16, u16), pub pen_lifted: bool } pub struct Robot { /*pub motors: Vec<Motor>,*/ pub acceleration: f32, pub current_quadrant: (u16, u16), pub print_area: (f32, f32) } impl Robot { pub fn start_robot() -> Se...
extern crate bindgen; extern crate cc; use std::env; use std::path::PathBuf; use std::fs; fn main() { // Tell cargo to tell rustc to link the system bzip2 // shared library. let mut build = cc::Build::new(); build.include("apriltag-2016-12-01"); println!("DO STUFF"); for file in fs::read_dir("...
fn bug() { [0; [|f @ &ref _| {} ; 0 ].len() ]; } fn main() {}
use crate::data::Coord; use ggez::{Context, filesystem}; use std::io::Read; use crate::{GRID_VERT_COUNT, GRID_HORZ_COUNT}; use std::str::Chars; #[allow(dead_code)] pub const NODE_FREE: i32 = 0; pub const NODE_WALL: i32 = -1; pub struct Variant { pub start: Coord, pub ends: Vec<Coord>, } pub struct Map { ...
pub mod code; pub mod person_definition{ pub struct Person { pub firstname: String, pub lastname: String, pub age: u32, } }
fn enum_divisors(n:i64) -> Vec<i64> { let mut res:Vec<i64> = Vec::new(); let mut i = 1; while i * i <= n{ if n % i == 0{ let f = n / i; if f != i{ res.push(f); } res.push(i); } i += 1; } res.sort(); res } fn...
use crate::lz77::window_byte_container::ByteBuffer; use std::cmp; use std::convert::TryFrom; use std::io::BufWriter; use std::io::Write; use crate::lz77::nodes::NodeType; use crate::lz77::window_byte_container::ByteWindow; use super::window_byte_container::IndexableByteWindow; const SEARCH_WINDOW_SIZE: u16 = 2047; c...
/* Copyright (c) 2023 Uber Technologies, Inc. <p>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 <p>http://www.apache.org/licenses/LICENSE-2.0 <p>Unless required by applicable law or agreed to ...
//! Parameters used by `Client` to send API requests. use chrono::{DateTime, Utc}; use serde::Serialize; use crate::response::SeriesID; use crate::serialization as ser; /// Parameter used to search for series with /// [`Client::search`](../client/struct.Client.html#method.search). #[derive(Debug)] #[non_exhaustive] ...
pub mod types; pub mod api; pub mod encode; pub mod wnd;
#[doc = "Register `RCC_PLL4FRACR` reader"] pub type R = crate::R<RCC_PLL4FRACR_SPEC>; #[doc = "Register `RCC_PLL4FRACR` writer"] pub type W = crate::W<RCC_PLL4FRACR_SPEC>; #[doc = "Field `FRACV` reader - FRACV"] pub type FRACV_R = crate::FieldReader<u16>; #[doc = "Field `FRACV` writer - FRACV"] pub type FRACV_W<'a, REG...
use std::{ io::Write, str::FromStr, sync::atomic::{AtomicBool, AtomicU8, Ordering}, }; use anyhow::Error; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; #[derive(Debug, Clone, Copy, PartialEq)] #[repr(u8)] pub(crate) enum Coloring { Auto = 0, Always, Never, } impl...
openga.operator.miningGene.PBILInteractiveWithEDA3_2_2
#[doc = "Register `DMAISR` reader"] pub type R = crate::R<DMAISR_SPEC>; #[doc = "Register `DMAISR` writer"] pub type W = crate::W<DMAISR_SPEC>; #[doc = "Field `DC0IS` reader - DMA Channel Interrupt Status"] pub type DC0IS_R = crate::BitReader; #[doc = "Field `DC0IS` writer - DMA Channel Interrupt Status"] pub type DC0I...
/* chapter 4 syntax and semantics type annotations */ fn main() { let n: i32 = 5; print!("value \"{}\" is bound \ to n with the type i32", n); } // output should be: /* value "5" is bound to n with the type i32 */
// What is the largest prime factor of the number 600851475143 ? use std::time::Instant; fn main() { let now = Instant::now(); println!("imperative lazy: {:?}", e3_imperative_lazy(600851475143)); println!("time:{:?}", now.elapsed()); let now = Instant::now(); println!( "imperative less lazy...
use std::io::prelude::*; use std::io::{BufReader, Read}; use std::sync::Arc; use vrp_core::construction::constraints::*; use vrp_core::models::common::*; use vrp_core::models::problem::*; use vrp_core::models::{Extras, Problem}; pub(crate) trait TextReader { fn read_problem(&mut self) -> Result<Problem, String> { ...
use std::collections::HashMap; use framework::{App, app, Size, Canvas, Color, macros::serde_json, Rect}; use lsp_types::SemanticTokensLegend; use serde::{Serialize, Deserialize}; #[derive(Clone, Debug, Serialize, Deserialize)] struct ColorScheme { size: Size, token_legend: Option<SemanticTokensLegend>, c...
use std::thread; use std::thread::{JoinHandle}; use std::sync::{Arc, Mutex}; use std::sync::mpsc; use std::sync::mpsc::Sender; type Job = Box<FnBox + Send + 'static>; pub trait FnBox { fn call_box(self: Box<Self>); } impl<F: FnOnce()> FnBox for F { fn call_box(self: Box<F>) { (*self)(); } } enum ThreadMessage...
use std::io ; fn main() { let mut x = 5 ; println!("The value of x is: {}", x) ; x = 6 ; println!("The value of x is: {}", x) ; // shadowing let y = 5 ; let y = y + 1 ; let y = y * 2 ; println!("The value of y is: {}", y) ; // tuples let tup: (i32, f64, u8) = (500, 6.4, 1) ; // let tup = (500, 6.4...
use reqwest; pub fn get(url: &str) -> Result<String, reqwest::Error> { Ok(reqwest::get(url)?.text()?) }
//! Crate for macro-free variadic tuple metaprogramming. //! //! # Rationale //! //! As of writing this crate, Rust does not support variadic generics //! and does not allow to reason about tuples in general. //! //! Most importantly, Rust does not allow one to generically //! implement a trait for all tuples whose ele...
#[doc = "Reader of register CONN_INDEX"] pub type R = crate::R<u32, super::CONN_INDEX>; #[doc = "Writer for register CONN_INDEX"] pub type W = crate::W<u32, super::CONN_INDEX>; #[doc = "Register CONN_INDEX `reset()`'s with value 0"] impl crate::ResetValue for super::CONN_INDEX { type Type = u32; #[inline(always...
//https://ptrace.fefe.de/wp/wpopt.rs // gcc -o lines lines.c // tar xzf llvm-8.0.0.src.tar.xz // find llvm-8.0.0.src -type f | xargs cat | tr -sc 'a-zA-Z0-9_' '\n' | perl -ne 'print unless length($_) > 1000;' | ./lines > words.txt use std::fs::File; use std::io::{self, BufRead, BufReader, Stdin}; use std::iter::FromI...
#[cfg(feature = "python")] pub mod py; /// Single-chain models for polymer physics. pub mod single_chain; /// The Boltzmann constant in units of J/(mol⋅K). pub static BOLTZMANN_CONSTANT: f64 = 8.314462618; /// The Planck constant in units of J⋅ns/mol. pub static PLANCK_CONSTANT: f64 = 0.06350779923502961;
#![recursion_limit = "100"] //! The network-agnostic DNS parser library //! //! [Documentation](https://docs.rs/dns-parser) | //! [Github](https://github.com/tailhook/dns-parser) | //! [Crate](https://crates.io/crates/dns-parser) //! //! Use [`Builder`] to create a new outgoing packet. //! //! Use [`Packet::parse`] to ...
use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc}; use rust_decimal::Decimal; use tiberius::{ColumnData, ColumnType, FromSql}; use uuid::Uuid; // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-tds/ce3183a6-9d89-47e8-a02f-de5a1a1303de #[derive(Copy, Clone, Debug)] pub enum MsSQLTypeSyste...
mod audio; mod dma; mod interrupts; pub mod memory; mod scheduler; mod timers; mod video; use dma::GbaDMA; pub use memory::GbaMemory; use arm::{Cpu, Cycles, Memory}; pub use audio::{sampler::GbaAudioSampler, Command, GbaAudio}; use scheduler::Scheduler; use util::bits::Bits; pub use video::{GbaVideo, SCREEN_HEIGHT, S...
use std::future::Future; use std::pin::Pin; use std::sync::Arc; use std::task::Context; use std::task::Poll; use hyper; use hyper::body::Body as HyperBody; use hyper::http::Request as HyperRequest; use hyper::http::Response as HyperResponse; use hyper::service::Service as HyperService; use crate::CommunicationChannel...
use crate::hash; use crate::util::to_string_lossy; use anyhow::{anyhow, Context, Result}; use serde::{Deserialize, Serialize}; use std::path::PathBuf; use std::{fs::File, path::Path}; /// Describes a fingerprinted benchmark. /// /// ``` /// # use sightglass_fingerprint::Benchmark; /// let benchmark = Benchmark::finger...
use include_dir::{include_dir, Dir}; use std::path::Path; use tempfile::TempDir; static PARENT_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR"); #[test] fn included_all_files_in_the_include_dir_crate() { let root = Path::new(env!("CARGO_MANIFEST_DIR")); validate_included(&PARENT_DIR, root, root); asser...
use x11::xlib::{ Display as XDisplay, XOpenDisplay, XCloseDisplay, }; use std::{ ops::Drop, ptr::null, }; use crate::Null; /// The Display Struct is just a wrapper of a [*mut Display] from XLib. /// /// When this struct is dropped, the reference will be dropped using [XCloseDisplay]. pub struct Di...
//! Contains common types that can be glob-imported (`*`) for convenience. pub use gfx::traits::Pod; pub use Renderer; pub use cam::{Camera, Projection}; pub use light::*; pub use mesh::{Mesh, MeshBuilder}; pub use mtl::{Material, MaterialBuilder}; pub use pipe::{Pipeline, PipelineBuilder, PolyPipeline, PolyStage, St...
use std; import std::vec; import std::task; import std::uint; import std::str; fn f(n: uint) { let i = 0u; while i < n { let thunk = g; task::join(task::spawn_joinable(thunk)); i += 1u; } } fn g() { } fn main(args: [str]) { let n = if vec::len(args) < 2u { ...
#![feature(macro_rules)] #![crate_name = "codegen"] use std::os; use std::io::BufferedWriter; use std::io::File; use std::io; use std::io::USER_DIR; use std::io::stdio::println; use std::io::fs::mkdir_recursive; use std::path::GenericPath; pub mod branchify; pub mod keycode; pub mod scancode; fn main() { let args...
use std::collections::{HashMap, VecDeque}; use aoc_lib::AocImplementation; fn main() { let day = Day6{}; day.start(6); } struct Day6 { } impl AocImplementation<String> for Day6 { fn process_input(&self, input: &str) -> Vec<String> { input.split('\n').map(|s| s.to_string()).collect() } f...
use crate::helper::async_io; use crate::reactor::{LazyHandle, PollEvented}; use mio::net::UdpSocket as MioUdpSocket; use std::future::Future; use std::io; use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr}; use std::pin::Pin; use std::task::{Context, Poll}; /// A UDP socket #[derive(Debug)] #[must_use = "A UDP socket does...
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// SloTypeNumeric : A numeric representation of the type of the service level objective (`0` for monito...
pub use self::game::HangmaneGame; mod game;
pub mod player_info_packet { pub struct Packet { players: Vec<Player>, } pub struct Player { uuid: uuid::Uuid, action: Action, } pub enum Action { AddPlayer(AddPlayer), UpdateGamemode(UpdateGamemode), UpdateLatency(UpdateLatency), UpdateDisplay...
use std::ops::{Add,Sub}; #[derive(Debug,Copy,Clone)] struct Point { x : i32, y : i32, } impl Add for Point { type Output = Point; fn add(self,other: Point) -> Point { Point {x:self.x + other.x,y:self.y + other.y } } } impl Sub for Point { type Output = Point; fn sub(self,other:P...
use crate::rtb_type_strict; rtb_type_strict! { ProductionQuality, ProfessionallyProduced=1; Prosumer = 2; UserGenerated = 3 }
use crate::ChainStore; use ckb_core::{cell::CellMeta, transaction::CellOutput}; /// Extend ChainStore /// Lazy load cell output from chain store pub trait LazyLoadCellOutput { fn lazy_load_cell_output(&self, cell_meta: &CellMeta) -> CellOutput; } impl<CS: ChainStore> LazyLoadCellOutput for CS { fn lazy_load_c...
//! PAM integration tests use sudo_test::{Command, Env, User}; use crate::{Result, PASSWORD, USERNAME}; #[test] fn given_pam_permit_then_no_password_auth_required() -> Result<()> { let env = Env("") .user(USERNAME) .file("/etc/pam.d/su", "auth sufficient pam_permit.so") .build()?; Co...
use std::fs::File; use std::io::prelude::*; use nom::*; use nom::character::complete::*; use nom::bytes::complete::*; #[allow(dead_code)] fn main_1() { let mut file = File::open("input.txt").unwrap(); let mut contents = String::new(); file.read_to_string(&mut contents).unwrap(); let mut count = 0; ...
#[macro_use] extern crate clap; extern crate gcmod; extern crate tempfile; use std::fs::{remove_file, File}; use std::io::BufReader; use std::path::Path; use clap::AppSettings; use gcmod::{ AppError, AppResult, DEFAULT_ALIGNMENT, Game, format_u64, format_usize, MIN_ALIGNMENT, NumberSt...
pub(crate) mod baseline_parse; pub(crate) mod baseline_parse_tokens; pub(crate) mod binary; pub(crate) mod external_command; pub(crate) mod named; pub(crate) mod path; use crate::parser::{registry, Unit}; use crate::prelude::*; use derive_new::new; use getset::Getters; use serde::{Deserialize, Serialize}; use std::fmt...
// vim: shiftwidth=2 use std::collections::HashMap; use crate::keys::{Layout, Mapping, KeyCode, Repeat}; use KeyCode::*; use crate::layout_generation::{USKeyboardLayout, make_us_mappings}; use lazy_static::lazy_static; use std::default::Default; lazy_static! { pub static ref DEFAULT_LAYOUTS: HashMap<String, &'stat...
#![feature(non_ascii_idents)] #![feature(exclusive_range_pattern)] #![allow(non_snake_case)] #[macro_use] extern crate conrod; #[macro_use] extern crate conrod_derive; extern crate find_folder; extern crate csv; extern crate num; extern crate num_complex; extern crate uom; mod parameters; mod functions; mod graphics...
use crate::protos::cao_common::{self, Empty}; #[derive(Clone, Debug)] pub struct HealthService {} #[tonic::async_trait] impl cao_common::health_server::Health for HealthService { async fn ping( &self, _r: tonic::Request<Empty>, ) -> Result<tonic::Response<Empty>, tonic::Status> { Ok(to...
use backend::environment::Environment; use backend::models as m; use backend; use clap::{Arg, App, SubCommand, ArgMatches}; use errors::*; use naming; use options::Options; use std::path::Path; fn parse_id_converter(input: &str) -> Result<Box<naming::Naming>> { let mut parts = input.split(":"); if let Some(fi...
use aide::openapi::v3::macros::api; use thiserror::Error; #[api] #[serde(rename_all = "camelCase")] pub struct LoginRequest { pub email: String, pub password: String, } #[api] #[serde(rename_all = "camelCase")] pub struct LoginResponse { pub token: String, } #[api] #[serde(rename_all = "camelCase")] pub ...
// Copyright 2020 tuxzz // // Licensed under the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>, // at your option. This file may not be copied, modified, // or distributed except according to those terms. /*! A safe rust wrapper of [libsndfile](http://www.mega-nerd.com/libsndfile/). With this crate, ...
#[aoc_generator(day3)] pub fn input_generator(input: &str) -> Vec<Vec<i32>> { input .lines() .map(|l| l.trim().chars().map(|c| c as i32 - 0x30).collect()) .collect() } pub fn convert_to_dec(num: &Vec<i32>) -> i32 { num.iter().fold(0, |dec, next| dec * 2 + next) } pub fn get_most_common_at_position(lis...
//! Contains the events and functionality to monitor the commands and responses that a `Client` //! sends and receives from the server. use std::time::Duration; use serde::Serialize; use crate::{ bson::{oid::ObjectId, Document}, error::Error, serde_util, }; pub use crate::cmap::ConnectionInfo; /// An e...
use std::{ borrow::Cow, cmp::{Ordering::Equal, PartialOrd}, collections::BTreeMap, }; use hashbrown::HashMap; use rosu_v2::prelude::{GameMode, GameMods, Score, User, UserStatistics, Username}; use twilight_model::id::{marker::UserMarker, Id}; use crate::{commands::osu::MinMaxAvg, util::osu::BonusPP}; use...
#[doc = "Reader of register SPINLOCK25"] pub type R = crate::R<u32, super::SPINLOCK25>; impl R {}
mod my { pub struct WitheBox<T> { pub contents: T, } #[allow(dead_code)] pub struct BlackBox<T> { contents: T, } impl<T> BlackBox<T> { pub fn new(contents: T) -> BlackBox<T> { BlackBox { contents: contents, } } } } fn...
use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub struct TransferFileMeta { pub name: String, pub size: u64, }
use crate::Material; use crate::Vec4; use crate::Vec3; #[derive(Debug)] pub struct Scene { pub objects: Vec<Sphere> } #[derive(Debug)] pub struct Sphere { pub origin: Vec4, pub radius: f64, pub material: Material, pub color: Vec3, } impl Scene { pub fn add_sphere(&mut self, origin: Vec4, ra...
use std::io::Read; use std::path::Path; use std::fs::File; use std::cmp::Ord; use std::borrow::Borrow; use iron::typemap::Key; use toml::from_str; use toml::value::{Table, Value}; #[derive(Clone)] pub struct Config(Table); impl Config { pub fn new(path: &str) -> Config { let path = Path::new(path); ...
// Problem 26 - Reciprocal cycles // // A unit fraction contains 1 in the numerator. The decimal representation of the // unit fractions with denominators 2 to 10 are given: // // 1/2 = 0.5 // 1/3 = 0.(3) // 1/4 = 0.25 // 1/5 = 0.2 // 1/6 = 0.1(6) // 1/7 = 0.(142857) // 1/8...
use cellular::cli; use cellular::image_manip::bitmap::BitMap; use cellular::image_manip::build_gif; use cellular::prog::{Message, ProgBar}; use std::convert::Into; use std::process::exit; use std::sync::mpsc; use std::thread; fn main() { let args = cli::parse_args().unwrap(); let mut init_line: BitMap; i...
/* * 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. */ use std::io; use std::path::PathBuf; use std::sync::Mutex; use std::time::SystemTime; use reverie:...
// SPDX-License-Identifier: Apache-2.0 pub mod builder; mod cpu; pub mod measure; mod mem; pub mod personality; use crate::backend::{Keep, Thread}; use cpu::Cpu; use mem::Region; use personality::Personality; pub use builder::{Builder, Hook}; pub use kvm_bindings::kvm_segment as KvmSegment; pub use kvm_bindings::kv...
pub mod write_user; // pub mod visibility_user; // pub mod show_users; pub mod delete_user;
#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Entity(usize);
mod annotation; pub mod key_provider_grpc; mod messages;
use std::fmt::Write; use tuples::Tuple; fn color_value_to_8bit(value: f32) -> u8 { if value > 1.0 { 255 } else if value < 0.0 { 0 } else { (value * 255.0).round() as u8 } } #[test] fn test_color_value_to_8bit() { assert_eq!(color_value_to_8bit(1.1), 255); assert_eq!(col...
use std::collections::HashMap; #[derive(Clone, Copy, PartialEq, Eq)] pub enum Color { R, G, B, Y, } #[derive(PartialEq, Eq)] pub struct Piece { id: usize, rot: usize, shape: Vec<Color>, } impl From<&str> for Piece { fn from(string: &str) -> Piece { let mut shape = Vec::with_ca...
use abin::{AnyBin, BinFactory, NewBin}; const EMPTY: &[u8] = &[]; const ONE: &[u8] = &[15]; const MANY: &[u8] = &[12, 44, 15, 8, 255, 0, 254]; const LARGE: &str = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy \ eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptu...
#[macro_use] mod macros; mod generated; #[cfg(feature = "std")] mod last; use core::fmt; pub use self::generated::Errno; impl Errno { /// Operation would block. This is the same as [`Errno::EAGAIN`]. pub const EWOULDBLOCK: Self = Self::EAGAIN; /// Same as [`Errno::EDEADLK`]. pub const EDEADLOCK: S...
mod alacritty_config; mod cli; mod error; pub use alacritty_config::AlacrittyConfig; pub use cli::Cli; pub use error::Error;
use ggez; use ggez::event; use ggez::graphics; use ggez::nalgebra as na; use ggez::{Context, GameResult}; use ggez::conf::NumSamples; use ggez::timer; use rand::Rng; use ggez::nalgebra::Point2; struct MainState { x: f32, y: f32 } impl MainState { fn new() -> GameResult<MainState> { let s = MainState { x: 0.0,...
#![cfg_attr(not(feature = "std"), no_std)] /// Edit this file to define custom logic or remove it if it is not needed. /// Learn more about FRAME and the core library of Substrate FRAME pallets: /// <https://substrate.dev/docs/en/knowledgebase/runtime/frame> pub use pallet::*; #[cfg(test)] mod mock; #[cfg(test)] mod...
use std::path::PathBuf; use std::fs::File; use std::io::Read; pub fn read_file(path: PathBuf) -> Result<String, ParserError> { e(File::open(path)) .and_then_e(size_from_file) .and_then_e(catch_one) .and_then(|_| Ok(String::from("File is non-empty"))) } #[derive(Debug)] pub enum ParserError...
// use std::string::String; fn main() { my_first_if(3); my_first_if(6); multi_else_if(8); multi_else_if(9); println!("Returned value is : {}", using_if_in_a_let(3)); println!("Returned value is : {}", using_if_in_a_let(6)); loop_with_loop("Hello, hikachan".to_string()); loop_with_whi...
extern crate battlefy; #[test] fn find_team() { let stage_id = "5d6fdb02c747ff732da36eb4"; let name = "Feeders"; let persistent_team_id = "5bfe1b9418ddd9114f14efb0"; match battlefy::Team::find(stage_id, name) { Ok(r) => match r { battlefy::SearchResult::Team(t) => assert_eq!(t.pid(...
#![deny( bad_style, trivial_casts, trivial_numeric_casts, unsafe_code, unstable_features )] #![cfg_attr(not(debug_assertions), deny(warnings))] pub mod channels; pub mod payload; pub mod utility; pub mod user_builders;
//! # A library for programming stackful coroutines in Rust. //! //! May is a high-performant library for programming stackful coroutines with which //! you can easily develop and maintain massive concurrent programs. It can be thought //! as the Rust version of the popular Goroutine. //! //! ## Features //! * The stac...
//! # `ext_trait` //! `ext_trait` is a procedural macro which provides you with a shortcut to the [extension trait pattern][1] //! //! [1]: https://github.com/rust-lang/rfcs/blob/master/text/0445-extension-trait-conventions.md //! # Examples //! Note that IntelliJ Rust really dislikes this macro, i.e. displays errors e...
table! { accession_numbers (id) { id -> Int4, accession_number -> Numeric, } } table! { test_accession_numbers (id) { id -> Int4, accession_number -> Numeric, } } allow_tables_to_appear_in_same_query!( accession_numbers, test_accession_numbers, );
// 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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::collection...
use std::{ alloc::{alloc, dealloc, Layout}, mem::{align_of, size_of}, ptr, }; use crate::indices::EntityId; pub struct HandleTable { entries: *mut Entry, cap: u32, free_list: u32, } unsafe impl Send for HandleTable {} unsafe impl Sync for HandleTable {} const SENTINEL: u32 = !0; impl Handle...
pub fn solution() -> String { let n: u64 = 600_851_475_143; let mut n_divided = n; let mut factors: Vec<u64> = vec![]; while n_divided % 2 == 0 { factors.push(2); n_divided /= 2; } let mut maybe_prime = 3; let mut max_factor = (n as f32).sqrt().floor() as u64; while n_divided > 1 && maybe_prime ...
fn main() { let mut v =vec![1,2,3,4,11]; while let Some(element) = v.pop() { println!("{}",element); } }
use volatile::prelude::*; use volatile::{WriteVolatile, ReadVolatile}; use common::IO_BASE; use console::kprintln; use timer::spin_sleep_ms; // Many thanks to // https://elinux.org/RPi_Framebuffer // and // https://github.com/raspberrypi/firmware/wiki/Mailbox // for info on address locations, etc const MAILBOX_BASE:...
use std::fs; use std::collections::HashMap; use std::collections::HashSet; use std::iter::FromIterator; fn parse(contents: &String) -> HashMap<String, HashSet<String>> { let mut results: HashMap<String, HashSet<String>> = HashMap::new(); for line in contents.lines() { let words: Vec<&str> = line.split(...
use super::components::*; use super::util::*; use rltk::{Point, RandomNumberGenerator, RGB}; use specs::prelude::*; pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity { return ecs .create_entity() .with(Position { pt: Point::new(player_x, player_y), }) ...
use crate::models::organisation::QueryOrganisation; use crate::{ models::organisation::{NewOrganisation, Organisation, UpdateOrganisation}, schema::{organisations, organisations::dsl::organisations as organisations_query}, }; use diesel::prelude::*; pub fn all(conn: &PgConnection) -> QueryResult<Vec<Organisati...
#![cfg_attr(external_doc, feature(external_doc))] #![cfg_attr(external_doc, doc(include = "../Readme.md"))] #![cfg_attr(external_doc, warn(missing_docs))] #![forbid(unsafe_code)] #![cfg_attr(not(feature = "vfs04"), allow(dead_code, unused_imports))] #[path = "read/_read.rs"] mod read; pub use read::*;