text
stringlengths
8
4.13M
use htmldsl::attributes; use htmldsl::elements; use htmldsl::style_sheet; use htmldsl::styles; use htmldsl::units; use htmldsl::TagRenderableIntoElement; pub fn render_page<'a>(body: elements::Body<'a>) -> String { let html = elements::Html { lang: attributes::Lang { tag: units::LanguageTag::En...
#[doc = "Register `AHB3LPENR` reader"] pub type R = crate::R<AHB3LPENR_SPEC>; #[doc = "Register `AHB3LPENR` writer"] pub type W = crate::W<AHB3LPENR_SPEC>; #[doc = "Field `FMCLPEN` reader - Flexible memory controller module clock enable during Sleep mode"] pub type FMCLPEN_R = crate::BitReader<FMCLPEN_A>; #[doc = "Flex...
fn is_anagram(w1: &String, w2: &String) -> bool { let mut c1 : Vec<char> = w1.chars().collect(); let mut c2 : Vec<char> = w2.chars().collect(); c1.sort(); c2.sort(); c1 == c2 && (w1 != w2) } pub fn anagrams_for<'a>(word: &str, inputs: &[&'a str]) -> Vec<&'a str> { let lower_word = word.to_str...
#[cfg(feature = "grapheme-clusters")] use unicode_segmentation::UnicodeSegmentation; use std::{cell::{Ref, RefCell}}; /// Pre-cached line/column lookup table for a string slice. pub struct LineColLookup<'source> { src: &'source str, line_heads: RefCell<Option<Vec<usize>>>, } impl<'source> LineColLookup<'sourc...
use tcod::colors::{self, Color}; use tcod::console::*; use tcod::input::{ Mouse }; use tcod::map::{Map as FovMap}; use super::util; use super::equipment::{Equipment}; // TYPES pub type Map = Vec<Vec<Tile>>; pub type Message = Vec<(String, Color)>; // TRAITS pub trait MessageLog { fn add<T: Into<String>>(&mut sel...
#[cfg(feature = "sound-cpal")] mod sound_cpal; mod sound_sdl; use rustzx_core::zx::sound::sample::SoundSample; #[cfg(feature = "sound-cpal")] pub use sound_cpal::SoundCpal; pub use sound_sdl::SoundSdl; pub const CHANNEL_COUNT: usize = 2; pub const DEFAULT_SAMPLE_RATE: usize = 44100; pub const DEFAULT_LATENCY: usize =...
use pairing::{CurveAffine, Engine}; use std::fmt; pub trait PolyEngine { type Commitment: Commitment<Point = <Self::Pairing as Engine>::G1Affine>; type Opening: Opening; type Pairing: Engine; // TODO: Make default generics of this trait } pub trait Commitment: Clone + Copy + Sized + Send + Sync + 'sta...
#![deny(warnings)] extern crate futures; extern crate tokio; extern crate tokio_core; extern crate tokio_io; extern crate trust_dns; use futures::Future; use tokio::net::{TcpListener, TcpStream}; use tokio::prelude::*; use tokio_io::io::{read_exact, write_all}; use trust_dns::client::{ClientFuture, ClientHandle}; use ...
pub use super::layer_panel::*; use crate::{ consts::{ASYMPTOTIC_EFFECT, FILE_EXPORT_SUFFIX, FILE_SAVE_SUFFIX, SCALE_EFFECT, SCROLLBAR_SPACING}, frontend::layer_panel::*, EditorError, }; use glam::{DAffine2, DVec2}; use graphene::{document::Document as InternalDocument, DocumentError, LayerId}; use serde::{Deserializ...
/// An enum to represent all characters in the GreekandCoptic block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum GreekandCoptic { /// \u{370}: 'Ͱ' GreekCapitalLetterHeta, /// \u{371}: 'ͱ' GreekSmallLetterHeta, /// \u{372}: 'Ͳ' GreekCapitalLetterArchaicSampi, /// \u{373}: 'ͳ'...
use std::io::prelude::*; use std::io::{self, copy}; use std::mem::drop; use std::thread::{spawn, JoinHandle}; use anyhow::Result; use friendly::bytes; use log::*; use os_pipe::{pipe, PipeReader, PipeWriter}; use crate::util::timing::Timer; /// Reader that reads from a background thread. pub struct ThreadRead { r...
// Copyright 2018 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. mod bss; mod scan; mod state; #[cfg(test)] mod test_utils; use fidl_mlme::{MlmeEvent, ScanRequest}; use self::scan::{DiscoveryScan, JoinScan, JoinScanFai...
use anyhow::Result; use itertools::Itertools; use std::{fs, thread::sleep, time::Duration}; #[derive(Debug, PartialEq)] struct SeatMap(Vec<Vec<char>>); impl SeatMap { fn occupied_in_direction(&self, x: usize, y: usize, x_offset: isize, y_offset: isize) -> bool { let mut x = x as isize; let mut y =...
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
use std::cmp::min; use std::io::SeekFrom; use std::io::Result; /// Readable file located on an ISO-9660 filesystem. pub struct IsoFile<'a, H: 'a> where H: ::std::io::Seek + ::std::io::Read, { handle: &'a mut H, start: u32, length: u32, pos: u64, } impl<'a, H: 'a> IsoFile<'a, H> where H: ::std:...
use crate::errors::ConnectorXPythonError; use crate::pandas::destination::PandasDestination; use crate::pandas::typesystem::PandasTypeSystem; use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc}; use connectorx::{ impl_transport, sources::bigquery::{BigQuerySource, BigQueryTypeSystem}, typesyste...
#![cfg(test)] use std::prelude::v1::*; use std::f64; use test; #[bench] fn bench_small_exact_3(b: &mut test::Bencher) { b.iter(|| format!("{:.2e}", 3.141592f64)); } #[bench] fn bench_big_exact_3(b: &mut test::Bencher) { b.iter(|| format!("{:.2e}", f64::MAX)); } #[bench] fn bench_small_exact_inf(b: &mut test...
//! This module handles system calls. use arch::schedule; use core::time::Duration; use elf; use memory::{Address, MemoryArea, VirtualAddress}; use multitasking::scheduler::READY_LIST; use multitasking::{get_current_process, CURRENT_THREAD, TCB}; use sync::time::Timestamp; /// This function accepts the syscalls and c...
// Copyright 2019. The Tari Project // SPDX-License-Identifier: BSD-3-Clause //! The Tari-compatible implementation of Ristretto based on the curve25519-dalek implementation use alloc::{string::ToString, vec::Vec}; use core::{ borrow::Borrow, cmp::Ordering, fmt, hash::{Hash, Hasher}, ops::{Add, Mul...
//! SideFuzz is an adaptive fuzzer that uses a genetic-algorithim optimizer in combination with t-statistics to find side-channel (timing) vulnerabilities in cryptography compiled to wasm. //! //! See the [README](https://github.com/phayes/sidefuzz) for complete documentation. //! //! Creating a target in rust is done ...
fn main() { // with a '!' -> Macro // without it -> Function println!("Hello, world!"); }
pub fn find_order(num_courses: i32, prerequisites: Vec<Vec<i32>>) -> Vec<i32> { use std::collections::HashSet; let n = num_courses as usize; if n == 0 { return vec![] } else if n == 1 { return vec![0] } let mut nodes_without_out = HashSet::<usize>::new(); let mut out_edges ...
use std::collections::HashMap; use std::fmt::Formatter; use std::num::ParseIntError; /// A span referencing the line where a statement came from. Starts at 0 #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] pub struct Span(pub usize); impl Span { pub fn line_number(&self) -> usize { sel...
use super::wasm_buf_apply; use crate::api::{self, json::JsonError}; /// Decodes a binary Receipt given as an offset to a Wasm buffer, /// and then returns an offset to a new Wasm buffer holding the decoded Receipt /// in a JSON format. pub fn decode_receipt(offset: usize) -> Result<usize, JsonError> { wasm_buf_app...
//! Common authn/authz logic use crate::{ error::ServiceError, models::app::{MemberEntry, Role}, }; use drogue_cloud_service_api::auth::user::{ authz::{Outcome, Permission}, UserInformation, }; use indexmap::map::IndexMap; /// A resource that can be checked. pub trait Resource { fn owner(&self) ->...
#[doc = "Register `ITLINE25` reader"] pub type R = crate::R<ITLINE25_SPEC>; #[doc = "Field `SPI1` reader - SPI1"] pub type SPI1_R = crate::BitReader; impl R { #[doc = "Bit 0 - SPI1"] #[inline(always)] pub fn spi1(&self) -> SPI1_R { SPI1_R::new((self.bits & 1) != 0) } } #[doc = "interrupt line 25...
//! [`Recorder`] implementation for counting the number of matches. //! //! This is faster than any recorder that actually examines the values. use super::*; use std::cell::Cell; /// Recorder that keeps only the number of matches, no details. pub struct CountRecorder { count: Cell<MatchCount>, } impl CountRecorde...
use common::grid::Pos; use std::collections::HashMap; /// A sparse grid stores a grid in a map, it can hold an infinite grid and it /// optimized for random access. Default values are not stored in the map, /// resulting in a smaller memory footprint. pub struct SparseGrid<T> { map: HashMap<Pos, T>, } impl<T> Spa...
use specs::{Component, VecStorage}; #[derive(Component, Default)] #[storage(VecStorage)] pub struct Material { pub opaque: bool, pub visible: bool, pub solid: bool, } pub fn smoke() -> Material { Material { opaque: true, visible: true, solid: false, } } pub fn stone() -> M...
mod eating_philosophers; mod readers_writers; mod sleeping_dresser; use eating_philosophers::eating_philosophers_run; use readers_writers::readers_writers_run; use readers_writers::Priority; use sleeping_dresser::sleeping_dresser_run; fn main() { //ReadersWriters //readers_writers_run(5, 5, Priority::Equal); ...
// // 0 1 0 Mnemosyne: a functional systems programming language. // 0 0 1 (c) 2015 Hawk Weisman // 1 1 1 hi@hawkweisman.me // // Mnemosyne is released under the MIT License. Please refer to // the LICENSE file at the top-level directory of this distribution // or at https://github.com/hawkw/mnemosyne/. // //!...
use std::ops::DerefMut; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use rotate_tree::{Node, rotate_in_place_deq, rotate_in_place_vec}; fn criterion_benchmark(c: &mut Criterion) { let mut cnt = 0; let mut tree12 = make_tree(18, &mut cnt); let mut tree16 = make_tree(24, &mut cnt)...
pub fn unique_paths(m: i32, n: i32) -> i32 { let (m, n) = if m > n { (m as i64, n as i64) } else { (n as i64, m as i64) }; (1..(n as i64)).fold(1, |acc, x| acc * (m+n-1-x) / x) as i32 }
#[cfg(test)] mod test { use rusqlite::{Connection, NO_PARAMS}; #[test] fn smoke_test() { let conn = Connection::open_in_memory().unwrap(); conn.execute( r#" CREATE TABLE IF NOT EXISTS foo ( my_int INTEGER NOT NULL, my_string TEXT NOT N...
#[doc = "Reader of register GPIO_HI_OUT"] pub type R = crate::R<u32, super::GPIO_HI_OUT>; #[doc = "Writer for register GPIO_HI_OUT"] pub type W = crate::W<u32, super::GPIO_HI_OUT>; #[doc = "Register GPIO_HI_OUT `reset()`'s with value 0"] impl crate::ResetValue for super::GPIO_HI_OUT { type Type = u32; #[inline(...
use rand::{thread_rng, Rng}; const ARRAY_LENGTH: usize = 32; fn main() { let mut array = [0u8; ARRAY_LENGTH]; thread_rng().fill(&mut array[..]); print!("Unsorted array: "); for element in &array { print!("{} ", element); } print!("\n"); bubsort(&mut array, 0); print!("Sorted...
#[doc = "Register `DMACHRBAR` reader"] pub type R = crate::R<DMACHRBAR_SPEC>; #[doc = "Field `HRBAP` reader - Host receive buffer address pointer"] pub type HRBAP_R = crate::FieldReader<u32>; impl R { #[doc = "Bits 0:31 - Host receive buffer address pointer"] #[inline(always)] pub fn hrbap(&self) -> HRBAP_R...
#![no_std] #![feature(alloc)] #[macro_use] extern crate alloc; use alloc::string::String; use alloc::vec::Vec; extern crate common; use common::bytesrepr::ToBytes; use common::contract_api::pointers::*; use common::contract_api::*; use common::key::Key; #[no_mangle] pub extern "C" fn call() { //This hash comes f...
fn main () { let closures = [1,2,3,4,5].iter().map(|&i| { move |j| i + j }).collect::<Vec<_>>(); println!("{}",closures[0](14)); }
use std::{mem, sync::Arc}; use rosu_v2::prelude::{GameMode, OsuError}; use twilight_model::{ application::interaction::{application_command::CommandOptionValue, ApplicationCommand}, id::{marker::UserMarker, Id}, }; use crate::{ commands::{ check_user_mention, osu::{option_discord, option_n...
pub mod shared; pub use ckb_snapshot::{Snapshot, SnapshotMgr}; pub(crate) const LOG_TARGET_CHAIN: &str = "ckb-chain";
pub fn square(s: u32) -> u64 { assert!(1 <= s && s <= 64, "Square must be between 1 and 64"); 2u64.pow(s-1) } pub fn total() -> u64 { (1..65).map(|x| square(x)).sum() }
use schema::Document; use schema::Term; /// Timestamped Delete operation. #[derive(Clone, Eq, PartialEq, Debug)] pub struct DeleteOperation { pub opstamp: u64, pub term: Term, } /// Timestamped Add operation. #[derive(Eq, PartialEq, Debug)] pub struct AddOperation { pub opstamp: u64, pub document: Doc...
use super::super::ParsedDate; use chrono::prelude::{Datelike, Local}; use time::Duration; use super::helper_macros::periods; named!(indexical_unit <&[u8], ParsedDate>, alt_complete!( alt!(tag_no_case!("today") | tag_no_case!("now")) => { |_| { let today = Local::today(); ...
use super::super::messages::WriteGTP; use super::*; use nom::IResult; use std::io; #[derive(Clone, Debug, PartialEq)] pub enum Value { Int(int::Value), Float(float::Value), String(string::Value), Vertex(vertex::Value), Color(color::Value), Motion(motion::Value), Boolean(boolean::Value), } macro_rules! impl_fro...
fn main() { // cf. http://doc.crates.io/build-script.html // libpq-dev //println! ("cargo:rustc-link-lib=pq"); //println! ("cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu"); }
use crate::data::base::Block; use crate::errors::ArgumentError; use crate::parser::{ hir::{self, Expression, RawExpression}, CommandRegistry, Text, }; use crate::prelude::*; use derive_new::new; use indexmap::IndexMap; #[derive(new)] pub struct Scope { it: Tagged<Value>, #[new(default)] vars: Index...
extern crate std; use super::super::prelude::{ wapi , ToRustBoolConvertion , LPMSG , CCINT , Message , Window , UINT , ToRustBoolConvertion }; pub fn GetMessage( message : &mut Message , window : Option<Window> , minFilter : Option<UINT> , maxFilter : Option<UINT> ) -...
use core::mem::size_of; use core::ptr::write; static mut index: usize = 0; pub unsafe fn make_global<T: Sized>(data: T) -> &'static mut T{ let new = (0x0000_FFFF_0000 + index) as *mut T; write(new, data); index += size_of::<T>(); return &mut *new; }
/// An enum to represent all characters in the IdeographicDescriptionCharacters block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum IdeographicDescriptionCharacters { /// \u{2ff0}: '⿰' IdeographicDescriptionCharacterLeftToRight, /// \u{2ff1}: '⿱' IdeographicDescriptionCharacterAboveToBel...
#[doc = "Register `SRRVR` reader"] pub type R = crate::R<SRRVR_SPEC>; #[doc = "Register `SRRVR` writer"] pub type W = crate::W<SRRVR_SPEC>; #[doc = "Field `SBRV` reader - cortex M0 access control register"] pub type SBRV_R = crate::FieldReader<u32>; #[doc = "Field `SBRV` writer - cortex M0 access control register"] pub...
use serde::{Deserialize, Serialize}; /// ORDER BY (ASC | DESC) #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)] pub enum Ordering { /// Ascending order Asc, /// Descending order Desc, }
use crate::safety::SafetyGame; use aiger::{Aiger, AigerLit}; use cudd::{CuddManager, CuddNode}; use maplit::hashmap; use std::collections::HashMap; impl<'a> SafetyGame<'a> { pub fn from_aiger(aiger: &Aiger, manager: &'a CuddManager) -> Self { assert!(aiger.is_reencoded()); let mut controllable_lit...
use channel; use endpoint; use failure::Error; use futures; use futures::sync::mpsc; use futures::Future; use futures::Sink; use futures::Stream; use identity; use local_addrs; use noise; use packet; use proto; use std::net::SocketAddr; use std::net::UdpSocket as StdSocket; use transport; use clock; #[derive(Debug, F...
use oxygengine::prelude::*; const HOST_URL: &str = "127.0.0.1:9009"; // Typical basic game host server that will listen for clients and reply any message it gets. #[derive(Default)] pub struct MainState { server: Option<ServerId>, } impl State for MainState { fn on_enter(&mut self, _: &mut Universe) { ...
mod connect; mod tls; use log::{debug, info, warn}; use std::{cmp, future::Future, io, net::SocketAddr, pin::Pin, sync::Arc, time::Duration}; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, net::TcpStream, time::timeout, }; use crate::{ client::connect::try_connect_all, client::tls::parse_client_he...
use super::{AdsPlcType, SubRange}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use num_traits::{Bounded, FromPrimitive, ToPrimitive}; use serde_json::Value; use std; use std::str::FromStr; pub fn number_from_value<T: ToPrimitive + FromPrimitive + FromStr>(d: &Value) -> T where <T as FromStr>::Err: ...
// unihernandez22 // https://atcoder.jp/contests/abc156/tasks/abc156_a // math use std::io::stdin; fn main() { let mut line = String::new(); stdin().read_line(&mut line).unwrap(); let words: Vec<i64> = line .split_whitespace() .map(|x| x.parse().unwrap()) .collect(); let ...
#[cfg(feature = "search")] fn func0() { println!("search"); } #[cfg(not(feature = "search"))] fn func0() { println!("not search"); } fn main() { func0(); }
//! Defines the interface and types for memory paging. //! //! # Guarantees //! //! 1. A page table owns all of its subtables. //! 2. The recursively mapped P4 table is owned by a RecusivePageTable struct. pub use self::entry::*; use memory::PAGE_SIZE; use memory::Frame; use memory::FrameAllocator; use self::tabl...
//! Comparison of indexed sequences of values. //! //! # Examples //! //! Quick plot. //! ```no_run //! use preexplorer::prelude::*; //! let many_pro_err = (0..5).map(|_| pre::ProcessError::new((5..15), (0..10).map(|i| i..10 + i))); //! pre::ProcessErrors::new(many_pro_err).plot("my_identifier").unwrap(); //! ``` //! ...
use std::borrow::Cow; #[derive(Default, Debug, Clone)] pub struct Stats { pub msg_type_tag: Cow<'static, str>, pub resp_type_tag: Option<Cow<'static, str>>, pub err_type_tag: Option<Cow<'static, str>>, pub has_queue: bool, pub queue_capacity: i64, pub queue_size: i64, pub has_parallel: b...
use bevy::prelude::*; use bevy_mod_picking::*; mod camera; mod cursor; mod voxel; mod window; fn main() { App::build() .add_plugin(window::Plugin) .add_default_plugins() .add_system(bevy::input::system::exit_on_esc_system.system()) .add_plugin(cursor::Plugin) .add_plugin(vo...
pub mod list_node; pub mod tree_node;
use super::archive_schema::Archive; use regex::Regex; use std::path::PathBuf; #[derive(Debug)] /// Arguments for Youtube-DL pub struct Arguments { /// Output directory pub out: PathBuf, /// Temporary Directory pub tmp: PathBuf, /// The URL to download pub url: ...
use io; const OFFSET: usize = 1; pub fn find_space() -> i32 { io::select_number() - OFFSET as i32 }
extern crate iron; extern crate router; // To build, $ cargo test // To use, go to http://127.0.0.1:3000/test use iron::{Iron, Request, Response, IronResult}; use iron::status; use router::{Router}; use std::sync::{Arc, Mutex}; fn main() { let mut raw_messages : Vec<String> = Vec::new(); let mut messages = A...
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // 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>,...
// MIT License // // Copyright (c) 2021 Miguel Peláez // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modif...
use nalgebra_glm as glm; use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use web_sys; use web_sys::WebGl2RenderingContext as GL; use crate::types::*; use regmach::dsp::types as rdt; impl BrowserDisplay<'_> { // todo establish common e...
use std::net::Ipv4Addr; use self::Option::*; const TAG_PAD: u8 = 0; const TAG_SUBNET_MASK: u8 = 1; const TAG_TIME_OFFSET: u8 = 2; const TAG_ROUTER: u8 = 3; const TAG_TIME_SERVER: u8 = 4; const TAG_NAME_SERVER: u8 = 5; const TAG_DOMAIN_NAME_SERVER: u8 = 6; const TAG_LOG_SERVER: u8 = 7; const TAG_COOKIE_SERVER: u8 = 8;...
/* Copyright ⓒ 2016 rust-custom-derive contributors. Licensed under the MIT license (see LICENSE or <http://opensource.org /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of <http://www.apache.org/licenses/LICENSE-2.0>), at your option. All files in the project carrying such notice may not be copied, m...
use matches::assert_matches; use common::TestClientBuilder; use mqtt3::proto::QoS::{AtLeastOnce, AtMostOnce, ExactlyOnce}; use mqtt3::proto::SubscribeTo; use mqtt3::{Event, ReceivedPublication}; use mqtt_broker::{AuthId, BrokerBuilder}; mod common; #[tokio::test] async fn basic_connect_clean_session() { let brok...
//! The pointer type. use SafeWrapper; use ir::{SequentialType, CompositeType, Type}; use sys; /// A pointer. pub struct PointerType<'ctx>(SequentialType<'ctx>); impl<'ctx> PointerType<'ctx> { /// Creates a new pointer type. pub fn new(element_ty: &Type, address_space: u32) -> Self { u...
pub(crate) mod deserializer; pub(crate) mod hir; pub(crate) mod parse; pub(crate) mod parse_command; pub(crate) mod registry; use crate::errors::ShellError; pub(crate) use deserializer::ConfigDeserializer; pub(crate) use hir::baseline_parse_tokens::baseline_parse_tokens; pub(crate) use parse::call_node::CallNode; pub...
use std::fmt; use std::convert::From; use yansi::Color::*; use codegen::StaticRouteInfo; use handler::Handler; use http::{Method, MediaType}; use http::uri::URI; /// A route: a method, its handler, path, rank, and format/media type. pub struct Route { /// The method this route matches against. pub method: Me...
use super::Particle; use std::collections::HashMap; use crate::types::Real; /// The particle storage system pub struct ParticleRegistry { pub particles: HashMap<String, Particle> } /// Implements `ParticleRegistry` impl ParticleRegistry { pub fn new() -> Self { Self { particles: HashMap::n...
#[macro_use] extern crate seed; use seed::prelude::*; mod sudoku; use sudoku::{Board, Cell}; // Model struct Model { pub board: Board, pub warning: String, pub selected: Option<(usize, usize)>, } impl Default for Model { fn default() -> Self { Self { board: Board::new(9), ...
#[link(name = "dupeimport")] extern "C" { fn bar(x: u32); } #[export_name = "foo"] pub fn foo(x: u32) { println!("in Rust, x = {}", x); unsafe { bar(x); } }
use crate::{SEED256_DERIVATION_ID, Seed256}; use anyhow::Error; use bip39::{Language, Mnemonic, MnemonicType}; use sha2::Sha256; use hmac::Hmac; use pbkdf2::pbkdf2; use zeroize::Zeroize; /// Simple helper to generate a fixed length blake2b output fn blake2b_256(input: &[u8]) -> [u8; 32] { let mut res = [0u8; 3...
fn main() { let a = if true { "abc" }; }
pub(crate) mod build_lex_table; pub(crate) mod build_parse_table; mod coincident_tokens; mod item; mod item_set_builder; mod minimize_parse_table; mod token_conflicts; use self::build_lex_table::build_lex_table; use self::build_parse_table::{build_parse_table, ParseStateInfo}; use self::coincident_tokens::CoincidentTo...
/* * 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 */ /// WidgetImageSizing : How to size the image on the widget. The values are based on the image `object-f...
#![doc = "generated by AutoRust 0.1.0"] #![allow(unused_mut)] #![allow(unused_variables)] #![allow(unused_imports)] use super::{models, API_VERSION}; #[non_exhaustive] #[derive(Debug, thiserror :: Error)] #[allow(non_camel_case_types)] pub enum Error { #[error(transparent)] Operations_List(#[from] operations::l...
use std::io; use std::path::{Path, PathBuf}; use rocket::fs::NamedFile; #[get("/<path..>", rank = 5)] pub async fn static_file(path: PathBuf) -> io::Result<NamedFile> { NamedFile::open(Path::new("static/").join(path)).await }
// use std::rc::Rc; use gltf; use shader::Shader; use render::Primitive; pub struct Mesh { // TODO!: Rc/RefCell + reuse (below) pub primitives: Vec<Primitive>, // TODO // pub weights: Vec<Rc<?>> pub name: Option<String> } impl Mesh { pub fn from_gltf(g_mesh: gltf::mesh::Mesh) -> Mesh { ...
extern crate advent_of_code_2017_day_10; use advent_of_code_2017_day_10::*; #[test] fn part_2_example_1() { assert_eq!(solve_puzzle_part_2(""), "a2582a3a0e66e6e86e3812dcb672a272"); } #[test] fn part_2_example_2() { assert_eq!( solve_puzzle_part_2("AoC 2017"), "33efeb34ea91902bb2f59c9920caa6cd"...
use super::{ FlowProperties, FlowPropertyVal, OperatorCategory, OperatorConstraints, IDENTITY_WRITE_FN, RANGE_0, RANGE_1, }; /// > 1 input stream of type T, 1 output stream of type T /// /// For each item passed in, pass it out without any change. /// /// ```hydroflow /// source_iter(vec!["hello", "world"]) //...
use lambda_http::http::StatusCode; use lambda_http::{lambda, Body, IntoResponse, Request, RequestExt, Response}; use lambda_runtime::{error::HandlerError, Context}; use rusoto_core::Region; use rusoto_dynamodb::{DynamoDb, DynamoDbClient, PutItemInput}; use serde_json::json; use std::env; use uuid::Uuid; use models::Sc...
use crate::execution::chunk::{Chunk, Opcode}; pub(crate) struct VM{ stack: Vec<i64> } impl VM { fn new() -> Self { VM{stack: vec![]} } pub fn run_chunk(chunk: &Chunk) -> Result<(), String> { let mut vm = VM::new(); for instruction in &chunk.code { match instructio...
//! [![github]](https://github.com/dtolnay/dyn-clone)&ensp;[![crates-io]](https://crates.io/crates/dyn-clone)&ensp;[![docs-rs]](https://docs.rs/dyn-clone) //! //! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github //! [crates-io]: https://img.shields.io/badge/crates.i...
// This file is part of Basilisk-node. // Copyright (C) 2020-2021 Intergalactic, Limited (GIB). // 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 // /...
// Copyright 2019, The Tari Project // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following // disclai...
extern crate clap; use clap::{App, Arg}; #[test] fn multiple_occurrences_of_flags_long() { let m = App::new("multiple_occurrences") .arg(Arg::from_usage("--multflag 'allowed multiple flag'") .multiple(true)) .arg(Arg::from_usage("--flag 'disallowed multiple fla...
#[doc = "Register `STGENR_PIDR1` reader"] pub type R = crate::R<STGENR_PIDR1_SPEC>; #[doc = "Field `PART_1` reader - PART_1"] pub type PART_1_R = crate::FieldReader; #[doc = "Field `DES_0` reader - DES_0"] pub type DES_0_R = crate::FieldReader; impl R { #[doc = "Bits 0:3 - PART_1"] #[inline(always)] pub fn ...
use strum_macros::Display; #[rustfmt::skip] #[derive(Debug, Clone, Display, Copy)] #[repr(u8)] pub enum TokenType { // Single-character tokens. LeftParen, RightParen, LeftBrace, RightBrace, Comma, Dot, Minus, Plus, Semicolon, Slash, Star, // One or two character tokens. Bang, BangEqual, Equal,...
extern crate passivetotal; use passivetotal::{client,config}; #[test] fn test_pdns_riskiq() { let conf = config::read_config().unwrap(); let client = client::PTClient::new(conf); let response = client.get_pdns("sf.riskiq.net"); let results = response.results.unwrap(); assert_eq!(results.len(), 2);...
use std::collections::HashMap; use procfs::process::FDTarget; use crate::{ network::{LocalSocket, Protocol}, OpenSockets, }; pub(crate) fn get_open_sockets() -> OpenSockets { let mut open_sockets = HashMap::new(); let mut inode_to_procname = HashMap::new(); if let Ok(all_procs) = procfs::process...
mod author_translator; mod content_manager_translator; mod reader_translator; pub use author_translator::*; pub use content_manager_translator::*; pub use reader_translator::*;
#![no_std] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))] extern crate libc; #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] mod libc { pub type c_void = u8; pub type c_int =...