text
stringlengths
8
4.13M
use std::{ future::Future, io, pin::Pin, task::{Context, Poll}, }; use futures_util::future::BoxFuture; #[cfg(feature = "tls")] use futures_util::FutureExt; use futures_util::future::{select_ok, SelectOk, TryFutureExt}; #[cfg(feature = "tls")] use native_tls::TlsConnector; #[cfg(feature = "tokio_io")]...
use crate::{ websocket::push_messages::InternalMessage, }; use actix::{ Actor, Message, Handler, Context, AsyncContext, WrapFuture, Recipient, ActorContext, ActorFuture, fut, ResponseActFuture, }; use log::{debug, error}; use redis::{ aio::{PubSub, Connection}, Msg, }; use std::{ collections...
use crate::coin::Coin; pub const X_BOARD_LENGTH: usize = 7; pub const Y_BOARD_LENGTH: usize = 6; pub type Board = [[Coin; Y_BOARD_LENGTH]; X_BOARD_LENGTH]; pub type Coord = (usize, usize); pub fn new_board() -> Board { [[Coin::Empty; Y_BOARD_LENGTH]; X_BOARD_LENGTH] } pub fn drop_coin(board: &mut Board, coin: C...
#![cfg_attr(not(feature = "std"), no_std)] use frame_support::traits::{Currency, Get, EnsureOrigin, fungible::Inspect}; use frame_support::{ decl_event, decl_error, decl_module, decl_storage, dispatch::DispatchResult, ensure, }; use sp_runtime::traits::{Convert}; use frame_system::{ensure_root, ensure_signed}; use...
use eos::types::*; use serde::Serialize; use serde_json; use stdweb::Value; use yew::prelude::*; #[derive(Serialize, Deserialize, Debug, Default)] pub struct ScatterRequiredFields { #[serde(skip_serializing_if = "Option::is_none")] pub accounts: Option<Vec<ScatterNetwork>>, } impl PartialEq for ScatterRequire...
#[doc = "Register `SPI_I2SCFGR` reader"] pub type R = crate::R<SPI_I2SCFGR_SPEC>; #[doc = "Register `SPI_I2SCFGR` writer"] pub type W = crate::W<SPI_I2SCFGR_SPEC>; #[doc = "Field `I2SMOD` reader - I2SMOD"] pub type I2SMOD_R = crate::BitReader; #[doc = "Field `I2SMOD` writer - I2SMOD"] pub type I2SMOD_W<'a, REG, const O...
use itertools::Itertools; fn is_valid(passphrase: &&str) -> bool { let words = passphrase.split_whitespace(); let unique_words = words.clone().unique(); words.count() == unique_words.count() } fn count_letters(word: &str) -> [usize; 28] { let mut rv = [0; 28]; for c in word.chars() { rv[c...
struct Point{ x: i32, y: i32, } fn test_function(x:&mut Point){ x.x+=1; x.y+=1; } fn main() { let x: u32=1_000_000; assert_eq!(1000000,x); }
// Copyright 2018 Vlad Yermakov // // 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 ...
//! `x-www-form-urlencoded` meets Serde extern crate dtoa; extern crate itoa; pub mod de; pub mod ser; #[doc(inline)] pub use self::de::{from_bytes, from_reader, from_str, Deserializer}; #[doc(inline)] pub use self::ser::{to_string, Serializer}; #[cfg(test)] mod tests { #[test] fn deserialize_bytes() { ...
/// function that prints "Hello World!" /// /// function definition fn main() { // Invoke print macro println!("Hello World!"); }
use std::env; use std::fs; use std::str::Lines; use std::collections::HashMap; pub struct VaultConfiguration { pub map: HashMap<String, String>, } impl VaultConfiguration { ///Creates a new structure containing key-value pairs from a file. ///The name of the virtual environment parameter, which contains t...
use crate::event::moisture::Measurement; #[derive(Debug, Deserialize, PartialEq, Eq)] pub struct ADCSettings { pub device: String, pub device_type: String, pub chip_select_gpio: u8, pub enable_gpio: u8, pub update: u64 } #[derive(Clone, Debug, Deserialize, PartialEq, Eq)] pub struct MoistureSensorSettings { pub...
use reqwest::blocking::Client; use crate::event::{Event, ToInfluxDB}; use crate::event::moisture::Measurement; use crate::settings::DatabaseSettings; pub struct Database { client: Client, write_url: String, auth_header: String } impl Database { pub fn new(settings: &DatabaseSettings) -> Self { let write_url = f...
use clap::{App, AppSettings, Arg, SubCommand}; use std::path::Path; mod dockerignore; mod executor; mod hasher; mod types; use dockerignore::*; use executor::{annotate_component, CommandConfig, CommandRegistry}; use hasher::*; use types::CustomError; enum Deps { Dependencies, Dependents, } fn main() -> Resul...
use error_chain::error_chain; use crate::concurrency::explicit_threads::walk_dir; error_chain! { foreign_links { IO(std::io::Error); WalkDir(walkdir::Error); SystemTime(std::time::SystemTimeError); Glob(glob::GlobError); Pattern(glob::PatternError); } } pub fn find_re...
pub mod generic; pub mod specialized; pub mod algorithms; pub mod bitvec;
pub const ADDRESS: &str = "0.0.0.0:80"; pub mod index;
extern crate orbclient; extern crate tetrahedrane; use tetrahedrane::vid::*; use tetrahedrane::start; fn main() { let mut window = start::Window::new(1280, 720, "Hello!", 1 as usize); window.window.set(Color::new(20, 40, 60).orb_color()); let point1 = DepthPoint::new(0.0, -0.5, 0.0); let point2 = ...
//! Hyper SSL support via modern versions of OpenSSL. //! //! Hyper's built in OpenSSL support depends on version 0.7 of `openssl`. This crate provides //! SSL support using version 0.9 of `openssl`. //! //! # Usage //! //! Hyper's `ssl` feature is enabled by default, so it must be explicitly turned off in your //! Car...
// Run-time: // status: signal use std::process; fn main() { unsafe { let ptr = std::ptr::null::<usize>(); *ptr + 1; } }
#[macro_use] extern crate log; use azure_core::prelude::*; use azure_storage::core::prelude::*; use azure_storage_queues::prelude::*; use std::error::Error; #[tokio::main] async fn main() -> Result<(), Box<dyn Error + Send + Sync>> { // First we retrieve the account name and master key from environment variables. ...
use std::collections::HashMap; use std::fmt; use std::ops::Deref; use std::borrow::{Cow}; use tuple::{TupleElements, Map}; use decorum::R32; use indexmap::set::IndexSet; use crate::{R, FontError}; use crate::parsers::{token, Token, comment, space, hex_string}; #[cfg(feature="unstable")] use slotmap::SlotMap; #[cfg(n...
use rand::Rng; use serde::{Deserialize, Serialize}; use std::iter; use crate::blueprints::Blueprint; use crate::vectors; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct Component { pub activity: usize, pub label: String, pub binding_sites: Vec<Vec<f32>>, // express new components ...
#[doc = "Register `HDPLSR` reader"] pub type R = crate::R<HDPLSR_SPEC>; #[doc = "Field `HDPL` reader - temporal isolation level This bitfield returns the current temporal isolation level."] pub type HDPL_R = crate::FieldReader; impl R { #[doc = "Bits 0:7 - temporal isolation level This bitfield returns the current ...
mod service; pub use service::*;
use crate::types::{DateTime, NonZeroU64, StdRng}; pub trait NanoSecondGenerator { fn gen_ns(&mut self, rng: &mut StdRng, dt: DateTime) -> Option<NonZeroU64>; }
use std::fs::create_dir; use std::path::PathBuf; use indicatif::ProgressBar; use walkdir::DirEntry; use crate::errors::{BoilrError, StandardResult}; use crate::utils::types::FileContent; use crate::utils::{create_and_write_file, prompt_overwrite_if_exist}; use crate::TEMPLATE_DIR_NAME; pub fn reconstruct( from_p...
pub use self::parsing::parse; mod lex; mod preproc; mod parsing; #[deriving(Show)] enum Error { IOError(::std::io::IoError), BadCharacter(char), SyntaxError(String), } #[must_use] type ParseResult<T> = Result<T,Error>; // vim: ft=rust
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// SyntheticsCiTestMetadataGit : Git information. #[derive(Clone, Debug, PartialEq, Serialize, Deser...
//! An element-tree style XML library //! //! # Examples //! //! ## Reading //! //! ``` //! use treexml::Document; //! //! let doc_raw = r#" //! <?xml version="1.1" encoding="UTF-8"?> //! <table> //! <fruit type="apple">worm</fruit> //! <vegetable /> //! </table> //! "#; //! //! let doc = Document::parse(doc_ra...
#[derive(Debug)] pub enum TokenType { // Single-character tokens. LPAREN, RPAREN, LBRACE, RBRACE, COMMA, DOT, MINUS, PLUS, SEMI, SLASH, STAR, // One or two character tokens. EX, EXEQ, EQ, EQEQ, GT, GTEQ, LT, LTEQ, // Literals. ID(String), STR(String), NUM(i32), // Keywords. AND, CLASS, ELSE,...
use axum::body::Bytes; use axum::http::StatusCode; use axum::{routing::get, Router}; use std::net::SocketAddr; const VERSION: &str = env!("CARGO_PKG_VERSION"); const PACKAGE_NAME: &str = env!("CARGO_PKG_NAME"); const DEFAULT_PORT: u16 = 3000; async fn hello() -> String { format!("{} {}", PACKAGE_NAME, VERSION) } ...
use std::panic; use rocket::{self, http::{ContentType, Header, Status}, local::Client}; use diesel::connection::SimpleConnection; use horus_server::{self, routes::paste::*}; use test::{run_test, sql::*}; #[test] fn does_show() { run(|| { let client = get_client(); let req = client.get(String::fro...
use super::AtomicLocation; use std::path; impl AtomicLocation { pub fn get_path(&self) -> &path::Path { path::Path::new(self.get_str()) } // FIXME: This needs to be returned in two parts or as a path pub fn get_str(&self) -> &str { match self { AtomicLocation::Base => "atomi...
extern crate bindgen; #[macro_use] extern crate log; extern crate docopt; #[macro_use] extern crate rustc_serialize; use bindgen::{Builder, LinkType, Logger}; use std::io::{self, Write}; use std::fs::File; use std::process::exit; #[derive(Debug)] struct StdLogger; impl Logger for StdLogger { fn error(&self, msg:...
use addressing; use sphinx::route::NodeAddressBytes; use std::error::Error; use std::net::SocketAddr; use tokio::prelude::*; #[derive(Debug)] pub struct MixPeer { connection: SocketAddr, } impl MixPeer { // note that very soon `next_hop_address` will be changed to `next_hop_metadata` pub fn new(next_hop_a...
extern crate futures; extern crate tokio_core; extern crate websocket; use websocket::async::Server; use websocket::message::OwnedMessage; use websocket::server::InvalidConnection; use futures::{Future, Sink, Stream}; use tokio_core::reactor::Core; fn main() { let mut core = Core::new().unwrap(); let handle = core...
//! //! This is a Rust implementation of the [bip39][bip39-standard] standard for Bitcoin HD wallet //! mnemonic phrases. //! //! //! [bip39-standard]: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki //! //! ## Quickstart //! //! ```rust //! use bip39::{Mnemonic, MnemonicType, Language, Seed}; //! //! //...
use crate::custom_types::exceptions::{arithmetic_error, index_error}; use crate::from_bool::FromBool; use crate::int_var::IntVar; use crate::operator::Operator; use crate::rational_var::RationalVar; use crate::runtime::Runtime; use crate::string_var::StringVar; use crate::variable::{InnerVar, Variable}; use num::traits...
pub trait CoordinateEncoder { fn decode(&self, index: usize) -> (u32, u32); fn encode(&self, x: i32, y: i32) -> Option<usize>; } pub struct LoopingEncoder { pub dimensions: (u32, u32), } impl CoordinateEncoder for LoopingEncoder { fn decode(&self, index: usize) -> (u32, u32) { ( in...
mod api; mod connection; mod utils;
extern crate clap; extern crate ctrlc; extern crate fatfs; extern crate tempfile; extern crate wait_timeout; use std::io::Write; use std::path::PathBuf; use std::process::{Child, Command}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::time::Duration; use wait_timeout::ChildExt; fn main()...
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. // // A test that visits the Place::Projection case of Visitor::visit_place // and the ProjectionElem::Index case of Visitor::visit_projec...
use std::time::Duration; use js_sys::{Promise}; use web_sys::{window}; use wasm_bindgen_futures::JsFuture; use wasm_bindgen::prelude::*; /// This is the wasm version of the sleep function. /// For now it is the only way to sleep. /// The precision of this function is 1ms. pub async fn sleep(duration: Duration) { ...
extern crate pulldown_cmark; use pulldown_cmark::{html, Parser, Event, Tag}; use std::borrow::Cow::{Owned}; fn main() { let markdown_str = r#"# Hello 人間は愚かな生物。 [俺のブログ](https://blog.himanoa.net) "#; let parser = Parser::new(markdown_str).map(|event| match event { Event::Start(Tag::Link(url, title)) =>...
/// An enum to represent all characters in the AlphabeticPresentationForms block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum AlphabeticPresentationForms { /// \u{fb00}: 'ff' LatinSmallLigatureFf, /// \u{fb01}: 'fi' LatinSmallLigatureFi, /// \u{fb02}: 'fl' LatinSmallLigatureFl, ...
use crate::error::{Error, ErrorType}; use crate::json::{ParseTokens, StackTokens, JSON}; use crate::scanner::Scanner; pub fn validate_begin_object( json_document: &mut JSON, scanner: &mut Scanner, ) -> Result<(), ()> { match &json_document.last_parsed_token { Some(last_parsed_token) => match last_parsed_toke...
#![doc = "generated by AutoRust 0.1.0"] #![allow(unused_mut)] #![allow(unused_variables)] #![allow(unused_imports)] use super::{models, API_VERSION}; #[non_exhaustive] #[derive(Debug, thiserror :: Error)] #[allow(non_camel_case_types)] pub enum Error { #[error(transparent)] Service_GetProperties(#[from] service...
use std::sync::Arc; use rosu_v2::prelude::{Score, User}; use twilight_model::channel::Message; use crate::{embeds::RecentListEmbed, BotResult, Context}; use super::{Pages, Pagination}; pub struct RecentListPagination { ctx: Arc<Context>, msg: Message, pages: Pages, user: User, scores: Vec<Score>...
use crate::client::mix_traffic::MixMessage; use crate::client::topology_control::TopologyAccessor; use crate::client::InputMessage; use futures::channel::mpsc; use futures::task::{Context, Poll}; use futures::{Future, Stream, StreamExt}; use log::{error, info, trace, warn}; use sphinx::route::Destination; use std::pin:...
extern crate regex; use std::env; use std::net::IpAddr; use std::str::FromStr; #[derive(Debug)] pub enum RequestMethod { Invalid, Get, Post, } impl Default for RequestMethod { fn default() -> RequestMethod { RequestMethod::Invalid } } #[derive(Default, Debug)] pub struct Request { pub remote_ad...
use std::fs; fn parse(contents: &String) -> Vec<i64> { contents.lines() .map(|x| x.parse::<i64>().unwrap()) .collect() } fn is_ok(f: i64, arr: &[i64]) -> bool { for i in arr.iter() { for j in arr.iter() { if i + j == f { return true; } } } ...
//! Collect ISBNs from across the data sources. use std::collections::HashMap; use std::fmt::Debug; use std::fs::read_to_string; use serde::Deserialize; use toml; use friendly::bytes; use crate::ids::collector::KeyCollector; use crate::prelude::Result; use crate::prelude::*; use polars::prelude::*; /// Collect ISBN...
use crate::error::UdpError; use crate::state::State; use crate::audio::output::AudioOutputMessage; use futures_util::{SinkExt, StreamExt}; use log::*; use mumble_protocol::crypt::ClientCryptState; use mumble_protocol::voice::VoicePacket; use mumble_protocol::control::msgs::CryptSetup; use std::net::{Ipv6Addr, SocketAd...
pub mod codic;
pub const NAME: &'static str = "Audrey fforbes-Hamilton";
//! # 455. 分发饼干 //! https://leetcode-cn.com/problems/assign-cookies/ //! 假设你是一位很棒的家长,想要给你的孩子们一些小饼干。但是,每个孩子最多只能给一块饼干。 //! 对每个孩子 i,都有一个胃口值 g[i],这是能让孩子们满足胃口的饼干的最小尺寸;并且每块饼干 j,都有一个尺寸 s[j] 。 //! 如果 s[j] >= g[i],我们可以将这个饼干 j 分配给孩子 i ,这个孩子会得到满足。你的目标是尽可能满足越多数量的孩子,并输出这个最大数值。 //! # 解题思路 //! 排序后采用贪心规则,最小的饼干满足胃口最小的孩子 pub struct So...
use spair::prelude::*; pub struct Error<'a>(pub &'a spair::FetchError); impl<'a, C: spair::Component> spair::Render<C> for Error<'a> { fn render(self, nodes: spair::Nodes<C>) { nodes.div(|d| { d.nodes() .span(|s| s.nodes().render(&self.0.to_string()).done()); }); } }
use std::{ net::{IpAddr, Ipv6Addr}, usize, }; use serde::{Deserialize, Serialize}; #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] pub struct Config { pub ip: std::net::IpAddr, pub port: u16, pub max_length: u64, pub db_cache_capacity: u64, } impl Def...
fn main() { let index = 8; for index in 0..4 { print!("{} ", index); } println!(":{}", index); }
extern crate advent_of_code_2017_day_11; use advent_of_code_2017_day_11::*; #[test] fn part_1_example_1() { assert_eq!(solve_puzzle_part_1("ne,ne,ne"), "3"); } #[test] fn part_1_example_2() { assert_eq!(solve_puzzle_part_1("ne,ne,sw,sw"), "0"); } #[test] fn part_1_example_3() { assert_eq!(solve_puzzle_p...
//! DMA sink use imxrt_hal::{ dma::{Channel, Circular, Peripheral, WriteHalf}, iomuxc, uart::Tx, }; /// DMA output type Output<M> = Peripheral<Tx<M>, u8, Circular<u8>>; pub enum Sink { _1(Output<iomuxc::consts::U1>), _2(Output<iomuxc::consts::U2>), _3(Output<iomuxc::consts::U3>), _4(Outpu...
use std::env::args; use std::io; mod one; mod two; mod three; mod four; mod five; mod six; mod seven; mod eight; mod nine; mod ten; fn main() { let args: Vec<_> = args().collect(); if args.len() > 1 { let stdin = io::stdin(); let buf = stdin.lock(); match args[1].as_ref() { ...
use std::cmp; use crate::types::{Block, ColumnType}; pub struct ChunkIterator<'a, K: ColumnType> { position: usize, size: usize, block: &'a Block<K>, } impl<'a, K: ColumnType> Iterator for ChunkIterator<'a, K> { type Item = Block; fn next(&mut self) -> Option<Block> { let m = self.block....
#[doc = "Register `PTPSSIR` reader"] pub type R = crate::R<PTPSSIR_SPEC>; #[doc = "Register `PTPSSIR` writer"] pub type W = crate::W<PTPSSIR_SPEC>; #[doc = "Field `STSSI` reader - System time subsecond increment"] pub type STSSI_R = crate::FieldReader; #[doc = "Field `STSSI` writer - System time subsecond increment"] p...
fn main() { // Blocks of code associated with the conditions in if expressions are sometimes called arms, // just like the arms in match expressions let number = 6; if number % 4 == 0 { // the condition in if must be a bool println!("number is divisible by 4"); } else if number % 3 ...
pub mod client; pub mod parse_links; pub mod parse_media; pub mod parse_url;
use crate::token::{ TokenKind, Token }; /// Lexical Analyzer #[derive(Debug, Clone)] pub struct Lexier { input: String, position: usize, read_position: usize, ch: char, } impl Lexier { pub fn new(input: String) -> Lexier { let mut lexier: Lexier; lexier = Lexier { input: input, ...
#[macro_use] extern crate serde_derive; #[macro_use] extern crate gumdrop; extern crate cert_machine; extern crate openssl; mod arg_parser; mod config_parser; mod kubernetes_certs; use config_parser::User; use config_parser::Instance; use std::collections::HashMap; use std::io::Write; use std::os::unix::fs::symlink; ...
use crate::crypto::vss::Vss; use crate::net::SignerID; use crate::signer_node::BidirectionalSharedSecretMap; use crate::signer_node::SharedSecret; use crate::signer_node::SharedSecretMap; use curv::cryptographic_primitives::secret_sharing::feldman_vss::{ ShamirSecretSharing, VerifiableSS, }; use tapyrus::{PrivateKe...
use crate::error::{Error, ErrorType}; use crate::json::{general_tokens::*, ParseTokens, StackTokens, JSON}; use crate::scanner::Scanner; // Given the json_document structure where the iterator index is in the // start of a Unicode escape sequence values, i.e. X in \uXXXX, // get the decimal representation of the escap...
use std::error; use std::fmt; use std::io; fn read_and_validate(b: &mut io::BufRead) -> Result<PositiveNonzeroInterger, ???> { let mut line = String::new(); b.read_line(&mut line); let num: i64 = line.trim().parse(); let answer = PositiveNonzeroInterger::new(num); answer } fn test_with_str(s: &st...
use crate::prelude::*; use crate::util; use std::cell::RefCell; use std::rc::Rc; use std::sync::{Arc, Mutex}; #[derive(Default, Clone)] pub struct Subject<O, S> { pub(crate) observers: O, pub(crate) subscription: S, } pub type LocalObserver<P> = Rc<RefCell<Vec<P>>>; pub type LocalSubject<'a, Item, Err> = Subje...
use std::cell::{self, RefCell}; use std::collections::HashMap; use std::fmt::{self, Debug}; use std::io::{self, ErrorKind}; use std::net::SocketAddr; use std::rc::Rc; use std::time::{Duration, Instant}; use futures::{Async, Future, Poll, Stream}; use mio::{Ready, SetReadiness}; use tokio_core::reactor::Timeout; use s...
use math::*; use num::*; use std::ops::*; use std::cmp::*; use std::fmt::*; pub enum MatrixResult<T> { Done(Matrix<T>), Error, } /// Some common functions for result checking. impl<T> MatrixResult<T> { /// Unwraps the value inside of a MatrixResult. If no value exists, the function panics. pub fn unwr...
{ "id": "4c78decb-7c29-4951-af2e-6a99ea5d7f79", "$type": "NestingPartResource", "Part": { "$type": "ResourcePart", "IntField": "1231", "StringField": "asdads" } }
use std::collections::HashSet; use std::result; use async_trait::async_trait; use regex::{Error, Regex}; use serde::{Deserialize, Serialize}; use serde_with::with_prefix; use tracing::instrument; use crate::config::DataServerConfig; use crate::storage::local::LocalStorage; #[cfg(feature = "s3-storage")] use crate::st...
/////////////////////////////////////////////////////////////////////////////// // // Copyright 2018-2019 Airalab <research@aira.life> // // 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...
mod layout; use std::io; use std::time::Duration; pub use std::thread::JoinHandle; use super::{Backend, Key, StdinReader, Terminal}; use crate::util::future::abortable::AbortHandle; pub use crate::modules::{ beatport::tui::Widget as BeatportWidget, bandcamp::tui::Widget as BandcampWidget, slider::tui::Widget as Sl...
#[derive(Debug)] pub enum Error { NetworkError(reqwest::Error), MalformedResponse(serde_json::error::Error), } impl From<reqwest::Error> for Error { fn from(error: reqwest::Error) -> Self { Error::NetworkError(error) } } impl From<serde_json::error::Error> for Error { fn from(error: serde_...
use sudo_test::{Command, Env, User}; use crate::{Result, PASSWORD, USERNAME}; #[test] fn etc_security_limits_rules_apply_according_to_the_target_user() -> Result<()> { let target_user = "ghost"; let original = "2048"; let expected = "1024"; let limits = format!( "{USERNAME} hard locks {origina...
use std::io; fn main() { let mut input = String::new(); println!("Input a char sequence to be evaluated..."); match io::stdin().read_line(&mut input) { Ok(_) => { let trimmed_input = input.trim().to_string(); let result = is_palindrome(trimmed_input); println!("I...
use std::convert::TryInto; use syn::parse::{Parse, ParseStream}; use syn::{Error, Result, Type}; use syn::{LitInt, Token}; use crate::glsl::{Glsl, GlslLine}; use crate::yasl_ident::YaslIdent; use crate::yasl_type::YaslType; #[derive(Debug)] enum LayoutKind { Input, Output, } impl From<&LayoutKind> for Glsl ...
#[derive(Debug, Clone, PartialEq)] pub enum DbPrivilege { CanRead, CanWrite, } #[derive(Debug, Clone)] pub struct User { pub username: String, pub password: String, pub privileges: Vec<DbPrivilege>, } impl Default for User { fn default() -> Self { Self { username: String::d...
use super::*; use log::debug; use opencv::{core::Mat as OpencvMat, core::Point as OpencvPoint, prelude::MatTrait}; use std::marker::PhantomData; pub mod convert_color; pub mod draw; pub mod filter; #[derive(Debug)] pub struct Mat<ColorSpace> { inner: OpencvMat, n_rows: i32, n_cols: i32, _type: Phantom...
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under both the MIT license found in the * LICENSE-MIT file in the root directory of this source tree and the Apache * License, Version 2.0 found in the LICENSE-APACHE file in the root directory * of this source tree. */ use b...
use std::path::Path; use nes::{LoadError, Emulator, StandardInput}; use sdl2::pixels::Color; use sdl2::event::Event; use sdl2::rect::Rect; use sdl2::keyboard::Keycode; use sdl2::audio::{AudioQueue, AudioSpecDesired}; use std::time::Duration; pub struct GuiObject { emulator: Emulator, save_slot: Option<Vec<u...
#![allow(dead_code)] #![cfg_attr(feature = "cargo-clippy", allow(clippy))] pub(crate) use self::root::tflite::*; pub(crate) use self::root::*; include!(concat!(env!("OUT_DIR"), "/tflite_types.rs"));
//! Renderer use crate::scan::ScanlineU8; use crate::base::RenderingBase; use crate::color::Rgba8; use crate::POLY_SUBPIXEL_SCALE; use crate::POLY_SUBPIXEL_MASK; use crate::POLY_SUBPIXEL_SHIFT; use crate::POLY_MR_SUBPIXEL_SHIFT; use crate::MAX_HALF_WIDTH; use crate::line_interp::LineParameters; use crate::line_interp...
// Copyright (c) 2016, <daggerbot@gmail.com> // This software is available under the terms of the zlib license. // See COPYING.md for more information. use winapi; use pixel_format::PixelFormatBridge; use util; /// Windows implementation for `PixelFormat`. #[derive(Clone)] pub struct PixelFormatProvider {...
pub fn read_clock_counter() -> u64 { unsafe { x86::time::rdtscp() } }
use super::{chunk_header::*, chunk_type::*, *}; use crate::param::{param_header::*, param_type::*, *}; use bytes::{Bytes, BytesMut}; use std::fmt; ///chunkHeartbeat represents an SCTP Chunk of type HEARTBEAT /// ///An endpoint should send this chunk to its peer endpoint to probe the ///reachability of a particular de...
/// varibles fn immutable_test() { let x = 5; // println! is a macro println!("The value of x is: {}", x); // can not assign twice to immutable varible x // x = 4; // println!("The new value of x is {}", x); } fn mutable_test() { let mut x = 5; println!("The value of x is: {}", x); ...
#[macro_use] extern crate clap; mod lib; mod cli; fn main() { let matches = cli::build_cli().get_matches(); let opt_name = matches.value_of("name"); let message = lib::build_message(opt_name); println!("{}", message); }
#![allow(dead_code)] use image; use glium::texture::Texture2d; use glium::Display; use std::collections::HashMap; use image::{ImageBuffer, Rgb, Rgba}; pub fn load(path: String, disp: &Display) -> Texture2d{ use std::path::Path; use glium::texture::RawImage2d; let img = image::open(Path::new(&path)).unwr...
pub fn run() { //Print to console println!("Hola desde el archivo print.rs"); // Basic Formatting println!("{} es de {}","Moises", "Ensenada"); //Positional Arguments println!("{0} es de {1} y a {0} le gusta {2}", "Moises", "Ensenada", "programar" ); // Named Arguments println!("{name...
use crate::client::Client; use serde::{Deserialize, Serialize}; use serde_json::Value; use crate::Error; use futures::compat::Future01CompatExt; use serde::de::DeserializeOwned; /// A request to retrieve a document from a CouchDB database. /// /// The request is lazy- it doesn't do a thing until you call its '[send](...
use std::time::Instant; use indicatif::{ProgressBar, ProgressStyle}; use minifier; use std::{ fs::File, io::{Read, Write}, path::Path, }; use walkdir::WalkDir; use flate2::write::GzEncoder; use flate2::Compression; enum SourceType { Css, Js, Json, } use std::{fs, io, path::PathBuf}; fn dir_...
mod commitfs; pub use commitfs::*;