text
stringlengths
8
4.13M
pub const BGP_PORT: u16 = 179; pub const BGP_HEADER_LEN: usize = 19; pub use capability::*; pub use client::Bgp; pub use client::Client; pub use client::Event; pub use client::Message; pub use communities::Communities; pub use message::MessageHeader; pub use neighbor::Neighbor; pub use neighbor::NeighborVec; pub use n...
extern crate rand; pub use rand::Rng; pub trait Vector<I32> { fn new_sorted(number: usize, min_dist: i32, max_dist:i32) -> Self where Self: Sized; fn new(number: usize, min_value: i32, max_value: i32) -> Self where Self: Sized; fn len(&self) -> isize; fn display(&self); fn sequential_search(&self,...
//! Process HTTP connections on the client. use async_std::io::{self, Read, Write}; use http_types::{Request, Response}; mod decode; mod encode; pub use decode::decode; pub use encode::Encoder; /// Opens an HTTP/1.1 connection to a remote host. pub async fn connect<RW>(mut stream: RW, req: Request) -> http_types::R...
use serde::{Deserialize, Serialize}; use sqlx::postgres::PgPool; use sqlx::sqlx_macros::Type; use sqlx::types::Uuid; use strum_macros::{Display, EnumString}; use thiserror::Error; pub mod drives; pub mod hosts; pub mod kernels; pub mod storage; pub mod vms;
use service::SamotopService; use tokio::net::TcpStream; #[derive(Clone)] struct DeadService; impl SamotopService for DeadService { fn handle(self, _socket: TcpStream) {} }
// Copyright 2014 The Servo 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>, at ...
#[doc = "Reader of register RSTB2R"] pub type R = crate::R<u32, super::RSTB2R>; #[doc = "Writer for register RSTB2R"] pub type W = crate::W<u32, super::RSTB2R>; #[doc = "Register RSTB2R `reset()`'s with value 0"] impl crate::ResetValue for super::RSTB2R { type Type = u32; #[inline(always)] fn reset_value() ...
use crate::{DocBase, VarType}; const DESCRIPTION: &'static str = r#" Measure of difference between the series and it's sma "#; const ARGUMENTS: &'static str = r#" **source (series)** Series of values to process. **length (int)** Number of bars (length). "#; pub fn gen_doc() -> Vec<DocBase> { let fn_doc = DocBase...
use procon_reader::ProconReader; fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let t: usize = rd.get(); for _ in 0..t { let n: usize = rd.get(); let x: Vec<u32> = rd.get_vec(n); solve(n, x); } } fn solve(n: usize, x: Vec<u32>) { ...
use input_i_scanner::InputIScanner; fn main() { let stdin = std::io::stdin(); let mut _i_i = InputIScanner::from(stdin.lock()); macro_rules! scan { (($($t: ty),+)) => { ($(scan!($t)),+) }; ($t: ty) => { _i_i.scan::<$t>() as $t }; ...
use anyhow::{ Context, Result, }; use std::path::Path; pub mod ds; pub mod utils; use crate::normalize::ds::{ entry::{ Normalized, Raw, }, so_tree, }; pub fn write_file(input_file: &Path, so_term_tree: &Path, output_file: &Path) -> Result<()> { let so_tree = so_tree::load(&so...
use crate::object::Point; use crate::global::*; use super::common_step::*; fn jacobi_method(grid: &Vec<Point>) -> bool { let update : Vec<(f64, bool, usize)> = grid.iter().map(move |x|step(grid, x.index, false)).collect(); update.iter().for_each(|x| { let mut t = grid[x.2].temperature.borrow_mut(); ...
#[cfg(feature = "codegen")] mod tests { use std::{ fmt::Debug, sync::{ atomic::{AtomicUsize, Ordering}, Arc, }, }; use legion::{ storage::Component, system, systems::CommandBuffer, world::SubWorld, IntoQuery, Query, Read, Resources, Schedule, ...
extern crate messycanvas; fn main() { messycanvas::daemon::main(); }
// Copyright 2023 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to ...
use failure::{format_err, Fallible, ResultExt}; use std::ffi::OsStr; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use std::path::Path; pub fn basename(file_path: &str) -> Fallible<&str> { let file_name = Path::new(file_path) .file_name() .and_then(|s: &OsStr| s.to_str()) ...
#[macro_use] extern crate hlua; fn main() { let mut lua = hlua::Lua::new(); lua.openlibs(); // we create a fill an array named `Sound` which will be used as a class-like interface { let mut sound_namespace = lua.empty_array("Sound"); // creating the `Sound.new` function sound_...
//! # Arithmetic //! //! ## Direct evaluation //! //! ```rust #![doc = include_str!("../../examples/arithmetic/parser.rs")] //! ``` //! //! ## Parse to AST //! //! ```rust #![doc = include_str!("../../examples/arithmetic/parser_ast.rs")] //! ```
mod kamada_kawai; mod mds; mod sgd; mod stress_majorization; use pyo3::prelude::*; pub fn register(py: Python<'_>, m: &PyModule) -> PyResult<()> { mds::register(py, m)?; kamada_kawai::register(py, m)?; stress_majorization::register(py, m)?; sgd::register(py, m)?; Ok(()) }
use ethabi::token::Token; use ethabi::{Address, Uint}; use primitive_types::U256; use std::char; use tiny_keccak; #[derive(Serialize, Debug)] #[serde(untagged)] pub enum Value { STRING(String), NUMBER(f64), BOOLEAN(bool), ARRAY(Vec<Value>), NULL, } static MAX_SAFE_INT: Uint = U256([900719925474099...
// 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. pub use crate::errors::ParseError; pub use crate::parse::{check_resource, HASH_RE, NAME_RE}; use std::fmt; use url::percent_encoding::percent_decode; use u...
//! Particle Swarm Optimization. //! //! # Example //! ``` //! extern crate meta_heuristics; //! extern crate rand; //! //! use meta_heuristics::pso; //! use std::cmp; //! //! #[derive(Clone, Copy)] //! struct Particle { //! pos: f64, //! vel: f64, //! best: (f64, f64), //! } //! //! fn eval_func(x: f64) ->...
use std::collections::BTreeSet; use std::sync::Arc; use crate::config::TableConfig; use crate::table::{DetachedRowData, TableSchema}; pub struct MemTable { config: Arc<TableConfig>, schema: Arc<TableSchema>, data: BTreeSet<DetachedRowData>, size: usize, } impl MemTable { pub fn new(config: &Arc<T...
//! Tests auto-converted from "sass-spec/spec/misc" //! version 0f59164a, 2019-02-01 17:21:13 -0800. //! See <https://github.com/sass/sass-spec> for source material.\n //! The following tests are excluded from conversion: //! ["mixin_content", "JMA-pseudo-test", "trailing_comma_in_selector", "warn-directive"] extern cr...
extern crate byteorder; extern crate http_muncher; extern crate inflector; extern crate libc; #[macro_use] extern crate plugkit; use inflector::Inflector; use std::collections::HashMap; use std::io::{Error, ErrorKind}; use plugkit::layer::Layer; use plugkit::context::Context; use plugkit::worker::Worker; use plugkit:...
enum ExprC { NumC { n : u32 }, BoolC { b : bool }, StringC { s : String }, IfC { i : Box<ExprC>, t : Box<ExprC>, e : Box<ExprC> }, IdC { i : String }, LamC { params : Vec<String>, body : Box<ExprC> }, AppC { fun_def : Box<ExprC>, params: Vec<Box<ExprC>> } } enum ValueV { NumV { n : u32...
#[macro_use] extern crate conrod_core; extern crate conrod_glium; #[macro_use] extern crate conrod_winit; extern crate find_folder; extern crate glium; extern crate image; use glium::Surface; use conrod_core::color::Color; use rand::prelude::*; mod support; fn generate_gradient() -> Vec<Color> { let mut rng = ...
/* * Open Service Cloud API * * Open Service Cloud API to manage different backend cloud services. * * The version of the OpenAPI document: 0.0.3 * Contact: wanghui71leon@gmail.com * Generated by: https://openapi-generator.tech */ #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct CloudServerResour...
// Copyright 2020-2021, The Tremor Team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agr...
#[doc = "Reader of register IP_HWCFGR0"] pub type R = crate::R<u32, super::IP_HWCFGR0>; #[doc = "Writer for register IP_HWCFGR0"] pub type W = crate::W<u32, super::IP_HWCFGR0>; #[doc = "Register IP_HWCFGR0 `reset()`'s with value 0x1111"] impl crate::ResetValue for super::IP_HWCFGR0 { type Type = u32; #[inline(a...
use std::io::prelude::*; fn primes(n:i32) -> Vec<i32> { let mut t : Vec<i32> = (0..n).collect(); t[1] = 0; let mut p : usize = 2; let nn = n as usize; 'outer : while p < nn { 'inner : loop { if p >= nn { break 'outer } else if t[p] ...
//! FFI Bindings for Berkeley DB 4.8. extern crate libc; pub mod ffi;
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[repr(transparent)] #[doc(hidden)] pub struct IRemoteTextConnection(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IRemoteTextConnection { type Vtable = I...
use defs::{FloatType, Vector3}; use core::{Ray, RayError, RayIntersection, ColorComponent}; use tools::{CompareWithTolerance}; use na; use na::{Rotation3, Unit}; #[derive(Debug)] pub enum RayPropagatorError { RayRelated(RayError), NoRefraction, NotRefractiveMaterial } pub struct RayPropagator<'intersec...
pub fn u32_in_range(val: u32, min: u32, max: u32) -> bool { val >= min && val <= max } pub fn valid_color_temp_range(model: &str) -> (u32, u32) { let devices = [("LB120", (2700, 6500)), ("LB130", (2500, 9000))] .iter() .filter(|(name, _)| model.contains(name)) .map(|(_, range)| *range) ...
pub mod other { pub fn print_from_other(){ println!("Some text from a sub module") } }
use std::convert::TryInto; use std::panic; use hashbrown::HashMap; use liblumen_alloc::erts::exception::{self, badmap, ErlangException, RuntimeException}; use liblumen_alloc::erts::process::ffi::ErlangResult; use liblumen_alloc::erts::process::trace::Trace; use liblumen_alloc::erts::term::{binary, prelude::*}; use li...
use crate::AUCTIONS; use rust_decimal::Decimal; use shylock_data::types::Asset; use yew::prelude::*; use yewtil::NeqAssign; #[derive(Properties, Clone, PartialEq)] pub struct Props { pub position: usize, pub asset: &'static Asset, } pub struct AssetView { props: Props, // link: ComponentLink<Self>, ...
#[doc = "Reader of register RDATA13R"] pub type R = crate::R<u32, super::RDATA13R>; #[doc = "Reader of field `RDATA3`"] pub type RDATA3_R = crate::R<u16, u16>; #[doc = "Reader of field `RDATA1`"] pub type RDATA1_R = crate::R<u16, u16>; impl R { #[doc = "Bits 16:31 - Regular conversion data for SDADC3"] #[inline...
/// /// 请你来实现一个 atoi 函数,使其能将字符串转换成整数。 /// /// 首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止。 /// /// 当我们寻找到的第一个非空字符为正或者负号时,则将该符号与之后面尽可能多的连续数字组合起来,作为该整数的正负号;假如第一个非空字符是数字,则直接将其与之后连续的数字字符组合起来,形成整数。 /// /// 该字符串除了有效的整数部分之后也可能会存在多余的字符,这些字符可以被忽略,它们对于函数不应该造成影响。 /// /// 注意:假如该字符串中的第一个非空格字符不是一个有效整数字符、字符串为空或字符串仅包含空白字符时,则...
#[allow(unused_imports)] use proconio::{marker::*, *}; use std::collections::{HashMap, HashSet}; #[allow(unused_imports)] use std::{cmp::Ordering, convert::TryInto}; #[fastout] fn main() { input! { n: usize, m: usize, mut h: i32, k: i32, s: Chars, mut items: [(i32, ...
use crate::file_util::read_non_blank_lines; use crate::day_eleven::Seat::{TAKEN, EMPTY, FLOOR}; #[derive(Debug, Eq, PartialEq, Clone)] enum Seat { TAKEN, EMPTY, FLOOR } trait SafeGet<'a, T> { fn safe_get(self, index: isize) -> Option<&'a T>; } impl <'a, T> SafeGet<'a, T> for &'a [T] { fn safe_get(self, i...
mod heap; mod iter; mod process_heap_alloc; mod semispace; mod stack_alloc; mod stack_primitives; mod term_alloc; mod virtual_alloc; mod virtual_binary_heap; pub use self::heap::{Heap, HeapAlloc}; pub use self::iter::HeapIter; pub use self::process_heap_alloc::ProcessHeapAlloc; pub use self::semispace::{GenerationalHe...
use std::fmt; use std::fmt::{Display, Formatter}; use std::time::{Duration, Instant}; pub struct Bench { name: String, pub loops: usize, pub ops: usize, start: Instant, duration: Duration, speed_factor: Option<f32>, } impl Bench { pub fn new(name: &str) -> Bench { Bench { ...
use std::future::Future; pub trait Executor { type Item; fn run(&self) -> Vec<Self::Item>; } pub struct MyExecutor; #[cfg(feature = "string-exec")] pub mod string_executor; #[cfg(feature = "num-exec")] pub mod number_executor;
// Copyright 2021 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to ...
// 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. //! Common utilities used by both directory and file traits. use { fidl::endpoints::ServerEnd, fidl_fuchsia_io::{ NodeMarker, CLONE_FLAG_S...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] pub const CCH_RM_MAX_APP_NAME: u32 = 255u32; pub const CCH_RM_MAX_SVC_NAME: u32 = 63u32; pub const CCH_RM_SESSION_KEY: u32 = 32u32; #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq,...
use std::io::Write; use std::fs::File; use rand::Rng; mod entropy; mod strategies; mod sim; mod test; use strategies::*; use sim::*; fn output(f: &mut File, s: String) { println!("{}", s); f.write_all(s.as_bytes()).expect("couldnt write to file"); f.write_all(b"\n").expect("couldnt write newline to file"...
use crate::config::{TargetPadding, TimeFormat}; use crate::{Config, LevelPadding, ThreadLogMode, ThreadPadding}; use log::{LevelFilter, Record}; use std::io::{Error, Write}; use std::thread; #[cfg(all(feature = "termcolor", feature = "ansi_term"))] use termcolor::Color; #[cfg(all(feature = "termcolor", feature = "ansi...
pub mod model_selection; pub mod quick_start; pub mod supervised; pub mod unsupervised; pub mod utils; use std::collections::HashMap; use structopt::StructOpt; #[derive(StructOpt)] /// Run SmartCore example struct Cli { /// The example to run. Pass `list_examples` to list all available examples! example_n...
#![feature(test)] extern crate rtfmt; extern crate test; use std::collections::BTreeMap; use test::Bencher; use rtfmt::{Generator, Value}; #[bench] fn complex(b: &mut Bencher) { let g = Generator::new("le message: {id}!").unwrap(); let mut map = BTreeMap::new(); map.insert("id".into(), Value::I64(42));...
use super::{Token, parsers::{parse_block_comments, parse_curly_brace, parse_identifier, parse_line_comment, parse_number, parse_operator, parse_parenthesis, parse_separator, parse_string, parse_terminator, parse_whitespace}}; pub struct Tokenizer { pub index: usize, pub file_content: Vec<char>, } impl Tokeniz...
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. pub fn serialize_operation_create_container( input: &crate::input::CreateContainerInput, ) -> Result<smithy_http::body::SdkBody, smithy_types::Error> { let mut out = String::new(); let mut object = smithy_json::serialize::JsonO...
// This file is derived from the lupine crate, which is licensed under MIT // and available at https://github.com/greglaurent/lupine/ /* 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 rest...
struct Solution; impl Solution { pub fn first_missing_positive(nums: Vec<i32>) -> i32 { let mut nums = nums; let len = nums.len(); let mut i = 0; while i < len { let num = nums[i]; // segregate the negative and positive // we don't care those valu...
// Copyright (C) 2020, Cloudflare, Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright notice, // this list...
use std::{any::TypeId, collections::HashMap}; use crate::{ actors::{actor_builder::ActorBuilder, actor_type::ActorType}, events::{event_builder::EventBuilder, event_type::EventType}, PacketReader, }; /// Contains the shared protocol between Client & Server, with a data that is /// able to map Event/Actor ...
use super::Pg; use crate::backend::BinaryRawValue; use std::num::NonZeroU32; use std::ops::Range; /// Raw postgres value as received from the database #[derive(Clone, Copy)] #[allow(missing_debug_implementations)] pub struct PgValue<'a> { raw_value: &'a [u8], type_oid_lookup: &'a dyn TypeOidLookup, } #[doc(hi...
#![cfg_attr(not(test), no_std)] #![feature(test)] // Used for #[may_dangle] on TypedArena #![feature(dropck_eyepatch)] // Used for arith_offset #![feature(core_intrinsics)] #![feature(new_uninit)] #![feature(maybe_uninit_slice)] // Used for the implementation of the arenas #![feature(raw_vec_internals)] extern crate a...
use crate::{Error, mock::*, PersonInfo}; use frame_support::{assert_ok, assert_noop}; use sp_runtime::DispatchError; #[test] fn it_works_for_health_ai() { new_test_ext().execute_with(|| { // 保存慢性病禁忌菜品 assert_noop!(HealthAi::save_taboo_foods(Origin::signed(0),1, vec![10, 10]),DispatchError::BadOrig...
#[macro_use] extern crate serde_derive; extern crate cargo_edit; extern crate cargo; extern crate docopt; use std::process::Command; use std::os::unix::process::CommandExt; use cargo_edit::Manifest; use cargo::core::shell::Verbosity; use cargo::core::Workspace; use cargo::ops::{compile, CompileOptions, CompileMode, C...
use crate::geom::{Vector, Rectangle, Transform}; #[derive(Clone, Copy, Debug)] ///A view into the world, used as a camera and a viewport pub struct View { pub(crate) normalize: Transform, pub(crate) opengl: Transform } impl View { ///Create a new view that looks at a given area pub fn new(world: Recta...
/* Timely code for the generators (data producers) specific to the Value Barrier example. */ use super::common::{Duration, Scope, Stream}; use super::generators::fixed_rate_source; use super::util::rand_range; use super::vb_data::{VBData, VBItem}; pub fn value_source<G>( scope: &G, loc: usize, fre...
//! Object traits. use crate::{ error::{MaxError, MaxResult}, notify::{Attachment, AttachmentError, Registration, RegistrationError, Subscription}, symbol::SymbolRef, }; use std::convert::TryInto; macro_rules! impl_obj_methods { ($o:expr) => { /// Post a message to max. fn post<M: Into...
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use crate::audio::{facade::AudioFacade, types::AudioMethod}; use failure::Error; use serde_json::Value; use std::sync::Arc; // Takes SL4F method command a...
extern crate gl; extern crate glfw; use std::ffi::CStr; use std::mem; use std::os::raw::c_void; use std::path::Path; use std::ptr; use cgmath::{Matrix4, vec2, vec3, Vector2, Vector3}; use image::GenericImage; use noise::{NoiseFn, Value}; use rand::Rng; use crate::shader::Shader; use self::gl::types::*; /* landscap...
pub mod cmd; pub mod logger; pub mod resources; pub type Logger = slog::Logger; pub type ArgFlags = clap::ArgMatches<'static>;
#[doc = "Reader of register MMCTIR"] pub type R = crate::R<u32, super::MMCTIR>; #[doc = "Writer for register MMCTIR"] pub type W = crate::W<u32, super::MMCTIR>; #[doc = "Register MMCTIR `reset()`'s with value 0"] impl crate::ResetValue for super::MMCTIR { type Type = u32; #[inline(always)] fn reset_value() ...
use url; use futures::future; use hyper::{Body, Request, Response, Server, StatusCode, Method, header}; use serde::Serialize; use hyper::rt::{self, Future}; use hyper::service::service_fn; use chrono_tz; use chrono::{DateTime, TimeZone}; use std::collections::HashMap; use when::{self, DateTimeError}; #[derive(Serializ...
#[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::PINENABLE0 { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'...
#[doc = "Reader of register CNT"] pub type R = crate::R<u32, super::CNT>; #[doc = "Writer for register CNT"] pub type W = crate::W<u32, super::CNT>; #[doc = "Register CNT `reset()`'s with value 0"] impl crate::ResetValue for super::CNT { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { ...
use std::sync::Mutex; use std::thread; use std::sync::Arc; fn main() { let me = Arc::new(Mutex::new(0)); let mut handlers = vec![]; for _ in 0..10 { let new_me = Arc::clone(&me); let handle = thread::spawn(move || { let mut num = new_me.lock().unwrap(); *num +=1 ...
use common::comm::ClusterCommunicator; use common::network::{Message, MessageType}; use std::sync::mpsc::Sender; use std::collections::HashMap; use chrono::{DateTime, Utc}; use rand::Rng; use serde_cbor; use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; // #[derive(Serialize, Deserialize, Debug)] //...
use proconio::input; #[allow(unused_imports)] use proconio::marker::*; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::f64::consts::*; #[allow(unused)] const INF: usize = std::usize::MAX / 4; #[allow(unused)] const M: usize = 1000000007; fn...
fn main() { windows::core::build_legacy!( Windows::Foundation::{IClosable, IStringable}, Windows::Win32::System::Com::IClassFactory ); }
use chrono::Utc; use ed25519_dalek::{Keypair, PublicKey, Signature, Signer, Verifier}; use hex::ToHex; use log::{error, info}; use miniz_oxide::{deflate::compress_to_vec, inflate::decompress_to_vec}; use serde::{Deserialize, Serialize}; use serde_bytes::Bytes; use serde_json::{from_slice, to_string}; use std::convert::...
use crate::{ demos::{Chunk, Demo}, types::{Hitable, HitableList, Ray, Sphere, Vec3}, Camera, }; pub struct HitableSphere; impl Demo for HitableSphere { fn name(&self) -> &'static str { "sphere-using-hit-table" } fn world(&self) -> Option<HitableList> { Some(HitableList { ...
use std::cmp::{max, min}; pub struct Input { pub text: String, pub mode: InputMode, idx: usize, } impl Input { pub fn idx(&self) -> &usize { &self.idx } } impl Default for Input { fn default() -> Input { Input { text: "".to_string(), mode: InputMode::No...
use std::collections::HashSet; use std::env; use std::error; use std::fs; type Error = Box<dyn error::Error>; fn main() -> Result<(), Error> { for input_file in env::args().skip(1) { println!("{}", input_file); let input = groups(&fs::read_to_string(input_file)?); println!( "\...
#[doc = "Reader of register MIS"] pub type R = crate::R<u32, super::MIS>; #[doc = "Reader of field `TATOMIS`"] pub type TATOMIS_R = crate::R<bool, bool>; #[doc = "Reader of field `CAMMIS`"] pub type CAMMIS_R = crate::R<bool, bool>; #[doc = "Reader of field `CAEMIS`"] pub type CAEMIS_R = crate::R<bool, bool>; #[doc = "R...
//! //! This crate was built to ease parsing files encoded in a Matroska container, such as [WebMs][webm] or [MKVs][mkv]. //! //! The main content provided by this crate is the [`MatroskaSpec`] enum. Otherwise, this crate simply provides type aliases in the form of [`WebmIterator`] and [`WebmWriter`]. //! //! [webm]:...
extern crate regex; use common; use self::regex::Regex; use std::collections::HashMap; #[derive(Clone, Debug)] struct Program { name: String, weight: i32, parent: Option<String>, children: Vec<String> } impl Program { pub fn from_line(line: &str) -> Self { lazy_static! { stati...
use num::traits::PrimInt; pub struct FibonacciIterator<Int> { a: Int, b: Int, } impl<Int> FibonacciIterator<Int> where Int: PrimInt, { pub fn new() -> Self { Self { a: Int::zero(), b: Int::one(), } } } impl<Int> Iterator for FibonacciIterator<Int> where ...
use crate::wallet::wallet::WalletType; use crate::base::crypto::signature::traits::signature::SignatureI; use crate::base::crypto::signature::guomi::SignatureGuomi; use crate::wallet::keypair::*; use crate::base::crypto::signature::sign::SignatureX; pub struct SignatureBuilder { signature: Box<dyn Signatu...
pub use ssd1306::{prelude::*, *};
use std::{fmt::Debug, sync::Arc}; use async_trait::async_trait; use data_types::{NamespaceId, PartitionKey, TableId}; use parking_lot::Mutex; use crate::{ buffer_tree::{namespace::NamespaceName, partition::PartitionData, table::TableMetadata}, deferred_load::DeferredLoad, }; /// An infallible resolver of [`P...
use super::super::exec::frame::{ObjectBody, VariableType}; use super::super::exec::jit::{FuncJITExecInfo, LoopJITExecInfo}; use super::super::exec::objectheap::ObjectHeap; use super::super::gc::gc::GcType; use super::classfile::read::ClassFileReader; use super::classfile::{ classfile::ClassFile, constant::Constant,...
#[doc = "Reader of register MTLTxQUR"] pub type R = crate::R<u32, super::MTLTXQUR>; #[doc = "Writer for register MTLTxQUR"] pub type W = crate::W<u32, super::MTLTXQUR>; #[doc = "Register MTLTxQUR `reset()`'s with value 0"] impl crate::ResetValue for super::MTLTXQUR { type Type = u32; #[inline(always)] fn re...
use std::net::IpAddr; use std::sync::atomic::Ordering; use std::sync::Arc; use std::sync::Mutex; use std::thread; use std::time::Duration; use num_cpus; use super::super::dummy; use super::super::dummy_keypair; use super::super::tests::make_packet; use super::super::udp::*; use super::KeyPair; use super::SIZE_MESSAGE...
pub fn raindrops(number: i64) -> String { let mut result = "" . to_string(); if number % 3 == 0 { result.push_str("Pling"); } if number % 5 == 0 { result.push_str("Plang"); } if number % 7 == 0 { result.push_str("Plong"); } if result.is_empty() { result =...
// Copyright 2021 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to ...
pub struct Solution; impl Solution { pub fn can_finish(num_courses: i32, prerequisites: Vec<Vec<i32>>) -> bool { let mut checker = LoopChecker::new(num_courses as usize); for prerequisite in prerequisites { checker.add_edge(prerequisite[0] as usize, prerequisite[1] as usize); } ...
use crate::extensions::srgb8::*; use nannou::prelude::*; pub fn soft_white() -> Hsl { // srgb8(249, 248, 245).into_hsl() hsl(0.12466522, 0.34505126, 0.9302026) } pub fn soft_black() -> Hsl { srgb8(26, 26, 22).into_hsl() }
impl Solution { pub fn is_valid(s: String) -> bool { let mut stack = Vec::new(); for c in s.chars() { if c == '(' || c == '[' || c == '{' { stack.push(c); continue; } match stack.pop() { Some(prev) => { ...
use aoc_runner_derive::{aoc, aoc_generator}; #[aoc_generator(day5)] fn generator(input: &str) -> Vec<i16> { let mut passes = input .lines() .map(|pass| seat_id(pass)) .collect::<Vec<i16>>(); passes.sort(); passes } fn splitter(pgm: &str, low: char, high: char, from: i16, to: i16) -...
fn main() { let input: Vec<i32> = include_str!("../input") .replace("\n", "") .split(',') .map(|num| num.parse().unwrap()) .collect(); println!("Part 1: {}", part1(&input)); println!("Part 2: {}", part2(&input)); } fn part1(input: &Vec<i32>) -> i32 { let mut result = i3...
//! Helper to simplify implementation of widget decorators. use crate::{ geometry::{measurement::MeasureSpec, BoundingBox, Position}, input::{controller::InputContext, event::InputEvent}, state::WidgetState, widgets::Widget, }; pub trait WidgetDecorator { type Widget: Widget; fn attach(&mut s...
use crate::mod_definition::{MappedModDefinition, ModDefinition}; use crate::mod_line_scanner::ASSUMED_FIRST_MONSTER_ID; use crate::{replace_use, LazyString}; use lazy_static::lazy_static; use maplit::btreeset; use regex::Captures; use std::cell::RefCell; use std::collections::{BTreeSet, HashMap}; use std::fs::File; use...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[cfg(feature = "Foundation_Collections")] pub mod Collections; #[cfg(feature = "Foundation_Diagnostics")] pub mod Diagnostics; #[cfg(feature = "Foundation_Metadata")] pub mod Metadata; #[cfg(feature = "Fo...