text
stringlengths
8
4.13M
//! Generic api response types use serde::{Deserialize, Serialize}; /// A Kubernetes status object #[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq)] pub struct Status { /// Status of the operation /// /// One of: `Success` or `Failure` - [more info](https://git.k8s.io/community/contri...
use min_max_heap::MinMaxHeap; use regex::Regex; use std::{ char::ParseCharError, collections::{HashMap, VecDeque}, str::FromStr, }; lazy_static! { static ref regexp: Regex = Regex::new( r"(?x) Step \s+ (?P<from>[A-Z]{1}) (?-x) must be finished before step (?x) \s* (?P<to...
use crate::{texture::Texture, vec3::Axis::*}; use std::sync::Arc; /// A alternating checkerboard pattern between two other textures. pub fn checkerboard(odd: Texture, even: Texture) -> Texture { Texture(Arc::new(move |uv_coords, hit_point| { let sines = (10.0 * hit_point[X]).sin() * (10.0 * hit...
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use errno::{set_errno, Errno}; use s2n_tls::{ config::Config, connection::{Builder, Connection}, enums::{Blinding, CallbackResult, Mode}, error::Error, }; use std::{ fmt, future::Future,...
use crate::photic_binding::x3d_binding::X3DRenderer; use std::cell::RefCell; use std::rc::Rc; use photic::{ pipeline::{ material::{Material, Material2, IsMaterial}, shader::{Shader, ShaderSource}, render_mesh::RenderMesh, }, x3d::Renderer3D, surface::Surface, Vertex, V...
#[no_mangle] pub extern "C" fn get_static_styles()->Static_Style{ Static_Style{ w_h:(300.0,40.0), rect:(RGB(0.40,0.15,0.20,1.0),300.0,40.0,2.0), image:(SpriteInfo{ first:(0.0,270.0), num_in_row:4.0, w_h:(150.0,90.0), pad:(10.0,10.0,0.0,0.0) },20.0,20.0,5.0,5.0), text...
pub mod enums; mod nation; pub use self::nation::*; mod raw_game_data; pub use self::raw_game_data::*; mod game_data; pub use self::game_data::*; mod player; pub use self::player::*; mod game_server; pub use self::game_server::*;
/* * 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 */ /// UsageSpecifiedCustomReportsData : Response containing date and type for specified custom reports. ...
// Interior vector utility functions. import option::{some, none}; import uint::next_power_of_two; import ptr::addr_of; native "rust-intrinsic" mod rusti { fn vec_len<T>(v: [T]) -> uint; } native "rust" mod rustrt { fn vec_reserve_shared<T>(&v: [mutable? T], n: uint); fn vec_from_buf_shared<T>(ptr: *T, c...
use std::collections::HashMap; use caolo_sim::prelude::Axial; use crate::protos::{cao_common, cao_world}; pub fn push_room_pl<Selector, T>( out: &mut HashMap<Axial, cao_world::RoomEntities>, room_id: Axial, f: Selector, accumulator: T, time: i64, ) where Selector: Fn(&mut cao_world::RoomEntit...
use serde::de; use serde::Deserialize; use std::fmt; #[derive(Debug, Clone, PartialEq)] pub struct ConnectorTopics { pub name: String, pub topics: Vec<String>, } #[derive(Debug, Deserialize)] struct Inner { topics: Vec<String>, } impl<'de> de::Deserialize<'de> for ConnectorTopics { fn deserialize<D>(...
use std::borrow::Borrow; use std::collections::HashSet; use std::hash::{Hash, Hasher}; use derive_more::{Deref, DerefMut}; pub type Id = String; #[derive(Clone, Debug, Eq)] pub struct Foo { id: Id, val: u32, } #[derive(Clone, Debug, Deref, DerefMut)] pub struct Set(HashSet<Foo>); impl Set { pub fn new()...
use std::io::{Stdout, Write}; static CLEAR_SCREEN: &[u8] = b"\x1b[2J"; static POSITION_CURSOR: &[u8] = b"\x1b[H"; pub struct Screen<'a> { stdio: &'a Stdout, } // io::stdout().write(&[char]).unwrap(); impl<'a> Screen<'a> { pub fn refresh(stdout: &'a mut Stdout) { stdout .write(CLEAR_SCREEN)...
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #![allow(nonstandard_style)] use core::sync::{atomic}; use crate::{kty}; #[cfg(target_pointer_width = "64")] #[path...
use crate::r650x::address::AddressMode; use crate::r650x::flags::MCRFlag::Zero; pub enum DecoderError { UnrecognizedInstruction } #[derive(Copy, Clone)] pub struct DecodedInstruction { instruction: super::instructions::Instruction, address_mode: AddressMode } pub fn decode(b: u8) -> Result<DecodedInstructi...
use azure_core::headers::{utc_date_from_rfc2822, CommonStorageResponseHeaders}; use azure_storage::core::xml::read_xml; use bytes::Bytes; use chrono::{DateTime, Utc}; use http::response::Response; use std::convert::TryInto; #[derive(Debug, Clone)] pub struct PeekMessagesResponse { pub common_storage_response_heade...
#[macro_use] extern crate tracing; use geojson::Feature; use gtfs_structures::Gtfs; use itertools::Itertools; use rgb::RGB8; use serde::Serialize; use std::{ops::Deref, path::Path, sync::Arc}; pub mod static_data; #[derive(Clone, Debug, Serialize)] pub struct RouteProperties { route_id: String, short_name: S...
#![warn(clippy::all)] mod errors; mod ip_utils; mod nic; mod print; mod tcp; pub use errors::TitError; pub use nic::start_nic; pub use print::tcp_key as print_tcp_key; pub use tcp::Tcp; pub use tcp::TcpListener; pub use tcp::TcpStream;
#![feature(macro_rules)] #![feature(globs)] #![experimental] extern crate serialize; extern crate encoding; pub use header::{Header, HeaderMap, FromHeader}; pub use address::{Address}; pub use message::{ MimeMessage, MimeMessageData, MimeMultipartType, }; pub mod utils; pub mod rfc5322; pub mod rfc2047; pub m...
//! # The XML `<localization>` format //! //! This is used in: //! - the `locale/locale.xml` file use std::{ collections::BTreeMap, fs::File, io::{self, BufReader}, path::Path, }; use displaydoc::Display; use quick_xml::{events::Event as XmlEvent, Error as XmlError, Reader as XmlReader}; use thiserror...
use once_cell::sync::Lazy; use regex::Regex; static REGEX: Lazy<Regex> = Lazy::new(|| { Regex::new(r"^(?P<min>\d+)\-(?P<max>\d+)\s(?P<char>\w):\s(?P<password>.*)$").unwrap() }); const INPUT: &str = include_str!("../../input/day_2.txt"); fn main() { let lines = INPUT.lines().collect::<Vec<&str>>(); let v...
//! A 2-dimensional grid class with utilities for access and display use std::fmt; /// The 2-dimensional grid class /// /// # Examples /// /// Make a 4x4 grid of integers: /// /// ``` /// use color_game::grid::Grid; /// let grid = Grid::new(4, 4, 0); /// assert_eq!(grid.height(), 4); /// assert_eq!(grid.width(), 4); ...
#[doc = "Register `ETZPC_TZMA0_SIZE` reader"] pub type R = crate::R<ETZPC_TZMA0_SIZE_SPEC>; #[doc = "Register `ETZPC_TZMA0_SIZE` writer"] pub type W = crate::W<ETZPC_TZMA0_SIZE_SPEC>; #[doc = "Field `R0SIZE` reader - R0SIZE"] pub type R0SIZE_R = crate::FieldReader<u16>; #[doc = "Field `R0SIZE` writer - R0SIZE"] pub typ...
use ckb_hash::new_blake2b; use merkle_cbt::{merkle_tree::Merge, CBMT as ExCBMT}; use crate::{packed::Byte32, prelude::*}; pub struct MergeByte32; impl Merge for MergeByte32 { type Item = Byte32; fn merge(left: &Self::Item, right: &Self::Item) -> Self::Item { let mut ret = [0u8; 32]; let mut b...
use std::fmt; use std::path::Path; use decoder; use decoder_class; use decoder_usecase; use visuals; use visuals_class; use visuals_case; pub fn call_class_draw(class_list: &Vec<decoder_class::Class>, relation_list: &Vec<decoder_class::Relation>, class_number: i32) { let path_first_part = "res/UML_class"; le...
use super::*; use std::sync::{Arc, RwLock}; use std::time::Instant; const MAX_BACKLOG: usize = 512; struct Inner { nickname: Option<String>, backlog: Queue<(Instant, Message)>, } pub struct State { channels: Arc<Channels>, inner: RwLock<Inner>, } impl Default for State { fn default() -> Self { ...
use crate::poseidon::params::PoseidonParams; use crate::rescue::params::RescueParams; use franklin_crypto::bellman::pairing::bn256::{Bn256, Fr}; use franklin_crypto::bellman::{Field}; use franklin_crypto::rescue::{bn256::Bn256RescueParams, RescueHashParams, StatefulRescue}; use franklin_crypto::{ bellman::plonk::be...
pub mod sudoku;
use actix_files::NamedFile; use actix_web::Result; pub async fn script() -> Result<NamedFile> { Ok(NamedFile::open("static/script.js")?) } pub async fn front_register() -> Result<NamedFile> { Ok(NamedFile::open("static/front/register.html")?) } pub async fn front_login() -> Result<NamedFile> { Ok(NamedFi...
use std::vec::Vec; use std::string::String; use std::collections::HashMap; //Returns a string with comments removed, with everything in lowercase pub fn sanitize_line(input: &mut String) { while let Some(i) = input.find(',') { input.remove(i); } match input.find(';') { Some(i) => *input = ...
mod series_reader; mod series_writer; pub use series_reader::{SeriesIterator, SeriesReader}; pub use series_writer::SeriesWriter; #[cfg(test)] mod test { use super::super::entry::Entry; use super::super::env; use super::super::error::Error; use super::*; use std::sync::Arc; use super::super::s...
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. // // A test that calls visit_aggregate pub fn main() { let x = [1, 2]; debug_assert!(x[0] == 1); debug_assert!(x[1] == 2); }...
#[doc = "Register `AWD2CR` reader"] pub type R = crate::R<AWD2CR_SPEC>; #[doc = "Register `AWD2CR` writer"] pub type W = crate::W<AWD2CR_SPEC>; #[doc = "Field `AWD2CH` reader - Analog watchdog 2 channel selection These bits are set and cleared by software. They enable and select the input channels to be guarded by the ...
pub trait Component { type Stored; }
use crate::CaretColor; use crate::CodeHighlightingColor; use crate::DiffColor; use crate::SerdeColor; use crate::ThemeImages; #[derive(Serialize, Deserialize, Clone, PartialEq, Debug)] pub struct Theme { name: String, background: SerdeColor, border_color: SerdeColor, caret: CaretColor, code_highlig...
extern crate tetrahedrane; use tetrahedrane::vid::*; use tetrahedrane::start; fn main() { let mut window = start::Window::new(640, 480, "Hello World!", 1 as usize); window.window.set(Color::new(20, 40, 60).orb_color()); let triangle = Triangle::new(DepthPoint::new(0.0, -0.5, 3.0), ...
use std::collections::HashSet; use bonuses::has_trula; use cards::{CardSuit, Trick, Hand, Card, TarockCard, Tarock21, TarockSkis}; #[deriving(Eq, PartialEq, Show)] pub enum ContractType { Three, Two, One, } pub mod beggar { #[deriving(Eq, PartialEq, Show)] pub enum Type { Normal, ...
use super::error::Error; use num_traits::FromPrimitive; use super::types; use std::io::Read; #[derive(Debug, Clone)] pub struct Header { pub ident_magic: [u8; 4], pub ident_class: types::Class, pub ident_endianness: types::Endianness, pub ident_version: u8, // 1 pub ident_abi: types::Abi, pub ...
use crate::*; use std::sync::Mutex; /// The Riddle time system core state. /// /// Manages tracking framerate and timer state. /// /// It is possible to manage the audio system state independantly - the most important /// thing to note is that [`ext::TimeSystemExt::process_frame`] must be called once per /// "frame"....
#[doc = "Reader of register FMC_BCHPBR1"] pub type R = crate::R<u32, super::FMC_BCHPBR1>; #[doc = "Reader of field `BCHPB`"] pub type BCHPB_R = crate::R<u32, u32>; impl R { #[doc = "Bits 0:31 - BCHPB"] #[inline(always)] pub fn bchpb(&self) -> BCHPB_R { BCHPB_R::new((self.bits & 0xffff_ffff) as u32) ...
pub mod ll; pub mod option;
use std::io; use std::sync::mpsc::Receiver; use std::thread; use anyhow::Result; use env_logger::Env; use log::{debug, info}; use space_packets::{Packet, Reader}; fn main() { // Setting up the logger let env_log = Env::default().default_filter_or("info"); env_logger::Builder::from_env(env_log).init(); ...
/* chapter 4 syntax and semantics */ fn main() { let greeting = "hello, there."; // greeting: &'static str println!("{}", greeting); } // output should be: /* */
use crate::{ api::{ api_v1, app_state::{AppConfig, AppSubscriber, AppSmtp, AppDatabase}, }, config::StartConfig, websocket::main_subscriber::MainSubscriber, }; use actix::Actor; use actix_files as fs; use actix_web::{ web, App, HttpServer, middleware::Logger, }; use err_derive::E...
#[doc = "Register `MIS` reader"] pub type R = crate::R<MIS_SPEC>; #[doc = "Field `OVR_MIS` reader - Data buffer overrun/underrun masked interrupt status"] pub type OVR_MIS_R = crate::BitReader<OVR_MIS_A>; #[doc = "Data buffer overrun/underrun masked interrupt status\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, P...
use std::{env, io, fmt}; use std::time::{Duration, SystemTime}; use std::error::Error; use std::collections::HashMap; use tokio::sync; use tokio::net::UdpSocket; use log::{debug, info, warn}; use futures::select; use futures::future::FutureExt; // Delta between NTP epoch (1900-01-01 00:00:00) and Unix epoch (1970-01-...
use ferris_says::say; use std::io::{stdout,BufWriter}; use std::mem; fn variables() { let byte = 5i8; let short = 5i16; let longlong = 5i128; let result = longlong + short as i128 + byte as i128; println!("signed sum: {}", result); let ubyte = 5u8; let ushort = 5u16; let ulonglong = 5...
use std::fs::read_to_string; use std::collections::HashSet; pub fn solve() { let answers = read_to_string("../inputs/6.txt").unwrap(); print!("Day 6 part 1: {}\n", part_1(&answers)); print!("Day 6 part 2: {}\n", part_2(&answers)); } fn part_1(answers: &str) -> usize { answers.split("\n\n") .m...
#[doc = "Register `CCR` reader"] pub type R = crate::R<CCR_SPEC>; #[doc = "Register `CCR` writer"] pub type W = crate::W<CCR_SPEC>; #[doc = "Field `CCR` reader - Clock control register in Fast/Standard mode (Master mode)"] pub type CCR_R = crate::FieldReader<u16>; #[doc = "Field `CCR` writer - Clock control register in...
use std::time::Duration; use trust_dns_proto::rr::RData; use trust_dns_resolver::config::ResolverConfig; use crate::{ error::{ErrorKind, Result}, options::ServerAddress, runtime::AsyncResolver, }; pub(crate) struct SrvResolver { resolver: AsyncResolver, } #[derive(Debug)] pub(crate) struct ResolvedC...
use std::collections::BTreeMap; use std::ops::RangeInclusive; use super::{RangeInclusiveMap, RangeMap}; // A simple but infeasibly slow and memory-hungry // version of `RangeInclusiveMap` for testing. // // Only understands `u32` keys, so that we don't // have to be generic over `step`. This is just for // testing, s...
use enet::*; use std::fs; use std::env; use std::thread; use bytes::BufMut; use rouille::*; mod config; #[path = "./handler/events.rs"] mod events; #[path = "./handler/gamepacket.rs"] mod gamepacket; pub use gamepacket::*; fn build_items_database(path: String) -> Box<[u8]> { let file = fs::read(path).expect("fail...
// droplet_limit number The total number of droplets the user may have // email string The email the user has registered for Digital // Ocean with // uuid string The universal identifier for this user // email_verified boolean If true, the user has verified their account /...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - CORDIC control/status register"] pub cordic_csr: CORDIC_CSR, #[doc = "0x04 - CORDIC argument register"] pub cordic_wdata: CORDIC_WDATA, #[doc = "0x08 - CORDIC result register"] pub cordic_rdata: CORDIC_RDATA, } #[do...
use avocado::prelude::*; use failure::Error; use rocket::http::Status; use rocket::outcome::IntoOutcome; use rocket::request::{self, Request, FromRequest}; use crate::model::auth_service::OpenID; // // Database backed session // #[derive(Debug, Clone, Serialize, Deserialize, Doc)] pub struct Session { #[serde(r...
mod maine; pub use maine::Maine;
extern crate argparse; extern crate polynomial; #[macro_use] extern crate uint; use uint::construct_uint; use argparse::{ArgumentParser, Collect, Store, StoreTrue}; use polynomial::Polynomial; use Vec; use std::str::FromStr; construct_uint! { pub struct U512(8); } fn main() { let mut verbose = fals...
// Play around with strings use std::string::String; fn main() { println!("Hello from strings"); }
fn triangle(n: i32) -> i32 { (0..n+1).fold(0, |sum, i| sum + i) } fn main() { println!("{}",triangle(10)); }
// Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT use clock::ChainEpoch; use forest_cid::Cid; use forest_encoding::{de::Deserializer, ser::Serializer}; use num_bigint::{ biguint_ser::{BigUintDe, BigUintSer}, BigUint, }; use serde::{Deserialize, Serialize}; /// Hello message https...
use std::fmt::Display; use reqwest::header; use crate::{ Client, Error, Image, Market, Page, Playlist, PlaylistItem, PlaylistItemType, PlaylistSimplified, Response, }; /// Endpoint functions relating to playlists. /// /// The parameter `snapshot_id` is the snapshot of the playlist to perform the operation on...
#![no_main] #![no_std] use keyboard as _; // global logger + panicking-behavior + memory layout #[cortex_m_rt::entry] fn main() -> ! { ack(10, 10); keyboard::exit() } fn ack(m: u32, n: u32) -> u32 { defmt::info!("ack(m={=u32}, n={=u32})", m, n); let mut big = [2; 512]; if m == 0 { n + 1 ...
extern crate inkwell; use self::inkwell::context::Context; use self::inkwell::targets::{InitializationConfig, Target}; use std::ptr::null; use std::mem::transmute; #[test] fn test_build_call() { let context = Context::create(); let module = context.create_module("sum"); let builder = context.create_build...
use std::sync::{atomic::*, Arc}; use std::time::Duration; use std::{str, thread}; use super::tempdir_with_prefix; use rocksdb::{DBInfoLogLevel as InfoLogLevel, DBOptions, Logger, DB}; #[derive(Default, Clone)] struct TestDrop { called: Arc<AtomicUsize>, } impl Drop for TestDrop { fn drop(&mut self) { ...
use crate::group::*; use crate::order::*; use crate::select::*; use crate::*; pub trait QueryDsl<T> { fn select(self, selectable: impl Into<Select>) -> QueryWithSelect<T>; fn filter(self, filter: impl Into<Filter>) -> Query<T>; fn or_filter(self, filter: impl Into<Filter>) -> Query<T>; fn join<K>(se...
use serde::{de, Deserialize, Deserializer}; use std::str::FromStr; pub fn de_u128_from_str<'de, D>(deserializer: D) -> Result<u128, D::Error> where D: Deserializer<'de>, { let s = String::deserialize(deserializer)?; u128::from_str(&s).map_err(de::Error::custom) } pub fn de_f64_from_str<'de, D>(deserialize...
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under both the MIT license found in the * LICENSE-MIT file in the root directory of this source tree and the Apache * License, Version 2.0 found in the LICENSE-APACHE file in the root directory * of this source tree. */ //! R...
use std::collections::LinkedList; pub fn solve_v1() -> u64 { let data = super::load_file("day9.txt"); let mut buf: LinkedList<u64> = LinkedList::new(); let mut numbers = data.lines().map(|n| n.parse::<u64>().unwrap()); // read preamble for _ in 0..25 { buf.push_back(numbers.next().unwrap()...
//! An example application using `prost-simple-rpc`. #![deny(missing_docs)] #![deny(missing_debug_implementations)] #![deny(missing_copy_implementations)] #![deny(trivial_casts)] #![deny(trivial_numeric_casts)] #![deny(unsafe_code)] #![deny(unstable_features)] #![deny(unused_import_braces)] #![deny(unused_qualification...
use super::context::*; use super::descriptions::*; use super::environment::Environment; use super::error::{CrawlResult, CrawlErrorKind, CrawlError}; use super::work::*; use conveyor_work::package::Package; use pathutils; use slog::Logger; use std::path::{Path, PathBuf}; use std::sync::Arc; use serde_json; use std::fs; ...
use std::sync::Arc; use std::time::Duration; use async_std::task; use hashbrown::HashMap; use nalgebra::Point3; use winit::{ dpi::LogicalSize, event, event::WindowEvent, event_loop::{ControlFlow, EventLoop}, }; use zerocopy::AsBytes; use renderer::{ Camera, Material, Mesh, Model, Renderer, Scene, ...
extern crate hyper; extern crate rrpcore; use hyper::Server; use rrpcore::RRPHandler; use rrpcore::filters::Filter; pub fn main() { Server::http("127.0.0.1:3000").unwrap().handle(RRPHandler { }).unwrap(); }
//! Modules related to the 65c816 ISA. use crate::isa::*; use crate::isa::encoding::*; /// Represents an immediate offset in the 65c816 ISA. #[derive(Copy, Clone, Ord, PartialOrd, PartialEq, Eq, Debug, Hash)] pub enum Imm { Imm8(u8), Imm16(u16), } mod imm_internal { pub enum ImmA { } pub enum ImmXy {...
use std::mem; use crate::prelude::*; pub fn quadratic(a: Efloat, b: Efloat, c: Efloat) -> Option<(Efloat, Efloat)> { let discrim = { let a = f64::from(a.raw()); let b = f64::from(b.raw()); let c = f64::from(c.raw()); b.powi(2) - 4.0 * a * c }; if discrim < 0.0 { Non...
#[doc = "Reader of register RCC_MP_APRSTSR"] pub type R = crate::R<u32, super::RCC_MP_APRSTSR>; #[doc = "Reader of field `RSTTOV`"] pub type RSTTOV_R = crate::R<u8, u8>; impl R { #[doc = "Bits 8:14 - RSTTOV"] #[inline(always)] pub fn rsttov(&self) -> RSTTOV_R { RSTTOV_R::new(((self.bits >> 8) & 0x7f...
import std::generic_os::setenv; import std::generic_os::getenv; import std::option; #[test] fn test_setenv() { // NB: Each test of setenv needs to use different variable names or the // tests will not be threadsafe setenv("NAME1", "VALUE"); assert (getenv("NAME1") == option::some("VALUE")); } #[test] ...
//! //! InfluxDB Value Variants //! use std::fmt; /// Type primitives as supported by InfluxDB and their conversions from/to Rust primitives #[derive(Debug, Clone, Serialize, Deserialize)] pub enum Value { /// Self explanatory integer type #[serde(rename="i64")] Integer(i64), /// Self explanatory float t...
#[doc = "Register `CR` reader"] pub type R = crate::R<CR_SPEC>; #[doc = "Register `CR` writer"] pub type W = crate::W<CR_SPEC>; #[doc = "Field `LPDS` reader - Low-power deep sleep"] pub type LPDS_R = crate::BitReader; #[doc = "Field `LPDS` writer - Low-power deep sleep"] pub type LPDS_W<'a, REG, const O: u8> = crate::B...
use std::collections::binary_heap::{BinaryHeap, PeekMut}; use std::cmp::{Reverse, Ordering}; use std::{mem, io}; use crate::{Error, Writer, Reader, ReaderIntoIter}; pub struct Entry<A> { iter: ReaderIntoIter<A>, key: Vec<u8>, val: Vec<u8>, } impl<A: AsRef<[u8]>> Entry<A> { // also fills the entry ...
// We dont use all the enums #[allow(dead_code)] enum Color { // These 3 are specified by their name Red, Blue, Green, // This tie u32 tuples to named color models RGB(u32, u32, u32), HSV(u32, u32, u32), HSL(u32, u32, u32), CMY(u32, u32, u32), CMYK(u32, u32, u32, u32), } fn main() { // Tuples ...
#![no_std] #![no_main] #![feature(default_alloc_error_handler)] use static_alloc::Bump; #[global_allocator] static A: Bump<[u8; 1 << 10]> = Bump::uninit(); use cortex_m_rt::entry; use cortex_m_semihosting::{ debug::{self, EXIT_SUCCESS}, hprintln as println, }; use panic_semihosting as _; use hacspec_lib as...
use crate::database::DbConn; use crate::user::User; use yew::prelude::*; use yew::services::DialogService; use yew::{html, Callback}; pub struct Login { user: Option<User>, on_log_in: Option<Callback<User>>, db_conn: DbConn, link: ComponentLink<Self>, state: State, } #[derive(Debug)] pub enum Msg ...
//! Commits to the advisory DB git repository use tame_index::external::gix; use crate::{ error::{Error, ErrorKind}, repository::{git::Repository, signature::Signature}, }; use std::time::{Duration, SystemTime}; /// Number of days after which the repo will be considered stale /// (90 days) const STALE_AFTER:...
#[macro_use] extern crate diesel; extern crate dotenv; pub mod models; pub mod schema; use diesel::pg::PgConnection; use diesel::prelude::*; use dotenv::dotenv; use std::env; pub fn establish_connection() -> PgConnection { dotenv().ok(); let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must ...
#[doc = "Reader of register RCC_I2C4CKSELR"] pub type R = crate::R<u32, super::RCC_I2C4CKSELR>; #[doc = "Writer for register RCC_I2C4CKSELR"] pub type W = crate::W<u32, super::RCC_I2C4CKSELR>; #[doc = "Register RCC_I2C4CKSELR `reset()`'s with value 0"] impl crate::ResetValue for super::RCC_I2C4CKSELR { type Type = ...
extern crate clap; use std::process; use clap::{App, Arg}; use wc_jake_toy; fn main() { let matches = App::new("wc") .version("0.1") .author("Jake Rottersman <rottersmanjake@gmail.com>") .about("Count words") .arg( Arg::with_name("lines") .help("count ...
use super::service; use anyhow::{anyhow, Result}; use log::{error, info, warn}; use pahkat_client::{package_store::InstallTarget, PackageStore}; use std::fs::OpenOptions; use std::process::Command; use std::sync::Arc; use std::{ path::{Path, PathBuf}, time::Duration, }; use structopt::StructOpt; #[derive(Debug...
pub fn times_two(num: i32) -> i32 { num * 2 } #[cfg(test)] mod tests { use super::times_two; #[test] fn retruns_twice_of_positive_numbers() { assert_eq!(4, times_two(2)); } #[test] fn retruns_twice_of_negative_numbers() { assert_eq!(-4, times_two(-2)); } }
#[get("/")] pub fn index() -> &'static str { "Hello, world!" } #[get("/<name>")] pub fn hello(name: String) -> String { format!("Hello, {}!", name) }
use crate::distribution::{Continuous, ContinuousCDF}; use crate::function::gamma; use crate::statistics::*; use crate::{Result, StatsError}; use rand::Rng; use std::f64; /// Implements the [Chi](https://en.wikipedia.org/wiki/Chi_distribution) /// distribution /// /// # Examples /// /// ``` /// use statrs::distribution...
use async_std::fs::{File, OpenOptions}; use futures::{executor, prelude::*, stream::FuturesOrdered}; use srmw::*; use std::{ io::{self, SeekFrom}, iter::FromIterator, time::Instant, }; fn main() { executor::block_on(async move { let mut original = File::open("examples/original").await.unwrap()...
// Import from `core` instead of from `std` since we are in no-std mode use core::result::Result; // Import heap related library from `alloc` // https://doc.rust-lang.org/alloc/index.html use alloc::vec::Vec; // Import CKB syscalls and structures // https://nervosnetwork.github.io/ckb-std/riscv64imac-unknown-none-elf...
// Copyright 2018 Fredrik Portström <https://portstrom.com> // This is free software distributed under the terms specified in // the file LICENSE at the top-level directory of this distribution. pub fn parse_external_link_end<'a>( state: &mut ::State<'a>, start_position: usize, nodes: Vec<::Node<'a>>, ) { ...
use core::marker::PhantomData; use necsim_core::{ cogs::{ CoalescenceSampler, DispersalSampler, EmigrationExit, EventSampler, Habitat, LineageReference, LineageStore, RngCore, SpeciationProbability, TurnoverRate, }, landscape::Location, }; use necsim_core_bond::NonNegativeF64; pub mod cond...
#![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 Sku { pub name: sku::Name, pub family: sku::Family, pub capacity: i32, } pub mod sku { use super::*...
extern crate futures; extern crate tokio; extern crate tokio_stomp; use std::time::Duration; use tokio_stomp::*; use tokio::executor::current_thread::{run, spawn}; use futures::future::ok; use futures::prelude::*; // This examples consists of two theads, each of which connects to a local server, // and then sends ei...
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. #[non_exhaustive] #[derive(std::fmt::Debug)] pub enum Error { ExpiredIteratorError(crate::error::ExpiredIteratorError), ExpiredNextTokenError(crate::error::ExpiredNextTokenError), InvalidArgumentError(crate::error::InvalidArgum...
use uint::{construct_uint, uint_full_mul_reg}; construct_uint! { pub struct U256(4); } construct_uint! { pub struct U512(8); } // construct_uint! { // pub struct U1024(16); // } // construct_uint! { // pub struct U2048(32); // } // construct_uint! { // pub struct U4096(64); // } // construct_...
use anyhow::{Context, Result}; use structopt::{clap::AppSettings, clap::crate_authors, clap::crate_description, clap::crate_version, StructOpt}; use uvm_cli; const SETTINGS: &'static [AppSettings] = &[ AppSettings::ColoredHelp, AppSettings::DontCollapseArgsInUsage, ]; #[derive(StructOpt, Debug)] #[structopt(v...
use crate::errors::{add_table_name, DbResult}; use diesel::prelude::*; use std::convert::Into; use crate::db::{models::AuthUser, schema::auth_user, DatabaseQuery, PooledConnection}; pub struct FindUserByName(String); impl FindUserByName { pub fn new(username: impl Into<String>) -> Self { Self(username.in...