text
stringlengths
8
4.13M
fn fib(z:&i32){ let mut a:i32 = 0; let mut b:i32 = 1; let mut c:i32 = 0; println!("{} \n{}",&a,&b); for _g in 0..*z-2{ c = a+b; print!("{} \n",c); a=b; b=c; } } fn main(){ let x:i32 = 10; fib(&x); }
use flatc_rust; use std::path::Path; fn main() { //let out_dir = env::var("OUT_DIR").unwrap(); let out_dir = "target"; let out_path = format!("{}/a19_data_persist/message/", out_dir); println!( "{}", format!( "cargo:rerun-if-changed={}/a19_data_persist/message/persisted_file...
// Hack of a crate until rust-lang/rust#51647 is fixed #![feature(no_core, panic_implementation)] #![no_core] extern crate core; #[panic_implementation] fn panic(_: &core::panic::PanicInfo) -> ! { loop {} }
use async_trait::async_trait; use serde::{Deserialize, Serialize}; use uuid::Uuid; pub type ObjectId = Uuid; #[async_trait] pub trait PersistenceManager { type Error: Send + Sync; async fn get_by_id<T>(&'async_trait self, id: ObjectId) -> Result<T, Self::Error> where T: Persistent + Deserialize<'...
use async_std::net::{SocketAddr, ToSocketAddrs}; use async_std::task; use regex::Regex; pub trait ToPqConfig { fn to_pq_config(&self) -> Result<PqConfig, ConfParseError>; } #[derive(Debug)] pub struct PqConfig { pub address: SocketAddr, pub cred: Option<Credential>, pub dbname: Option<String>, } #[de...
use rustlearn::ownership_demo::{complex_ownership_demo, simple_ownership_demo}; #[macro_use] extern crate rustlearn; fn main() { let value = fmt!(100); println!("{}", value); simple_ownership_demo::simple_borrow_test(); simple_ownership_demo::clone_copy_test(); complex_ownership_demo::borrow_fu...
use std::fmt::Debug; use serde::{Serialize,Deserialize}; pub fn parse_array<T:Copy+Serialize>(data:&[Vec<Option<T>>]) -> Result<Vec<Metadata<T>>, Error>{ if data.len() == 0 { return Err(Error(String::from("数组高度不得为0"))) } let mut size = 0; for y in data { for _ in y { size +=...
use std::mem; use std::ptr; use messages::Message; use storage::StorageValue; use libc::{c_char, size_t}; use assets::AssetBundle; use capi::common::*; use transactions::exchange::{ExchangeOfferWrapper, ExchangeWrapper}; use error::{Error, ErrorKind}; ffi_fn! { fn dmbc_exchange_offer_create( sender_publ...
#![feature(async_await)] use async_std::{io, task}; use async_trait::async_trait; use h1::{Handler, Params, Request, Response, H1}; pub struct PlaintextRoute; #[async_trait] impl Handler for PlaintextRoute { async fn call(&self, _request: Request<'_>, _params: Params<'_>) -> io::Result<Response> { let m...
use lexer::Lexer; use lexer::Token; use parser::ParseNode; use parser::Type; use parser::GrammarItem; use errors::error_index::{Error}; pub type ParseError = Error; pub type ParseResult = Result<ParseNode, ParseError>; pub struct Parser<'a>{ lexer: Lexer<'a> } impl<'a> Parser<'a>{ pub fn new(input: Lexer<'a>...
#![no_std] #![no_main] #![feature(isa_attribute)] use gba::prelude::*; const BLACK: Color = Color::from_rgb(0, 0, 0); const RED: Color = Color::from_rgb(31, 0, 0); const GREEN: Color = Color::from_rgb(0, 31, 0); const BLUE: Color = Color::from_rgb(0, 0, 31); const YELLOW: Color = Color::from_rgb(31, 31, 0); const PIN...
use aoc::*; fn main() -> Result<()> { let mut ip = 0; let mut mem: Vec<usize> = input("2.txt")? .split(',') .map(|s| s.parse().unwrap()) .collect(); mem[1] = 12; mem[2] = 2; loop { match mem[ip] { 1 => { let dst = mem[ip + 3]; ...
/// Register numbers used in bytecode operations have different meaning according to their ranges: /// 0x80000000-0xFFFFFFFF Negative indices from the CallFrame pointer are entries in the call frame. /// 0x00000000-0x3FFFFFFF Forwards indices from the CallFrame pointer are local vars and temporaries with th...
let joao = Funcionario { nome : "João", salario : 1000 }; //https://pt.stackoverflow.com/q/347484/101
use std::cell::{RefCell, RefMut}; use std::fmt; use std::mem; use std::ptr; use alloc::rc::Rc; use kernel_std::cpu::stack::Stack; #[derive(Debug, Clone, Copy)] pub enum Context { Empty, Kernel { // SYSV callee-saved registers rip: u64, rbx: u64, rsp: u64, ...
extern crate yaml_rust; use self::yaml_rust::{YamlLoader, Yaml}; use file; pub struct Configuration { pub packages: Vec<String>, pub files: Vec<file::FileResource>, pub hostname: String } impl Configuration { pub fn is_valid(&self) -> bool { let mut files_valid = true; for file_result ...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - control register 1"] pub cr1: CR1, #[doc = "0x04 - control register 2"] pub cr2: CR2, #[doc = "0x08 - control register 3"] pub cr3: CR3, #[doc = "0x0c - TAMP filter control register"] pub fltcr: FLTCR, #...
use core::{ffi::c_void, marker::PhantomData, mem::size_of, ptr::null_mut}; use crate::alloc::{alloc_array, Allocator}; pub(crate) struct RawArray<T, A: Allocator> { pub(crate) ptr: *mut T, pub(crate) capacity: usize, pub(crate) alloc: A, _phantom: PhantomData<T>, } impl<T, A: Alloc...
use std::fs; fn bsp(s: &str, n_lo: i32, n_hi: i32) -> i32 { s.chars().fold((n_lo, n_hi), |(lo, hi), c| { if c == 'F' || c == 'L' { (lo, (lo+hi)/2) } else { ((lo+hi)/2+1, hi) } }).0 } fn iter_ids<'a>(input: &'a [(&str, &str)]) -> impl Iterator<Item=i32> + 'a { ...
pub const ID_LENGTH: usize = 9; macro_rules! make_id { ($name:ident, $($firstchar:expr),+) => { #[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct $name { len: u8, buf: [u8; ID_LENGTH], } impl $name { #[inline] pub fn as_str(&self...
use std::mem; use std::ptr; use messages::Message; use libc::{c_char, size_t}; use assets::{Fees, MetaAsset}; use capi::common::*; use transactions::add_assets::AddAssetWrapper; use error::{Error, ErrorKind}; ffi_fn! { fn dmbc_tx_add_assets_create( public_key: *const c_char, seed: u64, e...
use kerla_runtime::arch::console_write; use kerla_runtime::print::{set_printer, Printer}; use kerla_utils::ring_buffer::RingBuffer; use crate::lang_items::PANICKED; use core::sync::atomic::Ordering; pub struct LoggedPrinter; pub const KERNEL_LOG_BUF_SIZE: usize = 8192; // We use spin::Mutex here because SpinLock's d...
use std::collections::HashMap; use anyhow::*; use lazy_static::lazy_static; use regex::Regex; const REQUIRED_FIELDS: [&str; 7] = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]; lazy_static! { static ref PATTERNS: HashMap<&'static str, Regex> = { let mut map = HashMap::new(); map.insert("byr", R...
#[doc = "Reader of register INTS0"] pub type R = crate::R<u32, super::INTS0>; #[doc = "Writer for register INTS0"] pub type W = crate::W<u32, super::INTS0>; #[doc = "Register INTS0 `reset()`'s with value 0"] impl crate::ResetValue for super::INTS0 { type Type = u32; #[inline(always)] fn reset_value() -> Sel...
/*! This crate provides a `FromStr` derive for newtypes on iterable collections on single types, such `Vec<T>` or `HashSet<T>`. The element is parsed by splitting the input along a pattern that you specify though the `#[item_separator]` attribute. The individual items are then parsed using their respective `FromStr` im...
pub mod fs; pub mod index; pub mod object; use chrono::{Local, TimeZone, Utc}; use fs::FileSystem; use index::{Entry, Index}; use index::diff::{diff_index, Diff}; use libflate::zlib::{Decoder, Encoder}; use object::blob::Blob; use object::commit; use object::commit::Commit; use object::tree; use object::tree::Tree; us...
pub struct Point2D { pub x: i32, pub y: i32, } impl Point2D { pub fn move_relative(&self, x: i32, y: i32) -> Self { Point2D { x: self.x + x, y: self.y + y, } } } #[cfg(test)] mod test { use super::*; #[test] fn move_rel() { let p = Point2D {...
pub mod feature; pub mod hotfix; pub mod release; pub mod setup;
use neon::prelude::*; fn get_cpu_num() -> u32 { match sys_info::cpu_num() { Ok(num) => num, Err(_) => 0 as u32, } } fn get_cpu_speed() -> u64 { match sys_info::cpu_speed() { Ok(speed) => speed, Err(_) => 0, } } fn get_os_type() -> String { match sys_info::os_type()...
use std::{cell, collections, collections::VecDeque, env, error::Error, fs, rc::Rc}; type Result<T> = std::result::Result<T, Box<dyn Error>>; fn main() -> Result<()> { let code = fs::read_to_string(env::args().nth(1).ok_or("no file")?)? + " $"; eval_list(&default_env(), vec(&list(&mut tokenize(code))))?; Ok(...
#![feature(fixed_size_array)] #[macro_use] extern crate bitflags; extern crate core; pub mod cpu; pub mod memory;
// Copyright (c) 2019-2021 Georg Brandl. Licensed under the Apache License, // Version 2.0 <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> // or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at // your option. This file may not be copied, modified, or distributed except // accordi...
use crate::{ smallnum::{U1, U2, U3}, RegName8, }; /// Instruction prefix type #[allow(clippy::upper_case_acronyms)] #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum Prefix { None, CB, DD, ED, FD, } impl Prefix { /// Returns prefix type from byte value pub fn from_byte(data: u8...
// implements the Canny edge feature pub struct Canny { } impl Canny { } pub fn find_canny_edges(/*Image*/) /*-> Canny*/ { }
// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate as libra_crypto; use crate::{ hash::{CryptoHash, CryptoHasher}, HashValue, }; use libra_crypto_derive::CryptoHasher; use tiny_keccak::{Hasher, Sha3}; /// This file tests the CryptoHasher derive macro defined in the c...
use super::{CoBuchiAutomaton, StateId}; use hyperltl::HyperLTL; use pest::Parser; use smtlib; use std::cell::RefCell; use std::collections::HashMap; use std::convert::TryInto; use std::error::Error; use std::os::unix::process::CommandExt; use std::process::Command; #[derive(Parser)] #[grammar = "automata/neverclaim.pe...
/// An enum to represent all characters in the VerticalForms block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum VerticalForms { /// \u{fe10}: '︐' PresentationFormForVerticalComma, /// \u{fe11}: '︑' PresentationFormForVerticalIdeographicComma, /// \u{fe12}: '︒' PresentationFormFo...
use crate::{ buffer::start_buffer_highlights, buffer::Buffer, buffer::BufferId, buffer::BufferUIState, command::LapceUICommand, command::LAPCE_UI_COMMAND, command::{LapceCommand, LAPCE_COMMAND}, editor::EditorSplitState, editor::EditorUIState, editor::HighlightTextLayout, exp...
extern crate rust2018; use rust2018::do_thing; #[test] fn test() { do_thing(); }
use crate::app::App; use std::future::Future; use std::net::SocketAddr; pub struct Server { app: App, } impl Server { pub fn new(app: App) -> Self { Server { app } } pub fn run<T: Into<SocketAddr> + 'static>(&self, addr: T) -> impl Future<Output = ()> { warp::serve(router::routes(&sel...
//! See the [parent crate documentation](https://docs.rs/serde_piecewise_default/) for more information. #![recursion_limit="512"] extern crate proc_macro; extern crate proc_macro2; #[macro_use] extern crate quote; extern crate syn; extern crate serde; use crate::proc_macro::TokenStream as RustTS; use crate::proc_mac...
/* chapter 4 primitive types */ fn main() {} // output should be: /* */
use crate::lexer::Token; use thiserror::Error; pub type ParseResult<T, E = ParseError> = Result<T, E>; #[derive(Error, Debug, Clone, PartialEq)] pub enum ParseError { #[error("{0}")] Custom(&'static str), #[error("Bad number")] BadNumber, #[error("Unexpected end of file")] UnexpectedEof, ...
use num::bigint::BigInt; use num::bigint::ToBigInt; // The modular_exponentiation() function takes three identical types // (which get cast to BigInt), and returns a BigInt: #[allow(dead_code)] pub fn mod_exp<T: ToBigInt>(n: &T, e: &T, m: &T) -> BigInt { // Convert n, e, and m to BigInt: let n = n.to_bigint()....
bitflags! { pub struct Modules: i32 { const Io = 1 << 0; const Fs= 1 << 1; const Utils = 1 << 2; #[cfg(feature = "http")] const Http = 1 << 3; } } impl Default for Modules { fn default() -> Modules { Modules::Io | Modules::Fs | Modules::Utils } }
use std::path::PathBuf; use std::fs; use std::env; use std::process; use std::fs::DirEntry; use regex::Regex; use std::result::Result::Ok; use crate::tn::args::Command; use std::ffi::OsString; pub mod args; const APP_NAME: &str = "tn"; type Result<T> = ::std::result::Result<T, Box<::std::error::Error>>; pub fn run(...
use quote::quote_spanned; use super::{ FlowProperties, FlowPropertyVal, OperatorCategory, OperatorConstraints, OperatorInstance, OperatorWriteOutput, WriteContextArgs, RANGE_0, RANGE_1, }; /// > 0 input streams, 1 output stream /// /// > Arguments: [`Stream`](https://docs.rs/futures/latest/futures/stream/trai...
// =============================================================================================== // Imports // =============================================================================================== use core::fmt; use core::fmt::Write; use core::ptr::Unique; use spin::{Mutex, RwLock}; // ===================...
#![allow(dead_code)] #![allow(unused_imports)] use std::fmt; use std::mem; #[derive(Debug)] pub struct List<T> { head: ListEnum<T> } impl<T> Drop for List<T> { fn drop(&mut self) { println!("Drop list head.."); } } impl<T> List<T> { pub fn new() -> Self { List { head: ListEnum::Empty...
use SafeWrapper; use ir::{User, Instruction, Value, CmpInst, FloatPredicateKind}; use sys; /// Integer comparison. pub struct FCmpInst<'ctx>(CmpInst<'ctx>); impl<'ctx> FCmpInst<'ctx> { /// Creates a new integer comparision instruction. pub fn new(predicate_kind: FloatPredicateKind, lhs: &Value,...
#[doc = "Reader of register RCC_UART1CKSELR"] pub type R = crate::R<u32, super::RCC_UART1CKSELR>; #[doc = "Writer for register RCC_UART1CKSELR"] pub type W = crate::W<u32, super::RCC_UART1CKSELR>; #[doc = "Register RCC_UART1CKSELR `reset()`'s with value 0"] impl crate::ResetValue for super::RCC_UART1CKSELR { type T...
pub mod include; pub use include::*;
//! Create HTML elements. Unfortunately at the moment this is the API – in the future we'll provide //! something a bit nicer to work with. use std::{borrow::Cow, collections::HashMap}; use super::listener::ListenerRef; pub mod diff; pub mod orchestrator; pub mod render; /// An HTML element. #[derive(Builder, Clone...
#[doc = "Register `RDATA` reader"] pub type R = crate::R<RDATA_SPEC>; #[doc = "Field `RES` reader - RES"] pub type RES_R = crate::FieldReader<u32>; impl R { #[doc = "Bits 0:31 - RES"] #[inline(always)] pub fn res(&self) -> RES_R { RES_R::new(self.bits) } } #[doc = "CORDIC result register\n\nYou ...
use actix_web::{web, App, HttpRequest, HttpServer}; async fn index(req: HttpRequest) -> &'static str { "Hello world!" } #[actix_rt::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .service(web::resource("/").to(index)) }) // .backlog(1024) .bind(...
use std::cmp::PartialOrd; struct Point<T> { x: T, y: T, } struct MixedPoint<T, U> { x: T, y: U, } impl<T, U> MixedPoint<T, U> { fn x(&self) -> &T { &self.x } fn y(&self) -> &U { &self.y } fn mixup<V, W>(self, other: MixedPoint<V, W>) -> MixedPoint<T, W> { ...
//! [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE-MIT) //! [![Apache License 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](./LICENSE-APACHE) //! [![docs.rs](https://docs.rs/x509-parser/badge.svg)](https://docs.rs/x509-parser) //! [![crates.io](https://img.shields.i...
use crate::network::disconnect_with_message; use crate::NetworkState; use ckb_logger::{debug, info}; use p2p::{ context::{ProtocolContext, ProtocolContextMutRef}, secio::PublicKey, traits::ServiceProtocol, }; use std::sync::Arc; /// Feeler /// Currently do nothing, CKBProtocol auto refresh peer_store after...
use mrbgpdv2::peer::Peer; use mrbgpdv2::config::Config; use mrbgpdv2::routing::LocRib; use tokio::time::{sleep, Duration}; use tokio::sync::Mutex; use std::str::FromStr; use std::env; use std::sync::Arc; #[tokio::main] async fn main() { tracing_subscriber::fmt::init(); let config = env::args() ...
//! ECDH mechanism types use crate::error::{Error, Result}; use crate::types::Ulong; use cryptoki_sys::*; use log::error; use std::convert::TryFrom; use std::ffi::c_void; use std::ops::Deref; /// ECDH derivation parameters. /// /// The elliptic curve Diffie-Hellman (ECDH) key derivation mechanism /// is a mechanism f...
//! Public data structures for pack index files use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; /// The data for a single pack file #[derive(Debug, Clone, Serialize, Deserialize)] pub struct PackFileRef { /// The path to the pack file relative to the installation pub path: String, } /// T...
#[cfg(test)] mod tests { use crate::intcode::{Intcode, Interrupt}; use crate::util; use crate::util::ListInput; #[test] fn test_advent_puzzle() { let mut output = None; let ListInput(rom) = util::load_input_file("day05.txt").unwrap(); let mut program = Intcode::new(&rom); ...
#![feature(proc_macro_hygiene)] #![feature(type_ascription)] use darkly; use darkly::{scanln, scanlns}; // note: should not be necessary since we add to macro // extern crate darkly_scanner; fn main() { // scanln!("hello {}foo", x: u32); // println!("you entered `{}`", x); // assert!(x == 42); // l...
use std::{fmt}; use std::error::Error; #[derive(Debug)] pub(crate) struct SimpleError { desc: String, } impl From<&'static str> for SimpleError { fn from(s: &'static str) -> Self { Self{ desc: String::from(s), } } } impl From<char> for SimpleError { fn from(c: char) -> Sel...
// q0064_minimum_path_sum struct Solution; impl Solution { pub fn min_path_sum(grid: Vec<Vec<i32>>) -> i32 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let mut grid = grid; for i...
// File: main.rs // Description: the file provides the overall program flow mod pdf; extern crate printpdf; use std::io::*; use pdf::*; fn main() { // Prints Greeting println!("\nWellcome to Receipt Creator!"); let reader = stdin(); let mut file_name = String::new(); print!("Data file: "...
use aoc_runner_derive::{aoc, aoc_generator}; #[aoc_generator(day5)] fn parse_input_day5(input: &str) -> Result<Vec<String>, String> { Ok(input.lines().map(|s| s.to_owned()).collect()) } fn bisect(min: usize, max: usize, code: &str, index: usize) -> usize { if min == max { min } else { matc...
pub const MSG_TYPE_LEN:usize = 3; #[derive(Debug)] pub enum SentenceType { AAM, // Waypoint Arrival Alarm ALM, // Almanac data APA, // Auto Pilot A sentence APB, // Auto Pilot B sentence BOD, // Bearing Origin to Destination BWC, // Bearing using Great Circle route DTM, // Datum being used...
use tokio_pty_process::AsyncPtyMaster; use tokio_pty_process::CommandExt; use std::process::Command; use tokio::io::{AsyncRead}; use std::io::{Read, Write,stdout}; use std::{thread, time}; use tokio; use passwd::Passwd; use tokio_file_unix; use failure::Error; use carrier::*; use futures::{Async, Future, Sink, Stream};...
mod parse; #[cfg(target_os = "windows")] mod winapi_compare; use registry_pol::v1::RegistryValueType; #[test] fn reg_dword_little_endian() { assert_eq!(RegistryValueType::REG_DWORD_LITTLE_ENDIAN, RegistryValueType::REG_DWORD); } #[test] fn reg_qword_little_endian() { assert_eq!(RegistryValueType::REG_QWORD_...
use crate::elements::Meta; /// A Capability Statement documents a set of capabilities (behaviors) of a FHIR Server for a particular version of FHIR that may be used as a statement of actual server functionality or a statement of required or desired server implementation. pub struct CapabilityStatement { /// The l...
#[derive(Clone, PartialEq, ::prost::Message)] pub struct Net { #[prost(message, optional, tag="1")] pub meta: ::std::option::Option<Meta>, #[prost(message, optional, tag="2")] pub ping: ::std::option::Option<PingPong>, #[prost(message, optional, tag="3")] pub pong: ::std::option::Option<PingPong...
use cosmwasm_std::{ coin, entry_point, from_binary, to_binary, BankMsg, Binary, CosmosMsg, Decimal, Deps, DepsMut, Env, MessageInfo, Order, Response, StdResult, Uint128, WasmMsg, }; use crate::cw721::{Cw721ExecuteMsg, Cw721ReceiveMsg}; use crate::error::ContractError; use crate::msg::{ CountResponse, Execu...
type Link<T> = Option<Box<Item<T>>>; struct Item<T> { value: T, next: Link<T>, } pub struct List<T> { head_item: Link<T>, } impl<T> List<T> { pub fn new() -> List<T> { List { head_item: None} } pub fn prepend(&mut self, i: T) { let new_item = Some(Box::new(Item { ...
use super::*; #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] #[repr(transparent)] pub struct NoiseFrequencyControl(u16); impl NoiseFrequencyControl { const_new!(); bitfield_int!(u16; 0..=2: u16, div_ratio, with_div_ratio, set_div_ratio); bitfield_bool!(u16; 3, counter_width, with_counter_width, set_counte...
fn main() { { let mut xx = String::from("hello"); // 可变变量 println!("{:?}", xx); let some1 = &xx; // 不可变引用 println!("{:?}", some1); // 这里使用了不可变引用 let some2 = &mut xx; // 这里获取了可变引用, 这样可以, 因为当前作用域后面没有再使用 some1 } { let mut xx = String::from("hello"); // 注意必须是可变变量 ...
extern crate cfg_if; use cfg_if::cfg_if; static mut GLOBAL_INT: i32 = 0; cfg_if! { // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. if #[cfg(feature = "wee_alloc")] { extern crate wee_alloc; #[global_allocator] static ALLOC: wee_alloc::WeeAll...
use core::ptr; use cortex_m::peripheral::NVIC; use atomic_polyfill::{compiler_fence, AtomicPtr, Ordering}; pub use embassy_macros::interrupt_declare as declare; pub use embassy_macros::interrupt_take as take; /// Implementation detail, do not use outside embassy crates. #[doc(hidden)] pub struct Handler { pub fu...
#![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)] Builds_List(#[from] builds::list::Err...
// Example code that deserializes and serializes the model. // extern crate serde; // #[macro_use] // extern crate serde_derive; // extern crate serde_json; // // use generated_module::[object Object]; // // fn main() { // let json = r#"{"answer": 42}"#; // let model: [object Object] = serde_json::from_str(&jso...
fn main() { /* Code as notes (splited into functions) here. */ slice_basic_usage(); detect_first_space_ie_word(); detect_first_space_ie_word_then_return(); string_slices_as_param(); other_slices_basic(); } // ----- ----- ----- ----- --- FIRST --- ----- ----- ----- ----- fn detect_first_spac...
use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct NewPostRequest { pub title: String, pub content: String, } #[derive(Debug, Serialize, Deserialize)] pub struct LoginRequest { pub login: String, pub password: String, } #[derive(Debug, Serialize, Deserialize)] pu...
#[doc = "Register `RWD` reader"] pub type R = crate::R<RWD_SPEC>; #[doc = "Field `WDC` reader - Watchdog configuration"] pub type WDC_R = crate::FieldReader; #[doc = "Field `WDV` reader - Watchdog value"] pub type WDV_R = crate::FieldReader; impl R { #[doc = "Bits 0:7 - Watchdog configuration"] #[inline(always)...
pub mod debug; pub mod math;
pub fn count_brute_inversions(arr: &[u64]) -> u64 { let n = arr.len(); let mut count = 0; for i in 0..n { for j in (i+1)..n { if arr[i] > arr[j] { count += 1; } } } count } //use std::cmp::max; pub fn sort_and_count_inversions(arr: &[u64]) -> (Vec<u64>, u64) { let n = arr.len()...
//! This crate is specifically used for one thing: turning expressions inside of a string //! into a value. This crate acts as a scientific calculator, and includes several functions. //! //! If you need a portion of the calculator changed or removed, please fork it, and make your //! changes. We encourage others to ch...
use {EventEntry, now_micro}; use std::fmt; use std::time::{SystemTime, UNIX_EPOCH}; use std::cmp::{Ord, Ordering}; use std::collections::HashMap; use rbtree::RBTree; extern crate libc; extern crate time; pub struct Timer { timer_queue: RBTree<TreeKey, EventEntry>, time_maps: HashMap<u32, u64>, time_id: u3...
use super::{ backend::Backend, entity::Entity, repository::{GetEntityFuture, ListEntitiesFuture, ListEntityIdsStream, Repository}, }; use futures_util::stream::{self, StreamExt}; use std::future::Future; pub fn relation_and_then< 'a, B: Backend + 'a, F: FnOnce(M1) -> Option<M2::Id> + Send + 'a,...
#[doc = "Reader of register FMC_BCHIER"] pub type R = crate::R<u32, super::FMC_BCHIER>; #[doc = "Writer for register FMC_BCHIER"] pub type W = crate::W<u32, super::FMC_BCHIER>; #[doc = "Register FMC_BCHIER `reset()`'s with value 0"] impl crate::ResetValue for super::FMC_BCHIER { type Type = u32; #[inline(always...
use std::error::Error; use regex::Regex; use crate::model::*; use super::common; pub fn change_tags(git_project: &mut GitProject, message: &str) -> Result<(), Box<dyn Error>> { let change_tags_command_format = Regex::new(r"\[([^\[\]\s]+)(?:@([^\[\]\s]+))?((?:[\s]+(?:[+-][\S]+))+)\]")?; // [my-task +bug], [my-task@...
#[allow(dead_code)] pub fn run(){ }// fn add ()
use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::identity::identity_utils::call_sender; use crate::lib::provider::create_agent_environment; use clap::Clap; use tokio::runtime::Runtime; mod call; mod create; mod delete; mod deposit_cycles; mod id; mod info; mod install; mod r...
use crate::{ ast::*, error::{marked_in_orig, ParseError}, lexer::{Lexer, Token, TokenType}, Options, }; #[derive(Debug)] pub struct Parser<'a> { text: &'a str, tokens: Vec<Token>, pos: usize, } macro_rules! return_binary_clause { ($self: ident, $operator: expr, $curr_token: ident) => {...
use chrono::{Duration, NaiveDate}; use db::plant::Plant; use rusqlite::types::*; use rusqlite::Connection; /// Tracking the growth and harvest of a specific plant pub struct Crop { /// Number of plants sown pub num_plants: u32, /// The date that the plants were planted pub date_planted: NaiveDate, ...
use influxdb::{Client, Query, Timestamp}; use influxdb::InfluxDbWriteable; use chrono::{DateTime, Utc}; #[async_std::main] // or #[tokio::main] if you prefer async fn main() { // Connect to db `test` on `http://localhost:8086` let client = Client::new("http://192.168.2.116:8086", "test"); #[derive(InfluxD...
#![windows_subsystem = "console"] #![allow(unused_imports)] #![allow(dead_code)] #![allow(unused_parens)] #![allow(non_snake_case)] #![allow(unused_mut)] #![allow(unused_variables)] extern crate winapi; //extern crate widestring; //use winapi::um::minwinbase::*; //use std::cmp; //use std::io; use winapi::shared::mi...
const INPUT: &str = include_str!("../input"); fn main() { let parsed_input = parse_input(INPUT); println!("{}", find_part_one_solution(parsed_input)); println!("{}", find_part_two_solution(parsed_input)); } fn parse_input(input: &str) -> &str { input.trim() } fn find_part_one_solution(polymer: &str) ...
//! This crate is a rust port of the [official ProtonVPN python cli](https://github.com/ProtonVPN/linux-cli). We aim for feature parity and to track changes from the official cli. This crate's only non-rust dependency is `openvpn.` You'll need to install it using your system's package manager. //! //! This crate **does...
use async_graphql::{ http::{playground_source, GraphQLPlaygroundConfig}, EmptyMutation, EmptySubscription, Schema, }; use async_graphql_rocket::{Query, Request, Response}; use rocket::{response::content, routes, State}; use starwars::{QueryRoot, StarWars}; pub type StarWarsSchema = Schema<QueryRoot, EmptyMutat...
#[doc = "Register `TIMCCR2` reader"] pub type R = crate::R<TIMCCR2_SPEC>; #[doc = "Register `TIMCCR2` writer"] pub type W = crate::W<TIMCCR2_SPEC>; #[doc = "Field `DCDE` reader - Dual Channel DAC trigger enable"] pub type DCDE_R = crate::BitReader; #[doc = "Field `DCDE` writer - Dual Channel DAC trigger enable"] pub ty...