text
stringlengths
8
4.13M
pub mod bit_wrapper; pub mod e256; pub mod ec; pub mod field; pub mod gf256; pub mod operation; pub mod poly;
use paige::*; fn main() { let page = Page::new(&[ Tag::Html.content(&[ Tag::Head.content(&[ Tag::Meta.attributes(&[Attr::Charset("UTF-8".into())]) ]), Tag::Body.style(&[Prop::Background("green".into())]).content(&[]) ]) ]); println!("{}", page.format(...
use super::BufferTag; use crate::tools::ctags::CTAGS_HAS_JSON_FEATURE; use rayon::prelude::*; use std::io::Result; use std::ops::Deref; use std::path::Path; use std::process::Stdio; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use subprocess::{Exec as SubprocessCommand, Redirection}; use tokio::p...
// Copyright 2022 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 agre...
use std::env; use std::error::Error; use std::fs; use std::path::PathBuf; use std::process::Command; use quote::{format_ident, quote}; fn main() -> Result<(), Box<dyn Error>> { let mut functions = vec![]; let mut tests = vec![]; for entry in fs::read_dir("vendor")? { let repo_path = entry?.path()...
use thiserror::Error; #[derive(Error, Debug)] pub enum PmError { #[error("index already exists")] IndexExists, }
mod cell; mod cells; use std::iter::Iterator; use rand::{self, Rng}; pub use self::cells::Cells; pub use self::cell::Cell; pub use self::cell::Team; pub struct GameOfLife { width: usize, height: usize, pub cells: Cells, } impl GameOfLife { pub fn new(width: usize, height: usize) -> GameOfLife { ...
use crate::lib::{default_sub_command, file_to_lines, parse_lines, Command}; use anyhow::Error; use clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand}; use nom::{branch::alt, character::complete, combinator::map, multi::many1}; use simple_error::SimpleError; use strum::VariantNames; use strum_macros::{EnumString,...
#![no_std] #![deny(unsafe_code)] extern crate stm32f4xx_hal as hal; use crate::hal::{i2c, i2s}; use crate::register::*; mod register; pub mod wave_header; const DEVICE_ADDRESS: u8 = 0x1A; #[derive(Debug)] pub enum Error { I2c(i2c::Error), I2s(i2s::Error), InvalidInputData, } pub struct Wm8960<I2C, I2S...
use crate::{ error::{ProtoError, ProtoErrorKind, ProtoErrorResultExt}, message::{ ChannelName, ChatCapabilitiesFlags, NowChatMsg, NowChatSyncMsg, NowChatTextMsg, NowString65535, NowVirtualChannel, }, sm::{VirtChannelSMResult, VirtualChannelSM}, }; use std::{cell::RefCell, rc::Rc, str::Fr...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[link(name = "windows")] extern "system" { #[cfg(feature = "Win32_Foundation")] pub fn RegisterLicenseKeyWithExpiration(licensekey: super::super::Foundation::PWSTR, validityindays: u32, status: *m...
use actix_web::{web, App, HttpServer}; use controller; #[actix_web::main] pub async fn run() -> std::io::Result<()> { HttpServer::new(|| { App::new() .service(controller::hello) .service(controller::echo) .route("/hey", web::get().to(controller::manual_hello)) }) ...
// Copyright 2019 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. use { fidl_fuchsia_wlan_service::{ErrCode, ScanRequest, ScanResult, WlanMarker, WlanProxy}, fidl_fuchsia_wlan_tap::WlantapPhyProxy, fuchsia_com...
use std::io::{self, Read}; #[macro_use] extern crate enum_map; use enum_map::EnumMap; #[derive(Copy, Clone, Debug, EnumMap)] pub enum Axis { Nw, N, Ne, } #[derive(Copy, Clone, Debug)] pub enum Direction { Forward, Backward, } #[derive(Copy, Clone, Debug)] pub struct Step { pub axis: Axis, pub d...
// The MIT License (MIT) // // Copyright (c) 2013 Jeremy Letang (letang.jeremy@gmail.com) // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitati...
use std::ops::Index; /// Represents a token in a material source file. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Token { /* Keywords */ Program, Property, /* Operator symbols */ Eq, /* Structural symbols */ Colon, SemiColon, OpenCurly, CloseCurly, /* Lit...
#![deny(warnings)] #![no_std] #[macro_use] extern crate bounded_registers; #[macro_use] extern crate typenum; pub mod ccu; pub mod de; pub mod de_mixer; pub mod dma; pub mod hdmi; pub mod hstimer; pub mod pio; pub mod sysc; pub mod tcon0; pub mod tcon1; pub mod timer; pub mod uart0; pub mod uart1; pub mod uart2; pub ...
//! # Jplaceholder //! [![Build Status](https://travis-ci.com/WebD-EG/Jplaceholder-Rust.svg?token=2xwgxyVwYTZY33ZwbM8M&branch=master)](https://travis-ci.com/WebD-EG/Jplaceholder-Rust) //! A Rust library for the JSON Placeholder API //! Documentation: [https://docs.rs/jplaceholder/1.0.1/jplaceholder/](https://docs.rs/j...
#[cfg(test)] mod tests { use std::collections::HashSet; use std::fs::File; use std::io::{BufReader, Lines}; use std::str::FromStr; use crate::reader::get_lines; use crate::grid::{Grid, Point}; #[test] fn test_part1() { let input = get_lines("./resources/inputs/day9-input.txt")...
use base_x; use diesel::debug_query; use diesel::prelude::*; use failure::{Fallible, ResultExt}; use std::{cmp, str}; use uuid::Uuid; use crate::db::{self, model::*, schema::*, Paginate}; pub struct PadsDao { pool: db::DBPool, } impl PadsDao { pub fn new(pool: &db::DBPool) -> Self { Self { pool: pool...
use crate::Register; /// Represents whether a pin is an input or an output. pub enum DataDirection { /// The pin is exclusively used for reading signals. Input, /// The pin is exclusively used for sending signals. Output, } /// An IO pin. pub trait Pin { /// The associated data direction register....
// This is cut-and-pasted from the example in the docs of src/lib.rs. fn main() { use cam_geom::*; use nalgebra::{Matrix2x3, Unit, Vector3}; // Create two points in the world coordinate frame. let world_coords = Points::new(Matrix2x3::new( 1.0, 0.0, 0.0, // point 1 0.0, 1.0, 0.0, // po...
use crate::Result; use serde::{Deserialize, Serialize}; #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] pub(crate) struct Response { pub filter: Filter, } #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] pub(crate) struct ResponseList { pub filters: Vec<Filter>, } /// A...
#[cfg(feature = "sgx")] use std::prelude::v1::*; use atomic::{Atomic, Ordering}; use crate::io::IoUringProvider; use crate::poll::{Events, Pollee}; // The common part of the socket's sender and receiver. pub struct Common<P: IoUringProvider> { fd: i32, pollee: Pollee, error: Atomic<Option<i32>>, phan...
use crate::ray::Ray; mod aabb; mod bvh; mod hit_record; mod hittable_list; mod sphere; pub use aabb::AABB; pub use bvh::BVH; pub use hit_record::HitRecord; pub use hittable_list::HittableList; pub use sphere::Sphere; pub trait Hittable: Send + Sync { fn hit(&self, ray: &Ray, t_min: f64, t_max: f64, rec: &mut Hit...
pub use VkPipelineColorBlendStateCreateFlags::*; #[repr(u32)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum VkPipelineColorBlendStateCreateFlags { VK_PIPELINE_COLOR_BLEND_STATE_CREATE_NULL_BIT = 0, } use crate::SetupVkFlags; #[repr(C)] #[derive(Clone, Copy, Eq, PartialEq, Hash)] pub struct VkPipelineColo...
extern crate tictactoe; use tictactoe::board::{Board, GameOutcome}; use tictactoe::player::Player; #[test] fn win() { let mut board = Board::new(); board.play_x(6).unwrap(); board.play_o().unwrap(); board.play_x(7).unwrap(); board.play_o().unwrap(); let outcome = board.play_x(8).unwrap().unwra...
use num::traits::PrimInt; use std::cmp::max; use unicode_segmentation::UnicodeSegmentation; pub fn largest_palindrome(digits: u32) -> u32 { let lower = 10.pow(digits - 1); let upper = 10.pow(digits); let range = lower..upper; range.fold(0, |largest, x| { match (lower..x + 1).rev().find(|y| is_...
use structopt::StructOpt; use super::{CliCommand, GlobalFlags}; pub const AFTER_HELP: &str = r#"EXAMPLES: To install the latest version of a package: $ deck install firefox To install a specific version of a package: $ deck install firefox:67.0.0-alpha1 To install multiple packages: $ deck i...
// Copyright 2022 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 ...
mod read_file; use std::io; fn main(){ let greeting = "Welcome to the software!\nPlease choose from the following menu: \n 1. Read from a file. \n 2. Write to a file.".to_string(); loop { println!("{}", greeting); let mut input = String::new(); io::stdin().read_line(&mut input).unwrap()...
use once_cell::sync::Lazy; use std::num::ParseIntError; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use pyo3::types::PyDict; use regex::Regex; use ukis_h3cellstore::clickhouse::compacted_tables::schema::{ AggregationMethod, ClickhouseDataType, ColumnDefinition, CompactedTableSchema, CompactedTab...
#![allow(dead_code)] #![allow(unused_imports)] use super::*; use super::poppy as pop; pub struct Louds { packed_bits: pop::Poppy<u64>, }
//! Contains types related to the [`World`] entity collection. use std::{ collections::HashMap, mem, ops::Range, sync::atomic::{AtomicU64, Ordering}, }; use bit_set::BitSet; use itertools::Itertools; use super::{ entity::{Allocate, Entity, EntityHasher, EntityLocation, LocationMap, ID_CLONE_MAPPI...
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. pub fn parse_http_generic_error( response: &http::Response<bytes::Bytes>, ) -> Result<smithy_types::Error, smithy_json::deserialize::Error> { crate::json_errors::parse_generic_error(response.body(), response.headers()) } pub fn de...
use std::cmp::{max, min}; use std::collections::{HashMap, HashSet}; use itertools::Itertools; use whiteread::parse_line; // dp // https://atcoder.jp/contests/joi2013yo/tasks/joi2013yo_d fn main() { let (d, n): (usize, usize) = parse_line().unwrap(); let mut tt: Vec<usize> = vec![]; for _ in 0..d { ...
use tree_walk_interpreter::interpreter::Interpreter; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use parser::lexer::Lexer; use parser::parser::Parser; use parser::resolver::Resolver; use parser::types::Pass; const PROGRAM: &str = " fun fibonacci(a) { if (a < 2) return a; return fibo...
use std::fs; use std::fs::OpenOptions; use std::io::prelude::*; const SOLUTION: &str = "use crate::AoCDay; pub struct Code; impl AoCDay for Code { fn part1(&self, _input: &mut dyn std::io::Read, _extra_argss: &[String]) -> String { todo!() } fn part2(&self, _input: &mut dyn std::io::Read, _extra...
use bit_set::BitSet; use itertools::Itertools; use board::group_access::GroupAccess; use board::stones::grouprc::GoGroupRc; use board::stones::stone::Stone; use graph_lib::topology::Topology; pub struct Go<'a, T: GroupAccess> { state: &'a T } impl<'a, T: GroupAccess> Go<'a, T> { pub fn new(state: &'a T) -> G...
use seed::{prelude::*, *}; pub fn view<Ms>() -> Node<Ms> { div!["not found"] }
#[derive(Default, Debug, Clone, PartialEq, serde_derive::Serialize, serde_derive::Deserialize)] pub struct Dynset { pub data: Data, } #[derive(Default, Debug, Clone, PartialEq, serde_derive::Serialize, serde_derive::Deserialize)] pub struct Data { #[serde(rename = "TrendingSet")] pub trending_set: Option<T...
//! https://github.com/lumen/otp/tree/lumen/lib/erl_docgen/src use super::*; test_compiles_lumen_otp!(docgen_edoc_xml_cb); test_compiles_lumen_otp!(docgen_otp_specs); test_compiles_lumen_otp!(docgen_xmerl_xml_cb); test_compiles_lumen_otp!(docgen_xml_check); test_compiles_lumen_otp!(docgen_xml_to_chunk); fn includes(...
use chrono::{DateTime, Utc}; use eyre::{Result, WrapErr}; use serde::{Deserialize, Serialize}; use std::fmt; use std::io::Write; use std::path::{Path, PathBuf}; #[derive(Debug, Serialize, Deserialize)] pub struct Meta { pub name: String, } #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone, Copy)]...
use generated_types::influxdata::iox::partition_template::v1 as proto; use snafu::{ResultExt, Snafu}; #[allow(clippy::enum_variant_names)] #[derive(Debug, Snafu)] pub enum Error { #[snafu(display("Client Error: Invalid partition template format : {source}"))] InvalidPartitionTemplate { source: serde_json::Erro...
pub fn verse(n: u32) -> String { match n { 0 => "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n".into(), 1 => "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of bee...
pub fn quicksort(a: &mut [i32], l: usize, h: usize) { if l < h { let p = partition(a, l, h); quicksort(a, l, p - 1); // left of pivot quicksort(a, p + 1, h); // right of pivot } } fn partition(a: &mut [i32], l: usize, h: usize) -> usize { let index = h; let pivot = a[index]; ...
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor 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 ...
extern crate time; extern crate postgres; use postgres::{PostgresConnection, NoSsl}; use time::Timespec; struct SensorPacket { id: i32, value: f64, name: String, time_created: time::Timespec } fn main() { let conn = PostgresConnection::connect("postgres://root:alphabeta@127.0.0.1:5432/local",&NoSsl).unwrap(...
#[allow(unused_imports)] use proconio::{marker::*, *}; #[fastout] fn main() { input! { n: i32, } let mut s = "0".repeat(10); for i in 0..10 { let d = 1 << i; s.replace_range((10-i-1)..(10-i), if n / d % 2 == 0 { "0" } else { "1" }); } println!("{}", s); }
use std::sync::Arc; use std::time::Instant; use crate::raw_event::RawEvent; use crate::serialization::SerializationSink; use crate::StringId; pub struct Profiler<S: SerializationSink> { event_sink: Arc<S>, start_time: Instant, } impl<S: SerializationSink> Profiler<S> { pub fn new(event_sink: Arc<S>) -> Se...
#![allow(bad_style)] #[macro_use] extern crate pest_derive; extern crate pest; mod parser { #[derive(Parser)] #[grammar = "../examples/calc.pest"] pub struct Parser; } use pest::{ Parser, iterators::Pairs, pratt_parser::{ PrattParser, Assoc::*, Op, }, }; use std::io::{stdin, stdout, Write, ...
mod network { #[derive(Clone)] pub struct PipeWrap { pipe_fd: Vec<usize>, } impl PipeWrap { fn new() -> Self { let mut fd: Vec<usize> = vec![]; fd.push(usize::MAX); fd.push(usize::MAX); Self { pipe_fd: fd, } ...
use std::ffi::CString; use std::os::raw::c_char; static MSG: &'static str = "[mozMeetup] hello from rust"; #[no_mangle] pub fn hello() -> *mut c_char { let s = CString::new(MSG).unwrap(); s.into_raw() } #[no_mangle] pub fn get_len() -> usize { MSG.len() } fn main() { // blank intentionally }
mod with_tuples_in_init_list; use super::*; #[test] fn without_tuple_in_init_list_errors_badarg() { run!( |arc_process| { ( Just(arc_process.clone()), (0_usize..255_usize), strategy::term(arc_process.clone()), strategy::term::is_n...
use std::collections::HashSet; const INPUT: &str = include_str!("./input"); fn parse_anyone_yes(input: &str) -> usize { input .trim_end() .split("\n\n") .map(|group| { group .lines() .flat_map(|s| s.chars()) .collect::<HashSet<_>>...
use crate::{ grammar::ty_path, grammar::{ty_name, Parser}, parser::Marker, SyntaxKind::*, T, }; use super::{method_decl, method_sig}; pub(crate) fn trait_decl(p: &mut Parser, m: Marker) { p.bump(T![trait]); ty_path(p); p.expect(T![=]); trait_expr(p); m.complete(p, TRAIT_DECL); ...
use std::convert::{TryFrom, TryInto}; use anyhow::*; use liblumen_alloc::erts::term::prelude::*; use crate::runtime::proplist::*; pub struct Options { pub positive: bool, pub monotonic: bool, } impl Default for Options { fn default() -> Self { Self { monotonic: false, po...
//! Representations of errors returned by this crate. use ssmarshal; #[cfg(feature = "use_std")] use std::io; #[cfg(feature = "use_std")] use std::result; #[cfg(not(feature = "use_std"))] use core::result; /// Type alias for results from this crate. pub type Result<T> = result::Result<T, Error>; /// Errors from th...
#[test] fn teest_const() { const N: i32 = 5; } #[test] fn test_static() { static N: i32 = 5; static NAME: &'static str = "Steve"; } #[test] fn test_mutable_static() { static mut N: i32 = 5; // mutating static variables is unsafe unsafe { N += 1; println!("N: {}", N); } }
fn main() { let x = String::from("hello"); let y = x; println!("{}", x) // error: x does not own a resource }
/// A color struct #[derive(Copy, Clone, Debug)] pub struct Color { pub r: u8, pub g: u8, pub b: u8, } impl Color { /// Get the manhattan distance between two colors pub fn dist(&self, color: &Color) -> u16 { ((color.r as i16 - self.r as i16).abs() + (color.g as i16 - self.g as i16).abs() +...
//! Container for resources, that can be any type. This is inspired by Shred and AnyMap. //! AnyMap didn't fill my usecase as there is no way to borrow mutably 2 values for different //! keys. (`get_mut(&mut self)`). //! //! This container is using interior mutability with `RefCell` to allow this usecase. //! Downcasti...
use super::day::{Day}; use itertools::Itertools; pub struct Day01 {} impl Day for Day01 { fn day_number(&self) -> &str { "01" } fn part_1(&self) -> String { let input: Vec<i32> = self.load_input() .lines() .filte...
pub struct Ball { pub x: i32, pub y: i32, x_dir: i8, y_dir: i8, } impl Ball { pub fn new(x_start: u32, y_start:u32) -> Ball { Ball { x: x_start as i32, x_dir: 1, y: y_start as i32, y_dir: 1, } } pub fn update(&mut self, width_...
use super::*; #[derive(Debug)] pub struct Block { pub index: usize, pub timestamp: u128, pub hash: BlockHash, pub prev_block_hash: BlockHash, pub nonce: u64, pub payload: String, pub difficulty: u128, } impl Block { pub fn new( index: usize, timestamp: u128, pre...
#[doc = r"Value read from the register"] pub struct R { bits: u16, } #[doc = r"Value to write to the register"] pub struct W { bits: u16, } impl super::DMACTL4 { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, ...
//! This module contains a wide variety of helper functions and structures that have //! no consistent theme. //! //! #![allow(unused)] use std::time::{Instant, Duration}; /// StopWatch is an Instant helper function used for timing. /// /// ## Example /// ``` /// let sw = StopWatch::new(); /// /// for i in 0..50{...
use std::{fs, path::Path}; use eyre::Result; use proc_macro2::{Punct, Spacing}; use quote::{format_ident, quote}; use serde::{Deserialize, Serialize}; use ungrammar::Grammar; use xshell::cmd; use crate::utils; #[derive(Debug, Serialize, Deserialize)] pub struct KindsSrc { punct: Vec<(String, String)>, keywor...
use crate::render::systems; use bevy::prelude::*; /// Plugin responsible for creating meshes to render the Rapier physics scene. pub struct RapierRenderPlugin; impl Plugin for RapierRenderPlugin { fn build(&self, app: &mut AppBuilder) { app.add_system_to_stage( stage::PRE_UPDATE, s...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[cfg(feature = "Win32_Data_Xml_MsXml")] pub mod MsXml; #[cfg(feature = "Win32_Data_Xml_XmlLite")] pub mod XmlLite;
extern crate libc; use std::env; use std::ffi::CString; #[link(name = "tts")] extern { fn tts_init() -> i32; fn tts_msg(msg: *const libc::c_char) -> i32; fn tts_close() -> i32; } fn main() { if env::args().len() < 2{ println!("ERROR: wrong number of command-line arguments."); println...
pub struct NumArray { nums: Vec<i32>, tree: Vec<i32>, } impl NumArray { pub fn new(nums: Vec<i32>) -> Self { let mut tree = nums.clone(); let mut p = 1; let mut q = 2; while p < tree.len() { let mut i = 0; while i + p < tree.len() { tr...
pub type DeviceConfiguration = libk4a_sys::k4a_device_configuration_t; pub type DepthMode = libk4a_sys::k4a_depth_mode_t; pub type ColorResolution = libk4a_sys::k4a_color_resolution_t;
#![allow(dead_code, unused_imports)] use shipyard::*; use shipyard_scenegraph::prelude::*; use std::borrow::{Borrow, BorrowMut}; use std::collections::{hash_map::Entry, HashMap}; use std::hash::Hash; mod helpers; use helpers::*; #[test] fn test_transform_dirty() { let (world, entities, _labels) = create_scene_grap...
use std::fs::File; use std::io; use std::io::prelude::*; use std::path::{Path, PathBuf}; use serde::{Deserialize, Serialize}; use crate::error::FatalError; pub trait ConfigSource { fn exclude_paths(&self) -> Option<&[String]> { None } fn sign_commit(&self) -> Option<bool> { None } ...
//! Bindings to the HydraHarp400 library from PicoQuant #[macro_use] extern crate num_derive; use pyo3::prelude::*; use pyo3::wrap_pyfunction; pub mod bindings { include!(concat!(env!("OUT_DIR"), "/bindings.rs")); } pub mod device; pub mod measurement; pub mod types; #[cfg(feature = "pyo3")] pub mod python_wrap...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct EmailDataProviderConnection(pub ::windows::cor...
extern crate num_complex; mod gamma; mod polynomials; mod ei; mod antiderivatives; pub mod sf{ pub use gamma::*; pub use polynomials::*; pub use ei::*; pub use antiderivatives::*; } pub mod nt; pub mod pc; #[allow(non_camel_case_types)] pub type c64 = num_complex::Complex<f64>; pub const TAU: f64 = 6.2831...
pub struct Solution; impl Solution { pub fn restore_ip_addresses(s: String) -> Vec<String> { let mut res = Vec::new(); rec(&mut String::new(), &s, 4, &mut res); res } } fn rec(head: &mut String, s: &str, count: usize, res: &mut Vec<String>) { if s.is_empty() || count == 0 { ...
#[doc = "Reader of register BDMUPDR"] pub type R = crate::R<u32, super::BDMUPDR>; #[doc = "Writer for register BDMUPDR"] pub type W = crate::W<u32, super::BDMUPDR>; #[doc = "Register BDMUPDR `reset()`'s with value 0"] impl crate::ResetValue for super::BDMUPDR { type Type = u32; #[inline(always)] fn reset_va...
use std::fmt; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum HeaderFlag { QueryRespone, AuthAnswer, Truncation, RecursionDesired, RecursionAvailable, AuthenticData, CheckDisable, } impl HeaderFlag { pub fn flag_mask(self) -> u16 { match self { HeaderFlag::Que...
//! The python `time` module. // See also: // https://docs.python.org/3/library/time.html pub use time::*; #[pymodule(name = "time", with(platform))] mod time { use crate::{ builtins::{PyStrRef, PyTypeRef}, function::{Either, FuncArgs, OptionalArg}, types::PyStructSequence, PyObjec...
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. pub fn serialize_operation_create_bot_version( input: &crate::input::CreateBotVersionInput, ) -> Result<smithy_http::body::SdkBody, smithy_types::Error> { let mut out = String::new(); let mut object = smithy_json::serialize::Js...
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. //! Monitor a process. //! //! This module only supports **Linux** platform. use std::collections::HashMap; use std::sync::Mutex; use crate::counter::{Counter, CounterVec}; use crate::desc::Desc; use crate::gauge::{Gauge, GaugeVec}; use crate::metric...
#[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Start ECB block encrypt"] pub tasks_startecb: TASKS_STARTECB, #[doc = "0x04 - Abort a possible executing ECB operation"] pub tasks_stopecb: TASKS_STOPECB, _reserved2: [u8; 248usize], #[doc = "0x100 - ECB block encr...
use crate::device::Device; use crate::measurement::{Measureable, Measurement}; use crate::types::convert_hydra_harp_result; use pyo3::exceptions; use pyo3::prelude::*; use pyo3::wrap_pyfunction; use std::collections::VecDeque; use std::thread::sleep; use std::time::Duration; fn unwrap_or_value_error<T>(x: i32) -> PyRe...
use std::collections::HashMap; use std::string::CowString; use std::borrow::Cow; use compiler::{EnvVar, Syntax}; use primitive::libprimitive; /// Compiles the global env from `base` pub fn libbase() -> HashMap<CowString<'static>, EnvVar> { let mut lib = HashMap::new(); for &(name, ref func) in libprimitive()....
use crate::window::{Window, Geometry}; use crate::stack::Stack; pub fn handle_layout<W>(view: &Geometry, windows: Stack<Window<W>>) -> Stack<Window<W>> { let window_count = windows.len(); if window_count == 0 { return windows; }; windows.into_iter().enumerate() .map(|(pos, (is_current, window))| { ...
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. pub fn parse_http_generic_error( response: &http::Response<bytes::Bytes>, ) -> Result<smithy_types::Error, smithy_json::deserialize::Error> { crate::json_errors::parse_generic_error(response.body(), response.headers()) } pub fn de...
//! An `Expression`. //! //! # Expression Rules //! ## Bitness //! We refer to the number of bits in the result of an `Expression` as its _bitness_. //! //! Expressions must always have the same bitness. For example, you cannot add an 8-bit and a //! 16-bit expression. You must extern or truncate one of these operands ...
use crate::{ Error, Result, lifecycle::{Event, Window}, }; /// The structure responsible for managing the game loop state pub trait State: 'static { /// Create the state given the window and canvas fn new() -> Result<Self> where Self: Sized; /// Tick the State forward one frame /// /// Will...
use sqlx::types::Json; use super::*; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Storage { pub id: Uuid, pub name: String, pub status: Status, pub storage_type: StorageType, pub config: Json<StorageConfig>, } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct NewStorage { ...
use core::fmt; use core::fmt::Debug; #[derive(Clone, Copy)] pub enum XpsError { StreamNotOpened, InvalidHeader, Unknown, FileNotLoaded, PathGetParent, PathToStr, MeshReadAscii, MeshReadBin, None, } impl Default for XpsError { fn default() -> XpsError { XpsError::Unknown } } impl Debug for ...
use std::io; use byteorder::ByteOrder; use crate::io::Buf; pub trait BufExt { fn get_uint_lenenc<T: ByteOrder>(&mut self) -> io::Result<Option<u64>>; fn get_str_lenenc<T: ByteOrder>(&mut self) -> io::Result<Option<&str>>; fn get_bytes_lenenc<T: ByteOrder>(&mut self) -> io::Result<Option<&[u8]>>; } imp...
use std::io::Write; use nickel::status::StatusCode::{Forbidden, NotFound}; use nickel::{NickelError, Request, Action, Continue, Halt}; use session::{ServerData}; pub fn error_handler<'a>(err: &mut NickelError<ServerData>, _: &mut Request<ServerData>) -> Action { if let Some(ref mut res) = err.stream { i...
//! Tests auto-converted from "sass-spec/spec/parser/interpolate" #[allow(unused)] use super::rsass; #[allow(unused)] use rsass::precision; mod t00_concatenation; mod t01_literal; mod t02_double_quoted; mod t03_single_quoted; mod t04_space_list_quoted; mod t05_comma_list_quoted; mod t06_space_list_complex; mod ...
use libdeflater::{Decompressor, DecompressionError}; pub enum Blob { Raw(Vec<u8>), Zlib(Vec<u8>) } impl Blob { pub fn into_data(self) -> Vec<u8> { match self { Blob::Raw(data) => data, Blob::Zlib(compressed) => { let mut decompressor = Decompressor::new(); ...
#[doc = "Reader of register EXTICR4"] pub type R = crate::R<u32, super::EXTICR4>; #[doc = "Writer for register EXTICR4"] pub type W = crate::W<u32, super::EXTICR4>; #[doc = "Register EXTICR4 `reset()`'s with value 0"] impl crate::ResetValue for super::EXTICR4 { type Type = u32; #[inline(always)] fn reset_va...
mod asm; mod direction; mod disasm; mod interpret; mod op; pub use crate::asm::*; pub use crate::direction::*; pub use crate::disasm::*; pub use crate::interpret::*; pub use crate::op::*;
use icell::scoped::{self, ICell}; fn main() { scoped::owner!(foo); scoped::owner!(bar); let value = ICell::new(10); foo.read(&value); bar.read(&value); }