text
stringlengths
8
4.13M
use std::fmt; use std::io; #[derive(Debug)] pub enum Error { Io(io::Error), Syntax(String), } impl From<io::Error> for Error { fn from(e: io::Error) -> Self { Error::Io(e) } } impl From<String> for Error { fn from(e: String) -> Self { Error::Syntax(e) } } impl Error { pub...
pub use std::fmt::{Debug, Display}; #[cfg(test)] pub use std::error::Error; #[cfg(not(test))] pub trait Error: Debug + Display { fn description(&self) -> &str; fn cause(&self) -> Option<&Error> { None } }
extern crate electrum_client; use electrum_client::Client; fn main() { let mut client = Client::new_ssl( "electrum2.hodlister.co:50002", Some("electrum2.hodlister.co"), ) .unwrap(); let res = client.server_features(); println!("{:#?}", res); }
use board; use tile; use cell; use std::vec::Vec; pub fn score_word(word: Vec<cell>&) -> usize { let letter_multiplier: usize = match word[0]._bonus { cell::Bonus::DoubleLetter => 2, cell::Bonus::TripleLetter => 3, _ => 1, }; let word_multiplier: usize = match word[0]._bonus { ...
// https://sope.prod.reuters.tv/program/rcom/v1/article-recirc?edition=cn&modules=rightrail,ribbon,bottom #[derive(Default, Debug, Clone, PartialEq, serde_derive::Serialize, serde_derive::Deserialize)] #[serde(rename_all = "camelCase")] pub struct TRRoot { pub rightrail: TRRibbon, pub ribbon: TRRibbon, pub...
fn main() { let mut n = 0; let mut frac = vec![]; while frac.len() < 1000000 { n += 1; let mut tmp = n; let mut stack = vec![]; while tmp > 0 { stack.push(tmp % 10); tmp /= 10; } while stack.len() > 0 { frac.push(stack.pop(...
use super::{Object, TaggedValue}; use crate::runtime::Symbol; use crate::SchemeExpression; impl Object { pub fn undef() -> Self { Object::new(TaggedValue::Undef) } pub fn nil() -> Self { Object::new(TaggedValue::Nil) } pub fn integer(value: i64) -> Self { Object::new(Tagged...
use bech32::ToBase32; use bitcoin_hashes::hash160; use bitcoin_hashes::Hash; use secp256k1::{Secp256k1}; use secp256k1::rand::{thread_rng}; use std::env; use std::io::Write; use std::sync::{atomic::AtomicBool, atomic::AtomicU64, atomic::Ordering, Arc}; use std::time::SystemTime; const CHARSET: [char; 32] = [ 'q', ...
use sparser_bitfield::{Bitfield, Change}; #[test] fn can_create_bitfield() { let _bits = Bitfield::new(); } #[test] fn basic_set_get() { let mut bits = Bitfield::new(); bits.set(0); assert_eq!( bits.get(0), true); } #[test] fn can_set_bits() { let mut bits = Bitfield::new(); bits.set(100); ...
use crate::{MavFrame, MavHeader, MavlinkVersion, Message}; use std::io::{self}; #[cfg(feature = "tcp")] mod tcp; #[cfg(feature = "udp")] mod udp; #[cfg(feature = "direct-serial")] mod direct_serial; mod file; /// A MAVLink connection pub trait MavConnection<M: Message> { /// Receive a mavlink message. ///...
#[doc = "Register `C2EMR2` reader"] pub type R = crate::R<C2EMR2_SPEC>; #[doc = "Register `C2EMR2` writer"] pub type W = crate::W<C2EMR2_SPEC>; #[doc = "Field `MR32` reader - CPU2 interrupt Mask on Direct Event input x+32"] pub type MR32_R = crate::BitReader<MR32_A>; #[doc = "CPU2 interrupt Mask on Direct Event input x...
mod schip8; use schip8::SChip8; use sdl2::{audio, event, keyboard::Keycode, pixels}; use std::{collections::HashMap, env, fs, io, time::Duration, time::SystemTime}; // Squarewave for audio output struct SquareWave { phase_inc: f32, phase: f32, volume: f32, } impl audio::AudioCallback for SquareWave { ...
pub mod selfupdate; pub mod watch; #[cfg(windows)] pub mod windows; use anyhow::{anyhow, Result}; use log::{info, warn}; use pahkat_client::{ config::RepoRecord, package_store::SharedStoreConfig, PackageKey, PackageStatus, PackageStore, }; use std::convert::TryFrom; use std::sync::Arc; use std::time::Duration; use...
#[doc = "Register `ITLINE11` reader"] pub type R = crate::R<ITLINE11_SPEC>; #[doc = "Field `DMAMUX` reader - DMAMUX"] pub type DMAMUX_R = crate::BitReader; #[doc = "Field `DMA1_CH4` reader - DMA1_CH4"] pub type DMA1_CH4_R = crate::BitReader; #[doc = "Field `DMA1_CH5` reader - DMA1_CH5"] pub type DMA1_CH5_R = crate::Bit...
use coverage::{FunctionCov, ProcessCov}; use coverage::RangeCov; use coverage::ScriptCov; use range_tree::RangeTree; use range_tree::RangeTreeArena; use rayon::prelude::*; use std::collections::BTreeMap; use std::collections::BTreeSet; use std::collections::HashMap; use std::iter::Peekable; pub fn merge_processes(mut ...
extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] extern crate derive_new; pub mod http; pub mod rtm; mod id; pub use self::id::*; mod timestamp; pub use self::timestamp::Timestamp; fn serialize_comma_separated<T, S>(items: &[T], serializer: S) -> Result<S::Ok, S::Error> where S: ::serde::...
#![recursion_limit = "1024"] #![allow(clippy::eval_order_dependence)] // extern crate wasm_bindgen; // extern crate web_sys; // extern crate yew; // extern crate yew_router; use wasm_bindgen::prelude::*; use web_logger; pub mod app; pub mod components; pub mod routes; use app::App; // Use `wee_alloc` as the global...
// use chrono::*; // use nom::*; pub mod parse_fns; /// This contains the various structs used to represent the AST #[derive(Clone,Debug,Hash,Eq,PartialEq,Ord,PartialOrd)] pub struct Identifier(pub String); impl FromStr for Identifier { type Err = (); fn from_str(s:&str) -> Result<Identifier,Self::Err> { ...
use std::io::BufRead; use std::env; use std::fs::File; use std::io::BufReader; use std::io; use std::time::Instant; use sudoku::solver; fn main() { let args: Vec<String> = env::args().collect(); let file = &args[1]; let rows: usize = args[2].parse().unwrap(); eprintln!("Start read..."); let star...
pub use self::opcode::*; pub use self::ty::*; pub use self::value::*; pub use self::context::*; pub use self::module::*; pub use self::attributes::*; pub use self::block::*; pub use self::function::*; pub use self::passes::*; pub mod opcode; pub mod ty; pub mod value; pub mod context; pub mod module; pub mod attribute...
use std::fs::File; use std::io; use std::io::{Read, BufRead, BufReader, BufWriter, Write}; fn main() { // open_file(); // read_bytes(); // write_bytes(); // stdin1(); // stdin2(); // iterators1(); // iterators2(); let a = errors1(); } fn open_file() { let mut f = File::open("recor...
use std::collections::HashSet; use serde_json::Value; use crate::validator::{scope::ScopedSchema, state::ValidationState, Validator}; pub fn validate_as_object(scope: &ScopedSchema, data: &Value) -> ValidationState { let object = match data.as_object() { Some(x) => x, None => return ValidationSta...
#![allow(unused_must_use)] extern crate nanomsg; use nanomsg::{Socket, Protocol}; use std::time::duration::Duration; use std::io::timer::sleep; fn collector() { let mut socket = Socket::new(Protocol::Pull).unwrap(); socket.bind("ipc:///tmp/pipeline_collector.ipc"); loop { match socket.read_to_string() { ...
use crate::libs::color::color_system; use isaribi::{ style, styled::{Style, Styled}, }; use nusa::prelude::*; pub struct Select {} impl Select { fn render(color: &str, attrs: Attributes, events: Events, children: Vec<Html>) -> Html { Self::styled(Html::select( attrs.class(Self::class("...
//! Library for versioning symbols in native libraries. //! //! This library provides a means by which native (C, C++, assembly) symbols can //! be automatically version mangled. This allows multiple versions of a Rust //! library with C, C++, and assembly code to be used in one application. //! //! # How it Works //! ...
/* * Copyright 2018 Intel Corporation * * 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 agre...
use crate::int_var::IntVar; use crate::looping::{self, IterAttrs, IterResult, NativeIterator}; use crate::runtime::Runtime; use crate::std_type::Type; use crate::variable::{FnResult, Variable}; use num::traits::Zero; use num::One; use std::cell::RefCell; use std::rc::Rc; #[derive(Debug, Clone)] pub struct Enumerate { ...
#[macro_use] extern crate log; extern crate pretty_env_logger; use warp::Filter; mod handler; #[tokio::main] async fn main() { pretty_env_logger::init(); // POST /invoke let route = warp::path!("invoke") .and(warp::post()) .and_then(handler::run); info!("Starting server ..."); wa...
use pyo3::prelude::*; use streamson_lib::strategy; use crate::{handler::BaseHandler, PythonOutput, PythonStrategy, RustMatcher}; /// Low level Python wrapper for Filter strategy #[pyclass] pub struct Filter { filter: strategy::Filter, } #[pymethods] impl Filter { /// Create a new instance of Filter #[new...
fn is_palindrome(s: &String) -> bool { for (a,b) in s.chars().zip(s.chars().rev()){ if a != b { return false; } } true } pub fn problem_036() -> u32 { let n = 1000000; let mut palindromes: Vec<u32> = vec![]; for i in 0..n { let base_10 = format!("{}",i); ...
use std::collections::HashMap; struct MorseDecoder { morse_code: HashMap<String, String>, } impl MorseDecoder { fn new() -> MorseDecoder { MorseDecoder{ morse_code : [("....-", "4"),("--..--", ","),(".--", "W"),(".-.-.-", "."),("..---", "2"),(".", "E"),("--..", "Z"),(".----", "1"),(".-..", "L...
use std::collections::HashMap; use std::collections::HashSet; use std::io; use std::io::BufRead; use std::io::BufReader; fn has_unique_words(words: &Vec<String>) -> bool { let mut word_set = HashSet::new(); for word in words { if word_set.contains(word) { return false; } wor...
use cocoa::base::id; /// The `MTLLibrary` protocol defines the interface for an object that represents a library of Metal /// shader functions. A `MTLLibrary` object can contain Metal shading language code that is compiled /// during the app build process or at runtime from a text string containing Metal shading langu...
#[doc = "Reader of register TIM15_AF1"] pub type R = crate::R<u32, super::TIM15_AF1>; #[doc = "Writer for register TIM15_AF1"] pub type W = crate::W<u32, super::TIM15_AF1>; #[doc = "Register TIM15_AF1 `reset()`'s with value 0x01"] impl crate::ResetValue for super::TIM15_AF1 { type Type = u32; #[inline(always)] ...
use std::cmp; use std::ptr; use std::mem; use std::cell::UnsafeCell; use alloc::heap; use alloc::oom::oom; use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering}; use std::sync::Arc; #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct SendError<T>(pub T); #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub str...
use std::fs::File; use std::io::Read; fn main() { let mut file = File::open("d03-input").unwrap(); let mut input = String::new(); file.read_to_string(&mut input).unwrap(); let (mut tree, mut col) = (0, 0); for line in input.lines() { let x = line.chars().nth(col); if x.unwrap() == '#' { tree += 1; } c...
use std::fmt; use crate::card; pub struct Foundation { cards: Vec<&'static card::Card>, suit: card::Suit, } impl Foundation { pub fn new(suit: card::Suit) -> Foundation { Foundation{cards: Vec::new(), suit} } pub fn get_top(&self) -> Option<&'static card::Card> { if self.cards.is_empty() { N...
pub mod automaton; pub mod cgol; pub mod grid; pub use automaton::Automaton; pub use cgol::Cgol;
//! # MCPI API //! `mcpi_api` is a wrapper for the Minecraft Pi Edition API handling parsing and other aspects for you. use std::io::prelude::*; use std::net::TcpStream; use std::io::BufReader; use std::cmp::{min, max}; #[cfg(test)] mod tests { #[test] fn development_tests() { } } ///Struct containing fu...
#![allow(non_snake_case)] #[allow(unused_imports)] use std::io::{self, Write}; #[allow(unused_imports)] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; #[allow(unused_imports)] use std::cmp::{max, min, Ordering}; macro_rules! input { (source = $s:expr, $($r:tt)*) => { let...
use anyhow::Result; use std::path::PathBuf; /// Returns path to executable pub fn get_rcterm_exec_path() -> Result<PathBuf> { Ok(std::env::current_dir()?.join("target/debug/rgit")) }
// SPDX-FileCopyrightText: 2020 HH Partners // // SPDX-License-Identifier: MIT pub mod algorithm; pub mod annotation; pub mod checksum; pub mod creation_info; pub mod document_creation_information; pub mod doubleopen; pub mod error; pub mod external_document_reference; pub mod external_package_reference; pub mod file_...
mod io; pub use io::*; pub trait ActorDirectiveT<Data> { fn exit_loop(&self) -> bool; fn input(self) -> Option<Data>; } #[async_trait::async_trait] pub trait Actor<D, I, O, IO> where I: ActorDirectiveT<D>, IO: ActorI<I> + ActorO<O> + Send + 'static, O: Send, D: Send, { ...
#[doc = "Reader of register CM4_PWR_CTL"] pub type R = crate::R<u32, super::CM4_PWR_CTL>; #[doc = "Writer for register CM4_PWR_CTL"] pub type W = crate::W<u32, super::CM4_PWR_CTL>; #[doc = "Register CM4_PWR_CTL `reset()`'s with value 0xfa05_0001"] impl crate::ResetValue for super::CM4_PWR_CTL { type Type = u32; ...
use std::ops::*; type V = usize; #[derive(Copy, Clone, Debug)] pub struct E<W> { pub to: V, pub cost: W, } #[derive(Clone, Debug)] pub struct Graph<W> { pub es: Vec<Vec<E<W>>>, } struct Entry<W>(V, W); impl_cmp!(Entry<W>; |a, b| b.1.partial_cmp(&a.1).unwrap(); where W: PartialOrd); impl<W> Graph<W> where W: Cop...
use game::cardmarco::*; pub struct Board { pub players: Vec<Player>, } enum_number!(PlayerEnum { Player1=0, Player2=1, Player3=2, Player4=3, Player5=4, }); impl Board { pub fn new(player_num: i32) -> Board { fn r_player_enum(i: i32) -> PlayerEnum { match i { ...
use std::env::current_dir; use std::path::PathBuf; use anyhow::{Context, Result}; use dirs::home_dir; use crate::cfg::Cfg; type LocalDir = PathBuf; type GlobalDir = PathBuf; pub fn reach_directories() -> Result<(LocalDir, GlobalDir)> { let local_dir = current_dir().context("fail to found current directory")?; ...
use std::rc::Rc; use crate::RrtHittable::Hittable; use crate::RrtHittable::hit_record; use crate::RrtRay::Ray; #[derive(Clone)] pub struct HittableList { hittables : Vec<Rc<dyn Hittable>> } impl HittableList { pub fn new() -> HittableList { HittableList { hittables : Vec::new() }...
use super::*; use crate::construction::heuristics::InsertionContext; use crate::solver::mutation::select_seed_job; use crate::solver::RefinementContext; /// A ruin strategy which removes random jobs from solution. pub struct RandomJobRemoval { /// Specifies limitation for job removal. limits: RuinLimits, } im...
// Copyright 2019, 2020 Wingchain // // 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 std::ops::{Add, Mul}; #[cfg(test)] mod tests { #[test] // list comprehension of sorts fn iterators() { let mapper = |v| ((v * 1235) + 2) / (4 * 16); let reducer = |mut acc: Vec<i32>, curr: i32| { acc.push(mapper(curr)); acc }; type V = Vec<i32>; let range = || 0..5; let exp: V = ve...
// src/code_test.rs use super::code::*; #[test] fn test_make() { let tests = vec![ ( Opcode::OpConstant, vec![65534], vec![Opcode::OpConstant as u8, 255, 254], ), (Opcode::OpAdd, Vec::new(), vec![Opcode::OpAdd as u8]), ( Opcode::OpGet...
use std::sync::{Mutex,RwLock,Arc,Barrier,Weak}; //use adminServer::AdminServer; use log::Log; use serverConfig::ServerConfig; use gameState::GameState; use storage::Storage; use httpRequester::HTTPRequester; use server::Server; use map::Map; pub struct AppData{ pub log:Log, pub serverConfig:ServerConfig, ...
use fdio::{fdio_sys, ioctl_raw}; use std::os::raw; use failure::Error; const PTY_EVENT_HANGUP: u8 = 1; const PTY_EVENT_INTERRUPT: u8 = 2; const PTY_EVENT_SUSPEND: u8 = 4; const PTY_EVENT_MASK: u8 = 7; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct pty_clr_set_t { pub clr: u32, pub set: u32, } #[repr(C)]...
use cpu::*; use mem::Memory; use hw::HW; use hw::storage; use hw::display; use std::io::prelude::*; pub struct ByteBdaEntry { idx: u8 } impl ByteBdaEntry { pub fn new(idx: u8) -> ByteBdaEntry { ByteBdaEntry { idx: idx } } pub fn get(&self, mem: &Memory) -> u8 { mem.read_u8(0x400 + self.idx as u32) } ...
#[doc = "Register `MTLTXQUR` reader"] pub type R = crate::R<MTLTXQUR_SPEC>; #[doc = "Register `MTLTXQUR` writer"] pub type W = crate::W<MTLTXQUR_SPEC>; #[doc = "Field `UFFRMCNT` reader - Underflow Packet Counter This field indicates the number of packets aborted by the controller because of Tx queue Underflow. This cou...
// http://codekata.com/kata/kata04-data-munging/ // // Kata04: Data Munging // // Martin Fowler gave me a hard time for Kata02, complaining that it was yet // another single-function, academic exercise. Which, or course, it was. So this // week let’s mix things up a bit. // // Here’s an exercise in three parts to do wi...
#[doc = "Reader of register CMP1_SW"] pub type R = crate::R<u32, super::CMP1_SW>; #[doc = "Writer for register CMP1_SW"] pub type W = crate::W<u32, super::CMP1_SW>; #[doc = "Register CMP1_SW `reset()`'s with value 0"] impl crate::ResetValue for super::CMP1_SW { type Type = u32; #[inline(always)] fn reset_va...
//ported from https://github.com/masahi/ocaml_practice/blob/master/mooc/klotski.ml use std::cmp::Ordering; use std::collections::BTreeSet; use std::ops::{Deref, DerefMut}; fn find_index<T>(pred: impl FnMut(&T) -> bool, vec: &Vec<T>) -> Option<usize> { vec.iter().position(pred) } /* fn flat_map<T, F>(rel: F) -> im...
use js_sys::Promise; use wasm_bindgen::JsValue; use web_sys::console; use web_sys::HtmlMediaElement; use yew::prelude::*; pub(crate) struct Thumb { audio_ref: NodeRef, } impl Component for Thumb { type Message = Msg; type Properties = Props; fn create(_ctx: &Context<Self>) -> Self { Self { ...
use crate::ast_transform::Transformer; use crate::scm::Scm; use crate::sexpr::{Sexpr, TrackedSexpr}; use crate::source::SourceLocation; use crate::syntax::Reify; #[derive(Clone)] pub struct Constant { pub value: Sexpr, pub span: SourceLocation, } impl_sourced!(Constant); impl Constant { pub fn new(value:...
fn surface_area(h: usize, w: usize, l: usize) -> usize { 2*h*w + 2*h*l + 2*w*l } fn smallest_side_area(h: usize, w: usize, l: usize) -> usize { *[h*w, h*l, w*l].iter().min().unwrap_or(&0) } fn smallest_side_perimeter(h: usize, w: usize, l: usize) -> usize { *[2*h+2*w, 2*h+2*l, 2*w+2*l].iter().min().unwrap...
use crate::hex::coordinates::{ direction::{HexagonalDirection, NUM_DIRECTIONS}, HexagonalVector, }; pub struct RingIter<V: HexagonalVector + HexagonalDirection> { edge_length: usize, direction: usize, next: V, edge_index: usize, } impl<V: HexagonalVector + HexagonalDirection> RingIter<V> { ...
//! Link: https://adventofcode.com/2019/day/4 //! Day 4: Secure Container //! //! You arrive at the Venus fuel depot only to discover it's protected by a password. //! The Elves had written the password on a sticky note, but someone threw it out. #[aoc_generator(day4)] fn input_generator(input: &str) -> (u32, u32){ ...
use nom; type NomError<'a> = nom::Err<nom::types::CompleteStr<'a>>; #[derive(Fail, Debug)] #[fail(display = "Parse error: {:?}", _0)] pub struct ParseError(nom::ErrorKind); impl<'a> From<NomError<'a>> for ParseError { fn from(e: NomError<'a>) -> Self { let kind = e.into_error_kind(); ParseError(k...
use super::*; pick! { if #[cfg(target_feature="avx2")] { #[derive(Default, Clone, Copy, PartialEq, Eq)] #[repr(C, align(32))] pub struct i8x32 { avx: m256i } } else if #[cfg(target_feature="sse2")] { #[derive(Default, Clone, Copy, PartialEq, Eq)] #[repr(C, align(32))] pub struct i8x32 { sse...
#[doc = "Register `RGCFR` reader"] pub type R = crate::R<RGCFR_SPEC>; #[doc = "Register `RGCFR` writer"] pub type W = crate::W<RGCFR_SPEC>; #[doc = "Field `CSOF0` reader - Generator Clear Overrun Flag 0"] pub type CSOF0_R = crate::BitReader; #[doc = "Field `CSOF0` writer - Generator Clear Overrun Flag 0"] pub type CSOF...
// Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 use crate::hashtypes::*; // decodes binary encoded data into its separate entities pub struct BytesDecoder<'a> { data: &'a [u8], } impl BytesDecoder<'_> { // constructs a decoder pub fn new(data: &[u8]) -> BytesDecoder { Bytes...
#![feature(arbitrary_self_types, futures_api, pin)] use std::future::{Future, FutureObj}; use std::mem::PinMut; use std::sync::{Arc, Mutex}; use std::task::{Context, Poll, Waker}; use std::thread; use std::time::Duration; /// State shared between the future and the timer thread struct SharedState { waker: Option<...
#[derive(Clone, Copy, PartialEq)] enum Cell { Floor, Empty, Occupied, } pub fn solve_part_one(input: &str) -> usize { let mut grid = process(input); let mut is_stable = false; while !is_stable { let mut grid_new = grid.clone(); is_stable = true; for y in 0..grid.len() ...
extern crate iref; use iref::Iri; fn main() -> Result<(), iref::Error> { let iri = Iri::new("https://www.rust-lang.org/foo/bar?query#frag")?; println!("scheme: {}", iri.scheme()); println!("authority: {}", iri.authority().unwrap()); println!("path: {}", iri.path()); println!("query: {}", iri.query().unwrap()); ...
pub mod file; pub mod hash; pub mod storage;
// This file is part of Substrate. // Copyright (C) 2020 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 S...
// Copyright 2020 <盏一 w@hidva.com> // 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 writing,...
extern crate protoc_rust_grpc; fn main() { protoc_rust_grpc::Codegen::new() .out_dir("src") .input("occlum_exec.proto") .rust_protobuf(true) .run() .expect("protoc-rust-grpc"); println!("cargo:rustc-link-search=native=../../build/lib"); println!("cargo:rustc-link-li...
//! Concrete implementations for the traits in [crate::lp_format] use std::fmt; use std::fmt::Formatter; use crate::lp_format::{AsVariable, Constraint, LpObjective, LpProblem, WriteToLpFileFormat}; /// A string that is a valid expression in the .lp format for the solver you are using pub struct StrExpression(pub Stri...
use base64; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use transpose; fn main() { let input = File::open("6.txt").unwrap(); let result = decrypt( &base64::decode( &BufReader::new(input) .lines() .map(|x| x.unwrap()) .c...
#![recursion_limit = "1024"] #[macro_use] extern crate error_chain; extern crate rss; extern crate reqwest; extern crate lettre; extern crate chrono; #[macro_use] extern crate serde_derive; extern crate serde_json; #[macro_use] extern crate tera; use std::io::Read; use std::io::Write; us...
#[doc = "Register `C2APB1FZR1` reader"] pub type R = crate::R<C2APB1FZR1_SPEC>; #[doc = "Register `C2APB1FZR1` writer"] pub type W = crate::W<C2APB1FZR1_SPEC>; #[doc = "Field `DBG_TIM2_STOP` reader - DBG_TIM2_STOP"] pub type DBG_TIM2_STOP_R = crate::BitReader; #[doc = "Field `DBG_TIM2_STOP` writer - DBG_TIM2_STOP"] pub...
#[macro_use] extern crate log; extern crate mongo_oplog; extern crate mongo_driver; mod utils; use std::sync::mpsc; use mongo_oplog::op_source; use mongo_oplog::op; #[ignore] #[test] fn test_op_source() { utils::log_init(); let pool = utils::get_mongo(); let (rx, join_handle) = op_source::create_oplog_...
use actix_web::dev::ServiceResponse; use actix_web::middleware::ErrorHandlerResponse; use actix_web::Result; pub fn internal_server_error<B>(res: ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> { eprintln!("INTERNAL_SERVER_ERROR: {:?}", res.request().uri()); Ok(ErrorHandlerResponse::Response(res)) } pu...
/** * [1] Main(search by title) // should be Videos instead * [2] Count(search by id) * [3] Video(search by id) */ // Should everything here be pub? or onyl used part? // [1] #[derive(Serialize, Deserialize, Debug)] pub struct Main { items: Option<Vec<VideosItem>>, } #[derive(Serialize, Deserialize, Debug)] ...
use serde::{Deserialize, Serialize}; pub type PricesResponse = Vec<IntradayPrice>; #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all(deserialize = "camelCase"))] pub struct IntradayPrice { date: String, minute: String, label: String, high: Option<f32>, low: Option<f32>, open: Option<...
//! Note: This crate is deprecated in favour of [rspotify](https://docs.rs/rspotify). //! //! aspotify is an asynchronous client to the [Spotify //! API](https://developer.spotify.com/documentation/web-api/). //! //! # Examples //! ``` //! # async { //! use aspotify::{Client, ClientCredentials}; //! //! // This from_en...
use std::panic; use rocket::{self, http::{Header, Status}, local::Client}; use diesel::connection::SimpleConnection; use horus_server::{self, routes::files::*}; use test::{run_test, sql::*}; #[test] fn get() { run(|| { let client = get_client(); let req = client.get("/file/".to_string() + FILE_ID...
use anyhow::Result; use bevy::ecs::{ component::Component, entity::{EntityMap, MapEntities}, world::{EntityMut, World}, }; /////////////////////////////////////////////////////////////////////////////// pub type MapWorldComponentsFn = fn(&mut World, &EntityMap) -> Result<()>; pub type MapEntityComponents...
use chrono::prelude::*; use serde::{Deserialize, Serialize}; use super::{Genre, Language, ProductionCompany, ProductionCountry}; /// Details from searching for [`Movie`] by name #[derive(Serialize, Deserialize, Debug)] pub struct Movie { /// The path to the poster for this movie pub poster_path: Option<String...
#![allow(dead_code,unused_imports,unused_must_use,unused_assignments)] #![allow(deprecated)] #![feature(slicing_syntax)] //! Run fuzzing against the `dns::hp` parser. extern crate dns; extern crate time; use std::io::net::udp::UdpSocket; use std::io::net::ip::{Ipv4Addr, SocketAddr}; use std::io::BufReader; use std::...
#[doc = "Register `SR1` reader"] pub type R = crate::R<SR1_SPEC>; #[doc = "Register `SR1` writer"] pub type W = crate::W<SR1_SPEC>; #[doc = "Field `SB` reader - Start bit (Master mode)"] pub type SB_R = crate::BitReader<SB_A>; #[doc = "Start bit (Master mode)\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialE...
// Simple 'hello' thread example. // Mainly inspired from official book at // http://doc.rust-lang.org/book/concurrency.html use std::thread; fn main() { println!("Hello from main"); thread::spawn(|| { println!("Hello from new thread"); }); }
#[macro_use] extern crate neon; extern crate neon_serde; extern crate sodiumoxide; #[macro_use] extern crate serde_derive; extern crate serde_json; mod auth_token; mod keyring; use auth_token::AuthToken; use keyring::Keyring; use neon::prelude::*; pub struct EccAuth { keyring: Keyring } impl EccAuth { fn new(k...
use rust_decimal_macros::dec; // Require using for reexportable feature #[cfg(feature = "reexportable")] use rust_decimal::Decimal; #[test] fn it_can_parse_decimal() { let tests = &[ ("0.00", dec!(0.00)), ("1.00", dec!(1.00)), ("-1.23", dec!(-1.23)), ("1.123456789012345678901234567...
use std::fs::File; use std::io::prelude::*; use std::net::TcpListener; use std::net::TcpStream; fn main() { let listener = TcpListener::bind("127.0.0.1:1234").unwrap(); for stream in listener.incoming() { let stream = stream.unwrap(); // this is 1 connection println!("Connection established!!"...
#![no_main] #[macro_use] extern crate libfuzzer_sys; extern crate valis_syntax; fuzz_target!(|data: &[u8]| { let tables = valis_syntax::SyntaxTables::default(); if let Ok(s) = std::str::from_utf8(data) { let _ = valis_syntax::ast::SourceFileNode::parse(s, &tables); } });
use epd1in54::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH}; /// Full size buffer for use with the 1in54 EPD /// /// Can also be manuall constructed: /// `buffer: [DEFAULT_BACKGROUND_COLOR.get_byte_value(); WIDTH / 8 * HEIGHT]` pub struct Buffer1in54BlackWhite { pub buffer: [u8; WIDTH as usize * HEIGHT as usize / 8], ...
pub mod http_handler; pub mod file_manager; pub mod thread_pool; pub mod request;
/* * 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 */ /// WidgetTextAlign : How to align the text on the widget. /// How to align the text on the widget. #[d...
use actix_web::*; use database; use serde_json; use misc; use msa; use std::str; use futures::future::Future; use models::QuerySubstrate; use flatten; use csv; use std::collections::HashMap; use futures::Stream; use std::fs::File; use std::io::prelude::*; pub fn get_status_controller(_req: HttpRequest<super::State>) ...
use a653rs::bindings::*; pub struct DummyHypervisor; impl ApexPartitionP4 for DummyHypervisor { fn get_partition_status<L: Locked>() -> ApexPartitionStatus { todo!() } fn set_partition_mode<L: Locked>( _operating_mode: OperatingMode, ) -> Result<(), ErrorReturnCode> { todo!() ...
// 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. use air::proof::Queries; use crypto::{ElementHasher, MerkleTree}; use math::FieldElement; use utils::{batch_iter_mut, collections::Vec, un...