text
stringlengths
8
4.13M
//! Linear operator use crate::solver::LinAlg; /// Linear operator trait. /// /// <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> /// <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script> /// /// Expresses a linear operator \\(K:...
struct Solution; impl Solution { pub fn island_perimeter(grid: Vec<Vec<i32>>) -> i32 { let mut ans = 0; for row in 0..grid.len() { for col in 0..grid[0].len() { if grid[row][col] != 1 { continue; } ans += 4; // 4 条边 ...
/** * Common constants for glfw. You shouldn't have to access these directly as each module * publicly exports them. */ use core::libc::c_int; /* GLFW version */ pub static VERSION_MAJOR : c_int = 3; pub static VERSION_MINOR : c_int = 0; pub static VERSION_REVISION : c_int...
use crypto::PublicKey; use assets::AssetBundle; use transactions::components::service::SERVICE_ID; use error::{Error, ErrorKind}; /// Transaction ID. pub const DELETE_ASSETS_ID: u16 = 400; evo_message! { /// `delete_assets` transaction. struct DeleteAssets { const TYPE = SERVICE_ID; const ID...
use std::collections::HashMap; pub fn solve_v1() -> i32 { let data = super::load_file("day6.txt"); let groups: Vec<&str> = data.split("\n\n").collect(); let mut count = 0; for group in groups { let mut chars: HashMap<u8, i32> = HashMap::new(); let answers = group.as_bytes(); fo...
use std::{fmt::Debug, ops::Index}; /// A Span is the information of a piece of source code inside a file. /// /// `Span`s are only meaningful when indexing the file it is originated from. #[derive(Clone, Copy, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Span ...
use std::convert::TryFrom; use std::time::Instant; fn main() { let img_path = "flower.jpeg"; invert_colours_threaded(img_path); invert_colours(img_path); } fn invert_colours_threaded (img_path: &str) { let img = image::open(img_path).unwrap().to_rgb(); let img_width = img.width(); let img_hei...
use std::io::{TcpListener, TcpStream, Acceptor, Listener}; fn handle(mut stream: TcpStream) { println!("New client {}", stream.peer_name()); let mut buf = [0u8, ..4096]; loop { match stream.read(buf) { Ok(0) => break, Ok(n) => { println!("{}", std::str::from_utf8(buf.slice(0, n))); ...
#[macro_use] extern crate lazy_static; extern crate parking_lot; extern crate smallvec; extern crate uuid; mod btree; mod fs; mod id;
extern crate libc; use std::ptr; use std::ffi::CStr; use std::ffi::CString; use std::thread::sleep; use std::time::Duration; use libc::c_int; use libc::c_void; mod ffi; pub use self::ffi::VslTransaction; pub use self::ffi::VslReason; pub use self::ffi::VslType; /// VsmType allows you to specify the location of the ...
use diesel::prelude::*; use sl_lib::models::*; use sl_lib::*; // delete it later and use filter for tera with rocket later instead use sl_lib::crud::create_user; use sl_lib::custom::{str_from_stdin, none_if_empty_or_string}; use console::Style; // use console::{style, Style}; // pub struct User { // pub id: i3...
pub mod geometry; pub mod lightning; pub mod system; pub mod frame; pub mod rendering;
use crate::crypto::utils; use std::vec::Vec; pub struct ChaCha20 { key: [u8; 32], nonce: [u8; 12], block_count: u32, current_state: [u32; 16], modulus: u64 } impl ChaCha20 { fn create_state(key: [u8; 32], nonce: [u8; 12], block_count: u32) -> [u32; 16] { let mut new_...
use derive_more::From; #[derive(Clone, Debug)] pub struct Foo; #[derive(Clone, Debug)] pub struct Bar; // using [derive(From)] from derive_more save us // implementing the following // // From<T> for Val { // fn from(input: T) -> Self { // Val::T(T) // } // } // // Where T can be Foo or Bar #[derive(...
use anyhow::Result; mod arguments; mod commands; mod configuration; mod error; fn main() -> Result<()> { arguments::run()?; Ok(()) }
use std::sync::Arc; use vulkano::device::Queue; use vulkano::format::ClearValue; use vulkano::format::Format; use vulkano::framebuffer::RenderPass; use vulkano::framebuffer::RenderPassAbstract; use vulkano::framebuffer::{ AttachmentDescription, LoadOp, PassDependencyDescription, PassDescription, RenderPassDesc, ...
use std::{ cmp::{max, min}, fmt::Display, sync::Arc, sync::{ atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}, Mutex, }, task::Poll, thread, time::Duration, }; use futures::FutureExt; use futures_timer::Delay; use prost::Message; use rand::Rng; use tokio::{ run...
// Exercise 1.2. // Translate the following expression into prefix form // (/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 3))))) // (* 3 (- 6 2) (- 2 7))) fn main (){ }
use crate::pcapng::blocks::common::opts_from_slice; use crate::errors::PcapError; use byteorder::{ByteOrder, ReadBytesExt}; use crate::pcapng::{UnknownOption, CustomUtf8Option, CustomBinaryOption}; use std::borrow::Cow; use derive_into_owned::IntoOwned; /// The Interface Statistics Block contains the capture statisti...
use std::pin::Pin; use std::sync::Arc; use dbus::channel::Sender; use dbus::arg; use std::future::Future; use std::marker::PhantomData; use crate::{Context, MethodErr, IfaceBuilder,stdimpl}; use crate::ifacedesc::Registry; use std::collections::{BTreeMap, HashSet}; use std::any::Any; use std::fmt; const INTROSPECTABLE...
#[doc = "Register `CFGR` reader"] pub type R = crate::R<CFGR_SPEC>; #[doc = "Register `CFGR` writer"] pub type W = crate::W<CFGR_SPEC>; #[doc = "Field `SW` reader - System clock switch This bitfield is controlled by software and hardware. The bitfield selects the clock for SYSCLK as follows: Others: Reserved The settin...
use slab::*; use std::ops::{Deref, DerefMut}; #[derive(Copy, Clone)] pub struct NodeId(usize); #[derive(Copy, Clone)] pub struct Node<T> { item: T, next: Option<usize>, prev: Option<usize>, } impl<T> Deref for Node<T> { type Target = T; fn deref(&self) -> &T { &self.item } } impl<T> ...
mod array; mod hash_map; mod hash_set; mod queue; mod raw_array; mod small_array; mod string; mod wstring; pub use array::*; pub use hash_map::*; pub use hash_set::*; pub use queue::Queue; pub(crate) use raw_array::*; pub use small_array::*; pub use string::*; pub use wstring::*;
use std::thread; use std::sync::{Arc, Mutex}; use substring::Substring; pub enum NucleicAcid { DNA, RNA } pub struct Strand { pub bases: String, pub index: usize, pub is_dna: bool, } pub struct Options { pub seq_len: usize, pub is_dna: bool, } pub fn transcribe_sequence(dna: String, opts...
use chrono::prelude::*; #[derive(Debug, Deserialize)] pub struct Notification { pub reason: String, pub subject: Subject, pub repository: Repository, } #[derive(Debug, Deserialize)] pub struct Subject { #[serde(rename = "type")] pub _type: String, pub title: String, pub url: String, } #[d...
use actix_web::{get, App, HttpServer, HttpRequest, middleware, HttpResponse, web}; use actix_files::NamedFile; use std::path::PathBuf; use std::io::Error; use actix_web::http::ContentEncoding; use serde::Deserialize; use std::fs; #[get("/{filename:.*}")] async fn index(req: HttpRequest) -> Result<NamedFile, Error> { ...
use super::*; pub struct SoundSystem { reader: ReaderId<Sound>, } impl SoundSystem { pub fn new(reader: ReaderId<Sound>) -> Self { SoundSystem { reader: reader } } } impl<'a> System<'a> for SoundSystem { type SystemData = ( ReadStorage<'a, ThreadPin<SoundData>>, ReadStorage<'a...
extern crate reqwest; extern crate serde; extern crate serde_json; use warheads::api; pub struct HttpApi {} impl HttpApi { fn post(client: &mut reqwest::Client, password: &str) -> reqwest::Result<reqwest::Response> { let url = "http://gitland.azurewebsites.net:80/api/warheads/launch?launchCode=" ...
use clap::CommandFactory; use clap_complete::{generate_to, Shell}; use std::env; use std::io::Error; use std::process; include!("src/cli.rs"); fn main() -> Result<(), Error> { let outdir = match env::var_os("OUT_DIR") { None => return Err(Error::new(std::io::ErrorKind::Other, "no $OUT_DIR!")), Som...
mod compute_constraints; mod linear_program; pub use compute_constraints::compute_constraints; //use crate::log; use crate::neighborhood::AgentNeighborhood; use crate::vec2::Vec2; use itertools::izip; #[allow(clippy::too_many_arguments)] pub fn orca_navigator( positions: &[Vec2], directions: &[Vec2], desired_v...
// Copyright 2020 EinsteinDB Project Authors. Licensed under Apache-2.0. // TODO: remove following line #![allow(dead_code)] use super::changer::Changer; use crate::evioletabftpb::{ConfChangeSingle, ConfChangeType, ConfState}; use crate::tracker::ProgressTracker; use crate::Result; /// Translates a conf state into 1...
/// An enum to represent all characters in the HangulJamoExtendedB block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum HangulJamoExtendedB { /// \u{d7b0}: 'ힰ' HangulJungseongODashYeo, /// \u{d7b1}: 'ힱ' HangulJungseongODashODashI, /// \u{d7b2}: 'ힲ' HangulJungseongYoDashA, /// ...
use actix_web::{error, http, HttpResponse}; #[derive(Fail, Debug)] pub enum FetchError { #[fail(display = "internal error")] StoreError, #[fail(display = "entry not found")] NotFoundError, #[fail(display = "no id provided")] NoProvidedIdError, #[fail(display = "unparseable id")] IDParsi...
#[doc = "Reader of register RCRC"] pub type R = crate::R<u32, super::RCRC>; #[doc = "Reader of field `RCR`"] pub type RCR_R = crate::R<u16, u16>; impl R { #[doc = "Bits 0:15 - RX CRC register"] #[inline(always)] pub fn rcr(&self) -> RCR_R { RCR_R::new((self.bits & 0xffff) as u16) } }
/* * A simple concurrency example in Rust using std::arc * * picked up bits from: https://github.com/mozilla/rust/issues/3562 * This program does foo. */ // Crate linkage metadata #[ link(name = "spawnARC", vers = "0.1.2", author = "smadhueagle") ]; #[pkg(id = "spawnARC", vers = "0.1.2")]; // Addi...
use handlegraph::handle::{Handle, NodeId}; use nalgebra_glm as glm; use crate::{ geometry::{Point, Rect}, universe::Node, view::View, }; #[derive(Debug, Clone, Copy, PartialEq)] pub enum LabelPos { World { point: Point, offset: Option<Point>, }, Handle { handle: Handle...
use std::fmt; use std::io::Write; ////////// From syntax.ml ///////// // Abstract Syntax // Variable names pub type Name = String; // Types #[derive(Debug)] pub enum Type { Int, Bool, Arrow(Box<Type>, Box<Type>), } impl Clone for Type { fn clone(&self) -> Type { match *self { Ty...
use std::io::prelude::*; use std::net::{TcpStream}; use std::error::Error; use ssh2::{Session, ErrorCode, ExtendedData}; use serde::Deserialize; use std::collections::HashMap; use log::{error, warn, info}; use crate::authenticator::Authenticator; use crate::resolver::Resolver; #[derive(Debug, Deserialize)] pub st...
//! Traits which expose underlying winit crate's types mod window; pub use window::*;
use std::{ rc::Rc, sync::{ atomic::{self, AtomicBool, AtomicU16, Ordering}, Arc, }, }; use anyhow::Context as _; use gba::{Button, ButtonSet}; use glutin::{ event::{ElementState, ModifiersState, VirtualKeyCode, WindowEvent}, PossiblyCurrent, WindowedContext, }; use parking_lot::Mute...
mod batch; mod cloud_table; mod continuation_token; pub mod de; pub mod paginated_response; pub mod table_client; mod table_entity; pub use batch::*; pub use cloud_table::*; pub use continuation_token::ContinuationToken; pub use paginated_response::PaginatedResponse; pub use table_client::*; pub use table_entity::*;
use bevy::prelude::*; use super::{is_path_empty, Piece, PieceColor, PieceType}; pub fn spawn_rook( commands: &mut Commands, material: Handle<StandardMaterial>, piece_color: PieceColor, position: (u8, u8), asset_server: &AssetServer, ) { let mesh: Handle<Mesh> = asset_server.load("models/chess_...
use std::{ fs }; pub fn main() -> Option<bool> { let file_contents = match fs::read_to_string( "./inputs/2020-12-06-aoc-01-input.txt" ) { Ok(c) => c, Err(e) => panic!("{:?}", e) }; let total_sum: usize = file_contents .split("\n\n") .map(|block| { le...
// `Iter`-like structure. // It only deals with &str (Vec<char>) (, so that we can build code simply). pub struct Consumer { queue: Vec<char>, pos: usize, } impl Consumer { pub fn new(s: &str) -> Self { let vec = s.chars().collect::<Vec<char>>(); Self { queue: vec, ...
use std::path::PathBuf; use std::sync::{atomic::AtomicBool, Arc}; use anyhow::Result; use filter::FilteredItem; use icon::{Icon, IconKind}; use jsonrpc_core::Params; use matcher::MatchType; use parking_lot::Mutex; use serde::Deserialize; use crate::stdio_server::{ rpc::{Call, MethodCall, Notification}, types:...
use crate::domain_block_processor::{ DomainBlockProcessor, PendingConsensusBlocks, ReceiptsChecker, }; use crate::{DomainParentChain, ExecutionReceiptFor, TransactionFor}; use domain_block_preprocessor::runtime_api_full::RuntimeApiFull; use domain_block_preprocessor::{DomainBlockPreprocessor, PreprocessResult}; use...
extern crate utils; use std::env; use std::io::{self, BufReader}; use std::io::prelude::*; use std::fs::File; use utils::*; #[derive(Debug)] struct Input { earliest_ts: u64, bus_ids: Vec<Option<u64>> } fn part1(input: &Input) -> u64 { let (least_wait, bus_id) = input.bus_ids.iter() .flatten() ...
use super::datasource::{ReaderBuilder, ReaderError}; use super::stream::{FilterStream, GroupByStream, InMemoryStream, LimitStream, LogFileStream, MapStream, RecordStream}; use crate::common; use crate::common::types::{DataSource, Tuple, Value, VariableName, Variables}; use crate::execution::stream::ProjectionStream; us...
// // Copyright 2020 The Project Oak Authors // // 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 o...
extern crate arrayfire; extern crate fnv; use arrayfire::{Array, Dim4, constant, add, col, row, cols, rows, join, lookup, set_col, set_row, maxof, replace, gt, ge, eq, max_all}; use std::hash::BuildHasherDefault; use std::collections::HashMap; use fnv::FnvHasher; pub type BElm = u8; type BSq = Vec<BElm>; type AlgnPs ...
// Problem 9 - Special Pythagorean triplet // // A Pythagorean triplet is a set of three natural numbers, a < b < c, for // which, a² + b² = c² // // For example, 3² + 4² = 9 + 16 = 25 = 5². // // There exists exactly one Pythagorean triplet for which a + b + c = 1000. // Find the product abc. fn main() { println!...
#[derive(Debug, Clone)] pub struct AssistantClient{ url: String, version: String, api_key: String } impl AssistantClient { pub fn new()-> AssistantClient{ AssistantClient{ url: "".to_string(), version: "".to_string(), api_key: "".to_string() } }...
use std::io; use std::net::{Ipv4Addr, UdpSocket, SocketAddr}; use std::time::Duration; use std::thread; use esp_idf_hal::interface::Interface; use dnsparse::{Header, HeaderKind, Answer, QueryKind, QueryClass, Message, OpCode, ResponseCode}; pub fn handle_request(socket: &UdpSocket, src: SocketAddr, request: Message,...
use super::*; use nom::{multi::many0, sequence::pair}; pub fn paren<'a, InnerP, Inner>(inner: InnerP) -> impl Parser<Input<'a>, Paren<Inner>, Err> where InnerP: Parser<Input<'a>, Inner, Err>, { delimited(lparen, inner, rparen) } pub fn tuple<'a, InnerP, Inner>(inner: InnerP) -> impl Parser<Input<'a>, Tuple<In...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - DMA2D control register"] pub cr: CR, #[doc = "0x04 - DMA2D Interrupt Status Register"] pub isr: ISR, #[doc = "0x08 - DMA2D interrupt flag clear register"] pub ifcr: IFCR, #[doc = "0x0c - DMA2D foreground memory ...
use literate::bin_search; fn main() { let target = 'a'; let collection = ['a', 'b', 'c']; println!("Target: {}", target); print!("Collection: "); for i in 0..collection.len() { print!("{}, ", collection[i]); } println!(""); match bin_search(&target, &collection) { Some...
//! JSON-LD helper methods use crate::config::BlogConfig; use serde_json::{json, Value}; pub static CONTEXT: &str = "http://schema.org"; pub fn full_url(config: &BlogConfig, path: &str) -> String { format!("{}/{}", config.site.url, path) } pub fn owner(config: &BlogConfig) -> Value { let photo = config ...
use super::range_wrapper::RangeInclusiveStartWrapper; use crate::std_ext::*; use std::collections::BTreeMap; use std::fmt::{self, Debug}; use std::marker::PhantomData; use std::ops::RangeInclusive; /// A map whose keys are stored as ranges bounded /// inclusively below and above `(start..=end)`. /// /// Contiguous and...
use std::path; mod file; mod location; mod operation; mod update; // mod recovery; /// The atomic operation to perform, we store a path relative to the working directory enum FileOperation { /// Files being replaced start in rw, then move to rc, but first files are moved from current to rp, finally rc is moved to...
use clap::App; use clap::ArgMatches; use crate::error::HnError; pub(crate) mod login; pub(crate) mod news; pub(crate) mod query; pub(crate) mod thread; pub(crate) mod tree; pub mod hacker_news; /// A trait defining the interface to add a subcommand to the command line /// application. pub trait HnCommand { ///...
pub mod client; pub mod common; pub mod entry; pub mod server; pub mod vecbuf; pub extern crate rustls; pub extern crate webpki; extern crate bytes; extern crate futures; extern crate iovec; extern crate tokio_io;
use q2::school_member; fn main() { school_member::student::get_marks(); }
use std::collections::HashMap; use std::string::ToString; use serde::ser::{Error, SerializeMap}; use serde::{Serialize, Serializer}; use serde_json::{json, Value}; use crate::schema::{PrimitiveType, Schema, UniqueItems}; // we output Draft 4 of the Json Schema specification because the downstream consumers // of the...
#[macro_use] extern crate lazy_static; use regex::Regex; use std::collections::HashSet; const RULES: &str = include_str!("../input.txt"); const MOLECULE: &str = &"CRnCaSiRnBSiRnFArTiBPTiTiBFArPBCaSiThSiRnTiBPBPMgArCaSiRnTiMgArCaSiThCaSiRnFArRnSiRnFArTiTiBFArCaCaSiRnSiThCaCaSiRnMgArFYSiRnFYCaFArSiThCaSiThPBPTiMgArCaPRn...
// Player Struct use super::velocity::Velocity; use super::item::Item; use sdl2::rect::Rect; pub struct Player<'p> { pub dst_rect: Option<Rect>, pub src_rect: Option<Rect>, pub texture: Option<sdl2::render::Texture<'p>>, pub velocity: Option<Velocity>, } impl Player<'_> { // Create player struct w...
use super::*; use std::io; pub struct TypeSection<'a>(pub &'a [u8], pub usize); pub struct TypeEntryIterator<'a>(&'a [u8], usize); pub enum TypeEntry<'a> { Function(FunctionType<'a>), } pub struct FunctionType<'a> { pub form: LanguageType, params_count: usize, params_raw: &'a [u8], pub return_ty...
use crate::cli::{SudoAction, SudoOptions}; use crate::system::{hostname, Group, Process, User}; use std::path::PathBuf; use super::{ command::CommandAndArguments, resolve::{resolve_current_user, resolve_launch_and_shell, resolve_target_user_and_group}, Error, }; #[derive(Debug)] pub struct Context { /...
pub mod anchor; pub mod category; pub mod iter; pub mod page; pub mod writer; pub use self::{ anchor::Anchor, iter::{PageIterator, RawPageIterator, TantivyPageIterator}, page::Page, writer::PageWriter, };
use crate::intro::Intro; use crate::resources::Lifes; use crate::resources::MaterialVector; use crate::util::*; use amethyst::{assets::Loader, input::is_close_requested, prelude::*, ui::TtfFormat}; pub struct Loading; impl<'a, 'b> State<GameData<'a, 'b>, StateEvent> for Loading { fn on_start(&mut self, data: Stat...
use amethyst::ecs::Entity; use amethyst::renderer::Material; pub struct MaterialVector { pub pad: Material, pub ball: Material, pub lifes: Vec<Material>, } #[derive(Default)] pub struct Lifes { pub lifes: u32, pub e: Option<Entity>, } #[derive(Default)] pub struct WindowSize { pub width: f32,...
use crate::{error, helpers, open}; use std::io::Write; use std::process::{Command, Stdio}; use std::sync::{atomic, Arc}; use std::time::SystemTime; use std::{fmt, fs, io}; use structopt::StructOpt; mod examples; use examples::Examples; #[derive(StructOpt, Debug)] pub struct NewOpts { /// The name of the playgrou...
// Copyright 2019. The Tari Project // SPDX-License-Identifier: BSD-3-Clause use crate::{ ristretto::{RistrettoPublicKey, RistrettoSecretKey}, signatures::{SchnorrSigChallenge, SchnorrSignature}, }; /// # A Schnorr signature implementation on Ristretto /// /// Find out more about [Schnorr signatures](https://...
#![allow(dead_code)] extern crate reqwest; // enum method enum Day{ Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday } impl Day { fn is_weekday(&self) -> bool { match self { &Day::Saturday | &Day::Sunday => return false, _ => return true } } } ...
fn main() { let i = convert_fracts(vec![(690, 1300), (87, 1310), (30, 40)]); print!("{:?}", i); } fn is_common_denominator(l: &[i64], denom: i64) -> bool { for t in l.iter() { if denom % t != 0 { return false; } } true } fn get_max_denominator(l: i64, k: i64) -> i64 { let mut d = 1; for i in 2 .. k / 2...
#[doc = "Reader of register CCR"] pub type R = crate::R<u32, super::CCR>; #[doc = "Reader of field `STKALIGN`"] pub type STKALIGN_R = crate::R<bool, bool>; #[doc = "Reader of field `UNALIGN_TRP`"] pub type UNALIGN_TRP_R = crate::R<bool, bool>; impl R { #[doc = "Bit 9 - Always reads as one, indicates 8-byte stack al...
#[doc = "Register `CSR` reader"] pub type R = crate::R<CSR_SPEC>; #[doc = "Register `CSR` writer"] pub type W = crate::W<CSR_SPEC>; #[doc = "Field `LSION` reader - Internal low-speed oscillator enable"] pub type LSION_R = crate::BitReader; #[doc = "Field `LSION` writer - Internal low-speed oscillator enable"] pub type ...
use criterion::{criterion_group, criterion_main}; use criterion::{BenchmarkId, Criterion}; #[cfg(unix)] use pprof::criterion::{Output, PProfProfiler}; use ppp::v2; fn ipv6_input() -> Vec<u8> { let prefix = b"\r\n\r\n\0\r\nQUIT\n"; let mut input: Vec<u8> = Vec::with_capacity(prefix.len()); input.extend_f...
pub mod closure; pub mod enums; pub mod guess_game; pub mod hello; pub mod structs; pub mod vectors; pub mod warmy;
use crate::types::*; pub(crate) unsafe fn get_last_base_out_struct_chain( mut s: *mut VkBaseOutStructure, ) -> *mut VkBaseOutStructure { while !(*s).p_next.is_null() { s = (*s).p_next as *mut VkBaseOutStructure; } return s; }
#[doc = "Register `DR` reader"] pub type R = crate::R<DR_SPEC>; #[doc = "Register `DR` writer"] pub type W = crate::W<DR_SPEC>; #[doc = "Field `DU` reader - Date units in BCD format"] pub type DU_R = crate::FieldReader; #[doc = "Field `DU` writer - Date units in BCD format"] pub type DU_W<'a, REG, const O: u8> = crate:...
use lc_render::{Chart, Color, LinearScale, PointType, ScatterView}; fn main() { let width = 800; let height = 600; let margin_top = 90; let margin_bottom = 50; let margin_left = 60; let margin_right = 40; let x_scale = LinearScale::new(0.0, 200.0, 0, width - margin_left - margin_right); ...
use rand::Rng; use crate::data::{EOChar, EOInt, EOShort}; #[derive(Debug, Default)] pub struct ServerSequencer { sequence_start: EOInt, upcoming_sequence_start: EOInt, sequence: EOInt, } impl ServerSequencer { pub fn init_new_sequence(&mut self) { let mut rng = rand::thread_rng(); sel...
#[doc = "Register `WPCR0` reader"] pub type R = crate::R<WPCR0_SPEC>; #[doc = "Register `WPCR0` writer"] pub type W = crate::W<WPCR0_SPEC>; #[doc = "Field `UIX4` reader - UIX4"] pub type UIX4_R = crate::FieldReader; #[doc = "Field `UIX4` writer - UIX4"] pub type UIX4_W<'a, REG, const O: u8> = crate::FieldWriter<'a, REG...
//! Tests auto-converted from "sass-spec/spec/non_conformant/parser/interpolate/13_escaped_single_quoted" #[allow(unused)] use super::rsass; // From "sass-spec/spec/non_conformant/parser/interpolate/13_escaped_single_quoted/01_inline.hrx" #[test] fn t01_inline() { assert_eq!( rsass( ".result {\...
use druid::widget::{Align, Button, Flex, Label, Padding, TextBox}; use druid::{AppLauncher, Data, Lens, LocalizedString, Widget, WidgetExt, WindowDesc}; const VERTICAL_WIDGET_SPACING: f64 = 20.0; const HORIZTONAL_WIDGET_SPACING: f64 = 8.0; const WINDOW_TITLE: LocalizedString<HelloState> = LocalizedString::new("Rakaly"...
extern crate clap; extern crate dirs; mod config; use clap::{App, SubCommand, Arg}; use std::path::Path; use std::io::prelude::*; use std::io::{BufReader, BufRead}; use std::fs::{OpenOptions, create_dir_all, read_dir}; use std::error::Error; use std::time::{SystemTime, Duration}; fn track_task(task_name: &str) -> Re...
use embedded_hal::blocking::i2c::{Operation as I2cOperation, Transactional}; const ADDR: u8 = 0x48; pub struct PCF8591<I2C> { i2c: I2C, } enum ADCNum { AIN0, AIN1, AIN2, AIN3, } impl<I2C> PCF8591<I2C> where I2C: Transactional, { pub fn new(i2c: I2C) -> Self { Self { i2c } } ...
mod expand_repeats; mod expand_tokens; mod extract_default_aliases; mod extract_tokens; mod flatten_grammar; mod intern_symbols; mod process_inlines; pub(crate) use self::expand_tokens::expand_tokens; use self::expand_repeats::expand_repeats; use self::extract_default_aliases::extract_default_aliases; use self::extra...
use std::str; #[derive(Clone, Debug, Default, Hash, PartialEq, Serialize, Deserialize)] pub struct Table { pub name: String, pub alias: Option<String>, } impl<'a> From<&'a str> for Table { fn from(t: &str) -> Table { Table { name: String::from(t), alias: None, } ...
use crate::{ _utils::error::BootError, account::controller::create_account_router, auth::controller::create_auth_router, import::controller::create_import_router, post::controller::create_post_router, search::{controller::create_search_router, cron_job::SearchCronJob}, tag::controller::create_tag_router, ...
#![warn(rust_2018_idioms)] // TODO: remove this! #![allow(dead_code)] use std::collections::HashMap; use crate::model::{FlatDeck, Hand, Player}; pub mod client; pub mod model; pub mod protocol; pub mod server; struct State { deck: FlatDeck, players: HashMap<Player, Option<Hand>>, } struct PlayerState { ...
// Copyright 2015-2016 Brian Smith. // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAI...
#![feature(box_syntax, box_patterns)] #![feature(plugin)] #![plugin(stainless)] extern crate tinytl; pub use tinytl::syntax::*; pub use tinytl::types::*; pub use tinytl::infer::*; pub use tinytl::env::*; pub use std::collections::HashMap; pub fn run_infer_spec(expr: &Expr, expect: &'static str) { assert_eq!(forma...
pub mod ast; pub mod env; pub mod eval; pub mod parse;
use std::convert::TryFrom; use std::fmt; use num_enum::TryFromPrimitive; use crate::device::Device; use crate::encoder::Encoder; use crate::error::Result; use crate::mode::Mode; use crate::object::Object; use crate::object::ObjectType; use crate::rawdevice::drm_mode_get_connector; #[allow(dead_code)] #[derive(Clone)...
extern crate info; fn main() { println!("info is: {}", info::INFO); }
use super::{Item, ItemMediaType, ListType, StrNum}; use std::error::Error; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct Manga { id: u32, status: u8, manga_id: u32, manga_title: StrNum, manga_num_chapters: i16, manga_publishing_status: u8, manga_...
use installer::archive::*; fn main(){ let args: Vec<String> = std::env::args().skip(1).collect(); let archive = archive(&args.get(0).unwrap()).unwrap(); println!("archived with len: {}", archive.len()); //let compressed = compress(&archive).unwrap(); //println!("compressed"); //let decompressed...
/* chapter 4 syntax and semantics */ fn main() { let a = vec![1, 2, 3]; let b = vec![1, 2, 3]; fn foo(a: &Vec<i32>, b: &Vec<i32>) -> i32 { // do stuff with a and b println!("{:?}\n{:?}", a, b); // hand back ownership, and the result of our function 42 } let answer...
use std::io::Result; /// 写入数据,并且同时写入到的follower/slaves, 但忽略follower的返回值。 /// 如果master写入失败,则请求直接返回。 /// 忽略所有follower的写入失败情况。 use std::pin::Pin; use std::task::{Context, Poll}; use futures::ready; use protocol::Protocol; use crate::{AsyncReadAll, AsyncWriteAll, Request, Response}; pub struct AsyncSetSync<M, F, P> { ...