text stringlengths 8 4.13M |
|---|
// Bloom filter Python library written in Rust
extern crate farmhash;
use farmhash::FarmHasher;
use std::hash::{Hash, Hasher};
use pyo3::prelude::*;
use pyo3::wrap_pymodule;
#[pyclass]
struct BloomFilter {
bv: Vec<bool>,
hashes: u64,
}
#[inline]
fn num_of_bits_in_vec(capacity: usize, error_rate: f64) -> u... |
use crate::{
components::VotingPanel, icon, smmdb::Course2Response, smmdb::Difficulty, styles::*, AppState,
Message,
};
use iced::{
button, container, Align, Background, Button, Color, Column, Container, Element, Image, Length,
Row, Space, Text,
};
use iced_native::widget::image::Handle;
#[derive(Debu... |
use {
super::{
concurrency::{Concurrency, DefaultConcurrency},
path::{Path, PathExtractor},
recognizer::Recognizer,
scope::{ScopeId, Scopes},
App, AppInner, ResourceData, RouteData, ScopeData, Uri,
},
crate::{
endpoint::Endpoint,
extractor::Extractor,
... |
use proc_macro2::{Span, TokenStream};
use quote::{format_ident, quote_spanned};
use syn::Ident;
use crate::codegen::unique::{CodeGenUnique, CodeGenUniqueNames};
use crate::validation::{
component::{Child, ChildType, Component},
AllComponents, AllUniques,
};
pub fn gen_mod_components(ecs: &Ident, all: &AllComp... |
extern crate macrotis;
#[macro_use] extern crate clap;
use macrotis::r53;
use macrotis::state;
use macrotis::resource;
use macrotis::compare;
use macrotis::{MacrotisConfig};
use macrotis::resource::{Resource, ResHash};
use macrotis::tinydns;
use std::collections::HashMap;
//use macrotis::MacrotisRecord;
//use std::env... |
use bitbuffer::{BitRead, BitWrite, BitWriteSized, BitWriteStream, LittleEndian};
use serde::{Deserialize, Serialize};
use crate::{ReadResult, Stream};
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct VoiceInitMessage {
codec: Strin... |
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... |
use pyo3::prelude::*;
#[pyfunction]
fn get_21() -> usize {
21
}
#[pymodule]
fn pyo3_mixed_include_exclude(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(get_21))?;
Ok(())
}
|
use amethyst::renderer::{TextureMetadata,ScreenDimensions,Projection,Camera,PngFormat,Texture,MaterialTextureSet,Sprite,SpriteSheetHandle,TextureCoordinates,SpriteSheet};
use amethyst::assets::{AssetStorage,Loader};
use amethyst::prelude::*;
use amethyst::core::cgmath::{Vector3, Matrix4};
use amethyst::core::transform:... |
//!
//! [`Device`](Device) and [`Surface`](Surface)
//! implementations using egl contexts and surfaces for efficient rendering.
//!
//! Usually this implementation's [`EglSurface`](::backend::drm::egl::EglSurface)s implementation
//! of [`GLGraphicsBackend`](::backend::graphics::gl::GLGraphicsBackend) will be used
//!... |
use crate::lib::error::{DfxError, DfxResult};
use crate::{error_invalid_argument, error_invalid_data};
use indicatif::{ProgressBar, ProgressDrawTarget};
use libflate::gzip::Decoder;
use semver::Version;
use serde::{Deserialize, Deserializer};
use std::collections::BTreeMap;
use std::os::unix::fs::PermissionsExt;
use s... |
use gtk::prelude::*;
use std::rc::Rc;
use std::cell::RefCell;
use std::collections::HashMap;
use crate::state::State;
use glib::clone;
pub fn setup_buttons_events(
buttons: &HashMap<String, gtk::SpinButton>,
state: &Rc<RefCell<State>>,
drawing_area: &Rc<RefCell<gtk::DrawingArea>>,
) {
// zoom button
... |
use crate::client::Client;
use ureq::{Error, Request};
use serde::{Deserialize};
#[derive(Deserialize)]
pub struct CountryNetwork {
pub comment: String,
pub features: Vec<String>,
pub mcc: String,
pub mncs: Vec<String>,
#[serde(rename = "networkName")]
pub network_name: String,
pub price: f... |
pub
fn it_vec() {
let v: Vec<i32> = (0..5).collect();
println!("{:?}", v);
assert_eq!(v, [0, 1, 2, 3, 4]);
}
|
use duktape::error;
use std::io;
use std::str;
error_chain!{
foreign_links {
Io(io::Error);
Utf8(str::Utf8Error);
}
links {
Duktape(error::Error, error::ErrorKind);
}
errors {
Resolve(path:String) {
description("ResolveError")
display("could ... |
use itertools::iproduct;
use lazy_static::lazy_static;
use scan_fmt::scan_fmt;
use std::{
cmp::Ordering,
collections::{HashMap, HashSet},
};
lazy_static! {
static ref COORDINATES: Vec<(i32, i32)> = include_str!("input.txt")
.lines()
.map(|line| {
let (x, y) = scan_fmt!(line, "{d... |
use crate::data::{Id, Item, Rating};
use crate::helpers::{ElementDataRef, QuerySelector};
use html5ever::{expanded_name, local_name, namespace_url, ns};
use kuchiki::NodeRef;
fn get_item_id(elem: &ElementDataRef) -> Id {
static ID_PREFIX: &str = "item_";
let attrs = elem.attributes.borrow();
let id = attrs... |
use crate::construction::constraints::{RouteConstraintViolation, TourSizeModule};
use crate::helpers::construction::constraints::create_constraint_pipeline_with_module;
use crate::helpers::models::domain::create_empty_solution_context;
use crate::helpers::models::problem::{test_fleet, test_multi_job_with_locations, tes... |
pub mod controller;
pub mod repository;
|
#![allow(dead_code)]
mod telegram;
use std::error::Error;
use std::env;
use telegram::run_bot;
fn main() -> Result<(), Box<dyn Error>> {
let token = env::var("TELEGRAM_BOT_TOKEN").expect("TELEGRAM_BOT_TOKEN not found");
run_bot(token)
}
|
use std::{fmt, io::Write, num::NonZeroUsize, ops::Range};
use rand::{distributions::WeightedIndex, prelude::Distribution, seq::SliceRandom, Rng};
use serde::Deserialize;
use crate::payload::{Error, Serialize};
use self::{
common::tags, event::EventGenerator, metric::MetricGenerator,
service_check::ServiceChe... |
use discorsd::commands::SlashCommandRaw;
use crate::Bot;
pub mod addme;
pub mod info;
pub mod ping;
pub mod rules;
pub mod stop;
pub mod uptime;
pub mod start;
pub mod system_info;
pub mod ll;
pub mod unpin;
pub mod test;
pub mod components;
pub mod start_game;
pub fn commands() -> Vec<Box<dyn SlashCommandRaw<Bot=Bo... |
#![feature(custom_attribute)]
use futures::Stream;
use tokio_core::reactor::Core;
use telegram_bot::*;
use std::collections::HashMap;
mod config;
fn main() {
let mut core = Core::new().unwrap();
let handle = core.handle();
let config = match config::Config::from_config() {
Ok(c) => c,
Err... |
use wasm_bindgen::prelude::*;
use crate::{active_tab, goto_page};
#[wasm_bindgen]
pub async fn archviz() {
// Set active tab.
active_tab("");
// Go to the page.
goto_page(
"/projects/archviz",
"/api/projects/archviz/archviz.html?ver=gIkkDibIHyE",
"Archviz",
)
.await;
... |
#[doc = "Register `HSEM_C2ICR` reader"]
pub type R = crate::R<HSEM_C2ICR_SPEC>;
#[doc = "Register `HSEM_C2ICR` writer"]
pub type W = crate::W<HSEM_C2ICR_SPEC>;
#[doc = "Field `ISC` reader - ISC"]
pub type ISC_R = crate::FieldReader<u32>;
#[doc = "Field `ISC` writer - ISC"]
pub type ISC_W<'a, REG, const O: u8> = crate::... |
use pyo3::prelude::*;
use numpy::
{
IntoPyArray,
PyArrayDyn,
PyReadonlyArrayDyn
};
pub fn register_module(py: Python<'_>, parent_module: &PyModule) -> PyResult<()>
{
let modified_canonical = PyModule::new(py, "modified_canonical")?;
super::asymptotic::py::register_module(py, modified_can... |
// Check if the final remaining boards are complete.
//
// Input:
// board depth idx
// ...
//
// board: hex representation of bit-board
// depth: the depth of the board
// idx: move index (the index of return value of Board#next)
#[macro_use]
extern crate precomp;
use std::process;
use precomp::{In, Out};
... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct OperationListResult {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub value: Vec<Operation>,
}... |
use futures::{
sink::{Sink, SinkExt},
stream::{Stream, StreamExt},
};
use tokio::sync::mpsc;
use tracing::{debug, error};
/// Forwards a Stream to a tokio::sync::mpsc::Sender of the same item type
pub async fn stream_to_sender<Item, S>(mut stream: S, sender: mpsc::Sender<Item>)
where
S: Stream<Item = Item>... |
use core::convert::TryInto;
use embedded_time::{duration::*, Clock, Instant};
use heapless::ArrayLength;
use super::{Error, Result, RingBuffer, Socket, SocketHandle, SocketMeta};
/// A TCP socket ring buffer.
pub type SocketBuffer<N> = RingBuffer<u8, N>;
#[derive(Debug, PartialEq, Eq, Clone, Copy, defmt::Format)]
pu... |
use itertools::Itertools;
use num_integer::Integer;
use regex::Regex;
use std::{cmp::Ordering, collections::HashMap};
#[aoc_generator(day12)]
pub fn day12_gen(input: &str) -> (Vec<i32>, Vec<i32>, Vec<i32>) {
lazy_static! {
static ref PATTERN: Regex =
Regex::new(r"<x=(?P<x>-?\d+),\s*y=(?P<y>-?\... |
#[doc = "Register `BSEC_OTP_STATUS` reader"]
pub type R = crate::R<BSEC_OTP_STATUS_SPEC>;
#[doc = "Field `SECURE` reader - SECURE"]
pub type SECURE_R = crate::BitReader;
#[doc = "Field `FULLDBG` reader - FULLDBG"]
pub type FULLDBG_R = crate::BitReader;
#[doc = "Field `INVALID` reader - INVALID"]
pub type INVALID_R = cr... |
use crate::CRC;
pub struct CRC8Impl<
const POLY: u8,
const INIT: u8,
const XOROUT: u8,
const REFIN: bool,
const REFOUT: bool,
>;
// pub type CRC8XModem = CRC8<0x1021, 0x0000, 0x0000, false, false>;
// pub type CRC8Genibus = CRC8<0x1021, 0xFFFF, 0xFFFF, false, false>;
// pub type CRC8CDMA2000 = CRC8... |
extern crate time;
extern crate byteorder;
extern crate getopts;
mod server;
mod client;
use client::test_client;
use server::test_server;
mod commands;
use std::io::{stdout, Write};
use getopts::Options;
use std::env;
#[macro_use]
extern crate log;
extern crate log4rs;
use std::default::Default;
static DEFAULT_HO... |
pub fn majority_element(nums: Vec<i32>) -> i32 {
let mut maj = 0;
let mut counter = 0;
for num in nums {
if counter == 0 {
maj = num;
counter = 1;
} else {
if num == maj {
counter += 1;
} else {
counter -= 1;
... |
use super::Generate;
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Kind {
I, T, O, J, L, S, Z,
}
#[derive(Copy, Clone, Debug)]
pub struct DeltaPos {
pub dx: isize,
pub dy: isize,
}
#[derive(Clone, Copy, Debug)]
pub struct Template(pub [DeltaPos; 4], pub Kind);
impl Generate for Template {
fn gen... |
use std::fmt;
use chrono::NaiveDate;
use serde::{Deserialize, Serialize};
use url::Url;
use crate::error::Result;
use crate::serialization as ser;
use crate::urls;
/// Custom type used for [`Movie`](./struct.Movie.html) ids.
#[derive(
Clone, Copy, Debug, Default, Hash, PartialEq, PartialOrd, Ord, Eq, Deserialize... |
#![allow(clippy::type_complexity)]
use crate::{
components::player::Player,
resources::{
globals::{GamePhase, Globals},
turn::TurnManager,
},
};
use oxygengine::prelude::*;
pub struct GameSystem;
impl<'s> System<'s> for GameSystem {
type SystemData = (
Write<'s, Globals>,
... |
mod beatmap;
mod configs;
mod map_tags;
mod osu_users;
mod tracking;
pub use self::{
beatmap::{DBBeatmap, DBBeatmapset},
configs::{
Authorities, EmbedsSize, GuildConfig, MinimizedPp, OsuData, Prefix, Prefixes, UserConfig,
},
map_tags::{MapsetTagWrapper, TagRow},
osu_users::{UserStatsColumn,... |
//
// Copyright 2021 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... |
//////////////////////////////////////////////////
// General notes
//
// - When heap objects fall out of scope, the drop
// function is called. The author can put code
// into this function to return the allocated
// memory.
// - Rust has a special annotation called the
// Copy trait. If a type implements thi... |
use std::io;
use std::io::{File, FileMode, fs, stdio};
mod plutomain {
static mut pluto_name: String =""; /* name (path) we were invoked with */
static ctlbase: String = "/var/run/pluto";
static mut pluto_listen: String = "";
static fork_desired: bool = true;
/* pulled from main for show_setup_plutomain() */
//static... |
extern crate cfg_if;
extern crate gif;
extern crate wasm_bindgen;
use cfg_if::cfg_if;
use gif::Encoder;
use wasm_bindgen::prelude::*;
mod utils;
cfg_if! {
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
if #[cfg(feature = "wee_alloc")] {
extern crate wee_al... |
//! The module implements [`HashMap`].
use super::ebr::{Arc, AtomicArc, Barrier, Tag};
use super::hash_table::cell::Locker;
use super::hash_table::cell_array::CellArray;
use super::hash_table::HashTable;
use std::borrow::Borrow;
use std::collections::hash_map::RandomState;
use std::hash::{BuildHasher, Hash};
use std:... |
error_chain! {
errors {
#[doc = "An error message from the SDL2 crate."]
SdlMsg(msg: ::std::string::String) {
description("sdl error")
display("{}", msg)
}
}
}
|
use crate::{backend::SchemaBuilder, prepare::*, types::*, SchemaStatementBuilder};
/// Rename a table
///
/// # Examples
///
/// ```
/// use sea_query::{*, tests_cfg::*};
///
/// let table = Table::rename()
/// .table(Font::Table, Alias::new("font_new"))
/// .to_owned();
///
/// assert_eq!(
/// table.to_st... |
pub mod kill_all_kruskal;
use rand::distributions::{IndependentSample, Range};
use std::ops::Mul;
use std::hash::Hash;
use typenum;
mod hall;
pub use self::hall::create_hall;
#[derive(Serialize, Deserialize, Clone)]
pub enum Level {
KillAllKruskal2D(kill_all_kruskal::Conf2D),
KillAllKruskal3D(kill_all_kruskal... |
pub fn length_of_longest_substring(s: String) -> i32 {
// use std::collections::HashSet;
// let hs: HashSet<_> = s.chars().collect();
// hs.len() as i32
// s.chars()
// .fold(String::new(), |mut acc, el| {
// if !acc.contains(el) {
// acc.push(el)
// }
... |
use crate::{
bet::Bet,
bet_database::{BetId, BetOrProp, BetState, CancelReason},
};
use anyhow::anyhow;
use bdk::{bitcoin::OutPoint, blockchain::UtxoExists};
use super::Party;
macro_rules! update_bet {
($self:expr, $bet_id:expr, $($tt:tt)+) => {
$self.bet_db.update_bets(&[$bet_id], |old_state, _, ... |
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::PADREGG {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w m... |
// Vicfred
// https://atcoder.jp/contests/abc160/tasks/abc160_a
// implementation
use std::io;
fn main() {
let mut s = String::new();
io::stdin()
.read_line(&mut s)
.unwrap();
let s = s.trim();
let s: Vec<char> = s.chars().collect();
if &s[2] == &s[3] && &s[4] == &s[5] {
... |
use crate::{
nla::{NlaBuffer, NlasIterator},
DecodeError, Index, Rest,
};
const RTGEN_FAMILY: Index = 0;
// const PADDING: Field = 1..4;
const ATTRIBUTES: Rest = 4..;
pub const NSID_HEADER_LEN: usize = ATTRIBUTES.start;
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct NsIdBuffer<T> {
buffer: T,
}
impl<... |
use super::archive_schema::Archive;
use super::paths::to_absolute;
use super::setup_archive::setup_archive;
use super::utils::Arguments;
use std::ffi::OsStr;
use std::fs::create_dir_all;
use std::io::{
Error as ioError,
Result as ioResult,
};
use std::path::Path;
use std::path::PathBuf;
/// Helper function to make ... |
use crate::entities::aggregation::NewAggregationStrategy;
use chrono::{DateTime, Utc};
#[derive(Serialize, Deserialize, PartialEq, Debug)]
pub struct StoragePoint {
pub value: f64,
}
#[derive(Serialize, Deserialize, PartialEq, Debug, GraphQLObject)]
#[graphql(description = "Data at a specific time")]
pub struct Poin... |
/* Redis Glue is provides abstractions over single and cluster mode Redis interactions
* Copyright 2021 Aravinth Manivannan <realaravinth@batsense.net>
*
* Licensed under the Apache License, Version 2.0 (the "License") or MIT
*/
//! Redis Client/Connection manager that can handle both single and clustered Redis In... |
//! A re-implementation of the "Datetime" parsing utility from the Taskwarrior
//! source.
// TODO: this module is not yet implemented
pub(crate) struct DateTime {}
impl DateTime {
/// Parse a datestamp from a prefix of input and return the number of bytes consumed in the
/// input
pub(crate) fn parse<S:... |
mod farm;
mod plot;
pub(crate) use farm::farm;
pub(crate) use plot::plot;
|
mod test_conds;
mod test_vec2;
mod vec2;
mod conds;
// #[macro_export]
// macro_rules! {
// () => {};
// } |
#[macro_use]
extern crate rustacuda;
use rustacuda::prelude::*;
use rustacuda::memory::DeviceBox;
use std::error::Error;
use std::ffi::CString;
fn main() -> Result<(), Box<dyn Error>> {
// Initialize the CUDA API
rustacuda::init(CudaFlags::empty())?;
// Get the first device
let device = Device::g... |
use super::Code;
#[derive(Debug)]
pub enum Paragraph {
Text(Text),
List(Vec<Text>),
Code(Code),
InvalidCode(Code),
SubSection(Box<Section>),
}
#[derive(Debug)]
pub struct Section {
title: Option<Text>,
content: Vec<Paragraph>,
}
#[derive(Debug, Clone)]
pub struct TextComponent {
text... |
#[doc = "Reader of register CH_AL3_READ_ADDR_TRIG"]
pub type R = crate::R<u32, super::CH_AL3_READ_ADDR_TRIG>;
impl R {}
|
/// ViewState: view model and interactions.
// rendering is done in view.rs
pub struct ViewState {
pub sort_by: Metric,
pub sort_dir: Dir,
pub alert: Option<String>,
}
impl Default for ViewState {
fn default() -> Self {
Self {
sort_by: Metric::Cpu,
sort_dir: Dir::Desc,
... |
use std::fs::File;
use std::io::prelude::*;
pub fn file2str(filename: &str) -> String {
let mut file = File::open(filename).expect("file not found");
let mut string = String::new();
file.read_to_string(&mut string)
.expect("error reading file");
string
}
pub fn str2vec_u32(input: &str) -> Vec<... |
#[doc = "Register `APB1_FZ` reader"]
pub type R = crate::R<APB1_FZ_SPEC>;
#[doc = "Register `APB1_FZ` writer"]
pub type W = crate::W<APB1_FZ_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 type DBG_TI... |
use azure_core::prelude::*;
use azure_identity::device_code_flow::{self, DeviceCodeResponse};
use azure_identity::refresh_token;
use azure_storage::core::prelude::*;
use futures::stream::StreamExt;
use oauth2::ClientId;
use std::env;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + S... |
use super::super::prelude::{
LONG
};
#[repr(C)]
pub struct Point {
pub x : LONG ,
pub y : LONG ,
}
pub type POINT = Point;
impl Point {
pub fn new(nx : LONG , ny : LONG) -> Point {
Point {
x : nx ,
y : ny ,
}
}
} |
fn main(){
println!("Hola madre, ya se programar en rust!");
}
|
// Copyright 2019, 2020 Parity Technologies
//
// 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... |
pub mod html_parser;
pub mod markdown_generator;
|
use std::io::{self, BufRead};
fn main() {
let lines : Vec<String> = io::stdin().lock().lines().map(|l| l.unwrap()).collect();
let ready_at = lines[0].parse::<usize>().unwrap();
let possibly_times : Vec<&str> = lines[1].split(',').collect();
let known_times = possibly_times.iter()
.filter(|t| **t... |
use crate::gui::UiNode;
use crate::interaction::InteractionModeTrait;
use crate::scene::commands::{ChangeSelectionCommand, SceneCommand};
use crate::scene::{EditorScene, GraphSelection, Selection};
use crate::settings::Settings;
use crate::{GameEngine, Message};
use rg3d::core::algebra::Vector2;
use rg3d::core::math::a... |
///// chapter 4 "structuring data and matching patterns"
///// program section:
//
fn main() {
let magician = "merlin";
let mut chars: Vec<char> = magician.chars().collect();
chars.sort();
for c in chars.iter() {
print!("{} ", c);
}
}
///// output should be:
/*
eilmnr
*/// end of output
|
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate exonum;
extern crate exonum_configuration;
extern crate router;
extern crate bodyparser;
extern crate iron;
use exonum_configuration::ConfigurationService;
use exonum::helpers::fabric::NodeBuilder;
pub mod ... |
use proc_macro2::TokenStream;
pub fn bits_to_byte_floor(leading_bits : &TokenStream) -> TokenStream
{
quote!{ (#leading_bits / 8) }
}
pub fn bits_to_byte_ceiling(leading_bits : &TokenStream) -> TokenStream
{
quote!{ ((#leading_bits + 7) / 8) }
}
pub fn get_bitmask(size_in_bits : &TokenStream, bits_consumed_i... |
#[doc = "Register `CSR49` reader"]
pub type R = crate::R<CSR49_SPEC>;
#[doc = "Register `CSR49` writer"]
pub type W = crate::W<CSR49_SPEC>;
#[doc = "Field `CSR49` reader - CSR49"]
pub type CSR49_R = crate::FieldReader<u32>;
#[doc = "Field `CSR49` writer - CSR49"]
pub type CSR49_W<'a, REG, const O: u8> = crate::FieldWri... |
// Copyright (C) 2021 Subspace Labs, Inc.
// 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 Software Foundation, either version 3 of the Li... |
use std::path::Path;
use futures::sink::SinkExt;
use futures::stream::{Stream, StreamExt};
use tokio::net::UnixStream;
use tokio_util::codec::{Framed, LinesCodec};
use persist_core::error::Error;
use persist_core::protocol::*;
pub struct DaemonClient {
socket: Framed<UnixStream, LinesCodec>,
}
impl DaemonClient... |
#[doc = "Register `DDRCTRL_CRCPARCTL0` reader"]
pub type R = crate::R<DDRCTRL_CRCPARCTL0_SPEC>;
#[doc = "Register `DDRCTRL_CRCPARCTL0` writer"]
pub type W = crate::W<DDRCTRL_CRCPARCTL0_SPEC>;
#[doc = "Field `DFI_ALERT_ERR_INT_EN` reader - DFI_ALERT_ERR_INT_EN"]
pub type DFI_ALERT_ERR_INT_EN_R = crate::BitReader;
#[doc ... |
#[doc = "Register `ITLINE30` reader"]
pub type R = crate::R<ITLINE30_SPEC>;
#[doc = "Field `USART2` reader - CEC"]
pub type USART2_R = crate::BitReader;
impl R {
#[doc = "Bit 0 - CEC"]
#[inline(always)]
pub fn usart2(&self) -> USART2_R {
USART2_R::new((self.bits & 1) != 0)
}
}
#[doc = "interrupt... |
#[doc = "Reader of register DATA_CHANNELS_H1"]
pub type R = crate::R<u32, super::DATA_CHANNELS_H1>;
#[doc = "Writer for register DATA_CHANNELS_H1"]
pub type W = crate::W<u32, super::DATA_CHANNELS_H1>;
#[doc = "Register DATA_CHANNELS_H1 `reset()`'s with value 0"]
impl crate::ResetValue for super::DATA_CHANNELS_H1 {
... |
//! Define an Orientation and associated methods.
use vec::Vec2;
/// Describes a vertical or horizontal orientation for a view.
#[derive(Clone,Copy,Debug,PartialEq)]
pub enum Orientation {
/// Horizontal orientation
Horizontal,
/// Vertical orientation
Vertical,
}
impl Orientation {
/// Returns th... |
#![allow(clippy::unused_unit)]
use once_cell::sync::Lazy;
use std::cmp::Reverse;
use wasm_bindgen::prelude::*;
mod filter;
mod storage;
use crate::filter::{Id, PostFilters, Score, XorfProxy};
use crate::storage::Storage;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
static FILT... |
/// functions having to do with primes for Project Euler
// credit goes to github.com/roycrippen/euler_rust for some of these, his style is great
fn len_int(n: u32) -> u32 {
// 0
std::iter::repeat_with({
let mut l = 0;
// can't call pow on ambiguous numeric type
move || match n / 10u32.... |
#[doc = "Register `HCCHAR0` reader"]
pub type R = crate::R<HCCHAR0_SPEC>;
#[doc = "Register `HCCHAR0` writer"]
pub type W = crate::W<HCCHAR0_SPEC>;
#[doc = "Field `MPSIZ` reader - Maximum packet size"]
pub type MPSIZ_R = crate::FieldReader<u16>;
#[doc = "Field `MPSIZ` writer - Maximum packet size"]
pub type MPSIZ_W<'a,... |
use crate::{api::get_post_view, api::get_posts, msg::Msg, state::State};
use anyhow::{bail, Result};
use futures::future::BoxFuture;
use termion::event::Key;
use tui::widgets::ListState;
pub fn update(
msg: Msg,
state_stack: &mut Vec<State>,
) -> Result<Option<BoxFuture<'static, Result<Msg>>>> {
let last_s... |
use crossbeam::atomic::AtomicCell;
use parking_lot::Mutex;
use rustc_hash::FxHashMap;
use std::{
any::TypeId,
collections::{hash_map::DefaultHasher, HashMap},
hash::Hasher,
sync::Arc,
};
use crate::{app::App, universe::Node};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum... |
mod board;
mod search;
fn main() {
use std::io;
use std::io::prelude::*;
let mut board = board::Board::initial_position();
let stdin = io::stdin();
for line in stdin.lock().lines() {
let command = line.unwrap();
let mut words = command.split_whitespace().into_iter();
match... |
use std::path::PathBuf;
use actix_files::NamedFile;
use actix_web::middleware::Logger;
use actix_web::{get, App, HttpRequest, HttpServer, Responder};
use anyhow::bail;
use anyhow::{Context, Result};
use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
#[get("/")]
async fn index(_req: HttpRequest) -> impl Responde... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Resource {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(d... |
use std::fs;
fn get_dimensions(line: &str) -> Vec<u32> {
let mut dims: Vec<u32> = line
.split('x')
.map(|dimensions| dimensions.parse().unwrap())
.collect();
dims.sort();
dims
}
fn part_1(input: &str) -> u32 {
input
.lines()
.map(|l| {
let dim = get_... |
use ComponentBitField;
use chunk::Chunk;
use commands::Commands;
use component_group::{Read, Write};
use entity::Entity;
use entity_collection::{Entities, EntityCollection};
use entity_template::EntityTemplate;
use shared_resources::SharedResources;
use std::any::Any;
use std::cell::RefCell;
use std::collections::HashM... |
use super::GetFlag;
use super::{Gender, GetFlag::*, Results, SpoilerLevel};
use serde::Deserialize;
/// All valid flags for get character method
pub const CHARACTER_FLAGS: [GetFlag; 7] =
[Basic, Details, Measures, Traits, Vns, Voiced, Instances];
/// Results returned from get character method
#[derive(Deserialize... |
use std::collections::VecDeque;
use std::convert::{TryFrom, TryInto};
use std::str::FromStr;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct IntcodeDevice {
ip: usize,
relative_offset: isize,
pub memory: Vec<i64>,
pub input: VecDequ... |
pub use crate::*;
pub fn generate_implicants(initial: Vec<Implicant>) -> Vec<Implicant> {
let mut generated = vec![];
let terms_count = initial[0].terms.len();
for i in 0..2u32 << (terms_count - 1) {
let bit_terms = format!("{:#032b}", i);
println!("{}", bit_terms);
let bit_terms = ... |
// A amaglamation of oauth2 library's Github, Wunderlist, and Microsoft's examples
use oauth2::basic::{BasicErrorResponse, BasicTokenType};
use oauth2::helpers;
use oauth2::TokenType;
use std::time::Duration;
use oauth2::reqwest::http_client;
use oauth2::{
AuthUrl, AuthType, AuthorizationCode, ClientId, ClientSecr... |
use crate::context::CommandRegistry;
use crate::data::TaggedDictBuilder;
use crate::errors::ShellError;
use crate::evaluate::{evaluate_baseline_expr, Scope};
use crate::parser::{hir, Operator};
use crate::prelude::*;
use crate::Text;
use chrono::{DateTime, Utc};
use chrono_humanize::Humanize;
use derive_new::new;
use s... |
use super::types::{DiffOptions, Only};
use crate::cmd::CmdRunner;
use crate::data::{Entry, Item, Status};
use crate::files;
use crate::index::Indexer;
use crate::path_str;
use crate::prompt::Prompt;
use anyhow::{bail, Result};
use crossterm::style::Stylize;
use inquire::MultiSelect;
use std::fmt;
use std::path::{Path, ... |
use tools;
use std::path::Path;
/// # Thumbnail
///
/// This structure holds all Information about a Thumbnail
/// and provides a function to create a Thumbnail.
/// This structure is part of a Media Item and should not be
/// used alone.
///
/// # To-Do
/// Add the creation Function once FFMPEG can be directly used.
... |
extern crate actix;
extern crate actix_web;
extern crate crypto_hash;
extern crate env_logger;
extern crate failure;
extern crate futures;
extern crate lettre;
extern crate lettre_email;
extern crate openssl;
extern crate rand;
extern crate serde_json;
extern crate time;
extern crate toml;
extern crate uuid;
#[macro_us... |
#![no_main]
#[macro_use]extern crate lazy_static;
#[macro_use]extern crate kiss_ui;
extern crate winapi;
extern crate user32;
use winapi::{c_int,HWND,HINSTANCE,LPSTR};
mod ffi;
mod appsettings;
mod window;
mod helpers;
mod stsclient;
mod translator;
mod apphandler;
use appsettings::*;
#[no_mangle]
#[... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.