text
stringlengths
8
4.13M
use input_i_scanner::InputIScanner; use arithmetic_series::arithmetic_series; 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::<$...
use std::str::FromStr; use crate::Error; /// `Feet` or `FlightLevel` #[derive(Eq, PartialEq, Debug)] pub enum AltitudeUnit { Feet, FlightLevel, } impl FromStr for AltitudeUnit { type Err = Error; /// # Examples /// /// ``` /// # use std::str::FromStr; /// # use openaip::AltitudeUnit;...
// Copyright 2020 IOTA Stiftung // // 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 in w...
grass::grass_query! { let a = open("data/a.bed"); let b = open("data/b.bed"); a | subtract(b) | as_bed3() | show_all(); }
use super::*; use proptest::prop_oneof; use proptest::strategy::Strategy; #[test] fn without_non_empty_list_or_bitstring_second_returns_firsts() { run!( |arc_process| { strategy::term(arc_process.clone()) .prop_filter("Second cannot be a list or bitstring", |second| { ...
#[doc = "Reader of register RIS"] pub type R = crate::R<u32, super::RIS>; #[doc = "Reader of field `INR0`"] pub type INR0_R = crate::R<bool, bool>; #[doc = "Reader of field `INR1`"] pub type INR1_R = crate::R<bool, bool>; #[doc = "Reader of field `INR2`"] pub type INR2_R = crate::R<bool, bool>; #[doc = "Reader of field...
pub fn gcd(a: u32, b: u32) -> u32 { fn gcd_rec(m: u32, n: u32) -> u32 { assert!( m >= n, "m must be larger than or equal to n; got m={}, n={}", m, n ); if n == 0 { m } else { gcd_rec(n, m % n) } } ...
use std::{ cmp::max, fmt::{Debug, Display}, sync::Arc, }; use crate::components::{ split_or_compact::start_level_files_to_split::{merge_small_l0_chains, split_into_chains}, Components, }; use async_trait::async_trait; use data_types::{CompactionLevel, ParquetFile, Timestamp}; use itertools::Itertoo...
// 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 ...
#[doc = "Reader of register BMCR"] pub type R = crate::R<u32, super::BMCR>; #[doc = "Writer for register BMCR"] pub type W = crate::W<u32, super::BMCR>; #[doc = "Register BMCR `reset()`'s with value 0"] impl crate::ResetValue for super::BMCR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Typ...
use std::ops::Deref; use std::sync::Arc; use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer}; use vulkano::command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage, DynamicState, SubpassContents}; use vulkano::descriptor::pipeline_layout::PipelineLayoutDesc; use vulkano::device::Device; use vulkano::device::D...
use crate::prelude::*; use gnudbm::GdbmOpener; use std::path::PathBuf; use serde_aux::prelude::*; use std::io; #[derive(Debug, Deserialize, Clone, Hash, PartialOrd, PartialEq, Eq)] pub struct Evr( #[serde(deserialize_with = "deserialize_number_from_string")] pub u64, pub String, pub String, ); impl From...
#[doc = "Reader of register BDTEUPR"] pub type R = crate::R<u32, super::BDTEUPR>; #[doc = "Writer for register BDTEUPR"] pub type W = crate::W<u32, super::BDTEUPR>; #[doc = "Register BDTEUPR `reset()`'s with value 0"] impl crate::ResetValue for super::BDTEUPR { type Type = u32; #[inline(always)] fn reset_va...
use std::marker::PhantomData; use std::ops::{Index, IndexMut}; use std::{mem, ptr}; use device::Device; use sys::*; use BufferType; #[derive(Copy, Clone)] struct BufferAttachment { geom: RTCGeometry, buf_type: BufferType, slot: u32, } impl BufferAttachment { fn none() -> BufferAttachment { Bu...
use crate::structs::raw::common::SubStatPropType; use crate::structs::raw::weapon_shared::WeaponType; use serde::Deserialize; #[derive(Deserialize)] #[serde(rename_all = "PascalCase")] pub struct WeaponProp { pub prop_type: Option<SubStatPropType>, pub init_value: Option<f64>, pub r#type: String, } #[deri...
#[doc = "Reader of register ISR"] pub type R = crate::R<u32, super::ISR>; #[doc = "Writer for register ISR"] pub type W = crate::W<u32, super::ISR>; #[doc = "Register ISR `reset()`'s with value 0"] impl crate::ResetValue for super::ISR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { ...
// 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 ...
#[doc = "Writer for register MICR"] pub type W = crate::W<u32, super::MICR>; #[doc = "Register MICR `reset()`'s with value 0"] impl crate::ResetValue for super::MICR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Master update Interrupt flag clear\n\nValue o...
use hello::ThreadPool; use std::io::{Read, Write}; use std::net::{TcpListener, TcpStream}; use std::time::Duration; use std::{fs, thread}; fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); let pool = ThreadPool::new(4); // // incoming 返回 TcpStream 的迭代器,stream 代表一个客户端和服务端之间打开的 con...
use crate::smb2::{header, requests}; pub mod create_request; pub mod negotiate_request; pub mod query_info_request; pub mod session_setup_authenticate_request; pub mod session_setup_negotiate_request; pub mod tree_connect_request; /// Builds a sync header with the corresponding parameters. /// - The tree id will only...
// Copyright 2019-2020 PolkaX. Licensed under MIT or Apache-2.0. use std::borrow::Borrow; use std::cmp::Ordering; use std::fmt; use std::ops::{Deref, DerefMut}; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize)] pub struct Key(String); impl fmt::Display for Key...
//! Support for building `explicit_bzero.c` backport for Linux w\ glibc < 2.25. #[cfg(any(feature = "linux-backport", feature = "windows"))] extern crate cc; #[cfg(any(feature = "linux-backport", feature = "windows"))] extern crate semver; fn main() { #[cfg(all(feature = "linux-backport", target_os = "linux"))] ...
use super::common::Span; use std::str::Chars; pub struct Lexer<'a> { chars: Chars<'a>, input_len: usize, } impl<'a> Lexer<'a> { pub fn new(input: &'a str) -> Lexer<'a> { Lexer { chars: input.chars(), input_len: input.len(), } } fn eat_next(&mut self) -> Opt...
#[doc = "Reader of register CFGR2"] pub type R = crate::R<u32, super::CFGR2>; #[doc = "Writer for register CFGR2"] pub type W = crate::W<u32, super::CFGR2>; #[doc = "Register CFGR2 `reset()`'s with value 0"] impl crate::ResetValue for super::CFGR2 { type Type = u32; #[inline(always)] fn reset_value() -> Sel...
#![allow(non_snake_case, non_upper_case_globals, non_camel_case_types, clippy::all)] #[cfg(feature = "Win32")] pub mod Win32;
use nix::fcntl::open; use nix::unistd::{close, read, write}; use nix::fcntl::OFlag; use nix::sys::stat::Mode; fn main() { let mut buf = [0u8; 1024]; let infile = open("file.in", OFlag::O_RDONLY, Mode::S_IRUSR).unwrap(); let outfile = open("file.out", OFlag::O_WRONLY | OFlag::O_CREAT, Mode::S_IRUS...
use std::fs::File; use std::io::prelude::*; use std::collections::HashSet; // --- file read fn read_file(filename: &str) -> std::io::Result<String> { let mut file = File::open(filename)?; let mut contents = String::new(); file.read_to_string(&mut contents)?; Ok(contents) } // --- model #[derive(Debug...
use crate::{ engine::{input::InputState, Engine}, game::components::{Input, Pawn}, math::*, particles::Particle, render::components::*, }; use hecs::{With, World}; mod debug; mod movement; mod soldier; pub use debug::*; pub use movement::*; pub use soldier::*; pub fn apply_input(world: &mut World,...
#[doc = "Reader of register FLTINR1"] pub type R = crate::R<u32, super::FLTINR1>; #[doc = "Writer for register FLTINR1"] pub type W = crate::W<u32, super::FLTINR1>; #[doc = "Register FLTINR1 `reset()`'s with value 0"] impl crate::ResetValue for super::FLTINR1 { type Type = u32; #[inline(always)] fn reset_va...
use crate::std::collections::BTreeMap; use serde::{Serialize,Deserialize}; use crate::contracts; use crate::types::TxRef; use crate::TransactionStatus; use crate::contracts::AccountIdWrapper; use crate::std::string::String; use crate::std::vec::Vec; // Logitude And Latitude type LongLati = (f64,f64); #[derive(Se...
use super::{AccDomain, AccReport}; use fnv::FnvHashMap as HashMap; use fnv::FnvHashSet as HashSet; use std::net::IpAddr; pub struct DNSAddRecord { pub dns_records: Vec<(String, IpAddr)>, } impl DNSAddRecord { pub fn new() -> DNSAddRecord { DNSAddRecord { dns_records: Vec::with_capacity(4),...
use wasmer_runtime_core::Instance; // TODO: Need to implement. /// emscripten: dlopen(filename: *const c_char, flag: c_int) -> *mut c_void pub extern "C" fn _dlopen(filename: u32, flag: c_int) -> u32 { debug!("emscripten::_dlopen"); -1 } /// emscripten: dlclose(handle: *mut c_void) -> c_int pub extern "C" fn...
use rnix::Error as NixError; use std::{env, fs, io::{self, Write}}; fn main() { let stdout = io::stdout(); let mut stdout = stdout.lock(); let file = match env::args().skip(1).next() { Some(file) => file, None => { eprintln!("Usage: error-report <file>"); return; ...
extern crate futures; use futures::prelude::*; use futures::stream::iter_ok; struct Join<T, U>(T, U); impl<T: Stream, U> Stream for Join<T, U> { type Item = T::Item; type Error = T::Error; fn poll(&mut self) -> Poll<Option<T::Item>, T::Error> { self.0.poll() } } impl<T, U: Sink> Sink for Jo...
//! Day 17 use std::{ collections::{HashMap, HashSet}, iter::repeat, }; use itertools::Itertools; trait Solution { fn part_1(&self) -> usize; fn part_2(&self) -> usize; } impl Solution for str { fn part_1(&self) -> usize { let mut dimension = parsers::input(3)(self).expect("Failed to pars...
use async_std::io::{Cursor, Read, Seek, Write}; use stackpin::FromUnpinned; use crate::PinCursor; unsafe impl<T> FromUnpinned<Cursor<T>> for PinCursor<T> where T: Unpin, Cursor<T>: Write + Read + Seek { type PinData = (); unsafe fn from_unpinned(src: Cursor<T>) -> (Self, Self::PinData) { ...
use actix_web::{web, HttpResponse}; pub fn config(cfg: &mut web::ServiceConfig) { cfg.service(web::resource("/").route(web::get().to(index))) .service(web::resource("/favicon.ico").route(web::get().to(favicon_ico))) .service(web::resource("/layout.css").route(web::get().to(layout_css))) .se...
//! Main module of way-cooler ipc. use std::sync::Mutex; use std::sync::mpsc::{self, Sender}; use std::thread; use dbus::tree::{Factory, ObjectPath, Tree, MTFn, MethodErr}; mod utils; mod keybindings; mod dbus_message; pub use self::dbus_message::DBusMessage; mod session; pub use self::session::DBusSession; mod int...
use anyhow::{Context, Result}; pub fn find_matches(content: &str, pattern: &str, mut writer: impl std::io::Write) -> Result<()> { for line in content.lines() { if line.contains(pattern) { writeln!(writer, "{}", line).with_context(|| "error writing mathces")?; // return Err(anyhow::E...
#![feature(dynamic_lib)] #![allow(deprecated)] extern crate bootstrap_rs as bootstrap; extern crate winapi; extern crate kernel32; use std::dynamic_lib::DynamicLibrary; use std::path::Path; use std::mem; use std::thread; use std::fs; use std::rc::Rc; use std::cell::RefCell; use bootstrap::time::Timer; use bootstrap:...
use std::fmt::{self, Display}; use std::ops::{Deref, DerefMut}; use std::str::FromStr; /// A wrapper for anything that implements FromStr to make it serde::Deserialize. Will turn /// Display to serde::Serialize. Probably should be used with Cid, PeerId and such. /// /// Monkeyd from: https://github.com/serde-rs/serde/...
/// Syscall errors #[derive(Eq, PartialEq, Debug, Clone, Copy)] pub enum SysError { /// Index out of bound IndexOutOfBound, /// Field is missing for the target ItemMissing, /// Buffer length is not enough, error contains actual data length LengthNotEnough(usize), /// Data encoding error ...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[link(name = "windows")] extern "system" {} pub type DialApp = *mut ::core::ffi::c_void; #[repr(transparent)] pub struct DialAppLaunchResult(pub i32); impl DialAppLaunchResult { pub const Launched: Se...
pub use vek; pub mod raw_volume; pub mod raw_volume_sampler; pub mod region; pub mod sampler; pub mod volume; pub mod voxel; pub mod cubic_surface_extractor; pub mod mesh; pub mod vertex;
// Copyright © 2016-2017 VMware, Inc. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use std::collections::{HashMap, HashSet}; use std::iter::FromIterator; use vr::VersionedReplicas; use rabble::{Pid, NodeId}; use namespace_msg::NamespaceId; #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] ...
#[doc = "Reader of register ITLINE20"] pub type R = crate::R<u32, super::ITLINE20>; #[doc = "Reader of field `TIM15`"] pub type TIM15_R = crate::R<bool, bool>; impl R { #[doc = "Bit 0 - TIM15"] #[inline(always)] pub fn tim15(&self) -> TIM15_R { TIM15_R::new((self.bits & 0x01) != 0) } }
use super::helpers::{ reverse_multiply_assign, reverse_multiply_c_long, reverse_multiply_c_long_assign, }; use crate::integer::Integer; use core::ops::Mul; // Mul The multiplication operator *. // ['Integer', 'Integer', 'Integer', 'Integer::multiply_assign', 'lhs', // ['ref_mut'], ['ref']] impl Mul<Integ...
const THE_ANSWER: u8 = 42; pub fn fast() -> u8 { THE_ANSWER } pub fn slow() -> u8 { std::thread::sleep(std::time::Duration::from_millis(1)); THE_ANSWER }
#[doc = "Reader of register CFGR2"] pub type R = crate::R<u32, super::CFGR2>; #[doc = "Writer for register CFGR2"] pub type W = crate::W<u32, super::CFGR2>; #[doc = "Register CFGR2 `reset()`'s with value 0"] impl crate::ResetValue for super::CFGR2 { type Type = u32; #[inline(always)] fn reset_value() -> Sel...
#[doc = "Reader of register DSI_VVSACCR"] pub type R = crate::R<u32, super::DSI_VVSACCR>; #[doc = "Reader of field `VSA`"] pub type VSA_R = crate::R<u16, u16>; impl R { #[doc = "Bits 0:9 - Vertical Synchronism Active duration"] #[inline(always)] pub fn vsa(&self) -> VSA_R { VSA_R::new((self.bits & 0...
use std::io::{self, BufRead}; fn get_input() -> Vec<i32> { let stdin = io::stdin(); let stdin = stdin.lock(); let result : Vec<_> = stdin.lines().map(|l| l.expect("could not read stdin").parse().expect("could not parse i32")).collect(); if result.len() >= i32::max_value() as usize { panic!("inp...
extern crate lit; #[cfg(test)] mod tests { use std::env::consts; #[test] fn lit() { lit::run::tests(|config| { config.add_search_path("lit/"); config.add_extension("test"); config.constants.insert("arch".to_owned(), consts::ARCH.to_owned()); config.constants.insert("...
use crate::rust_info::RustTypeCaptionStrategy; use itertools::Itertools; use ritual_common::errors::{bail, Error, Result}; use ritual_common::string_utils::CaseOperations; use ritual_common::utils::MapIfOk; use serde_derive::{Deserialize, Serialize}; use std::str::FromStr; /// Rust identifier. Represented by /// a vec...
#![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 IInstalledDesktopApp(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IInstalledDesktopApp { type Vtable = IIn...
use std::borrow::Cow; use std::collections::BTreeSet; use std::env; use std::fmt; use std::sync::atomic::{AtomicBool, Ordering}; use lazy_static::lazy_static; use crate::term::{wants_emoji, Term}; #[cfg(feature = "ansi-parsing")] use crate::ansi::{strip_ansi_codes, AnsiCodeIterator}; #[cfg(not(feature = "ansi-parsi...
use sdl2::render::Texture; use sdl2::rect::{Point, Rect}; pub struct Sprite { pub texture: Texture } pub struct Transform { pub position: Point, pub size: Rect, pub scale: u32, } impl Transform { pub fn new(size: Rect, position: Point) -> Self { Transform { size, position, scale: 2 ...
// use crate::webassembly::Memory; pub fn align_memory(ptr: u32) -> u32 { (ptr + 15) & !15 } // pub fn static_alloc(size: u32, static_top: &mut u32, memory: &Memory) -> u32 { // let old_static_top = *static_top; // let total_memory = memory.maximum_size() * Memory::PAGE_SIZE; // // NOTE: The `42949672...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - CAN Control"] pub ctl: CTL, #[doc = "0x04 - CAN Status"] pub sts: STS, #[doc = "0x08 - CAN Error Counter"] pub err: ERR, #[doc = "0x0c - CAN Bit Timing"] pub bit_: BIT, #[doc = "0x10 - CAN Interrupt"] ...
use piston::window::Size; use graphics::*; use gfx_graphics::GfxGraphics; use gfx::{Resources, CommandBuffer}; use errors::*; // a full screen of information laid out using standard units pub struct Screen { dimensions: [usize; 2], } impl Screen { pub fn new(size: Size) -> Self { Self { dimensions: [...
//============================================================================== // Notes //============================================================================== // mcu::spi.rs //============================================================================== // Crates and Mods //===============================...
macro_rules! heap_object_impls { ($type:ty) => { impl TryFrom<$crate::heap::object_heap::HeapObject> for $type { type Error = &'static str; fn try_from(value: $crate::heap::object_heap::HeapObject) -> Result<Self, Self::Error> { $crate::heap::object_heap::HeapData::f...
use std::io; fn main() { let mut reader = io::stdin(); let mut input = String::new(); println!("Which number of the fibonacci sequence would you like to calculate?"); reader.read_line(&mut input).ok().expect("failed to read line"); let input_opt: Option<u32> = input.trim().parse::<u32>().ok(); ...
// Copyright 2022 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 ...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtGui/qinputmethod.h // dst-file: /src/gui/qinputmethod.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin =>...
use ckb_jsonrpc_types::{ BlockNumber, BlockView, CellWithStatus, EpochNumber, EpochView, HeaderView, OutPoint, TransactionWithStatus, }; use ckb_types::H256; macro_rules! jsonrpc { ( $(#[$struct_attr:meta])* pub struct $struct_name:ident {$( $(#[$attr:meta])* pub fn ...
extern crate web3_rs_wasm; use web3_rs_wasm::futures::Future; fn main() { let (_eloop, http) = web3_rs_wasm::transports::Http::new("http://localhost:8545").unwrap(); let web3 = web3_rs_wasm::Web3::new(http); let accounts = web3.eth().accounts().wait().unwrap(); println!("Accounts: {:?}", accounts); }...
fn main(){ proconio::input!{a:u64,b:u64}; println!("{}safe",if a<=b{"un"}else{""}) }
//! Collect [Tracy] profiles in tracing-enabled applications. //! //! Assuming the application is well instrumented, this should in practice be a very low effort way //! to gain great amounts of insight into an application performance. //! //! Note, however that Tracy is ultimately a profiling, not an observability, to...
#![allow(clippy::std_instead_of_core)] extern crate std; use std::prelude::v1::*; use super::*; mod list; mod binary_tree; mod dyn_trait; /// This results in tree depths that are enough to cause stack overflows when /// `deep_safe_drop` is not used for a `Drop` impl. You may increase this but /// more RAM will be...
use super::*; use std::fmt::{self, Display, Formatter}; use std::ops::BitOr; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct fmx_DataVect { _address: u8, } #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct fmx_ExprEnv { _address: u8, } #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct fmx_RowVect { ...
//! System control //! //! Size: 4K use core::marker::PhantomData; use core::ops::{Deref, DerefMut}; use static_assertions::const_assert_eq; pub const PADDR: usize = 0x01C0_0000; register! { SRamCtrl, u32, RW, Fields [ Bits WIDTH(U32) OFFSET(U0) ] } const_assert_eq!(core::mem::size_of::<...
use std::{ future::Future, pin::Pin, sync::Arc, task::{Context, Poll}, }; use futures::future::BoxFuture; use parking_lot::Mutex; use tokio::task::JoinHandle; /// Receiver for [`CancellationSafeFuture`] join handles if the future was rescued from cancellation. /// /// `T` is the [output type](Future::...
use criterion::{black_box, criterion_group, criterion_main, Criterion}; pub fn criterion_benchmark(c: &mut Criterion) { c.bench_function("sieve 1000 - my optimized version using only single vec", |b| { b.iter(|| sieve::primes_up_to(black_box(1000))) }); c.bench_function("sieve 1000 - my original so...
use instant::{Duration, Instant}; use crate::{ inertia::Inertia, render::{ render_target::RenderTarget, scene::{Drawable, Scene}, }, ship::{Land, Ship, Throttle}, }; struct IntegrationController { clock: Instant, } impl IntegrationController { fn new() -> IntegrationController ...
#![cfg(test)] use crate::sim::{BisectStrategy, SimulationState}; use crate::strategies::*; // there's a progress assertion in the simulator we hope won't trip here // basically, we're testing a strategy is capable of driving the confidence // to some arbitrary threshold (e.g. five nines), no matter how slowly fn run_...
use std::str; use serialize::{Decodable, json}; use request::Request; use typemap::Key; use plugin::{Phantom, Plugin, Pluggable}; // Plugin boilerplate struct JsonBodyParser; impl Key for JsonBodyParser { type Value = String; } impl<'a, 'b> Plugin<Request<'a, 'b>> for JsonBodyParser { fn eval(req: &mut Request, _:...
use crate::args_setup; use crate::object::cons_list::ConsList; use crate::object::Node; use crate::vm::VM; pub(crate) fn logic_gt(vm: &mut VM, args_list: ConsList<Node>) -> Result<Node, String> { let args = args_setup!(args_list, ">", ==, 2); let arg1 = vm.eval(args[0])?; let arg2 = vm.eval(args[1])?; ...
// See LICENSE file for copyright and license details. use std::rand::{task_rng, Rng}; use std::collections::hashmap::HashMap; use cgmath::{Vector2}; use error_context; use core::types::{Size2, MInt, UnitId, PlayerId, MapPos}; use core::conf::Config; use core::game_state::GameState; use core::fs::FileSystem; use core:...
#![allow(clippy::comparison_chain)] #![allow(clippy::collapsible_if)] use std::cmp::Reverse; use std::cmp::{max, min}; use std::collections::{BTreeSet, HashMap, HashSet, VecDeque}; use std::fmt::Debug; use itertools::Itertools; use whiteread::parse_line; const ten97: usize = 1000_000_007; /// 2の逆元 mod ten97.割りたいときに使...
use openexr_sys as sys; use std::ffi::CString; use std::path::Path; use crate::core::{ error::Error, frame_buffer::{Frame, FrameBuffer, FrameBufferRef}, header::HeaderRef, }; type Result<T, E = Error> = std::result::Result<T, E>; #[repr(transparent)] pub struct InputFile(pub(crate) *mut sys::Imf_InputFi...
/// /// Prints to STDOUT if the log level is set to ```log_level=debug```. #[macro_export] macro_rules! debug_log { ($fmt:expr) => { if cfg!(feature = "log_level=debug") { println!($fmt); } }; ($fmt:expr, $($args:tt)*) => { if cfg!(feature = "log_level=debug") { ...
use super::*; pub struct Camera { pub center: Vec2<f32>, pub target_position: Vec2<f32>, pub fov: f32, pub target_fov: f32, } impl Camera { pub fn new(fov: f32) -> Self { Self { center: vec2(0.0, 0.0), fov, target_fov: fov, target_position: v...
/* An implementation of SAT solver, based on "An Extensible SAT-solver" (Niklas Een, Niklas Sörensson, SAT 2003) */ use crate::*; use std::ops::Index; #[derive(Debug, PartialEq, Eq, Clone, Copy)] enum Reason { Undet, Branch, Clause(usize), } impl Reason { fn is_clause(self) -> bool { match se...
use mailbox_rs::{ mb_channel::*, mb_std::{ async_std::task::{Context, Poll}, *, }, }; pub struct WaitEvent; impl<RA: MBPtrReader, WA: MBPtrWriter, R: MBPtrResolver<READER = RA, WRITER = WA>> MBAsyncRPC<RA, WA, R> for WaitEvent { fn poll_cmd( &self, server_name: &str, ...
use abi_stable::{ sabi_trait::prelude::TD_Opaque, std_types::{RArc, RBox, Tuple1, Tuple2, Tuple3} }; #[abi_stable::sabi_trait] pub trait RFoo<'a, T: Copy + 'a> { fn get(&'a self) -> &'a T; } impl<'a, A: Copy + 'a> RFoo<'a, A> for Tuple1<A> { fn get(&'a self) -> &'a A { &self.0 } } impl<...
mod bsp_level; mod bsp_lumps; mod lightmap_packer; mod vertex; pub use bsp_level::BspLevelLoader; use bsp_lumps::BspLumps; pub use vertex::Vertex;
use std::time::Duration; use stdweb::js; use yew::prelude::*; // This is because the inbuilt TimeoutService appears buggy, copying it here makes it work fn to_ms(duration: Duration) -> u32 { let ms = duration.subsec_millis(); ms + duration.as_secs() as u32 * 1000 } pub fn create_timeout(duration: Duration, ca...
use futures::future::join_all; use generational_arena::{Arena, Index}; use nalgebra::Vector2; use std::env::args; use std::error::Error; use std::net::SocketAddr; use std::num::Wrapping; use std::time::Duration; use std::time::SystemTime; use tokio::net::{TcpListener, TcpStream, UdpSocket}; use tokio::prelude::*; use t...
pub fn parsing_table() -> [[&'static str; 33]; 25] { /* function that creates the parsing table */ let mut table = [["error"; 33]; 25]; /* defining non terminals of the table */ table[0][0] = "null"; table[1][0] = "S"; table[2][0] = "V"; table[3][0] = "I"; table[4][0] = "G"; table[5...
use sqlx::types::chrono; use sqlx::FromRow; #[derive(FromRow, Debug)] pub struct ExamModel { pub id: i32, pub name: String, pub description: String, } #[derive(FromRow, Debug)] pub struct QuestionModel { pub id: i32, pub content: String, } #[derive(FromRow, Debug)] pub struct AnswerModel { pu...
#[macro_use] extern crate clap; extern crate surf; extern crate serde_json; extern crate image; extern crate url; use async_std::task; use clap::App; use serde_json::Value; use std::io::Cursor; use std::str::from_utf8; use url::form_urlencoded::{byte_serialize}; fn main() -> Result<(), surf::Exception> { let yaml =...
//! //! Take an AST and transform it into bytecode //! //! Inspirational code: //! <https://github.com/python/cpython/blob/main/Python/compile.c> //! <https://github.com/micropython/micropython/blob/master/py/compile.c> #![deny(clippy::cast_possible_truncation)] use crate::{ error::{CodegenError, CodegenError...
pub unsafe fn paging() { // Disable MMU asm!( "mrs x0, sctlr_el1", "bic x0, x0, 1", "msr sctlr_el1, x0", "isb", lateout("x0") _ ); }
use crate::domain::cloc::ClocSummary; use crate::domain::suggest::ModelSuggest; use core_model::coco_struct::ClassInfo; use core_model::Settings; use std::fs; use std::path::PathBuf; pub struct Suggester; impl Suggester { pub fn run(project: String) { if let Ok(model) = Suggester::load_struct(project) { ...
#[doc = "Reader of register MIS"] pub type R = crate::R<u32, super::MIS>; #[doc = "Reader of field `RORMIS`"] pub type RORMIS_R = crate::R<bool, bool>; #[doc = "Reader of field `RTMIS`"] pub type RTMIS_R = crate::R<bool, bool>; #[doc = "Reader of field `RXMIS`"] pub type RXMIS_R = crate::R<bool, bool>; #[doc = "Reader ...
// 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 ...
pub mod prime; pub mod util;
//! This module implements the `catalog` CLI command use clap_blocks::catalog_dsn::CatalogDsnConfig; use thiserror::Error; use crate::process_info::setup_metric_registry; #[allow(clippy::enum_variant_names)] #[derive(Debug, Error)] pub enum Error { #[error("Catalog error: {0}")] Catalog(#[from] iox_catalog::...
fn main() { println!("Hello, world!"); let stu = Student { name: String::from("hello world"), age: 10, }; let lsu = Teacher { name: String::from("lao jiang"), age: 30, subject: String::from("消费"), }; println!("学生姓名: {}, age: {}", stu.get_name(), stu.get_a...
use graph_generator_lib::*; use osquery_generator_lib::{ generator::OSQueryGenerator, metrics::OSQueryGeneratorMetrics, }; #[tokio::main] #[tracing::instrument] async fn main() -> Result<(), Box<dyn std::error::Error>> { let (env, _guard) = grapl_config::init_grapl_env!(); let service_name = env.service...