text
stringlengths
8
4.13M
extern crate maze as lib; pub fn main() { lib::run(); }
#[doc = "Reader of register WF39"] pub type R = crate::R<u8, super::WF39>; #[doc = "Writer for register WF39"] pub type W = crate::W<u8, super::WF39>; #[doc = "Register WF39 `reset()`'s with value 0"] impl crate::ResetValue for super::WF39 { type Type = u8; #[inline(always)] fn reset_value() -> Self::Type {...
//! Tests for the `pidfd` type. use libc::{kill, SIGSTOP}; #[cfg(feature = "event")] use rustix::event; use rustix::fd::AsFd; use rustix::{io, process}; use serial_test::serial; use std::process::Command; #[test] #[serial] fn test_pidfd_waitid() { // Create a new process. let child = Command::new("yes") ...
// todo use crossterm insted to be consistent use crate::model::tui::widgets::base_widget::EventHandler; use crate::model::tui::widgets::screens::Widgets; use async_trait::async_trait; use crossterm::event::Event; use image::RgbImage; use termion::{color, cursor}; use tui::widgets::Widget; use tui::{buffer::Buffer, lay...
use crate::helper::tritvector::TritVector; use crate::dispatcher::environment::Environment; #[derive(Clone)] pub struct Effect<'a> { pub env: &'a mut Environment<'a>, pub delay: usize, } impl<'a> Effect<'a> { pub fn new(env: &'a mut Environment<'a>, delay: usize) -> Effect<'a> { Effect { ...
use std::error::Error; use std::fs::File; use std::io::prelude::*; use rustc_serialize::json; use arguments::{Arguments, ValueArgument}; use console; #[derive(RustcDecodable, Debug)] pub struct Configuration { default_cluster: String, cluster: Vec<Cluster>, ext: Option<String> } #[derive(RustcDecodab...
#[macro_use] extern crate log; #[macro_use] extern crate bitflags; #[macro_use] extern crate error_chain; extern crate rand; #[macro_use] extern crate nom; extern crate byteorder; extern crate bytes; extern crate slab; extern crate rotor; mod error; #[macro_use] mod topic; #[macro_use] mod proto; mod packet; mod encod...
// In this test, the relation `In` is inappropriately derived in a rule, even // though it is marked as an @input. mod datalog { use crepe::crepe; crepe! { @input struct In(u32, u32); In(0, 0); } } fn main() {}
mod query; mod argument; mod field; mod selection; mod fragment; mod inline_fragment; pub use query::query::Query; pub use query::argument::Argument; pub use query::field::Field; pub use query::selection::Selection; pub use query::fragment::Fragment; pub use query::inline_fragment::InlineFragment;
use std::fs::{read_dir, DirEntry, ReadDir}; use std::io; use std::path::PathBuf; #[derive(Debug)] pub struct DirIteratorError { pub path: String, pub err: io::Error, } impl DirIteratorError { pub fn new<T: ToString>(path: T, err: io::Error) -> Self { DirIteratorError { path: path.to_st...
use serde_json::{Result, Map, Value}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; #[derive(Serialize, Deserialize, Debug)] struct Info { name: String, info: Vec<HashMap<String, String>>, } fn main() -> Result<()> { // let d = HashMap::new() let json = r#" { "name": "琼台博客...
extern crate fib; use std::env; use std::process; use fib::rabbits; fn main() { let args: Vec<String> = env::args().collect(); if args.len() != 3 { println!("Please provide 2 input numbers"); process::exit(1); } let v: Vec<u64> = args.iter().filter_map(|a| a.parse().ok()).collect();...
/// EtherCAT SDO/PDO Value #[derive(Debug, Clone, PartialEq)] pub enum Value { /// BIT Bool(bool), /// BYTE Byte(u8), /// SINT I8(i8), /// INT I16(i16), /// DINT I32(i32), /// LINT I64(i64), /// USINT U8(u8), /// UINT U16(u16), /// UDINT U32(u32...
#[macro_use] extern crate lazy_static; use wasm_bindgen::prelude::*; use std::cell::RefCell; use std::sync::Mutex; lazy_static! { static ref BUFFER1: Mutex<RefCell<Vec<u32>>> = Mutex::new(RefCell::new(vec![])); static ref BUFFER2: Mutex<RefCell<Vec<u32>>> = Mutex::new(RefCell::new(vec![])); } #[wasm_bindgen] ...
//! SCPI Parser and response formatter //! pub mod expression; pub mod parameters; pub mod response; pub mod suffix; pub mod tokenizer; pub use tokenizer::util::{mnemonic_compare, mnemonic_match}; /// Wrappers to format and discriminate SCPI types pub mod format { /// Hexadecimal data #[derive(Debug, Partia...
#[macro_use] extern crate hyper; extern crate leecher; use hyper::Server; use hyper::server::{Request, Response}; use leecher::url_type::{url_type, UrlType}; use leecher::download; use hyper::status::StatusCode; fn handler(request: Request, mut response: Response) { let raw = request.uri.to_string(); let base = ...
/* * @lc app=leetcode.cn id=7 lang=rust * * [7] 整数反转 */ // @lc code=start impl Solution { pub fn reverse(x: i32) -> i32 { let mut res = 0; let mut sign = 1; if x < 0{ sign = -1; } let mut x = x.abs(); while x > 0 { let new = res * 10 + x %...
use std::ops::{BitXor, BitXorAssign}; use nimiq_bls::PublicKey; use nimiq_collections::bitset::BitSet; use crate::contribution::AggregatableContribution; /// Struct that defines an identity. /// An identity is composed of zero, one or more signers of a contribution. #[derive(Clone, std::fmt::Debug, Default, PartialE...
use minifb::{Key, Window, WindowOptions}; use std::{ sync::mpsc::{self, Receiver, Sender}, thread, }; pub struct WatcherHandle { sender: Sender<ToWatcher>, receiver: Receiver<FromWatcher>, wants_to_close: bool, } impl WatcherHandle { pub fn update(&mut self) { while let Ok(message) = self.receiver.try_recv()...
// This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Softwa...
use core::cell::Cell; use core::future::Future; use core::marker::PhantomData; use core::mem; use core::pin::Pin; use core::ptr::NonNull; use core::task::{Context, Poll, RawWaker, RawWakerVTable, Waker}; use super::cell::UninitCell; use super::header::Header; use super::state::State; use super::task::Task; use crate::...
pub trait OpenFile { fn open_file(&self) -> Result<io::BufWriter<fs::File>>; } impl<'a> OpenFile for &'a str { fn open_file(&self) -> Result<io::BufWriter<fs::File>> { let rel_path = self; log::trace!("opening {}", rel_path); let file = fs::File::create(&rel_path); let file = ...
use std::io; use failure::Fail; use serde_json; #[derive(Fail, Debug)] pub enum KvReaderError { #[fail(display = "IO error: {}", _0)] Io(#[cause] io::Error), #[fail(display = "serde_json error: {}", _0)] Serde(#[cause] serde_json::Error), #[fail(display = "Key not found")] KeyNotFound, } impl ...
//! Issues and tracks dynamic clients use crate::{ config::DhcpConfig, models::{Dhcp, Session}, }; use color_eyre::eyre; use parking_lot::RwLock; use sqlx::sqlite::SqlitePool; use std::{collections::HashMap, net::Ipv4Addr, sync::Arc}; use uuid::Uuid; /// Responsible for tracking Internet Profocol (IP) address...
use std::net::{TcpListener,TcpStream}; use std::io::prelude::*; use std::thread; use std::time::Duration; use std::fs; use web_server::ThreadPool; fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); let tp = ThreadPool::new(4); for stream in listener.incoming(){ let _stream = s...
#![windows_subsystem = "windows"] #[cfg(target_os = "windows")] mod ui; #[cfg(target_os = "windows")] fn main() { use plastic_core::nes::NES; use std::env::args; use ui::NwgProvider; let args = args().collect::<Vec<String>>(); let nes = if args.len() >= 2 { NES::new(&args[1], NwgProvider...
#![feature(const_size_of)] extern crate log; extern crate env_logger; extern crate bytes; extern crate crypto; extern crate futures; extern crate tokio_io; extern crate tokio_core; extern crate tokio_proto; extern crate tokio_service; extern crate rustc_serialize; extern crate byteorder; pub mod hash; mod codec; mod ...
use wasmer_runtime_core::{ codegen::{Event, EventSink, FunctionMiddleware, InternalEvent}, module::ModuleInfo, vm::{Ctx, InternalField}, wasmparser::{Operator, Type as WpType, TypeOrFuncType as WpTypeOrFuncType}, Instance, }; static INTERNAL_FIELD: InternalField = InternalField::allocate(); /// Me...
use std::error::Error; use probe_rs::{ architecture::{ arm::{ ap::{GenericAp, MemoryAp}, armv6m::Demcr, memory::Component, sequences::DefaultArmSequence, ApAddress, ApInformation, ArmProbeInterface, DpAddress, MemoryApInformation, }, ...
mod command; mod split; use std::io::{stdin, stdout, Write}; use std::process::{Child, Command, Stdio}; use crate::command::process_cd; use crate::split::split_command; fn main() { loop { print!("> "); stdout().flush().unwrap(); let mut input = String::new(); stdin().read_line(&m...
// // gash.rs // // Starting code for PS2 // Running on Rust 0.9 // // University of Virginia - cs4414 Spring 2014 // Weilin Xu, David Evans // Version 0.4 // extern mod extra; extern mod native; use std::{io, run, os}; use std::io::buffered::BufferedReader; use std::io::{File, Append, ReadWrite}; use std::io::stdin; ...
mod features { use std::{ env, fs, io, path::Path, process::{Command, Stdio}, }; fn test_example(path: &Path, out_file: &Path, expected_result: bool) { let old_rlib = path.join("libold.rlib").to_str().unwrap().to_owned(); let new_rlib = path.join("libnew.rlib").to_st...
use rand::Rng; use crate::hittable::HitRecord; use crate::ray::Ray; use crate::vec3::Vec3; use super::{Material, MaterialT}; /// Material that scatters incoming rays in random directions. #[derive(Debug)] pub struct Dielectric { /// Refractive index ref_idx: f32, } impl Dielectric { /// Return a new Die...
#[derive(PartialEq, Debug)] pub enum Allergen { Eggs, //1 Peanuts, //2 Shellfish, //4 Strawberries, //8 Tomatoes, //16 Chocolate, //32 Pollen, //64 Cats //128 } pub struct Allergies(pub i32); impl Aller...
extern crate env_logger; extern crate paryxa_server; extern crate warp; use paryxa_server::{graphiql, graphql}; use std::env; use warp::Filter; const LOG: &str = "paryxa-server"; fn main() { if env::var("RUST_LOG").is_err() { env::set_var("RUST_LOG", LOG); } let log = warp::log(LOG); env_log...
use std::fs::OpenOptions; use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; use std::env; use std::process; use std::io::Write; use std::iter::Iterator; fn main() { let args: Vec<String> = env::args().collect(); if args.len() < 3 { println!("Usage:"); println!("list_splitt...
/* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use thi...
use std::collections::BTreeSet; use std::io::prelude::*; use std::io::BufReader; use std::iter::FromIterator; use std::num::ParseIntError; use std::path::PathBuf; use structopt::StructOpt; fn part1(input: &[i64]) -> Option<i64> { let numbers = BTreeSet::from_iter(input); for number in numbers.iter().cloned() {...
#[allow(unused_imports)] use tracing::{info, warn, debug, error, trace, instrument, span, Level}; use std::sync::Mutex as StdMutex; use std::sync::Arc; use crate::comms::Metrics; use crate::meta::*; use crate::error::*; use crate::header::*; use crate::event::*; use crate::index::*; use crate::redo::*; use super::*; ...
#[doc = "Reader of register PIDR1"] pub type R = crate::R<u32, super::PIDR1>; #[doc = "Bits\\[11:8\\] of the 12-bit part number of the component. The designer of the component assigns this part number\n\nValue on reset: 13"] #[derive(Clone, Copy, Debug, PartialEq)] pub enum PART_1_A { #[doc = "13: Indicates bits\\[...
use std::error::Error; use std::fmt; use std::fs; use std::num::ParseIntError; use std::path::Path; use std::str::FromStr; use failure; use regex::Regex; use bio_types::annot::loc::*; use bio_types::annot::pos::*; use bio_types::strand::*; //use rust_htslib::bam::record::Record; //use transcript::*; /// Mapping of ...
// Rust Simplicity Library // Written in 2020 by // Andrew Poelstra <apoelstra@blockstream.com> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warra...
mod vec; use std::fs::File; use std::io; use std::io::Write; use vec::Ray; use vec::Vec3; fn hit_sphere(center: &Vec3, radius: f32, r: &Ray) -> bool { let oc = r.origin - *center; let a = r.direction.dot(&r.direction); let b = 2.0 * oc.dot(&r.direction); let c = oc.dot(&oc) - radius * radius; let ...
#[allow(unused_imports)] use serde_json::Value; #[derive(Debug, Serialize, Deserialize)] pub struct MappingUsersRulesRuleExtended { /// Specifies the operator to make rules on specified users or groups. #[serde(rename = "operator")] pub operator: Option<String>, /// Specifies the properties for user ma...
use anchor_lang::prelude::*; // import みたいなもの declare_id!("7sKC8VRyn6np3wpx8jrYpQBgWkhCH3SPZTtR8aawpJPy"); #[program] // macro pub mod solanagifportal { // module use super::*; pub fn start_stuff_off(ctx: Context<StartStuffOff>) -> ProgramResult { // Get a reference to the account. let base_account = &mut...
use crate::parse::NomParse; use nom::{ branch, bytes::complete as bytes, character::complete as character, combinator as comb, multi, sequence, Finish, IResult, }; use std::{ collections::{HashMap, HashSet}, fmt::{self, Display, Formatter}, fs, io, }; #[derive(Clone, Copy, Debug, Eq, Hash, PartialE...
pub type OptionCode = u16; pub const OPTION_CLIENTID: OptionCode = 1; // [RFC8415], ORO: No, SINGLETON: Yes pub const OPTION_SERVERID: OptionCode = 2; // [RFC8415], ORO: No, SINGLETON: Yes pub const OPTION_IA_NA: OptionCode = 3; // [RFC8415], ORO: No, SINGLETON: No pub const OPTION_IA_TA: OptionCode = 4; // [RFC8415], ...
use imperative_rs::InstructionSet; #[derive(InstructionSet)] enum Star { #[opcode = "0b0*0*000y_xxxxxxxx"] Bin { x: u8, y: bool }, #[opcode = "0xf*_xy"] Hex { x: u8, y: u8 }, } #[test] fn encoding_star_opcodes() { { let mut mem = [0, 0]; let instr = Star::Bin { x: 0xab, y: true }; ...
#[derive(Clone)] pub struct Shuffle { random: XorShift, } impl Shuffle { pub fn new() -> Self { Shuffle { random: XorShift::new(), } } pub fn shuffle<T: Clone>(&mut self, vec: &mut [T]) { let n = vec.len(); for i in (0..n).rev() { let j = self.ra...
//! Stores the [Shape] trait, as well as modules containing its implementation. use crate::intersection::Intersection; use crate::material::Material; use crate::matrix::Matrix; use crate::ray::Ray; use crate::tuple::Tuple; pub mod plane; pub mod sphere; /// Represents a 3D shape with all methods to be able to render...
// use itertools::Itertools; // use itertools::MinMaxResult::MinMax; // use std::cmp::Ordering; use std::collections::HashMap; #[aoc_generator(day11)] pub fn input_generator(input: &str) -> HashMap<(usize, usize), bool> { let mut seat_map = HashMap::new(); input.lines().enumerate().for_each(|(y , line)| { line...
mod app; use std::env; use dotenv::dotenv; use actix_cors::Cors; use tokio::sync::Mutex; use actix_web::rt::net::TcpStream; use actix_web::{App, HttpServer, web}; use crate::app::AppError; use crate::app::configs::get_configs; use crate::app::routers::app_routers; use crate::app::helpers::process::run_script; use crat...
#[cfg(feature = "entrypoint")] mod entrypoint; pub mod processor; pub mod errors; pub mod instructions; #[cfg(test)] mod tests { use solana_program::pubkey::Pubkey; use solana_program_test::*; use solana_sdk::{signature::Signer, transaction::Transaction}; use crate::instructions as ixs; const ...
#![no_std] use core::arch::wasm32::*; use core::cmp::{max, min}; use wasm_bindgen::prelude::*; struct PixelmatchOption { pub include_anti_alias: bool, pub threshold: f32, pub diff_color: Rgba, pub anti_aliased_color: Rgba, } pub struct Rgba(u8, u8, u8, u8); const IMAGE_LENGTH_ERROR: isize = -1; const...
//! Stream Prototype Crate //! //! This crate exposes an unified interface to stream-like interfaces. It also implements that interface for the TCP, TLS and QUIC protocols. //! //! The most important trait is the [`ConnectionHandler`] trait, which is used by the protocol implementations to receive connections. //! //! ...
use ffi; /// Implemented for fixed size type those representation is directly compatible with ODBC pub unsafe trait FixedSizedType: Sized + Default { fn c_data_type() -> ffi::SqlCDataType; } unsafe impl FixedSizedType for u8 { fn c_data_type() -> ffi::SqlCDataType { ffi::SQL_C_UTINYINT } } unsafe...
use super::parts::BranchCommit; #[derive(Deserialize, Debug)] pub struct BranchPayload { commit: BranchCommit, } impl BranchPayload { pub fn sha(&self) -> &str { &self.commit.sha } }
fn main() { println!("{}\nPackage: {}\nVersion: {}\nQuantum: {} {}", magickwand::get_copyright().unwrap(), magickwand::get_package_name().unwrap(), magickwand::get_version().unwrap(), magickwand::get_quantum_depth().unwrap(), magickwand::get_quantum_range().unwrap() ...
mod simple; mod test; pub use self::simple::RayTraceSimpleMaterial; pub use self::test::RayTraceCheckerboardMaterial; use hit::RayTraceMaterialHit; pub trait RayTraceMaterial: Send + Sync { fn get_hit(&self, x: f64, y: f64) -> RayTraceMaterialHit; }
fn main() { #[derive(Debug)] enum IpAddrKind { V4, V6 } #[derive(Debug)] struct IpAddr { _kind: IpAddrKind, _address: String, } let four = IpAddrKind::V4; let six = IpAddrKind::V6; let home = IpAddr { _kind: four, _address: String::from("127.0.0.1"), ...
use std::{net::SocketAddr, rc::Rc}; use crate::Timer; use super::{ ack_manager::AckManager, entities::{entity_notifiable::EntityNotifiable, entity_type::EntityType}, events::{event::Event, event_manager::EventManager, event_type::EventType}, manifest::Manifest, packet_reader::PacketReader, pac...
use crate::utils::{db, db::SLED, ENCODER}; use actix_multipart::Multipart; use actix_web::{error, post, HttpRequest, HttpResponse, Result}; use futures::{StreamExt, TryStreamExt}; use serde::Serialize; use std::string::ToString; use tokio::{ fs::{rename, File}, io::AsyncWriteExt, }; #[derive(Serialize)] struct...
// Copyright 2021 WHTCORPS INC Project Authors. Licensed under Apache-2.0. //! Provides wrappers for types that comes from 3rd-party and does not implement slog::Value. #[macro_use] extern crate slog; #[allow(unused_extern_crates)] extern crate edb_alloc; pub mod test_util; pub struct DisplayValue<T: std::fmt::Dis...
#[cfg(test)] mod tst; #[cfg(test)] pub(crate) use tst::*; mod constants; pub(crate) use constants::*; /// Fast functions with 350.0 ULP error bound mod fast; pub use fast::{cosf as cos_fast, powf as pow_fast, sinf as sin_fast}; /// Functions with 0.5 ULP error bound mod u05; pub use u05::{ cospif as cospi_u05, hy...
extern crate lambda_runtime as lambda; extern crate log; extern crate simple_logger; extern crate chrono; extern crate data_encoding; extern crate serde; extern crate serde_json; extern crate serde_derive; #[macro_use] extern crate lazy_static; extern crate regex; extern crate rayon; use serde_derive::{Serialize, ...
use core::task::{RawWaker, RawWakerVTable, Waker}; use super::header::Header; /// A waker that does absolutely nothing pub(crate) struct NoopWaker(RawWaker); // ===== impl Noopwaker ===== impl NoopWaker { const RAW_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(Self::clone, Self::no_op, Self::no_op,...
// Copyright 2019 Conflux Foundation. All rights reserved. // Conflux is free software and distributed under GNU General Public License. // See http://www.gnu.org/licenses/ #[derive(Clone, Copy, Debug, DeriveMallocSizeOf, PartialEq)] #[repr(u8)] pub enum SnapshotKeptToProvideSyncStatus { No = 0, InfoOnly = 1, ...
#[test] fn test_readlink() { use rustix::fs::{open, readlink, symlink, Mode, OFlags}; let tmp = tempfile::tempdir().unwrap(); let _ = open( tmp.path().join("foo"), OFlags::CREATE | OFlags::WRONLY, Mode::RUSR, ) .unwrap(); symlink("foo", tmp.path().join("link")).unwrap()...
#[macro_use] extern crate clap; use clap::{App, Arg}; use std::net::ToSocketAddrs; use std::str::FromStr; use vban_autogain::app; fn main() { let socket_addrs_validator = |s: String| match s.to_socket_addrs() { Ok(_) => core::result::Result::Ok(()), Err(s) => core::result::Result::Err(s.to_string(...
use super::Client; use cursive::views::{Dialog, EditView, ListView, Button}; use std::cell::RefCell; use std::rc::Rc; use std::sync::{Arc, Mutex}; //use cursive_async_view::AsyncView; pub fn add_task_view(client: Arc<Mutex<Client>>, list_name: Rc<RefCell<String>>) -> cursive::views::Dialog { Dialog::new() ...
/* * @lc app=leetcode.cn id=48 lang=rust * * [48] 旋转图像 */ // @lc code=start use std::mem::swap; impl Solution { pub fn rotate(matrix: &mut Vec<Vec<i32>>) { let n = matrix.len(); { for x in 0..n { for y in 0..x { let (part1, part2) = matrix.split_...
struct Solution; impl Solution { fn min_steps(n: i32) -> i32 { let n = n as usize; let mut dp = vec![0; n + 1]; for i in 2..=n { dp[i] = i; for j in (2..i).rev() { if i % j == 0 { dp[i] = dp[j] + i / j; break; ...
fn find_group_sum( source: &[i32], n: u8 ) -> i32 { let mut sum = 0; for term in source { sum += term; } sum / n as i32 } fn find_first_group( source: &[i32], collected: &[i32], current_sum: i32, required_sum: i32, extra_group_count: u8 ) -> Option<Vec<i32>> { let mut head = source.to_vec(); let mut tail = Ve...
use crate::util::{check_pointer, check_return, AutoPtr}; use crate::Qualifier::*; use acl_sys::{ acl_entry_t, acl_get_permset, acl_get_qualifier, acl_get_tag_type, acl_permset_t, ACL_GROUP, ACL_GROUP_OBJ, ACL_MASK, ACL_OTHER, ACL_UNDEFINED_TAG, ACL_USER, ACL_USER_OBJ, }; use std::ptr::null_mut; /// The subject...
//! Showcases advanced CAN filter capabilities. //! Does not require additional transceiver hardware. #![no_main] #![no_std] use bxcan::{ filter::{ListEntry16, ListEntry32, Mask16}, ExtendedId, Fifo, Frame, StandardId, }; use panic_halt as _; use cortex_m_rt::entry; use nb::block; use stm32f1xx_hal::{can::Ca...
#[macro_export] macro_rules! v023_convert_key { ($keycode:expr) => {{ ::conrod_winit::v021_convert_key!($keycode) }}; } /// Maps winit's mouse button to conrod's mouse button. /// /// Expects a `winit::MouseButton` as input and returns a `conrod_core::input::MouseButton` as /// output. /// /// Requires...
// Copyright 2020 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 crate::structures::version::Version; impl Version { pub fn new() -> Self { Version::default() } }
use crate::{ error::Error, tds::codec::{ColumnData, FixedLenType, TokenRow, TypeInfo, VarLenType}, FromSql, }; use std::{fmt::Display, sync::Arc}; /// A column of data from a query. #[derive(Debug, Clone)] pub struct Column { pub(crate) name: String, pub(crate) column_type: ColumnType, } impl Colu...
//---------------------------------------------------------------------------// // Copyright (c) 2017-2020 Ismael Gutiérrez González. All rights reserved. // // This file is part of the Rusted PackFile Manager (RPFM) project, // which can be found here: https://github.com/Frodo45127/rpfm. // // This file is licensed un...
use actix_web::{ AsyncResponder, HttpRequest, HttpResponse, FutureResponse, Json }; use db::{AppState}; use futures::{Future}; use std::collections::HashMap; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct MemberParams { pub member_email: String, pub name: String, pub phone: Option<Stri...
use crate::readers::{Index, Value}; /// Convert a hashmap to a list of key and value pairs pub fn dict2items(val: &mut Value, _idx: &[Index]) -> Value { match val { Value::Object(map) => { Value::Array(map.drain() .map(|(k, v)| Value::Array(vec![ Value::Str(k), v ])) ...
use span; use tracing_core::{subscriber::Interest, Metadata}; pub trait Filter<N> { fn callsite_enabled(&self, metadata: &Metadata, ctx: &span::Context<N>) -> Interest { if self.enabled(metadata, ctx) { Interest::always() } else { Interest::never() } } fn e...
#[derive(Deserialize, Debug)] pub struct StatusPayload { state: State, } impl StatusPayload { pub fn state(&self) -> &State { &self.state } } #[derive(Deserialize, Debug)] pub enum State { Failure, Pending, Success }
use anyhow::{Context, Result}; use regex::{Captures, Regex}; macro_rules! static_regex { ($pattern:literal) => {{ lazy_static! { static ref RE: regex::Regex = regex::Regex::new($pattern).unwrap(); } &*RE }} } pub fn regex_captures<'a>(regex: &Regex, string: &'a str) -> Result<Captures<'a>> { regex.cap...
use std::{ alloc::{alloc, dealloc, handle_alloc_error, Layout}, iter::{FromIterator, Take}, marker::PhantomData, mem, ops::{Deref, DerefMut}, ptr::{self, NonNull}, }; /// A node of a `CircularList`. /// /// Contains the data and the pointers to the next and previous nodes. /// /// This is an in...
use dtl::Value; const HUNDREDS: [&'static str; 10] = [ "", "сто", "двести", "триста", "четыреста", "пятьсот", "шестьсот", "семьсот", "восемьсот", "девятьсот", ]; const TENS: [&'static str; 10] = [ "", "", "двадцать", "тридцать", "сорок", "пятьдесят", "шестьдесят", "семьдесят", "восемьдесят", "девя...
//! Args, Env, Result, and Value pub use crate::{Args, Env, Result, Value};
extern crate amethyst_core; extern crate collision; extern crate rhusics_core; extern crate rhusics_ecs; extern crate shrev; extern crate specs; pub use self::bundle::{BasicPhysicsBundle2, BasicPhysicsBundle3, DefaultBasicPhysicsBundle2, DefaultBasicPhysicsBundle3}; pub use self::sync::{time_syn...
#![allow(unused_imports, unused_variables, dead_code)] use std::{ env, fs, io::{Cursor, Read, Seek, SeekFrom}, }; use iced::Application as _; use byteorder::{BigEndian, ReadBytesExt}; use chrono::NaiveTime; mod decode; mod segment; mod ui; mod widgets; fn convert_ts(ts: u32) -> NaiveTime { let millis =...
use std::fs::File; use std::io::{BufReader, Read, Write}; use std::path::Path; use std::{fs, io}; use env_logger::{Builder, Env, Target}; use crate::relation::Input; use crate::solver::Payload; mod evaluate; mod relation; mod solver; mod unify; fn visit<P: AsRef<Path>>(dir: P, cb: &dyn Fn(&Path)) -> io::Result<()> ...
//! STM32F4DISCOVERY demo application //! //! This demo application sports a serial command-interface for controlling what the LED //! ring does: cycle clock-wise, counter clock-wise, or follow the accelerometer. #![deny(unsafe_code)] #![no_main] #![no_std] use core::fmt::Write; use cortex_m_semihosting::hprintln; u...
use itertools::Itertools; use regex::Captures; pub mod defaults; pub mod options; use defaults::{RE, SORTER}; use options::Options; pub fn has_classes(file_contents: &str) -> bool { RE.is_match(file_contents) } pub fn sort_file_contents(file_contents: String, options: &Options) -> String { RE.replace_all(&f...
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 //! Transaction Readiness indicator //! //! Transaction readiness is responsible for indicating if //! particular transaction can be included in the block. //! //! Regular transactions are ready iff the current state nonce //! (obta...
#[allow(unused_imports)] use serde_json::Value; #[derive(Debug, Serialize, Deserialize)] pub struct JobJobChangelistcreateParams { /// Newer snapshot ID. #[serde(rename = "newer_snapid")] pub newer_snapid: i32, /// Older snapshot ID. #[serde(rename = "older_snapid")] pub older_snapid: i32, ...
mod stack; use stack::StackX; fn main() { let mut the_stack = StackX::new(10); the_stack.push(20); the_stack.push(40); the_stack.push(60); the_stack.push(80); while !the_stack.is_empty() { print!("{} ", the_stack.pop()); } println!(); }
use rocket::config::{ConfigBuilder, Environment, LoggingLevel}; use super::super::super::errors::Result; pub const NAME: &'static str = "routes"; pub const ABOUT: &'static str = "List of all of the available routes"; pub fn run() -> Result<()> { let app = super::rocket( ConfigBuilder::new(Environment::Pr...
#[allow(unused_imports)] use serde_json::Value; #[derive(Debug, Serialize, Deserialize)] pub struct SummaryClientClientItem { /// The class of the operation. #[serde(rename = "class")] pub class: String, /// Rate of input (in bytes/second) for an operation since the last time isi statistics collected t...
use std::env; use std::time::Duration; use std::thread; use std::fs; struct GameState { current_state: Vec<Vec<char>>, tmp_state: Vec<Vec<char>>, iter: u32, } impl GameState { fn new(x: usize, y: usize, init: Vec<&str>) -> GameState { let mut state = GameState { current_state : v...
//! Iterators over torrent file information. use bip_util::sha; use metainfo::File; /// Iterator over each File within the MetainfoFile. pub struct Files<'a> { index: usize, files: &'a [File], } impl<'a> Files<'a> { pub fn new(files: &'a [File]) -> Files<'a> { Files { index: 0, ...