text
stringlengths
8
4.13M
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors. // // 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 ...
use crate::IdTokenPayload; use jsonwebtoken::errors::Result as JwtResult; use jsonwebtoken::{DecodingKey, EncodingKey, Header, Validation}; pub fn decode_id_token(id_token: &str, secret: &str) -> JwtResult<IdTokenPayload> { let key = DecodingKey::from_secret(secret.as_bytes()); let validation = Validation::def...
pub mod forget_password_form;
use super::*; impl Mask { pub fn count(self) -> u32 { self.0.count_ones() } pub fn has_mote_than_one_bit_set(self) -> bool { self.0 & (self.0.wrapping_sub(1)) != 0 } pub fn index_of_least_significant_bit(self) -> u32 { self.0.trailing_zeros() } pub fn index_of_most_s...
use commons::math::{lerp_2, map_value, p2, v2, P2, PI, TWO_PI, V2}; use ggez::conf::WindowMode; use ggez::event::{self, EventHandler, KeyCode, KeyMods, MouseButton}; use ggez::graphics::{Color, DrawMode, DrawParam, Rect}; use ggez::{graphics, Context, ContextBuilder, GameResult}; use nalgebra::{Point2, Vector2}; use no...
use serde_derive::Deserialize; use serde_derive::Serialize; #[derive(Serialize, Deserialize, Debug)] pub struct ResponseMessage { pub message: String, }
#[cfg(feature = "jit")] mod jitfunc; use super::{ tuple::PyTupleTyped, PyAsyncGen, PyCode, PyCoroutine, PyDictRef, PyGenerator, PyStr, PyStrRef, PyTupleRef, PyType, PyTypeRef, }; #[cfg(feature = "jit")] use crate::common::lock::OnceCell; use crate::common::lock::PyMutex; use crate::convert::ToPyObject; use cra...
// 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 ...
use dirs::home_dir; use log::{debug, trace}; use serde::{Deserialize, Serialize}; use std::fmt; use std::fs; use std::io::{self, Read, Write}; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Item { pub id: u64, pub name: String, pub obtained: bool, pub created_at: String, } impl fmt::Displa...
use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct TemporaryUser { pub email: String, pub password: String, }
use crate::api::v1::ceo::product::model::ShopInfo; use crate::api::v1::user::shop::model::{GetList, GetWithId}; use crate::errors::ServiceError; use crate::models::msg::Msg; use crate::models::shop::Shop; use crate::models::DbExecutor; use crate::schema::shop::dsl::{id, shop as tb}; use actix::Handler; use diesel; use ...
use crate::smb2::requests::session_setup::SessionSetup; /// Serializes the session setup request body. pub fn serialize_session_setup_request_body(request: &SessionSetup) -> Vec<u8> { let mut serialized_request: Vec<u8> = Vec::new(); serialized_request.append(&mut request.structure_size.clone()); serializ...
#![no_std] #![feature(allocator_api)] #![feature(test)] #![feature(trusted_len)] #![feature(exact_size_is_empty)] #![feature(let_else)] #![feature(str_internals)] #![feature(const_option_ext)] #![feature(slice_take)] #![feature(arbitrary_enum_discriminant)] #![feature(min_specialization)] #![feature(extend_one)] #![fea...
use proconio::input; fn main() { input! { x:i32, y:i32, z:i32, } println!("{} {} {}", z, x, y); }
//! <div align="center"> //! <h1>awto</h1> //! //! <p> //! <strong>Awtomate your 🦀 microservices with awto</strong> //! </p> //! //! </div> //! //! # awto-cli //! //! Command-line-interface for compiling projects built with [`awto`](https://docs.rs/awto). //! //! See more on the [repository](https://github.c...
#[macro_use] extern crate clap; extern crate da_lab; use da_lab::*; use clap::App; pub const SETTING_JSON: &'static str = "setting.json"; fn main() { task::init(); let cli = load_yaml!("exec.yml"); let m = App::from_yaml(cli).get_matches(); let setting_json = m.value_of("setting").unwrap_or(SETTING...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)]...
use proconio::input; fn main() { input! { n: usize, ss: [String; n], }; for i in (0..n).rev() { println!("{}", ss[i]); } }
//! A generic event loop for games and interactive applications #![deny(missing_docs)] #![deny(missing_copy_implementations)] extern crate clock_ticks; extern crate window; use std::thread::sleep_ms; use std::cmp; use std::marker::PhantomData; use std::cell::RefCell; use std::rc::Rc; use window::Window; /// Render ...
//! IOx authorization client. //! //! Authorization client interface to be used by IOx components to //! restrict access to authorized requests where required. #![deny(rustdoc::broken_intra_doc_links, rust_2018_idioms)] #![warn( missing_copy_implementations, missing_docs, clippy::explicit_iter_loop, //...
// 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 ...
pub use self::{ module::{Module, ModuleFromPathError, ModuleKind}, module_provider::{ FileSystemModuleProvider, InMemoryModuleProvider, ModuleProvider, OverlayModuleProvider, }, module_provider_owner::{ModuleProviderOwner, MutableModuleProviderOwner}, package::{Package, PackagesPath}, us...
use super::{CelestialBody, Contract}; use crate::codec::{Decode, Encode}; use crate::{remote_type, RemoteObject}; use std::collections::BTreeMap; remote_type!( /// Waypoints are the location markers you can see on the map view showing you where contracts /// are targeted for. With this structure, you can obtain coord...
fn solve(n: usize, a: &Vec<Vec<usize>>) { let mut ymins = vec![n; 10]; let mut ymaxs = vec![1; 10]; let mut xmins = vec![n; 10]; let mut xmaxs = vec![1; 10]; for i in 0..n { for j in 0..n { let d = a[i][j]; let y = i + 1; let x = j + 1; ymins[d...
use std::{ fs::{self}, io::Cursor, ops::Deref, path::{Path, PathBuf}, sync::Arc, }; use super::database::SenseiDatabase; use crate::{disk::FilesystemLogger, node::NetworkGraph}; use bitcoin::{ blockdata::constants::genesis_block, hashes::hex::FromHex, BlockHash, Network, Txid, }; use lightning:...
use scheme::LispResult; use scheme::error::LispError::*; use scheme::value::Sexp; use scheme::value::Sexp::*; // pair? // Predicates non-empty list pub fn is_pair(args: &[Sexp]) -> LispResult<Sexp> { let arity = args.len(); if arity != 1 { return Err(ArityMismatch("pair?".to_string(), 1, arity)); }...
/// /// Creates a retina map that can be used to simulate nyctalopia. /// /// # Arguments /// /// - `res` - resolution of the returned retina map /// - `severity` - the severity of the disease, value between 0 and 100 /// pub fn generate(res: (u32, u32), severity: u64) -> image::ImageBuffer<image::Rgba<u8>, Vec<u8...
use std::cmp; pub type CartId = String; pub type CatalogId = String; pub type PromotionId = String; pub type Quantity = u32; pub type Amount = i32; #[derive(Debug, Clone)] pub struct Product { pub catalog_id: CatalogId, pub unit_price: Amount, } #[derive(Debug, Clone)] pub struct CartItem { item: Produc...
use super::*; // A collection of terms to be added #[derive(Clone)] pub struct TermSum { pub terms: Vec<Term> } impl TermSum { pub fn new(terms: Vec<Term>) -> TermSum { TermSum { terms: terms, } } } impl From<Term> for TermSum { fn from(term: Term) -> TermSum { Ter...
fn main() { let mut book = Vec::new(); book.push(1); { let r = &mut book; // var book tidak dapat diakses krn masih di pinjam via muttable refernce // `&mut` // println!("{:?}", book.len()); r.push(2); println!("{:?}", r); } book.push(3); ...
use std::env; use std::fs::File; use std::io; use std::io::{BufWriter, Write}; use rand::prelude::*; use delaunay_mesh::geo::{Bbox, Vec2}; use delaunay_mesh::DelaunayMesh; pub fn main() -> io::Result<()> { let npoints = env::args() .skip(1) .next() .and_then(|n| n.parse().ok()) .u...
use crate::vector2::Vector2; const PI: f32 = 3.14159265359; #[derive(Debug, Copy, Clone)] pub struct Circle { pub origin: Vector2, pub radius: f32 } impl Circle { #![allow(unused)] pub fn new(x: f32, y: f32, radius: f32) -> Self { Self { origin: Vector2::new(x, y), ra...
//! This is the testsuite for `deploy`. It runs the tests in `test/src/bin/` first directly, and then deployed to a local `fabric`. //! //! At the top of each test is some JSON, denoted with the special comment syntax `//=`. //! `output` is a hashmap of file descriptor to a regex of expected output. As it is a regex en...
#[macro_use] extern crate clap; extern crate sisterm; use sisterm::flag; use sisterm::setting; use std::env; use clap::{App, AppSettings, Arg, SubCommand}; use serialport::available_ports; #[tokio::main] async fn main() { let matches = build_app().get_matches(); #[cfg(windows)] enable_ansi_support(); ...
// 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 ...
use super::*; use crate::{ inline_storage::alignment::{AlignTo1, AlignTo16, AlignTo2, AlignTo4, AlignTo8}, nonexhaustive_enum::{ examples::{ command_a, command_b, command_c, command_h_mismatched_discriminant, command_serde, const_expr_size_align, generic_a, generic_b, many_range...
use crate::{NumBytes, Read, UnsignedInt, Write}; use alloc::string::String; use core::fmt; macro_rules! key_type { ($ident:ident, $bytes:literal) => { /// TODO depreciate, newer signature types cannot be represented as a fixed size structure /// EOSIO Public Key /// <https://github.com/EOSI...
use chrono::prelude::*; pub fn construct_calendar_url(query: &str) -> String { if query == "cal" { let google_calendar = "https://calendar.google.com/calendar/u/0/r/"; google_calendar.to_string() } else { construct_calendar_url_date(&query[4..]) } } pub fn construct_calendar_url_date(query: &str) -...
use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use std::io::Error; use crate::util; const PROP_FILE_NAME: &str = "/slackrypt.properties"; pub fn get_properties() -> Result<HashMap<String, String>, Error> { let mut props = HashMap::new(); let path = util::de...
#![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 INDClient(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for INDClient { type Vtable = INDClient_abi; const ...
// run-rustfix #![warn(clippy::unseparated_literal_suffix)] #![allow(dead_code)] fn main() { let _ok1 = 1234_i32; let _ok2 = 1234_isize; let _ok3 = 0x123_isize; let _fail1 = 1234i32; let _fail2 = 1234u32; let _fail3 = 1234isize; let _fail4 = 1234usize; let _fail5 = 0x123isize; let...
use crate::AppState; use actix_web::{web, Error, HttpResponse}; use biscuit::jwa; use biscuit::jwa::Algorithm; use biscuit::jwk::*; use biscuit::jws::Secret; use biscuit::Empty; use num::BigUint; use ring::signature::KeyPair; use serde_json::json; use std::format; pub async fn keys(state: web::Data<AppState>) -> Resul...
#![no_std] #![no_main] extern crate panic_halt; extern crate stm32f1xx_hal as hal; use cortex_m::asm; use cortex_m_rt::entry; use hal::prelude::*; use embedded_hal::digital::v2::OutputPin; use hal::rcc::{Rcc, Clocks}; use hal::flash::Parts; #[entry] fn main() -> ! { // 获取 Peripherals let peripherals = hal::p...
/* * Copyright 2020 Fluence Labs Limited * * 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 a...
extern crate regex; use std::collections::VecDeque; use std::collections::HashSet; use std::collections::HashMap; fn main() { let mut input = part1_input(); println!("{:?}", input.ring); for _ in 0..100 { input.do_move(); // println!("{:?}", input.ring); } println!("After 100 mov...
// 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 yew::prelude::*; use yew::{InputData}; use js_sys::{Date}; use yew::services::websocket::{WebSocketService, WebSocketStatus, WebSocketTask}; use yew::format::Json; use anyhow::Error; use yew::services::ConsoleService; enum Msg { WsConnect, Received(Result<String, Error>), Open, Disconnect, Post...
//! Timers use crate::time::Hertz; use embedded_hal::timer::{CountDown, Periodic}; // use void::Void; /// Hardware timers pub struct Timer<TIM> { clocks: rcu::Clocks, timer: TIM, } use crate::rcu; use crate::pac::TIMER2; impl Timer<TIMER2> { pub fn timer2<T>(timer2: TIMER2, timeout: T, clocks: rcu::Clock...
use crate::{DocBase, VarType}; const DESCRIPTION: &'static str = r#" The exp function of x is e^x, where x is the argument and e is Euler's number. "#; pub fn gen_doc() -> Vec<DocBase> { let fn_doc = DocBase { var_type: VarType::Function, name: "exp", signatures: vec![], descriptio...
pub mod windows; /// Check [CLICOLOR] status /// /// - When `true`, ANSI colors are supported and should be used when the program isn't piped, /// similar to [`term_supports_color`] /// - When `false`, don’t output ANSI color escape codes, similar to [`no_color`] /// /// See also: /// - [terminfo](https://crates.io/...
use bytemuck; use glam::vec2; use shaderc::CompileOptions; use wgpu::{ShaderModuleDescriptor, TextureView}; use winit::event::VirtualKeyCode; use super::{camera::Camera, Vertex, VertexBuffer}; use crate::{ rendering::{Display, PetriEventHandler}, simulation::Simulation, timing::timer::time_func, }; #[repr...
#![no_std] #[cfg(test)] #[macro_use] extern crate double; #[cfg(test)] #[macro_use] extern crate hamcrest2; extern crate quicksilver; #[macro_use] extern crate num_derive; extern crate futures; extern crate getrandom; extern crate num_traits; #[macro_use] extern crate alloc; mod controlled; mod field; mod gamestate...
use yaml_rust::YamlEmitter; use serde::Serialize; use frontmatter::parse_and_find_content; use pulldown_cmark::{html, Options, Parser}; use wasm_bindgen::prelude::*; #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; #[wasm_bindgen] pub fn render_markdown...
extern crate humansize; use humansize::{format_size, FormatSizeOptions, DECIMAL}; fn main() { // Create a new FormatSizeOptions struct starting from one of the defaults let custom_options = FormatSizeOptions::from(DECIMAL).decimal_places(5); // Then use it println!("{}", format_size(3024usize, custom_...
use std::vec::Vec; pub struct RenderGroup { pub alpha: bool, pub posable: bool, pub specular: String, pub bump1_rep: bool, pub bump2_rep: bool, pub spec1_rep: bool, pub tex_count: i32, pub texture_types: Vec<std::ffi::CString>, } impl RenderGroup { pub fn new(render_group_num: i32) -> Render...
use super::*; use std::collections::HashMap; #[derive(Debug, PartialEq)] pub struct Color { pub gui: String, pub cterm: String, } pub type ColorName = Option<&'static str>; pub type Palette = HashMap<&'static str, Color>; #[derive(Debug)] pub enum HighlightAttr { Nothing, None, Bold, Italic,...
//! A surface is the output of a [`compositor`](crate::compositor). //! //! A surface also implements the [`source`](crate::source) trait, //! meaning you can nest surfaces. //! //! Surfaces can be written to a file. mod surface_2d; pub use surface_2d::Surface2D;
// Draw some multi-colored geometry to the screen // This is a good place to get a feel for the basic structure of a Quicksilver app extern crate quicksilver; use quicksilver::{ Result, geom::{Circle, Line, Rectangle, Transform, Triangle, Vector}, graphics::{Background::Col, Color}, lifecycle::{Setting...
extern crate sodiumoxide; extern crate byteorder; extern crate hex; extern crate bit_vec; extern crate serde; extern crate serde_json; #[macro_use] extern crate serde_derive; #[macro_use] pub mod encoding; #[macro_use] pub mod messages; pub mod crypto; pub mod storage;
// 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::{ buffer_writer::{BufferWriter, ByteSliceMut}, mac::{self, FrameControl, HtControl, MgmtHdr, RawHtControl}, }, fai...
fn main() { let a = "a1".to_string(); let b = "b1".to_string(); println!("sample1 = {:?}", sample1(&a)); println!("sample2 = {:?}", sample2(&a, &b)); println!("sample3 = {:?}", sample3(&a, &b)); println!("sample4 = {}", sample4(&a, &b)); let r1; { let b2 = "b2".to_string(); ...
use std::fmt; use crate::TargetJobId; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct JobId(uuid::Uuid); impl JobId { pub fn new() -> Self { Self(uuid::Uuid::new_v4()) } /// Binary reprensentation pub fn to_bytes(self) -> Vec<u8> { self.0.as_bytes().to_vec() } ...
#![link(name="git2")] extern crate git2; use git2::git2; #[test] fn test_config() { let repo = match git2::Repository::open(&Path::new("/storage/home/achin/devel/libgit2.rs/tests/data/repoA")) { Ok(r) => r, Err(e) => fail!("Failed to open repo:\n{}", e.message) }; assert!(repo.is_empty() =...
#![cfg(feature = "mppa")] use telamon_kernels::{linalg, Kernel}; use telamon_mppa as mppa; macro_rules! test_output { ($name:ident, $kernel:ty, $num_tests:expr, $params:expr) => { #[test] fn $name() { let _ = env_logger::try_init(); let mut context = mppa::Context::new(); ...
use crate::repositories::*; use diesel::r2d2::ConnectionManager; use diesel::r2d2::Pool; use diesel::PgConnection; use crate::dao::*; use crate::service::UserService; use crate::service::PsqlUserService; #[derive(Clone)] pub struct AppState { pub pool: Box<Pool<ConnectionManager<PgConnection>>>, } impl AppState ...
#[allow(unused_imports)] use proconio::{ input, fastout }; fn solve(n: i32, a: i32, b: i32) -> i32 { n - a + b } fn run() -> Result<(), Box<dyn std::error::Error>> { input! { n: i32, a: i32, b: i32, } println!("{}", solve(n, a, b)); Ok(()) } fn main() { match run() { E...
//! Creating a blank window is all well and good, but drawing something to it is even better. //! //! Rendering in Quicksilver usually takes the form: //! ```no_run //! # use quicksilver::{graphics::{Background, Drawable}, lifecycle::Window}; //! # fn func(window: &mut Window, some_drawable: impl Drawable, some_backgro...
use std::io::Read; fn main() { let mut buf = String::new(); // 標準入力から全部bufに読み込む std::io::stdin().read_to_string(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); let K: i32 = iter.next().unwrap().parse().unwrap(); let S: i32 = iter.next().unwrap().parse().unwrap(); let mut result...
use std::collections::HashSet; use crate::core::{Part, Solution}; pub fn solve(part: Part, input: String) -> String { match part { Part::P1 => Day08::solve_part_one(input), Part::P2 => Day08::solve_part_two(input), } } struct Trail { knots: Vec<(i32, i32)>, length: usize, } impl Trai...
#![feature(proc_macro_hygiene, decl_macro)] use rocket_contrib::json::Json; mod models; use models::ImgurImg; #[macro_use] extern crate rocket; #[get("/")] fn index() -> &'static str { "Hello, worldd!" } #[post("/image", format = "json", data = "<img>")] fn upload(img: Json<ImgurImg>) -> String { let comment = ...
use backend::flow::FlowGraph; use backend::interference::Interference; use backend::liveness::Liveness; use backend::*; use hashbrown::{HashMap, HashSet}; use std::iter::FromIterator; pub fn alloc<P>(p: &mut P::Prg) where P: Platform, P::Reg: 'static, { for f in p.functions_mut() { alloc_function::...
pub use common::*; pub mod common; pub use ts_36_331::*; pub mod ts_36_331;
use leptos::*; use crate::{auth, components::Button}; #[component] pub fn Account(cx: Scope) -> impl IntoView { let logout_action = auth::state(cx).logout_action; view! { cx, <div> <p>"Congrats, you're in!"</p> <Button on:click=move |_cx| { logout_action.dispat...
use byteorder::{LittleEndian, ReadBytesExt}; use crate::decode::Decode; use crate::encode::Encode; use crate::mysql::protocol::TypeId; use crate::mysql::type_info::MySqlTypeInfo; use crate::mysql::{MySql, MySqlData, MySqlValue}; use crate::types::Type; use crate::Error; use std::str::from_utf8; /// The equivalent MyS...
mod types; pub mod solver; pub mod dimacs; pub use types::*;
extern crate reqwest; extern crate jplaceholder; extern crate serde_json; use jplaceholder::*; fn generate_post(id: i32) -> Post { let mut response = reqwest::get(&format!("https://jsonplaceholder.typicode.com/posts/{}", id)).expect("failed"); let text = response.text().expect("failed"); let json: Post = s...
use std::fs; use scraper::{Html, Selector}; use selectors::attr::CaseSensitivity; use clap::{App, Arg}; #[derive(Default)] struct RollResult { player_name: String, date: String, // die: String, // result: u8, } fn main() { // ARGs let matches = App::new("rust_test") .version("0...
//https://leetcode.com/problems/maximum-product-difference-between-two-pairs/submissions/ impl Solution { pub fn max_product_difference(nums: Vec<i32>) -> i32 { let max_first = next_max(&nums, 100000); let max_second = next_max(&nums, max_first); let min_first = next_min(&nums, 1000...
pub(super) mod gc_works; pub(super) mod global; pub(super) mod mutator; pub use self::global::GenCopy; pub use self::global::GENCOPY_CONSTRAINTS;
use std::{convert::TryInto, num::NonZeroU8, str::FromStr}; #[cfg(feature = "fuzz")] use arbitrary::Unstructured; #[cfg(not(feature = "fuzz"))] use bonfida_bot::{ state::{unpack_assets, PoolHeader}, }; #[cfg(feature = "fuzz")] use crate::state::{unpack_assets, PoolHeader}; use solana_program::{instruction::{Inst...
#[doc = r"Value read from the register"] pub struct R { bits: u16, } #[doc = r"Value to write to the register"] pub struct W { bits: u16, } impl super::TXIS { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w...
#![feature(option_unwrap_none, try_blocks)] use std::process::exit; extern crate pest; #[macro_use] extern crate pest_derive; use parser::parser; mod compile; mod parser; fn main() { let ast = match parser("let x = 6\nx +6") { Ok(ast) => ast, Err(error) => { println!("{}", error); ...
#![cfg(feature = "macros")] use std::time::Duration; use actix::prelude::*; use actix_rt::time::sleep; struct MyActor; impl Actor for MyActor { type Context = Context<Self>; fn started(&mut self, ctx: &mut Self::Context) { ctx.run_interval(Duration::from_millis(100), |_this, ctx| { if !...
#[doc = "Reader of register HWCFGR1"] pub type R = crate::R<u32, super::HWCFGR1>; #[doc = "Reader of field `NBIOPORT`"] pub type NBIOPORT_R = crate::R<u8, u8>; #[doc = "Reader of field `CPUEVTEN`"] pub type CPUEVTEN_R = crate::R<u8, u8>; #[doc = "Reader of field `NBCPUS`"] pub type NBCPUS_R = crate::R<u8, u8>; #[doc = ...
use std::f64; trait ArreaGet { fn area(&self) -> f64; } struct square { height: u32, width: u32, } impl square { fn new(w_t: u32, h_t: u32) -> Self { square { height: h_t, width: w_t, } } } impl ArreaGet for square { fn area(&self) -> f64 { (self.h...
use types::{char_t, int_t, void_t, size_t, ssize_t, uint_t}; use types::{off_t}; use types::{pid_t, uid_t, gid_t}; use syscalls::{sys_unlink, sys_rmdir, sys_read, sys_write, sys_close, sys_lseek}; use syscalls::{sys_getpid, sys_getuid, sys_geteuid, sys_setuid, sys_setgid, sys_setsid}; #[cfg(all(target_os = "linux", ta...
use crate::ray::Ray; use crate::vec3::Vec3; #[derive(Debug)] pub struct Camera { pub origin: Vec3, pub lower_left_corner: Vec3, pub horizontal: Vec3, pub vertical: Vec3, } impl Camera { pub fn new() -> Self { Self { origin: Vec3::zero(), lower_left_corner: Vec3(-2.0...
extern crate pi_db; pub mod vec;
use std::ptr::NonNull; use std::sync::atomic::AtomicUsize; struct Buf<T> { data: *mut T, read: AtomicUsize, write: AtomicUsize, } pub struct Producer<T> { buf: NonNull<Buf<T>>, } impl<T> Producer<T> { pub fn push(&mut self, T) { } } pub struct Consumer<T> { buf: NonNull<Buf<T>>, }
use collectxyz::nft::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use cosmwasm_std::{ entry_point, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, }; use cw2::{get_contract_version, set_contract_version}; use crate::error::ContractError; use crate::execute as ExecHandler; ...
// 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 { crate::errors::QmuxError, crate::transport::{ClientId, SvcId}, crate::transport::{QmiResponse, QmiTransport}, bytes::{BufMut, BytesMu...
/// HTTP parsing. /// /// Provides a `parse_message` function to parse incoming requests or responses from /// a stream. use std::collections::HashMap; use std::fmt; use std::hash::Hash; const CRLF: &str = "\r\n\r\n"; #[derive(Debug, PartialEq)] pub enum HttpError { ParsingError, InvalidStatusCode, } #[deriv...
/*! This module contains code related to template support. */ use crate::app; use crate::error::{Blame, MainError, Result, ResultExt}; use regex::Regex; use std::borrow::Cow; use std::collections::HashMap; use std::fs; use std::path::PathBuf; lazy_static! { static ref RE_SUB: Regex = Regex::new(r#"#\{([A-Za-z_][A-...
pub enum Event { QUIT, PAUSE, }
//! Construct cylinders that are curved sheets, not volumes. use surface::{Sheet, LatticeType}; use coord::{Coord, Direction, Translate, rotate_coords, rotate_planar_coords_to_alignment}; use describe::{unwrap_name, Describe}; use error::Result; use iterator::{ResidueIter, ResidueIterOut}; use system::*; use std...
use rustler; use rustler::{NifEnv, NifTerm, NifEncoder, NifResult}; #[derive(NifTuple)] struct AddTuple { lhs: i32, rhs: i32, } pub fn tuple_echo<'a>(env: NifEnv<'a>, args: &[NifTerm<'a>]) -> NifResult<NifTerm<'a>> { let tuple: AddTuple = try!(args[0].decode()); Ok(tuple.encode(env)) } #[derive(NifMa...
use proptest::strategy::{Just, Strategy}; use proptest::{prop_assert_eq, prop_oneof}; use crate::erlang::negate_1::result; use crate::test::strategy; #[test] fn without_number_errors_badarith() { run!( |arc_process| { ( Just(arc_process.clone()), strategy::term:...
/*! This create provides weak pointers for `Pin<std::rc::Rc<T>>` and `Pin<std::rc::Arc<T>>` ## Motivation `Pin<std::rc::Rc<T>>` and `Pin<std::rc::Arc<T>>` cannot be converted safely to their `Weak<T>` equivalent if `T` does not implement `Unpin`. That's because it would otherwise be possible to do something like thi...
//! //! Traits for fields //! use crate::internal::Fields; use crate::Field; /// Provides methods to add fields to elements. pub trait FieldExt { /// Add a single field. fn add_field(&mut self, field: Field) -> &mut Self; /// Add multiple fields at once. fn add_fields<'a>(&mut self, fields: impl Into...
#[allow(unused)] mod graphics; use graphics::{shader::*, vao::VertexArrayObject}; use sdl2::{ event::{Event, WindowEvent}, keyboard::{Mod, Scancode}, mouse::*, }; use std::path::Path; fn aspect_ratio(width: i32, height: i32) -> (f32, f32) { if width > height { (width as f32 / height as f32, ...