text
stringlengths
8
4.13M
#![allow(dead_code)] #![allow(unused_variables)] fn ifstatement(){ let temp = 15; if temp > 30{ println!("hawt"); } else if temp < 10{ print!("coldlol"); } else { println!("ok"); } let day = if temp > 20{"sunny!"} else{"cloudy"}; //if statement can be ex...
/// Constructs a new `Rc<T>` /// /// # Examples /// /// ``` /// use std::rc::Rc; /// /// let five = Rc::new(5); /// ``` /// /// ``` /// Simple `&str` patterns: /// /// ``` /// let v: Vec<&str> = "Mary had a little lamb".split(' ').collect(); /// assert_eq!(v, vec!["Mary", "had", "a", "little", "lamb"]); /// ``` /// ///...
use std::{ cmp::min, io, io::{BufReader, Read, Seek, SeekFrom}, }; pub struct ByteChunkIter<R> { pub start_byte_index: usize, end_byte_index_exclusive: usize, current_byte_index: usize, pub chunk_size: usize, buf: BufReader<R>, } impl<R: Seek> ByteChunkIter<R> { pub fn new( ...
use crate::{grammar::Parser, SyntaxKind::*, T}; use super::ty_name; pub(crate) fn gen_arg_list(p: &mut Parser) { let m = p.start(); p.bump(T![<]); ty_name(p); while p.eat(T![,]) { ty_name(p); } p.expect(T![>]); m.complete(p, GENERIC_ARG_LIST); }
extern crate cargo_submodules_test; fn main() { println!("{:?}", cargo_submodules_test::foo()); }
use super::ByteRecord; use crate::{ array::{Primitive, PrimitiveArray}, datatypes::*, types::NativeType, }; pub trait PrimitiveParser<T: NativeType + lexical_core::FromLexical, E> { fn parse(&self, bytes: &[u8], _: &DataType, _: usize) -> Result<Option<T>, E> { // default behavior is infalible...
use proconio::input; fn main() { input! { n: usize, a: [u32; n], }; let ans = a.iter().sum::<u32>(); println!("{}", ans); }
// These are common OSM keys. Keys used in just one or two places don't really need to be defined // here. // These're normal OSM keys. pub const NAME: &str = "name"; pub const HIGHWAY: &str = "highway"; pub const MAXSPEED: &str = "maxspeed"; // The rest of these are all inserted by A/B Street to plumb data between d...
//! Tests auto-converted from "sass-spec/spec/selector-functions/is_superselector" #[allow(unused)] use super::rsass; #[allow(unused)] use rsass::set_precision; /// From "sass-spec/spec/selector-functions/is_superselector/any_is_not_superselector_of_different_prefix" #[test] fn any_is_not_superselector_of_different_pr...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[cfg(feature = "ApplicationModel_ExtendedExecution_Foreground")] pub mod Foreground; #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :...
use rmps; use rocksdb::{Error, DB}; use std::boxed::Box; use std::collections::HashMap; use std::option::Option; #[derive(Serialize, Deserialize, Debug, Clone)] pub enum ColumnDataType { Int(String), Text(String), } impl ColumnDataType { pub fn get_name(&self) -> &String { match self { ...
use sdl2; use sdl2::controller::Button; use sdl2::event::{Event, EventType as SdlEventType}; use sdl2::keyboard::Keycode; use sdl2::mouse::{MouseButton as SdlMouseButton, MouseUtil}; use sdl2::EventPump; use sdl2::EventSubsystem; use sdl2::GameControllerSubsystem; use sdl2::Sdl; use utilities::prelude::*; use std::op...
use crate::common::{ListenerId, NetError, NetProtocol, Port, SocketAddress, SocketId}; // Socket events /// An event that is sent whenever a socket should be opened /// The `port` field must be specified when using UDP #[derive(Debug, Clone)] pub struct OpenSocket { pub new_id: SocketId, pub remote_address: S...
#[doc = "Reader of register IC"] pub type R = crate::R<u32, super::IC>; #[doc = "Writer for register IC"] pub type W = crate::W<u32, super::IC>; #[doc = "Register IC `reset()`'s with value 0"] impl crate::ResetValue for super::IC { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { ...
#[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::RXCSRH6 { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'...
use std::fmt::Display; use data_types::{CompactionLevel, ParquetFile, Timestamp}; use crate::{ components::split_or_compact::start_level_files_to_split::{ merge_small_l0_chains, split_into_chains, }, RoundInfo, }; use super::DivideInitial; #[derive(Debug, Default)] pub struct MultipleBranchesDiv...
use std::io; use std::io::prelude::*; use std::str; use std::fmt; use std::net::{Ipv4Addr, TcpStream, UdpSocket}; use std::time::{Instant, Duration}; #[derive(Debug,PartialEq,Clone)] pub struct Board { pub ip: Ipv4Addr, pub mac: [u8; 6], } pub fn autodiscover() -> io::Result<Vec<Board>> { let mut boards: ...
// Copyright (c) The diem-devtools Contributors // SPDX-License-Identifier: MIT OR Apache-2.0 use crate::{ output::OutputFormat, reporter::Color, test_filter::{FilterMatch, TestFilterBuilder}, }; use anyhow::{anyhow, Context, Result}; use camino::{Utf8Path, Utf8PathBuf}; use duct::cmd; use once_cell::sync:...
// Cloning when Handling an Option or a Result pub struct large_string_vec { // we may have a "String" in a specific position collection: Vec<(char, Option<String>)>, } // error impl impl large_string_vec { pub fn error_unwrap(&mut self) -> Result<(), char> { for iterm in &self.collection { ...
#[macro_use] mod common; use common::util::*; static UTIL_NAME: &'static str = "ln"; #[test] fn test_symlink_existing_file() { let (at, mut ucmd) = testing(UTIL_NAME); let file = "test_symlink_existing_file"; let link = "test_symlink_existing_file_link"; at.touch(file); let result = ucmd.args...
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). pub mod structs; use icu_datetime::options::{length, DateTimeFormatOptions}; use std::fs::File; use std::io::BufRead...
macro_rules! say_hello { // `()` menandakan bahwa macro tidak punya arg () => { println!("Hello world!"); }; } fn main() { println!("Hello world!"); say_hello!(); }
use std::cmp::Ordering; use std::vec::Vec; // Implements sequential search with a search key as a sentinel // Input: An array a of n elements and a search key k // Output: The index of the first element in a[0..n-1] whose value is equal to k // or -1 if no such element is found fn sequential_search_2(a: &[u8], k: u...
use chrono::{prelude::*, Duration}; use juniper::{execute_sync, EmptyMutation, EmptySubscription, Variables}; #[derive(juniper::GraphQLScalarValue)] struct SampleDate(DateTime<Utc>); struct Query; #[juniper::graphql_object(context = Context)] impl Query { fn now() -> SampleDate { SampleDate(Utc::now()) ...
use crate::lint::core::Filter; pub mod filter_nothing; pub mod filter_test; pub fn get_all_filters() -> Vec<Box<dyn Filter>> { vec![Box::new(filter_test::TestModuleFilter)] }
// revisions: base nll // ignore-compare-mode-nll //[nll] compile-flags: -Z borrowck=mir use std::any::Any; fn foo<T: Any>(value: &T) -> Box<dyn Any> { Box::new(value) as Box<dyn Any> //[base]~^ ERROR E0759 //[nll]~^^ ERROR lifetime may not live long enough } fn main() { let _ = foo(&5); }
extern crate itertools; use std::fs::File; use std::io::BufReader; use std::io::BufRead; use std::collections::HashSet; use itertools::Itertools; #[derive(PartialEq, Eq, Hash, Clone)] struct Coord { x: i32, y: i32, } fn step(lights: &HashSet<Coord>) -> HashSet<Coord> { let mut new_state: HashSet<Coord> =...
use std::env; fn main() { let zmq_has = match env::var("ZMQ_HAS") { Ok(value) => value, Err(..) => panic!("Please set the ZMQ_HAS environment variable (e.g. \"ipc,pgm,tipc,norm,curve,gssapi\")") }; println!("rerun-if-env-changed=ZMQ_HAS"); for has in zmq_has.split(",") { print...
use std::cmp::{max, min}; use std::collections::{HashMap, HashSet}; use itertools::Itertools; use whiteread::parse_line; fn main() { let (n, m): (usize, usize) = parse_line().unwrap(); let mut paths: Vec<Vec<usize>> = vec![vec![]; n + 1]; for _ in 0..m { let (a, b): (usize, usize) = parse_line().u...
#[cfg(test)] mod contract;
use crate::protocol::parts::{ExecutionResult, ServerError}; // use std::backtrace::Backtrace; use thiserror::Error; /// A list specifying categories of [`HdbError`](crate::HdbError). /// #[derive(Error, Debug)] //Copy, Clone, Eq, PartialEq, #[non_exhaustive] pub enum HdbError { /// Deserialization of a `ResultSet`...
/// Generates permutation of numbers passed. /// [1, 2, 3] -> [123, 132, 213, 231, 312, 321] pub fn nums_10(nums: Vec<u32>) -> Vec<u32> { let numlen = nums.len(); if numlen == 1 { nums } else { let mut sols = vec![]; for (index, number) in nums.iter().enumerate() { let ...
use codec::Encode; use pallet_mixnet::types::{ Ballot, DecryptedShare, DecryptedShareProof, NrOfShuffles, PublicKey as SubstratePK, PublicKeyShare, PublicParameters, Title, Topic, TopicId, TopicResult, VoteId, VotePhase, }; use substrate_subxt::{Call, EventsDecoder, NodeTemplateRuntime}; #[derive(Encode)] pub ...
// // This file contains common utilities for dealing with PostgreSQL WAL files and // LSNs. // // Many of these functions have been copied from PostgreSQL, and rewritten in // Rust. That's why they don't follow the usual Rust naming conventions, they // have been named the same as the corresponding PostgreSQL function...
//! Local filesystem relish storage. //! //! Page server already stores layer data on the server, when freezing it. //! This storage serves a way to //! //! * test things locally simply //! * allow to compabre both binary sets //! * help validating the relish storage API use std::{ future::Future, path::{Path,...
use std::fs::File; use std::io::prelude::*; use std::env; fn main() -> std::io::Result<()> { let args: Vec<String> = env::args().collect(); let mut contents = String::new(); for arg in &args[1..] { let mut _fichier = match File::open(&arg){ Ok(_e) => { let mut _file = Fi...
use std::io::Read; use rand::rngs::StdRng; use rand::{RngCore, SeedableRng}; pub struct Reader(StdRng); impl Read for Reader { fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> { self.0.fill_bytes(buf); Ok(buf.len()) } } impl Reader { pub fn new(s: u64) -> Self { Self(...
#[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - SCT configuration register"] pub config: CONFIG, #[doc = "0x04 - SCT control register"] pub ctrl: CTRL, #[doc = "0x08 - SCT limit register"] pub limit: LIMIT, #[doc = "0x0c - SCT halt condition register"] p...
use super::VarResult; use crate::ast::stat_expr_types::VarIndex; use crate::ast::syntax_type::SyntaxType; use crate::helper::ensure_srcs; use crate::helper::{ move_element, pine_ref_to_bool, pine_ref_to_color, pine_ref_to_f64, pine_ref_to_i64, pine_ref_to_string, }; use crate::runtime::context::{downcast_ctx, C...
//! ECDSA tests mod p256; mod p384; #[macro_export] macro_rules! ecdsa_tests { ($signing_key:ty, $verifying_key:ty, $test_vectors:expr) => { fn example_signing_key() -> $signing_key { let vector = $test_vectors[0]; // Add SEC1 tag byte let mut pk = vec![0x04]; ...
use crate::RpcContext; use anyhow::{anyhow, Context}; use pathfinder_common::BlockId; #[derive(serde::Deserialize, Debug, PartialEq, Eq)] pub struct GetStateUpdateInput { block_id: BlockId, } crate::error::generate_rpc_error_subset!(GetStateUpdateError: BlockNotFound); pub async fn get_state_update( context:...
use ash::extensions::{ext, khr}; use ash::version::{EntryV1_0, InstanceV1_0}; use ash::{self, vk}; use lazy_static::lazy_static; use parking_lot::{RwLock, RwLockReadGuard}; use std::ffi::CStr; use std::fmt; use std::mem; use std::sync::Arc; use crate::imp::{debug, AdapterInner, InstanceExt, InstanceInner, SurfaceInn...
#[derive(Clone, Copy)] pub enum Controller { Invalid, Auto, Handheld, Player(u8), } pub enum Key { None, A = 1, B = 2, X = 4, Y = 8, LStick = 16, RStick = 32, L = 64, R = 128, ZL = 256, ZR = 512, Plus = 1024, Minus = 2048, DPadRight = 16384, ...
pub fn zeros1d(size: u32) -> Vec<f64> { vec![0.0 size as usize] } pub fn zeros2d(size1: u32, size2: u32) -> Vec<Vec<f64>> { vec![vec![0.0; size2 as usize]; size1 as usize] }
#[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::_3_GENA { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, ...
// Copyright 2018 The Rio Advancement Inc // //! A module containing the middleware of the HTTP server use std::str; use rand::{self, Rng}; use error::{Result, Error}; use handlebars::Handlebars; use failure::SyncFailure; use config; use lib_load; /// path where the .so file stored const ROOT_PATH: &'static str = "...
fn no_large_group(pw: &[u8]) -> bool { let mut last = pw[0]; let mut last_count = 1; for &p in &pw[1..] { if p == last { last_count += 1; } else { if last_count == 2 { return true; } last = p; last_count = 1; ...
#[path = "insert_before_3/with_nil_reference_child_appends_new_child.rs"] pub mod with_nil_reference_child_appends_new_child; #[path = "insert_before_3/with_reference_child_inserts_before_reference_child.rs"] pub mod with_reference_child_inserts_before_reference_child; use super::*; use wasm_bindgen::JsCast; use js_...
//required in order for near_bindgen macro to work outside of lib.rs use crate::domain::RegisteredAccount; use crate::errors::account_management::ACCOUNT_NOT_REGISTERED; use crate::*; use crate::{ core::Hash, domain::{Account, YoctoNear}, errors::account_management::{ ACCOUNT_ALREADY_REGISTERED, INS...
use crate::{ event::metric::{Metric, MetricKind, MetricValue}, shutdown::ShutdownSignal, topology::config::{DataType, GlobalOptions, SourceConfig, SourceDescription}, Event, }; use chrono::Utc; use futures::{ compat::Future01CompatExt, future::{FutureExt, TryFutureExt}, stream::StreamExt, };...
use pickledb::{PickleDb, PickleDbDumpPolicy, SerializationMethod}; use std::time::Duration; use std::{thread, time}; mod common; #[cfg(test)] extern crate rstest; use rstest::rstest_parametrize; #[rstest_parametrize(ser_method_int, case(0), case(1), case(2), case(3))] fn auto_dump_policy_test(ser_method_int: i32) {...
use crate::decode::Decode; use crate::encode::{Encode, IsNull}; use crate::error::BoxDynError; use crate::mssql::io::MssqlBufMutExt; use crate::mssql::protocol::type_info::{Collation, CollationFlags, DataType, TypeInfo}; use crate::mssql::{Mssql, MssqlTypeInfo, MssqlValueRef}; use crate::types::Type; use std::borrow::C...
fn main() { // This test validates that IMap pulls in its dependencies including IIterator and IKeyValuePair. // This is a particularly interesting test because IMap only mentions IKeyValuePair indirectly // through its interface requirement on the specialization of IIterable. windows::core::build_legac...
extern crate pest; #[macro_use] extern crate pest_derive; use parser::parse; use std::env; use std::fs::File; use std::io::prelude::*; use tokenizer::tokenize; mod tokenizer; mod parser; mod stdlib; fn main() { let args: Vec<String> = env::args().collect(); if args.get(0).is_none() { eprintln!("Please provi...
//error-pattern:no clauses match fn main() { #macro([#trivial(), 1*2*4*2*1]); assert(#trivial(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) == 16); }
use super::ast_utils::*; use super::type_printer::print_type; pub fn print_at_depth (s: String, depth: isize) { let mut str = String::from(""); for _ in 0..depth * 4 { str += &String::from(" "); } str += &s; eprintln!("{}", str); } pub fn print_ast_node (node: &ASTNode, depth: isize) { ...
fn main() { println!("Damn, that's so cool!"); }
#[cfg(feature = "ffi")] use std::env; fn main() { #[cfg(feature = "ffi")] link_search(); } #[cfg(feature = "ffi")] fn link_search() { let manifest = env!("CARGO_MANIFEST_DIR"); if cfg!(target_os = "windows") { println!(r"cargo:rustc-link-search={}/libraries/Win/x64", manifest); } else if cfg!...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtWidgets/qdialogbuttonbox.h // dst-file: /src/widgets/qdialogbuttonbox.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // mai...
// Copyright (c) 2016 DWANGO Co., Ltd. All Rights Reserved. // See the LICENSE file at the top-level directory of this distribution. //! Fiber related components (for developers). //! //! Those are mainly exported for developers. //! So, usual users do not need to be conscious. use std::fmt; use std::sync::Arc; use st...
use std::fmt; use std::time::Duration; use hyper::Client; use hyper::Url; use hyper::header::Connection; use hyper::status::StatusCode; use hyper::client::RedirectPolicy; use stopwatch::Stopwatch; use time::Duration as TimeDuration; #[derive(Debug, Eq, PartialEq)] pub enum StatusOrError { Status(StatusCode), ...
use crate::{types::*, utils::regex::SerializeRegex}; use enum_dispatch::enum_dispatch; use lazy_static::lazy_static; use serde::{Deserialize, Serialize}; use unicase::UniCase; #[derive(Debug, Serialize, Deserialize)] pub struct Matcher { pub matcher: either::Either<either::Either<String, GraphId>, SerializeRegex>,...
use crate::schema::u_user; /// User flag pub enum UserFlag { /// 是否启用 Enabled = 1, /// 是否激活 Activated = 2, /// 是否为超级用户 SuperUser = 4, } #[derive(Queryable, Insertable, AsChangeset, Debug, Clone, Serialize, Deserialize)] #[table_name = "u_user"] #[primary_key("id")] #[changeset_for(u_users)] pu...
use std::{ borrow::Cow, collections::{hash_map::RandomState, HashMap}, hash::{BuildHasher, Hash}, marker::PhantomData, }; /// Factory for creating cache storage. pub trait CacheFactory: Send + Sync + 'static { /// Create a cache storage. /// /// TODO: When GAT is stable, this memory allocat...
use std::iter::FromIterator; use heck::CamelCase; use proc_macro2::TokenStream; use quote::{format_ident, quote, quote_spanned}; use syn::spanned::Spanned; use crate::{error::Error, util::ProcMacro}; pub struct ProtobufService { ident: syn::Ident, input: syn::ItemImpl, items: Vec<syn::ImplItem>, } struc...
use crate::{ widgets::{pod::WidgetPod, TypedWidget}, Backend, }; pub trait BoxComponent<T, B: Backend>: TypedWidget<T, B> + Sized + 'static {} pub trait Component<T, B: Backend> { fn component(self) -> WidgetPod<T, B>; }
pub mod choice; pub mod history; pub mod strategy; use choice::*; use history::*; use strategy::*; /// Game holds the data for a sequence of encounters between two strategies. pub struct Game { rounds: usize, h1: History, h2: History, } impl Game { pub fn new(rounds: usize) -> Self { Game { ...
use std::collections::{HashSet}; #[cfg(test)] mod tests { use super::*; #[test] fn basic() { assert_eq!(center_intersect_distance( parse("R8,U5,L5,D3"), parse("U7,R6,D4,L4"), ), 6); assert_eq!(center_intersect_distance( parse("R75,D30,R83,U83,L12...
// 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. //! AccountManager manages the overall state of Fuchsia accounts and personae on //! a Fuchsia device, installation of the AuthProviders that are used to o...
use std::any::Any; use std::ops::{Bound, RangeBounds}; use crate::mutators::integer::{ binary_search_arbitrary_u16, binary_search_arbitrary_u32, binary_search_arbitrary_u64, binary_search_arbitrary_u8, }; use crate::Mutator; const INITIAL_MUTATION_STEP: u64 = 0; macro_rules! impl_int_mutator_constrained { ($n...
mod lib; use lib::queue::*; fn main() { let mut queue = Queue::<i32>::new(16); queue.add(3); queue.add(2); queue.add(1); let peek = match queue.peek() { Ok(x) => x, Err(_e) => 0, }; println!("peek = {:?}", peek); let res = match queue.remove() { Ok(res) => res, ...
fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let n: usize = rd.get(); let q: usize = rd.get(); let edges: Vec<(usize, usize)> = (0..(n - 1)) .map(|_| { let a: usize = rd.get(); let b: usize = rd.get(); (a - 1, b ...
#![feature(test, plugin, decl_macro)] #![plugin(rocket_codegen)] extern crate rocket; extern crate rocket_contrib; extern crate rust_embed; use std::path::PathBuf; use std::ffi::OsStr; use std::io::Cursor; use rocket::response; use rocket::http::{ContentType, Status}; use rocket::State; use rust_embed::*; #[get("/")]...
use ggez::graphics::spritebatch::SpriteBatch; use ggez::graphics::{Color, DrawMode, DrawParam, Drawable, Mesh, Point2, Rect}; use ggez::{Context, GameResult}; use grid; use hexadventure::prelude::*; use hexadventure::world::mob; pub const WIDTH: u32 = 24; pub struct Sidebar {} impl Sidebar { pub fn new() -> Self...
//! Framing for the TNC control protocol //! use std::string::String; use bytes::{Buf, BytesMut}; use futures_codec::{Decoder, Encoder}; use crate::protocol::response::Response; /// Frames and sends TNC control messages pub struct TncControlFraming {} impl TncControlFraming { /// New TNC control message framer ...
#![allow(dead_code)] fn main() { #[cfg(windows)] win_link_libs(); } fn win_link_libs() { println!("cargo:rustc-link-lib=ws2_32"); println!("cargo:rustc-link-lib=netapi32"); println!("cargo:rustc-link-lib=version"); }
mod attributes; pub use attributes::*; mod properties; pub use properties::*; mod tags; pub use tags::*; /// An HTML element. #[derive(Clone)] pub struct El { pub name: String, pub is_text: bool, pub paired: bool, pub attributes: Vec<Attr>, pub style: Vec<Prop>, pub content: Vec<El>, } impl El { ...
// Copyright 2018 Grove Enterprises LLC // // 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 ...
use core::str::from_utf8; use crate::errors::{Error, RnResult}; /// Convert a byte to a decimal string. /// /// If the buffer is too small, `Error::BadParameter` is returned. pub(crate) fn u8_to_str<S>(val: u8, buf: &mut [u8]) -> RnResult<&str, S> { let chars = match val { 0..=9 => 1, 10..=99 => 2...
use block_device::BlockDevice; use super::partition::Partition; use collections::vec::*; const PARTITION_TABLE_OFFSET: usize = 0x01BE; pub struct MbrDeviceDriver<'a> { first_partition: Partition<'a>, } impl<'a> MbrDeviceDriver<'a> { pub fn new(block_device: &'a BlockDevice) -> MbrDeviceDriver<'a> { i...
pub struct WorkoutPlan { pub id: String, pub name: String, pub start_date: String, pub end_date: String, pub workout_ids: Vec<String>, }
use std::cmp::Ordering; use super::snowflake::ProcessUniqueId; use super::*; /// /// A `Tree` builder that provides more control over how a `Tree` is created. /// pub struct TreeBuilder<T> { root: Option<Node<T>>, node_capacity: usize, swap_capacity: usize, } impl<T> TreeBuilder<T> { /// /// Crea...
#[doc = "Reader of register AHB1ENR"] pub type R = crate::R<u32, super::AHB1ENR>; #[doc = "Writer for register AHB1ENR"] pub type W = crate::W<u32, super::AHB1ENR>; #[doc = "Register AHB1ENR `reset()`'s with value 0x0100"] impl crate::ResetValue for super::AHB1ENR { type Type = u32; #[inline(always)] fn res...
use serde::Serialize; use tide::{Body, Request}; #[derive(Debug, Serialize)] struct Item { name: String, value: i32, } #[async_std::main] async fn main() -> tide::Result<()> { let mut app = tide::new(); app.at("/items").get(find_items); app.listen("127.0.0.1:8080").await?; Ok(()) } async ...
// 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 ...
#![feature(plugin)] #![plugin(rocket_codegen)] #![feature(plugin, custom_derive, const_fn)] #![plugin(rocket_codegen)] extern crate rocket; #[macro_use] extern crate diesel; extern crate dotenv; extern crate r2d2; extern crate r2d2_diesel; pub mod schema; use diesel::pg::PgConnection; use r2d2::{ Pool, Config }; us...
// auto generated, do not modify. // created: Wed Jan 20 00:44:03 2016 // src-file: /QtQml/qqmlcomponent.h // dst-file: /src/qml/qqmlcomponent.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin ...
use crate::db::Message; use hyper::{ Body, Request, Response, }; use routerify::{ Middleware, Router, RouterBuilder, ext::RequestExt, RequestInfo }; use anyhow::{Error, Result}; use tracing::{info, error}; use tokio::sync::mpsc::Sender; mod api; async fn logger(req: Request<Body>) -> R...
//! Prints counter manipulation methods. use crate::ir; use crate::print; use proc_macro2::TokenStream; use quote::quote; /// Prints the value of a counter increment. If `use_old` is true, only takes into account /// decisions that have been propagated. pub fn increment_amount( value: &ir::CounterVal, use_old:...
pub mod oauth1;
use crate::AST; use std::collections::HashMap; #[derive(Debug, Clone)] pub struct Env { vars: HashMap<EnvKey, AST>, natives: HashMap<String, fn(Vec<AST>) -> Result<AST, String>>, frames: u8, debug: bool, } #[derive(Debug, Clone, Hash, PartialEq, Eq)] struct EnvKey { frame: u8, name: String, } ...
pub struct Stride<I> { iter: I, stride: usize, } impl<I> Iterator for Stride<I> where I: Iterator { type Item = I::Item; #[inline] fn next(&mut self) -> Option<I::Item> { let ret = self.iter.next(); if self.stride > 1 { self.iter.nth(self.stride - 2); } ...
use std::env::args; use std::path::Path; use std::fmt::Display; use std::io::Error; use walkdir::WalkDir; use histo::Histogram; fn process_entry(histogram: &mut Histogram, entry: &walkdir::DirEntry) -> Result<(), Error> { if entry.file_type().is_file() { let mut count = 0; for fe in fiemap::fiemap(entry.pat...
/// detekuje číslo na obrázku, viz zadání /// před kompilací je potřeba nainstalovat tesseract tak, /// aby libleptonica a libtesseract byly v PATH /// a nainstalovat ces language pack pro tesseract /// /// ### Kompilace: /// ```bash /// cargo build --release /// ``` /// Binární soubor bude target/release/odmociny /// ...
pub use VkDebugReportObjectTypeEXT::*; #[repr(u32)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum VkDebugReportObjectTypeEXT { VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT = 0, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT = 1, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT = 2, VK_DEBUG_REPORT_OBJECT_T...
// xfail-boot // error-pattern: cyclic import import zed.bar; import bar.zed; fn main(vec[str] args) { log "loop"; }
pub mod exam_service; pub mod student_answer_service; pub mod student_exam_service;
use std::fmt::Debug; use crate::util::AsAny; use self::conversion::{AsEvent, AsNetworkEvent}; use self::util::CloneableEvent; pub trait Event: AsAny + AsEvent + AsNetworkEvent + Debug + Send { } #[typetag::serde(tag = "event")] pub trait NetworkEvent: CloneableEvent + Event { } impl<T: 'static + NetworkEvent> Event...
use rlb::backend::{Backend, BackendError, BackendPool}; use rlb::balancing::RoundRobinBalancing; use std::sync::atomic::Ordering; #[test] fn backend_new_test() { let backend = Backend::new(String::from(":5000"), Some(String::from("/health"))); assert_eq!(backend.alive.load(Ordering::Acquire), false); asser...
#[cfg(target_arch = "aarch64")] fn main() { // TODO: compile the ffi file in here"; println!("cargo:rustc-link-search=native=armffi/lib"); println!("cargo:rustc-link-lib=static=armffi"); } #[cfg(target_arch = "x86_64")] fn main() { }