text
stringlengths
8
4.13M
use crate::syscalls; use crate::ALLOCATOR; use core::intrinsics; use core::ptr; // _start and rust_start are the first two procedures executed when a Tock // application starts. _start is invoked directly by the Tock kernel; it // performs stack setup then calls rust_start. rust_start performs data // relocation and s...
// Copyright (c) 2015, <daggerbot@gmail.com> // All rights reserved. use std::ffi::CString; use std::mem::zeroed; use std::ptr::{ null, null_mut, }; use std::sync::atomic::{ AtomicBool, Ordering, ATOMIC_BOOL_INIT, }; use libc::{ c_char, c_int, c_uint, c_ulong, c_void, }; use ::colormap::{ Color...
#![cfg_attr(feature = "unstable-testing", feature(plugin))] #![cfg_attr(feature = "unstable-testing", plugin(clippy))] extern crate gssapi_sys; pub mod buffer; pub mod context; pub mod credentials; pub mod error; pub mod name; pub mod oid; pub mod oid_set; pub use buffer::Buffer; pub use credentials::Credentials; pu...
use common::race_run::NewRaceRun; pub trait RunStore { type Error; type Key; fn create_racerun(&self, new_run: &NewRaceRun) -> Result<Self::Key, Self::Error>; fn get_racerun(&self, id: &Self::Key) -> Result<Option<NewRaceRun>, Self::Error>; }
use std::f32::INFINITY; use std::collections::{HashSet, VecDeque}; use generational_arena::Arena; use crate::consts::EPSILON; use crate::types::{Vec3, Mat3, Quat, ColliderHandle, EntityHandle}; use crate::collider::InternalCollider; use crate::orientation::Orientation; /// The internal representation of any physical...
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::VCFG { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut ...
use super::{ Typeck, Load, Unload, ty::{ GetTy, Inference } }; use ty::{ Ty, }; use mutable::Mutability; use expr::{ Expr, }; use ident::Identifier; use std::cell::RefCell; use ir::{ Chunk, hir::HIRInstruction, }; use ir_traits::{ WriteInstruction }; use n...
use std::convert::TryInto; use napi::*; use crate::sk::*; impl Path { #[inline(always)] pub fn create_js_class(env: &Env) -> Result<JsFunction> { env.define_class( "Path2D", path_constructor, &vec![ // Standard Path2d methods Property::new(&env, "addPath")?.with_method(add_p...
// 12 days of xmahs // // loop incrementing for days // match on days // loop decrementing gifts fn main() { println!("days of xmas!"); // increment loop for days let mut days = 1; while days < 13 { println!("on day {} of xmas, somebody gave to me...", days); // decrement loop for gif...
//! Replaces parts of the game's streaming system to allow the loading of replacement files inside IMGs, //! and also manages the loaded replacements. // fixme: The `stream` module is messy, poorly documented and full of hacky code. // fixme: Opcode 0x04ee seems to break when animations have been swapped. use std::{ ...
#![allow(missing_docs, dead_code)] pub(crate) mod factory; pub mod fixture;
use std::sync::Arc; use bevy::prelude::*; use crate::{ actions::{ActionBuilder, ActionBuilderWrapper}, scorers::{Score, ScorerBuilder}, thinker::ScorerEnt, }; // Contains different types of Considerations and Actions #[derive(Clone)] pub struct Choice { pub(crate) scorer: ScorerEnt, pub(crate) ac...
//! This module conveniently exports common subroutines necessary for hacspecs pub use crate::array::*; pub use crate::bigint_integers::*; pub use crate::buf::*; pub use crate::machine_integers::*; pub use crate::math_integers::*; pub use crate::math_util::{ct_util::*, *}; pub use crate::seq::*; pub use crate::traits:...
extern crate shared; use shared::primes::PrimeStream; fn main() { let primes = PrimeStream::new().take(10001); println!("{}", primes.last().unwrap()); }
use crate::ctx::ClientContext; use anyhow::Result; use maud::html; use rustimate_core::poll::{Poll, PollStatus}; use rustimate_core::util::NotificationLevel; use rustimate_core::RequestMessage; use std::collections::HashMap; use std::str::FromStr; use std::sync::RwLock; use uuid::Uuid; pub(crate) fn on_update_poll(ct...
//! The page for viewing a single repository and its tags use crate::registry::{self, RepoName}; use seed::browser::fetch; use seed::prelude::*; use seed::{a, attrs, button, div, error, h2, img, input, span, C}; use semver::Version; use std::cmp::Ordering; pub struct Model { repo: RepoName, tags: Vec<Tag>, } ...
use crate::components::Tabs; use crate::components::Token; use crate::root::{AppRoute, DataHandle}; use crate::{ data::{MealPlans, MealPlansItem, MealPlansItemRecipesItem}, date::next_seven_days, services::{Error, MealPlansService, RecipeService}, }; use oikos_api::components::schemas::RecipeList; use wasm_...
use futures::future::FutureExt; use std::alloc::Layout; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use tokio_util::sync::ReusableBoxFuture; #[test] fn test_different_futures() { let fut = async move { 10 }; // Not zero sized! assert_eq!(Layout::for_value(&fut).size(), 1); ...
use crate::grammar::ast::eq::ast_eq; use crate::grammar::ast::{eq::AstEq, Expression}; use crate::grammar::model::{HasSourceReference, WrightInput}; use crate::grammar::parsers::expression::binary_expression::primary::parse_expr; use crate::grammar::tracing::trace_result; use nom::IResult; use std::mem::discriminant; ...
/********************************************** > File Name : _TextEditor.rs > Author : lunar > Email : lunar_ubuntu@qq.com > Created Time : Sun Aug 14 11:52:27 2022 > Location : Shanghai > Copyright@ https://github.com/xiaoqixian **********************************************/ use std::cel...
use crate::ctypes::{c_char, c_void, wchar_t}; use crate::shared::basetsd::{INT8, LONG_PTR, SIZE_T, UINT16, UINT32, UINT64, UINT8}; use crate::shared::dxgiformat::DXGI_FORMAT; use crate::shared::dxgitype::DXGI_SAMPLE_DESC; use crate::shared::guiddef::{GUID, IID, REFGUID, REFIID}; use crate::shared::minwindef::{BOOL, BYT...
use eval::lua_hash; use eval::LuaErr; use eval::LuaNative; use eval::LV; // pub fn lua_getattr(tlb: &LV, key: &LV) -> Result<LV, LuaErr> {} pub fn lua_ssetattr(tbl: &mut LV, key: &str, value: LV) -> Result<(), LuaErr> { return lua_setattr(tbl, &LV::LuaS(key.to_string()), value); } pub fn lua_setattr(tbl: &mut LV...
pub mod errors; use async_trait::async_trait; use ldap3::{exop::WhoAmI, Ldap, LdapConnAsync, LdapError as Error}; pub type Pool = deadpool::managed::Pool<Ldap, errors::LdapError>; pub struct Manager(pub &'static str); #[async_trait] impl deadpool::managed::Manager<Ldap, Error> for Manager { async fn create(&self...
#[doc = "Reader of register PID1"] pub type R = crate::R<u32, super::PID1>; #[doc = "Reader of field `PER_ID_1`"] pub type PER_ID_1_R = crate::R<u8, u8>; impl R { #[doc = "Bits 0:7 - Peripheral ID 1"] #[inline(always)] pub fn per_id_1(&self) -> PER_ID_1_R { PER_ID_1_R::new((self.bits & 0xff) as u8) ...
extern crate opencv; extern crate time; use opencv::core; use opencv::highgui; use opencv::imgproc; //use opencv::highgui::VideoCapture; use std::time::Instant; //int lowH[4] = { 0, 51, 75, 20 }; //int highH[4] = { 10, 75, 107, 35 }; //int lowS[4] = { 158, 127, 127, 85 }; //int highS[4] = { 255, 255, 255, 255 }; ...
use std::io; use std::io::ErrorKind; use std::{collections::HashSet, ffi::OsStr}; /// Mount options accepted by the FUSE filesystem type /// See 'man mount.fuse' for details // TODO: add all options that 'man mount.fuse' documents and libfuse supports #[derive(Debug, Eq, PartialEq, Hash, Clone)] pub enum MountOption {...
extern crate buplab; #[macro_use] extern crate log; use buplab::types::Size2; use buplab::Config; static CONFIG: Config = Config { app_name: "Buplab", app_organization: "Proggerij", app_qualifier: "nl", default_window_config: buplab::sdl::WindowConfig { size: Size2 { w: 320, h: 240 }, }, }...
// 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/. use core::{ ops::{Add, Sub}, cmp::{Ord, PartialOrd, Ordering}, fmt::{self, Debug}, }; use crate::{ kt...
//! This crate provides various matcher algorithms for line oriented search given the query string. //! //! The matcher result consists of the score and the indices of matched items. //! //! There two steps to match a line: //! //! // RawSearchLine //! // | //! // | //! // | //! // ↓ //!...
//! Nonspecific utilities and helpers for matters tangential to hyphenation. use std::iter::Fuse; pub struct Intersperse<I> where I: Iterator { inner: Fuse<I>, element: I::Item, sequent: Option<I::Item> } impl<I> Iterator for Intersperse<I> where I: Iterator, I::Item: Clone { type Item = I::...
#![doc(html_no_source)] include!("src/impl.rs"); fn main() { resource_dir("./tests").build().unwrap(); }
use std::collections::HashMap; use std::net::SocketAddr; use std::ops::Deref; use std::time::Duration; use crate::packet::{self, KeyExchange, Packet, Version}; /// The `Hassh` of SSH fingerprinting #[derive(Clone, Debug, PartialEq)] pub struct Hassh { pub ts: Option<Duration>, pub src: SocketAddr, pub des...
use std::ops::{Range, Deref, DerefMut}; use std::cmp::Ordering; use crate::microvm::memory::MemoryError; use crate::microvm::memory::address::*; use crate::microvm::memory::address_space::AddressSpace; pub struct SparseAddressSpace<Address: AddressType> { spaces: Vec<OffsetAddressSpace<Address, dyn AddressSpace<Add...
use crate::utils::{sleep, wait_until}; use crate::{Net, Spec}; use log::info; pub struct IBDProcess; impl Spec for IBDProcess { crate::name!("ibd_process"); crate::setup!(num_nodes: 7, connect_all: false); fn run(&self, net: &mut Net) { info!("Running IBD process"); let node0 = &net.nod...
use amethyst::{ core::Transform, core::timing::Time, ecs::{Join, ReadStorage, ReadExpect, System, WriteStorage, Write}, shrev::EventChannel, }; use crate::pong::{Ball, Paddle, AREA_HEIGHT, PongEvent}; use crate::audio::SoundEvent; pub struct BounceSystem { last_bounce: f32, } impl BounceSystem { ...
use serde::{Serialize, Deserialize, Serializer}; use serde::ser::SerializeStruct; use blake2::{Blake2b, Digest}; use libp2p::PeerId; use std::net::SocketAddr; #[derive(Debug, Serialize, Deserialize)] pub enum Message { ClientRequest(ClientRequest), PrePrepare(PrePrepare), Prepare(Prepare), Commit(Commi...
mod mod_ops; extern crate byteorder; use byteorder::{BigEndian, WriteBytesExt}; use std::mem; use getopts::Options; use yaml_rust::YamlLoader; use std::fs; use std::env; use num_traits::cast::ToPrimitive; fn main() { // --- Adding cmd line arguments: ------------------ // -f: Path to input data yaml-file l...
#![cfg_attr(not(feature = "std"), no_std)] use liquid::storage; use liquid_lang as liquid; #[liquid::contract] mod parallel_ok { use super::*; type Balance = u128; #[liquid(storage)] struct ParallelOk { balances: storage::Mapping<String, Balance>, } #[liquid(methods)] impl Paral...
#[derive(Debug)] struct U { i: i32, s: String, } fn mod_u(u: &U) -> U { // update syntax requires value not reference. // copies values. fails if trying to reuse String value. U { s: String::from("new"), ..*u } } fn main() { let u = U { i: 100, s: String::from("string"), };...
#![allow(unused_variables)] use std::collections::HashMap; use std::str::FromStr; type Database = HashMap<String, String>; type CmdOutput = Result<String, CmdError>; type ErrorMsg = Option<String>; #[derive(Debug, PartialEq)] pub enum Cmd { Ping, Echo { output: String }, Set { key: String, value: String ...
use amethyst::core::{SystemDesc, Transform}; use amethyst::derive::SystemDesc; use amethyst::ecs::{ Entities, Join, LazyUpdate, Read, ReadStorage, System, SystemData, World, Write, WriteStorage, }; use amethyst::renderer::SpriteRender; use ncollide2d::bounding_volume::{BoundingVolume, AABB}; use ncollide2d::math::...
use ic_cdk::export::candid::Principal; use ic_cdk::export::candid::{CandidType, Deserialize}; use ic_cdk::storage; use ic_cdk::*; use ic_cdk_macros::*; use sha2::{Digest, Sha256}; use std::collections::BTreeMap; type Wall = Vec<Post>; type Admins = Vec<Principal>; type Addresses = BTreeMap<String, String>; static mut ...
#[allow(clippy::pub_enum_variant_names)] #[derive(Clone, Copy, EnumIter, Debug, Display, PartialEq)] pub(in crate) enum DraftVersion { Draft4, } impl Default for DraftVersion { fn default() -> Self { Self::Draft4 } }
// fn main() { // let ten: f64 = 10.0; // let mut longest = 0; // let mut longest_i = 0; // for i in 1..1000 { // // easy pickings // // 10's proper divisors except 1 // if i % 2 == 0 || i % 5 == 0 { // continue; // } // // long division // /...
//! This project is used for creating a digital sawtooth signal. //! //! Runs entirely locally without hardware. Rounding might be different than on //! device. Except for when printing you must be vigilent to not become reliant //! on any std tools that can't otherwise port over no no_std without alloc. //! //! `cargo...
use std::ops::{Index, IndexMut}; use enum_iterator::IntoEnumIterator; use matrix::prelude::Conventional; use matrix::{Element, Position, Size}; use crate::action::ActionError::PieceOnMove; use crate::action::{Action, ActionError, ActionType}; use crate::coordinate::Coordinate; use crate::direction::Direction; #[deri...
fn main() { let input = "1113122113"; println!("Part 1: {}", part1(input)); println!("Part 2: {}", part2(input)); } fn part1(input: &str) -> usize { let mut result = input.to_string(); for _ in 0..40 { result = look_and_say(&result); } result.len() } fn part2(input: &str) -> usize ...
use crate::migrations; use crate::types::{ CellTransaction, IndexerConfig, LiveCell, LockHashCapacity, LockHashCellOutput, LockHashIndex, LockHashIndexState, TransactionPoint, }; use ckb_db::{ db::RocksDB, Col, DBIterator, DefaultMigration, Direction, IteratorMode, Migrations, RocksDBTransaction, }; use...
use std::io::Cursor; use std::io::prelude::*; use byteorder::{LittleEndian, ReadBytesExt}; use std::fs::File; use std::io::BufReader; use std::io; use std::convert; #[derive(Debug)] pub enum Error { Err(String), IOError(io::Error), } impl convert::From<io::Error> for Error { fn from(e: io::Error) -> Err...
use yew::prelude::*; use yew_router::prelude::*; use crate::app::Route; #[derive(Debug, Properties, PartialEq)] pub struct Props { pub children: Children, } #[function_component(Container)] pub fn container(props: &Props) -> Html { // 用于跳转到不同的路由 let navigator = use_navigator().unwrap(); let set_titl...
use crate::actions::Action; use crate::error::Result; use crate::shared::installer::InstallerRegistry; use crate::shared::{FileSystemResource, PackageLog, PackageRepository}; // ------------------------------------------------------------------------------------------------ // Public Types // -------------------------...
use super::expression::Expression; use super::variable::LocalVariable; use crate::ast_transform::Transformer; use crate::scm::Scm; use crate::source::SourceLocation; use crate::syntax::Reify; use crate::utils::Named; #[derive(Debug, Copy, Clone)] pub enum LetContKind { IndefiniteContinuation, ExitProcedure, } ...
#[macro_export] macro_rules! bench_func { ($b: ident, op => $func: ident, ty => $t: ty) => {{ const LEN: usize = 1 << 13; let elems = <$t as mathbench::RandomVec>::random_vec(0, LEN); let mut i = 0; $b.iter(|| { i = (i + 1) & (LEN - 1); unsafe { $func(elems.ge...
#[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult}; use crate::error::ContractError; use crate::msg::{ConfigResponse, InstantiateMsg, QueryMsg}; use crate::state::{Config, read_config, store_config}; #[cfg_attr(no...
use std::fmt::Display; use std::fmt::Formatter; use std::fmt::Result as FmtResult; use std::fmt::Write; #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub enum State { Unknown, Known(String), } impl<S> From<S> for State where S: Into<String>, { fn from(s: S) -> Self { State::Known(s.into()) ...
#[test] fn flex_grow_less_than_factor_one() { let layout = stretch::node::Node::new( stretch::style::Style { size: stretch::geometry::Size { width: stretch::style::Dimension::Points(500f32), height: stretch::style::Dimension::Points(200f32), ..Defa...
pub mod character; pub mod movie; pub mod user;
use aoc2020::aoc::load_data; use nom::{ bits::complete::*, branch::*, bytes::complete::*, character::complete::*, combinator::*, multi::*, sequence::*, IResult, }; use regex::Regex; use std::collections::HashMap; use std::io::BufRead; fn binary_partition(input: &str, lower: char, upper: char) -> u64 { // 1...
use argon2::{self, Config}; use bson::{doc, oid::ObjectId}; use failure::Fail; use mongodb::Database; use rand::Rng; use serde::{Deserialize, Serialize}; const USERS_COLLECTION: &str = "users"; #[derive(Debug, Fail)] pub enum UserError { #[fail(display = "NotFound")] NotFound, #[fail(display = "Database")...
use cosmwasm_std::{ to_binary, Api, CanonicalAddr, Extern, HumanAddr, Querier, QueryRequest, StdResult, Storage, Uint128, WasmQuery, }; use mirror_protocol::staking::{PoolInfoResponse, QueryMsg, RewardInfoResponse}; pub fn query_mirror_reward_info<S: Storage, A: Api, Q: Querier>( deps: &Extern<S, A, Q>, ...
use nom::*; use super::*; use std::str; use std::str::{from_utf8,FromStr}; ////////// Tokens // Ignored named!(comment_inline<()>, do_parse!( tag!("/*") >> take_until_and_consume!("*/") >> () ) ); named!(comment_line<()>, do_parse!( tag!("//") ...
use std::fmt::Display; use std::fs::File; use std::io::{self, BufReader, BufWriter, Read, Seek, SeekFrom}; use std::path::Path; use crate::savable::Savable; use super::MirrorMode; /// Size of one PRG bank pub const PRG_PAGE_SIZE: usize = 0x4000; /// Size of one CHR bank pub const CHR_PAGE_SIZE: usize = 0x2000; /// S...
use std::process; use dotenv::dotenv; use std::env; use rand::Rng; extern crate querystring; extern crate paho_mqtt as mqtt; fn main() { dotenv().ok(); let mut rng = rand::thread_rng(); let mqtt_server = env::var("MQTT_SERVER").unwrap(); let mqtt_publish = env::var("MQTT_PUBLISH").unwrap(); let cli = mqtt::...
//! popcnt /// Count bits set. pub trait Popcnt { /// Counts the bits that are set. /// /// **Keywords**: Population count, count ones, Hamming weight, Sideways /// sum. /// /// # Instructions /// /// - [`POPCNT`](http://www.felixcloutier.com/x86/POPCNT.html): /// - Description: P...
use std::collections::{HashMap, HashSet}; use apllodb_shared_components::{ApllodbError, ApllodbResult}; use apllodb_storage_engine_interface::{ ColumnName, RowProjectionQuery, RowSchema, TableColumnName, }; use serde::{Deserialize, Serialize}; use crate::{ entity::Entity, version::{active_versions::Active...
//! Uses the oauth library to set get an fresh access token extern crate oauth2; extern crate rustc_serialize; use std; use rustc_serialize::json; use std::fs::File; use std::io::Read; #[derive(RustcDecodable, RustcEncodable)] struct Secret { client_id: String, client_secret: String, auth_url: String, ...
// {% include 'doc.template' %} use crate::core::expression::*; /// Represents an attribute which a mathematical structure may exhibit. pub enum Attribute { /// Represents the anticommutative property of a binary operation. Anticommutative, /// Represents the associative property of a binary operatio...
use std::convert::{TryFrom, TryInto}; use proc_macro2::Span; use syn::{spanned::Spanned, Error, ExprReturn, Result}; use crate::glsl::Glsl; use super::YaslExprLineScope; #[derive(Debug)] pub struct YaslExprReturn { return_token: syn::token::Return, expr: Option<Box<YaslExprLineScope>>, } impl YaslExprReturn...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Instruction and Data Tightly-Coupled Memory Control Registers"] pub itcmcr: ITCMCR, #[doc = "0x04 - Instruction and Data Tightly-Coupled Memory Control Registers"] pub dtcmcr: DTCMCR, #[doc = "0x08 - AHBP Control regist...
// 2019-01-09 // On va présenter l'intérêt de if let fn main() { // Voyons le cas de figure à remplacer. // On fait passer match pour éxécuter du code si une_valeur_u8 égale 3 // Définir la variable 3u8 veut dire "entier positif à 8 bits, valeur 3" // La définir avec Some() permet de... et bah en fai...
use std::cmp::Reverse; use std::collections::HashMap; use std::{env, fs}; use std::fs::File; use std::io::BufWriter; use csv::Writer; use itertools::Itertools; fn main() { let dir = fs::read_dir(env::args().nth(1).expect("Pass the directory by the command line")).unwrap(); let needles = env::args().skip(2); ...
use super::*; use crate::classification::{quotes::QuoteClassifiedBlock, ResumeClassifierBlockState, ResumeClassifierState}; use crate::debug; struct Block<'i, I, const N: usize> where I: InputBlockIterator<'i, N>, { quote_classified: QuoteClassifiedBlock<I::Block, usize, N>, idx: usize, are_colons_on: ...
/// Assume a condition is true. /// /// * When true, return `Ok(true)`. /// /// * Otherwise, return [`Err`] with a message and the values of the /// expressions with their debug representations. /// /// # Example /// /// ```rust /// # #[macro_use] extern crate assertable; fn main() { /// let x = assume!(true); /// //...
extern crate combine; extern crate combine_language; use combine::parser::char::{alpha_num, letter, string}; use combine::{satisfy, EasyParser, Parser}; use combine_language::{Identifier, LanguageDef, LanguageEnv}; fn main() { let env = LanguageEnv::new(LanguageDef { ident: Identifier { start: l...
//! A runtime for writing reliable, asynchronous, and slim applications. //! //! Tokio is an event-driven, non-blocking I/O platform for writing asynchronous //! applications with the Rust programming language. At a high level, it //! provides a few major components: //! //! * A multi threaded, work-stealing based task...
use std::collections::HashMap; use std::fs::File; use std::io::BufReader; use std::io::prelude::*; fn main() { let file = File::open("input.txt").expect("file not found"); let mut reader = BufReader::new(file); let mut contents = String::new(); reader.read_to_string(&mut contents).expect("could not rea...
extern crate rand; extern crate base64; use crate::commons::{AnswerInfo, CommitInfoPayload, CONCAT}; use uuid::Uuid; use openssl::sha::Sha256; use rand::Rng; use rand::distributions::Alphanumeric; use openssl::rsa::Rsa; use openssl::pkey::{Public}; use openssl::bn::{BigNum, BigNumContext}; pub fn calculate_commit(am...
// 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. use crate::utils::{are_equal, EvaluationResult}; use core::slice; use winterfell::{ crypto::Hasher, math::{fields::f128::BaseEleme...
// Copyright 2014 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 ...
#![allow(dead_code)] //use ::fib; pub mod fib; pub mod matching; pub mod mapping; pub mod nest; fn main() { case1(); case2(); case3(); mapping::test_map2(); nest::apple() } fn case1() { fn call_function_on(f: impl Fn(i64), x: i64) { f(x) } // This works call_function_on(...
use std::fs; use std::collections::HashMap; #[derive(Debug)] struct Object { name: String, parent: Option<String>, } impl Object { fn new(name: &str) -> Self { Object { name: name.to_owned(), parent: None, } } } fn parse_orbits(input: &str) -> HashMap<String, O...
#[doc = "Register `TIM4_SMCR` reader"] pub type R = crate::R<TIM4_SMCR_SPEC>; #[doc = "Register `TIM4_SMCR` writer"] pub type W = crate::W<TIM4_SMCR_SPEC>; #[doc = "Field `SMS1` reader - Slave mode selection When external signals are selected the active edge of the trigger signal (tim_trgi) is linked to the polarity se...
#[doc = "Register `DMACCARxBR` reader"] pub type R = crate::R<DMACCARX_BR_SPEC>; #[doc = "Register `DMACCARxBR` writer"] pub type W = crate::W<DMACCARX_BR_SPEC>; #[doc = "Field `CURRBUFAPTR` reader - Application Receive Buffer Address Pointer"] pub type CURRBUFAPTR_R = crate::FieldReader<u32>; #[doc = "Field `CURRBUFAP...
pub use self::axpy::Axpy; mod axpy;
//! Authorize using the client credentials flow //! //! For example: //! //! ```no_run //! use azure_identity::client_credentials_flow; //! use oauth2::{ClientId, ClientSecret}; //! use url::Url; //! //! use std::env; //! use std::error::Error; //! //! #[tokio::main] //! async fn main() -> Result<(), Box<dyn Error>> { ...
//! Utilities for game state management. use resource::resource_system::ResourcSystem; use engine::event::WindowEvent; use renderer::Pipeline; use ecs::World; /// Types of state transitions. pub enum Trans { /// Continue as normal. None, /// Remove the active state and resume the next state on the stack o...
use domain_runtime_primitives::{BlockNumber as DomainNumber, Hash as DomainHash}; use sc_transaction_pool::error::Result as TxPoolResult; use sc_transaction_pool_api::error::Error as TxPoolError; use sc_transaction_pool_api::TransactionSource; use sp_api::ProvideRuntimeApi; use sp_core::traits::SpawnNamed; use sp_domai...
struct Solution; /// https://leetcode.com/problems/house-robber/submissions/ impl Solution { /// 0 ms 2 MB pub fn rob(nums: Vec<i32>) -> i32 { let mut dp = vec![0; nums.len() + 1]; dp[1] = nums[0]; for i in 2..dp.len() { let robbed = dp[i - 2] + nums[i - 1]; let ...
fn main() { let x : _= "hello world"; let y = &Box::new(x); println!("{:?}", x); println!("{:?}", y); }
// q0013_roman_to_integer struct Solution; impl Solution { pub fn roman_to_int(s: String) -> i32 { let c = [ "I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M", ]; let n = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]; let mut i = n.len() - 1...
use types::Int as Int; use types::Float as Float; pub type Cmplx = (Float, Float); pub fn get_passes_mandelbrot(in_z: Cmplx, mx: Int, dr: Float) -> Int { let mut cnt : Int = 0; let c : Cmplx = in_z; let mut z : Cmplx = c; loop { let xsq : Float = z.0*z.0; let ysq : Float = z.1*z.1; //mandelbrot z = ((xsq-y...
// use builder::Builder; use lltype::*; pub static RANGE_GEN_ID : &'static str = "!range_gen"; pub static RANGE_GEN_INIT : &'static str = "!range_gen_init"; pub static RANGE_GEN_NEXT : &'static str = "!range_gen_next"; ///All the info needed to create and use a Generator in llvm. ///llvm generator types are structu...
use core::time::Duration; use core::fmt; use core::sync::atomic::{AtomicPtr, AtomicU64, AtomicUsize, Ordering}; use core::ops::Deref; use core::mem::transmute; use alloc::collections::BTreeMap; use alloc::alloc::{Allocator, Global, Layout}; use alloc::sync::{Arc, Weak}; use spin::Mutex; use ptr::NonNull; use sys_const...
pub mod boxblock; pub mod character; pub mod craftboard; pub mod terran; pub mod textboard; mod util; pub use boxblock::Boxblock; pub use character::Character; pub use craftboard::Craftboard; pub use terran::Terran; pub use textboard::Textboard; const ORDER_BOXBLOCK: f64 = 1.0; const ORDER_CRAFTBOARD: f64 = 10.0; con...
/// This module contains user-friendly names for the various items in the AST, to report in case they are missing pub trait UserFriendly { const DESCRIPTION: &'static str; } // this is in a submodule so it can be switched off and replaced by a blanket implementation for test-cases #[cfg(not(test))] mod names { ...
use std::path::{PathBuf}; use std::{fs, io, fmt}; use std::fmt::Formatter; use std::str::FromStr; use std::time::{Instant, Duration}; use super::error::{ImagicError, GetFilesResult}; use image::{ImageFormat}; /// STRUCTURES /// pub struct Elapsed(Duration); #[derive(Debug, PartialEq)] pub enum Mode { Single, ...
/* This is part of mktcb - which is under the MIT License ********************/ use log::{Record, Level, Metadata, LevelFilter}; use snafu::{OptionExt}; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use crate::error::Result; use crate::error; use std::io::Write; struct Logger; static LO...
use testutil::*; mod testutil; #[test] fn instance() { let client = get_client(); assert_eq!(get_api_key().to_string(), client.api_key); assert_eq!(SENT_WITH, client.sent_with); }
use super::{Operation, ShallowCopy}; use inner::Inner; use read::ReadHandle; use std::collections::hash_map::RandomState; use std::hash::{BuildHasher, Hash}; use std::sync::atomic; use std::sync::{Arc, MutexGuard}; use std::{mem, thread}; /// A handle that may be used to modify the eventually consistent map. /// /// ...
// Copyright 2021 The Simlin Authors. All rights reserved. // Use of this source code is governed by the Apache License, // Version 2.0, that can be found in the LICENSE file. use std::borrow::BorrowMut; use std::collections::{BTreeSet, HashMap, HashSet}; use std::rc::Rc; use float_cmp::approx_eq; use crate::ast::{s...