text
stringlengths
8
4.13M
// 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 ...
use std::ffi::OsStr; #[cfg(not(any(target_os = "macos", windows)))] use std::fs; use std::io; #[cfg(windows)] use std::os::windows::process::CommandExt; use std::process::{Command, Stdio}; #[rustfmt::skip] #[cfg(not(windows))] use { std::error::Error, std::os::unix::process::CommandExt, std::os::unix::io::...
use std::io::{self, Write}; use std::os::unix::net::UnixStream; use std::path::Path; #[repr(u8)] pub enum Command { Disable = 0, Enable = 1, #[allow(dead_code)] TriggerNow = 2, } pub struct XIdleHookClient { stream: UnixStream, } impl XIdleHookClient { /// Initializes a new XIdleHookClient fo...
use shared_bus::{I2cProxy, NullMutex}; use ssd1306::{displaysize::DisplaySize128x32, prelude::*, Builder, I2CDIBuilder}; use stm32f4xx_hal::{ gpio::{ gpioa::{self, PA10, PA6, PA7, PA9}, gpiob::{PB8, PB9}, Alternate, AlternateOD, OpenDrain, Output, PushPull, AF4, AF7, }, i2c::I2c, ...
use crate::ast::{Loop, LoopKind}; use crate::lexer::*; use crate::parsers::expression::assignment::multiple::left_hand_side; use crate::parsers::expression::assignment::multiple::multiple_left_hand_side; use crate::parsers::expression::expression; use crate::parsers::program::compound_statement; use crate::parsers::pro...
use lazy_static::lazy_static; use std::collections::HashMap; #[derive(Debug, Eq, PartialEq, Clone, Copy, Hash)] pub enum TokenType { Plus, Minus, Asterisk, Slash, Assign, Bang, LessThan, GreaterThan, Equal, NotEqual, Comma, Semicolon, LParen, RParen, LBrace, ...
use tokenizer::consumers::*; use tokenizer::symbol::Symbol; pub mod keyword; pub mod symbol; pub mod consumers; #[derive(Debug, PartialEq)] pub enum Token { Float(f32), Integer(i32), Symbol(symbol::Symbol), Keyword(keyword::Keyword), Constant(String), String(String), Comment(String), } pub fn tokenize(...
extern crate pest; use pest::error::Error; use pest::Parser; #[derive(Parser)] #[grammar = "grammars/ck2txt.pest"] pub struct CK2Parser; use crate::json::JSONValue; pub fn parse(ck2txt: &str) -> Result<JSONValue, Error<Rule>> { let parsing_iter = CK2Parser::parse(Rule::file, ck2txt)?.skip(1).next().unwrap(); ...
use otspec::{read_field, stateful_deserializer}; use serde::de::{DeserializeSeed, SeqAccess, Visitor}; use serde::{Serialize, Serializer}; #[derive(Debug, PartialEq)] pub struct loca { pub indices: Vec<Option<u32>>, } stateful_deserializer!( loca, LocaDeserializer, { locaIs32Bit: bool }, fn visit_...
mod utils; // we only compile js if we target wasm #[cfg(target_arch = "wasm32")] pub mod js; // we only compile python if we target python build #[cfg(feature = "python")] pub mod python; pub use x25519_dalek::PublicKey; pub use x25519_dalek::StaticSecret; use rand::CryptoRng; use rand::Rng; use chacha20poly1305::...
#[derive(Clone, Debug, PartialEq)] pub struct Game { pub random_seed: i64, pub tick_count: i32, pub map_size: f64, pub skills_enabled: bool, pub raw_messages_enabled: bool, pub friendly_fire_damage_factor: f64, pub building_damage_score_factor: f64, pub building_elimination_score_factor:...
use crate::cpu::Cpu; use crate::opcode::addressing_mode::{AddRegister, AddressMode}; use crate::opcode::*; use std::string::ToString; pub struct Load { /// Addressing mode. mode: AddressMode, /// Which register to load from. register: Register, /// Convenience to store the op code. opcode: u8...
use crate::hierarchy::SceneGraph; use crate::traits::required::*; use crate::{ components::*, views::{LocalTransformDataMut, LocalTransformStoragesMut}, }; use shipyard::*; use shipyard_hierarchy::*; use std::collections::HashSet; pub fn local_transform_sys<V, Q, M, N>( mut local_trs_storages_mut: LocalTra...
// 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::utils::skip, bitfield::bitfield, byteorder::{BigEndian, ByteOrder, LittleEndian}, num::{One, Unsigned}, num_derive::{FromP...
use projecteuler::digits; use projecteuler::helper; /* Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits Note: x must start with the digit 1. Suppose it starts with a digit >1 => 6x would contain more digits than x. */ fn main() { helper::check_bench(|| { ...
extern crate find_folder; extern crate image; extern crate piston_window; use image::*; use piston_window::*; use rand::distributions::{Distribution, Uniform}; use std::time::Instant; fn main() { const WINDOW_WIDTH: u32 = 1050; const WINDOW_HEIGHT: u32 = 1050; const CLEAR_COLOR: [f32; 4] = [1.0; 4]; ...
use std::{ env::var, io::{stderr, stdout, Write}, process::{exit, Command, Output}, }; const DEFAULT_BRANCH: &str = "default"; const DEFAULT_REMOTE: &str = "origin"; fn main() { git_version(); git_init(); git_remote(); git_fetch(); git_checkout(); git_log(); } fn git_version() { ...
#[doc = r"Value read from the register"] pub struct R { bits: u8, } #[doc = r"Value to write to the register"] pub struct W { bits: u8, } impl super::RXTYPE5 { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'...
#![allow(dead_code)] use std::borrow::Borrow; #[derive(Debug, PartialEq, Clone)] pub enum Code { Acc, Jmp, Nop, } #[derive(Debug, PartialEq, Clone)] pub struct Instruction { pub code: Code, pub val: i32, } fn str_to_instruction(ss: &str) -> Instruction { let mut ss = ss.split(' '); let c...
use std::collections::vec_deque::VecDeque; use std::fmt::{self, Debug, Display}; use crate::erts::ModuleFunctionArity; use crate::process::Frame; #[derive(Default)] pub struct Stack(VecDeque<Frame>); impl Stack { pub fn len(&self) -> usize { self.0.len() } pub fn pop(&mut self) -> Option<Frame> ...
//老师想给孩子们分发糖果,有 N 个孩子站成了一条直线,老师会根据每个孩子的表现,预先给他们评分。 // // 你需要按照以下要求,帮助老师给这些孩子分发糖果: // // // 每个孩子至少分配到 1 个糖果。 // 相邻的孩子中,评分高的孩子必须获得更多的糖果。 // // // 那么这样下来,老师至少需要准备多少颗糖果呢? // // 示例 1: // // 输入: [1,0,2] //输出: 5 //解释: 你可以分别给这三个孩子分发 2、1、2 颗糖果。 // // // 示例 2: // // 输入: [1,2,2] //输出: 4 //解释: 你可以分别给这三个孩子分发 1、2、1 颗糖果。 // 第三个孩子...
use chrono::Utc; use serde::{Deserialize, Serialize}; use std::{ fs::{DirEntry, File}, io::Read, }; use crate::markdown::Markdown; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ArticleMeta { pub category: String, #[serde(default)] pub tags: Vec<String>, #[serde(default)] pub a...
use std::fmt; use crate::ir; use fxhash::FxHashSet; use itertools::Itertools; use serde::{Deserialize, Serialize}; /// Unique identifier for `InductionVar` #[derive( Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, )] pub struct IndVarId(pub u32); /// A multidimentional induction...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[link(name = "windows")] extern "system" {} pub const CLSID_WMPMediaPluginRegistrar: ::windows_sys::core::GUID = ::windows_sys::core::GUID { data1: 1433004021, data2: 16971, data3: 19347, ...
// 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 agre...
#[test] fn mem_transmute() { fn inc_fn(x: u32) -> u32 { x + 1 }; let fn_ptr = inc_fn as *const u32; let func: fn(i32) -> i32 = unsafe { std::mem::transmute(fn_ptr) }; assert_eq!(11, func(10)); } #[test] fn mem_maybe_uninitialized() { let mut s: String = unsafe { std::mem::uninitializ...
use rand::Rng; use crate::cell::Cell; use crate::grid::Grid; use crate::row::Row; use crate::automaton::Automaton; use crate::renderer::Renderer; pub struct Seeds { grid: Grid, } impl Seeds { pub fn new(n_rows: usize, n_cols: usize) -> Seeds { let mut rows = vec![ Row { c...
use layout::{Entry, StreamVec, FlexMeasure, Item}; use output::{Output}; use num::Zero; //use layout::style::{Style}; use units::Length; use std::fmt::{self, Debug}; #[derive(Copy, Clone, Debug, Default)] struct LineBreak { prev: usize, // index to previous line-break path: u64, // one bit for each branch ...
use gdal::errors::Result; use gdal::spatial_ref::{CoordTransform, SpatialRef}; use gdal::vector::*; use gdal::{Dataset, Driver}; use std::fs; use std::path::Path; fn run() -> Result<()> { let dataset_a = Dataset::open(Path::new("fixtures/roads.geojson"))?; let mut layer_a = dataset_a.layer(0)?; let fields_...
extern crate reqwest; use log::{info, warn}; use serde::{Deserialize, Serialize}; use serde_json::json; use std::fmt; type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; #[derive(Debug)] struct ClientError(String); impl fmt::Display for ClientError { fn fmt(&self, f: &mut fmt::Forma...
extern crate walkdir; use clap::OsValues; use regex::Regex; use std::ffi::OsStr; use std::fmt::{Error, Formatter}; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::PathBuf; use std::{fmt, io}; use walkdir::WalkDir; type SearchResultProcessor = dyn Fn(&SearchResult, bool); /// The holder of state ...
use std::alloc::{Alloc, Layout, GlobalAlloc, AllocErr}; use std::ptr::NonNull; use super::super::{Mutex, MutexGuard}; use super::Dlmalloc; pub struct GlobalDlmalloc; unsafe impl GlobalAlloc for GlobalDlmalloc { #[inline] unsafe fn alloc(&self, layout: Layout) -> *mut u8 { <Dlmalloc>::malloc(&mut get(...
use crate::types::CustomRetrieveValue; use aws_sdk_dynamodb::{ error::GetItemError, model::AttributeValue, output::GetItemOutput, types::SdkError, }; use log::{self, debug}; use aws_sdk_dynamodb::Client; pub async fn retrieve_database_item( table_name: &str, retrieve_value: &CustomRetrieveValue, clie...
use crate::types::*; use serde::{Serialize, Deserialize}; /* Messages sent by the Clients to the servers. */ #[derive(Debug, Serialize, Deserialize)] pub enum ClientMessage { LimitOrderMsg(LimitOrderMsg), } #[derive(Debug, Serialize, Deserialize)] pub struct LimitOrderMsg { pub user: UserId, pub order_id: OrderI...
use utilities::prelude::*; use crate::impl_vk_handle; use crate::prelude::*; use std::sync::Arc; #[derive(Debug)] pub struct Semaphore { device: Arc<Device>, semaphore: VkSemaphore, } impl Semaphore { pub fn new(device: Arc<Device>) -> VerboseResult<Arc<Semaphore>> { let semaphore_ci = VkSemapho...
extern crate minifb; use std::sync::{Arc, RwLock}; use std::time::{Duration, Instant}; use self::minifb::{Key, WindowOptions, MouseMode}; use std::thread::sleep; use std::fmt; use memory; use window; pub struct DebugScreen { pub window: minifb::Window, pub scroll: u16, pub offset: u16, pub width: usiz...
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2017 The Ninja-rs Project Developers. All Rights Reserved. // // 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:/...
/* Copyright 2020 Timo Saarinen 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 writing, software d...
use flame::Span; use std::cmp::Ordering; use std::collections::{hash_map, HashMap}; pub struct Profiler { occurances: HashMap<String, (usize, f64)>, } impl Default for Profiler { fn default() -> Self { Self { occurances: Default::default(), } } } impl Profiler { pub fn rec...
#[doc = "Reader of register SCAR_PRG"] pub type R = crate::R<u32, super::SCAR_PRG>; #[doc = "Writer for register SCAR_PRG"] pub type W = crate::W<u32, super::SCAR_PRG>; #[doc = "Register SCAR_PRG `reset()`'s with value 0"] impl crate::ResetValue for super::SCAR_PRG { type Type = u32; #[inline(always)] fn re...
pub mod sema; mod transforms; mod translate; pub use self::sema::*; pub use self::transforms::*; pub use self::translate::*;
use std::collections::HashMap; use std::fmt; pub type Item = i32; #[derive(Debug)] pub struct Pair(usize, usize); impl fmt::Display for Pair { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{} {}", self.0, self.1) } } #[aoc_generator(day10)] pub fn input_generator(input: &str)...
use crate::matrices::Matrix44::*; use crate::vectors::{Vector2::*, Vector3::*, Vector4::*}; use crate::defs::*; use pancurses::Window; pub struct FrameBuffer { width: i32, height: i32 } impl FrameBuffer { fn new(w: i32, h:i32) -> FrameBuffer { FrameBuffer { width: w, height...
fn main() { let x = 13; match x { 1 => println!("satu"), 2 | 3 | 5 | 7 | 11 => println!("bil prima"), 13..=19 => println!("Anak muda"), _ => println!("Tidak ada yg spesial"), } let boolean = true; let binary = match boolean { false => 0, true => 1, }; println!("{} -> {}", boolean, bina...
fn main() { panic!("This should show a backtrace. Please ?"); }
// Copyright (c) 2016 The Rouille developers // 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 your option. All files in the project carrying such // notice may not be co...
extern crate rand; extern crate sdl2; use std::process; use std::env::args; use std::time::{Instant, Duration}; mod cpu; mod bus; mod rom; use cpu::Cpu; use bus::Bus; use rom::Rom; use sdl2::rect::{Rect}; use sdl2::event::{Event}; use sdl2::keyboard::Keycode; use sdl2::audio::{AudioCallback, AudioDevice, AudioSpec...
use super::{LzfError, LzfResult}; /// Decompress the given data, if possible. /// An error will be returned if decompression fails. /// /// The length of the output buffer can be specified. /// If the output buffer is not large enough to hold the decompressed data, /// BufferTooSmall is returned. /// Otherwise the num...
use juniper::{ graphql_interface, graphql_object, EmptySubscription, FieldResult, FieldError, GraphQLObject, GraphQLInputObject, ID, RootNode, http::GraphQLRequest }; use tide::{Body, Request, Response, StatusCode}; use uuid::Uuid; use bson::{Bson, doc}; use mongodb::{Client, options::ClientOptions, Co...
// 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. #![feature(async_await, await_macro, futures_api)] #![deny(warnings)] use failure::{Error, ResultExt}; use fidl::endpoints::ServiceMarker; use fidl_fuchsi...
extern crate regex; use std::io; use std::fs; use std::io::BufRead; use std::path::Path; use std::collections::HashSet; use regex::Regex; fn main() { let input = parse_input(); let program = input.program; println!("{}", program.find_loop()); println!("Looking for termination..."); for i in 0..p...
use super::VarResult; use crate::ast::syntax_type::{FunctionType, FunctionTypes, SimpleSyntaxType, SyntaxType}; use crate::helper::{pine_ref_to_f64, pine_ref_to_i64}; use crate::runtime::context::{downcast_ctx, Ctx}; use crate::types::{Callable, Float, Int, PineFrom, PineRef, RuntimeErr, Series, NA}; use std::mem; use ...
#[allow(dead_code)] #[allow(deprecated)] fn read_line_from_stdin() -> String { let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).unwrap(); buffer.trim_right().to_owned() } fn main() { println!( "{}", read_line_from_stdin().chars().filter(|c| *c == '1').count() ...
use front::stdlib::object::{PROTOTYPE, INSTANCE_PROTOTYPE, ObjectData, Property}; use serialize::json::from_str; use front::stdlib::function::Function; use std::collections::btree_map::BTreeMap; use std::cmp::Ordering; use std::ops::*; use serialize::json::Json::*; use std::string::String; use serialize::json::{ToJson,...
#[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::RIS { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w ...
import libc::{c_char, c_int, c_long, size_t, time_t}; import io::{reader, reader_util}; import result::{result, ok, err, methods}; import std::time; export timespec, get_time, tm, empty_tm, now, at, now_utc, at_utc, strptime; #[abi = "cdecl"] #[nolink] native mod libtime { // F...
// 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 APB4LPENR"] pub type R = crate::R<u32, super::APB4LPENR>; #[doc = "Writer for register APB4LPENR"] pub type W = crate::W<u32, super::APB4LPENR>; #[doc = "Register APB4LPENR `reset()`'s with value 0"] impl crate::ResetValue for super::APB4LPENR { type Type = u32; #[inline(always)] ...
//! Metric instrumentation for a [`NamespaceCache`] implementation. use std::sync::Arc; use async_trait::async_trait; use data_types::{NamespaceName, NamespaceSchema}; use iox_time::{SystemProvider, TimeProvider}; use metric::{DurationHistogram, Metric, U64Gauge}; use super::{ChangeStats, NamespaceCache}; /// An [`...
// 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. use std::{collections::HashSet, ops::Range}; // https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml const EPHEMER...
use crate::fd::AsFd; use crate::pid::Pid; #[cfg(not(target_os = "espidf"))] use crate::termios::{Action, OptionalActions, QueueSelector, Termios, Winsize}; use crate::{backend, io}; /// `tcgetattr(fd)`—Get terminal attributes. /// /// Also known as the `TCGETS` (or `TCGETS2` on Linux) operation with `ioctl`. /// /// #...
use crate::{ velement::{Children, Ns}, VElement, VNonKeyedElement, S, }; macro_rules! elements { ($($ident:ident => $name:expr,)+) => { $( pub fn $ident<Message: 'static>() -> VNonKeyedElement<Message> { VElement::new(Ns::Svg, $name) } )+ pub ...
use futures::{Future, Sink, Stream}; #[derive(Debug)] pub(super) struct State { subscriptions: std::collections::HashMap<String, crate::proto::QoS>, subscriptions_updated_send: futures::sync::mpsc::Sender<SubscriptionUpdate>, subscriptions_updated_recv: futures::sync::mpsc::Receiver<SubscriptionUpdate>, ...
use std::error::Error; use std::fs; use std::path::Path; use heed::byteorder::BE; use heed::types::*; use heed::zerocopy::{AsBytes, FromBytes, Unaligned, I64}; use heed::{Database, EnvOpenOptions}; use serde::{Deserialize, Serialize}; fn main() -> Result<(), Box<dyn Error>> { let path = Path::new("target").join("...
#[macro_use] extern crate clap; extern crate victoria_dom; use clap::App; use std::fs::File; use std::io::BufReader; use std::io::{self, Read}; use std::process; use victoria_dom::DOM; use walkdir::WalkDir; static mut PARAM_VERBOSITY: u64 = 0; fn v_printer(verbosity: u64, message: &'static str) { unsafe { ...
use proconio::input; use std::iter; fn reverse(n: u64) -> u64 { let mut n = n; let mut m = 0; while n > 0 { m = m * 10 + n % 10; n /= 10; } m } fn f(x: u64) -> u64 { let y = reverse(x); x.min(y).min(reverse(y)) } fn main() { assert_eq!(reverse(123), 321); assert_eq...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[link(name = "windows")] extern "system" {} #[repr(transparent)] pub struct ExtendedExecutionForegroundReason(pub i32); impl ExtendedExecutionForegroundReason { pub const Unspecified: Self = Self(0i32...
#[allow(unused_variables)] fn main() { let x = Some(1); // match is exhaustive let x = match x { Some(x) => x, None => 1, }; // pattern non refutable let x = 1; let y: Option<&str> = None; // You can't do that, that's refutable // let Some(y) = y; // If you wanna do that, use if let if let Some(y) =...
use super::super::gl; use super::{ BlendState, BufferState, ColorBufferState, CullFaceState, DepthBufferState, FrontFaceState, ProgramState, TextureState, VertexArrayState, ViewportState, }; use glutin::{ContextWrapper, PossiblyCurrent}; use winit::window::Window; pub struct OpenGLContext { pub color_buffe...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct AppointmentCalendarCancelMeetingRequest(pub ::...
// 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. //! A state machine for associating a Client to a BSS. //! Note: This implementation only supports simultaneous authentication with exactly one STA, the //...
use serde::{Deserialize, Serialize}; use std::collections::HashMap; #[derive(PartialEq, Clone, Serialize, Deserialize, Debug)] pub struct Activity { pub id: String, pub lat: f64, pub lon: f64, } #[allow(dead_code)] impl Activity { fn new(id: String, lat: f64, lon: f64) -> Activity { Activity {...
use nodes::prelude::*; pub struct Aside { inner: NodeP } impl Aside { pub fn new(inner: NodeP) -> Aside { Aside { inner: inner } } } impl Node for Aside { fn childs(&self, out: &mut Vec<NodeP>) { self.inner.childs(out); } fn layout(&self, env: LayoutChain, ...
extern crate ws; use ws::listen; fn main() { let listen_url = "0.0.0.0:8082"; //let listen_url ="127.0.0.1:8082"; println!("Runing Server"); listen(listen_url, |out| { move |msg| { let response: String = format!("Hello {}", msg); println!("{}", response); ou...
use std::mem; use std::cell::UnsafeCell; pub struct Arena { data: UnsafeCell<Vec<Vec<u8>>>, } impl Arena { pub fn with_capacity(capacity: usize) -> Arena { Arena { data: UnsafeCell::new(vec![Vec::with_capacity(capacity)]), } } fn alloc_bytes(&self, bytes: usize, align: usi...
/// print a markdown template, with other arguments taking `$0` to `$9` places in the template. /// /// Example: /// /// ``` /// use lazy_static::lazy_static; /// use minimad::mad_inline; /// use termimad::*; /// /// let skin = MadSkin::default(); /// mad_print_inline!( /// &skin, /// "**$0 formula:** *$1*", // the...
/// File defining raw text /// use core::*; use latex_file::*;
use crate::*; use std::cell::RefCell; use std::thread; use std::time::Duration; #[derive(Default)] pub struct ThreadResources { count: usize } #[derive(Default)] pub struct ThreadTest { resources: RefCell<ThreadResources>, pub window: Window, layout: FlexboxLayout, font: Font, counter: Tex...
// Copyright 2013 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 ...
#[derive(Debug)] enum Errors {} const INPUT: &str = include_str!("../../input/01"); fn solution(input: &str) -> i32 { let mut seen = std::collections::BTreeSet::new(); let mut current = 0; seen.insert(current); input .lines() .filter_map(|x| x.parse::<i32>().ok()) .cycle() //...
pub mod component; pub mod paddle;
// Copyright 2017 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::cell::RefCell; use std::rc::Rc; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use web_sys::{Element, Event}; #[wasm_bindgen] extern "C" { #[wasm_bindgen(js_namespace = console)] fn log(s: &str); } macro_rules! console_log { ($($t:tt)*) => (log(&format_args!($($t)*).to_string())) } #[wasm_...
//! Represents the `output` array table in the package manifest. use std::collections::BTreeSet; use std::fmt::{Display, Formatter, Result as FmtResult}; use serde::de::{Deserializer, Error as DeError}; use serde::ser::Serializer; use serde::{Deserialize, Serialize}; use crate::hash::Hash; use crate::id::OutputId; u...
use rand::{rngs::SmallRng, RngCore, SeedableRng}; use std::convert::TryInto; use tokio::time::sleep; mod proto { tonic::include_proto!("ortiofay.olix0r.net"); } #[derive(Clone)] pub(crate) struct Api { rng: SmallRng, } impl Api { pub fn server() -> proto::ortiofay_server::OrtiofayServer<Self> { p...
#![recursion_limit = "128"] extern crate proc_macro; #[macro_use] extern crate quote; #[macro_use] extern crate syn; use proc_macro2::TokenStream; use quote::{quote, quote_spanned}; use syn::spanned::Spanned; use syn::{parse_macro_input, parse_quote, Data, DeriveInput, Fields, GenericParam, Generics, Index, Ident, Da...
#[doc = "Reader of register IER2"] pub type R = crate::R<u32, super::IER2>; #[doc = "Writer for register IER2"] pub type W = crate::W<u32, super::IER2>; #[doc = "Register IER2 `reset()`'s with value 0"] impl crate::ResetValue for super::IER2 { type Type = u32; #[inline(always)] fn reset_value() -> Self::Typ...
extern crate facade; use facade::oo_facade::run_oo; use facade::fn_facade::run_fn; fn main(){ run_oo(); run_fn(); }
#[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::AES_DMAMIS { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&...
//! The main Image API use crate::parameters::*; #[derive(Default, Debug, Clone, PartialEq)] pub struct Image { pub host: String, pub prefixes: Vec<String>, pub identifier: String, pub region: Region, pub size: Size, pub rotation: Rotation, pub quality: Quality, pub format: Format } impl Image { /...
use clap::{App, Arg}; use serde_derive::Deserialize; use std::process::exit; static REGISTRY: &str = "typeable"; static REPOSITORY: &str = "octopod-web-app-example"; #[derive(Debug, Deserialize)] struct Resp { results: Vec<Tag>, } #[derive(Debug, Deserialize)] struct Tag { name: String, } async fn do_reques...
#[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::EV2_CTRL { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w ...
#[doc = "Reader of register PCROP1BER"] pub type R = crate::R<u32, super::PCROP1BER>; #[doc = "Reader of field `PCROP1B_END`"] pub type PCROP1B_END_R = crate::R<u8, u8>; impl R { #[doc = "Bits 0:7 - PCROP1B area end offset"] #[inline(always)] pub fn pcrop1b_end(&self) -> PCROP1B_END_R { PCROP1B_END_...
// auto generated, do not modify. // created: Wed Jan 20 00:44:03 2016 // src-file: /QtNetwork/qtcpsocket.h // dst-file: /src/network/qtcpsocket.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begi...
use firefly_diagnostics::{SourceSpan, Span, Spanned}; use firefly_syntax_base::{Deprecation, FunctionName}; use super::{Expr, Ident, Name, Type}; /// Type definitions /// /// ## Examples /// /// ```text /// %% Simple types /// -type foo() :: bar. /// -opaque foo() :: bar. /// /// %% Generic/parameterized types /// -t...
use std::fmt; use super::hooks::HookError; /// This error is returned by the `Manager::recycle` function #[derive(Debug)] pub enum RecycleError<E> { /// Recycling failed for some other reason Message(String), /// The error was caused by the backend Backend(E), } impl<E> From<E> for RecycleError<E> { ...
// 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 { fidl_fuchsia_wlan_service::{ErrCode, ScanRequest, ScanResult, WlanMarker, WlanProxy}, fidl_fuchsia_wlan_tap::WlantapPhyProxy, fuchsia_com...
use super::memory; use super::opcodes::Opcode::*; use super::instructions::Instruction; const SIGN: usize = 7; const OVERFLOW: usize = 6; const BREAK: usize = 4; const DECIMAL: usize = 3; const INTERRUPT: usize = 2; const ZERO: usize = 1; const CARRY: usize = 0; pub struct Cpu { reg_pc...
#[path = "random_integer_1/returns_integer_between_0_inclusive_and_max_exclusive.rs"] pub mod returns_integer_between_0_inclusive_and_max_exclusive; use self::returns_integer_between_0_inclusive_and_max_exclusive::EXCLUSIVE_MAX; use super::*; #[wasm_bindgen_test] async fn returns_integer_between_0_inclusive_and_max_e...
use nj_sys as sys; use std::{ffi::CString, ptr}; #[cfg(windows)] mod delayload; #[no_mangle] fn ctor() { println!("Hello from wallet"); #[cfg(windows)] delayload::process(); unsafe { let modname = CString::new("wallet").unwrap(); let filename = CString::new("lib.rs").unwrap(); ...