text stringlengths 8 4.13M |
|---|
use crate::{
backend::Backend,
examples::data::ExampleData,
utils::{shell_quote, shell_single_quote},
};
use drogue_cloud_service_api::endpoints::Endpoints;
use patternfly_yew::*;
use serde_json::json;
use yew::prelude::*;
#[derive(Clone, Debug, Properties, PartialEq, Eq)]
pub struct Props {
pub endpoi... |
// data.rs provides structs and enums to represent data recived from clients as we store it before
// usage.
use crate::server::network::packet;
#[derive(Clone, Eq, PartialEq, Debug)]
/// The WebSocket server's state and storage
pub struct ServerData {
/// represents the highest unique ID handed out by the server... |
#[derive(Debug)]
pub enum OpCode {
OpReturn
}
pub struct Chunk {
pub code: Vec<OpCode>
}
impl Chunk {
pub fn new() -> Self {
Chunk {
code: Vec::new()
}
}
} |
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=libarm_cortexM4lf_math.a");
// Link against prebuilt cmsis math
println!(
"cargo:rustc-link-search={}",
std::env::var("CARGO_MANIFEST_DIR").unwrap()
);
println!("cargo:rustc-link-lib=static... |
fn main() {
let compiler_knows_this_is_initialized;
let mut x = 1u8; ... |
use oxygengine::prelude::*;
#[allow(dead_code)]
#[derive(Debug, Copy, Clone)]
pub enum FollowMode {
Instant,
Delayed(Scalar),
}
#[derive(Debug, Copy, Clone)]
pub struct Follow(pub Option<Entity>, pub FollowMode);
impl Component for Follow {
type Storage = VecStorage<Self>;
}
|
use amethyst::{
//assets::{ AssetStorage, Loader, Handle },
//core::transform::Transform,
ecs::{ Component, DenseVecStorage },
//prelude::*,
//renderer::{ Camera, ImageFormat, SpriteRender, SpriteSheet, SpriteSheetFormat, Texture }
};
pub const VELOCITY_X : f32 = 75.0;
pub const VELOCITY_Y : f32 = 50.0;
pub... |
use http::{is_valid_url, resolve_url, retrieve_asset};
use std::default::Default;
use std::io;
use html5ever::parse_document;
use html5ever::rcdom::{Handle, NodeData, RcDom};
use html5ever::serialize::{serialize, SerializeOpts};
use html5ever::tendril::TendrilSink;
enum NodeMatch {
Icon,
Image,
StyleSheet... |
use glob::glob;
use scraper::{Html, Selector};
use version_compare::Version;
use std::{cmp::Ordering, fs};
use std::collections::HashMap;
fn compare_versions (a: &String, b: &String) -> Ordering {
let parts_a = a.split("/").collect::<Vec<_>>();
let parts_b = b.split("/").collect::<Vec<_>>();
Version::from... |
use std::sync::MutexGuard;
use nia_interpreter_core::EventLoopHandle;
use nia_interpreter_core::NiaGetDefinedActionsCommandResult;
use nia_interpreter_core::NiaInterpreterCommand;
use nia_interpreter_core::NiaInterpreterCommandResult;
use nia_protocol_rust::GetDefinedActionsResponse;
use crate::error::NiaServerError... |
use num::traits::{Num, NumCast};
use super::mm::{MM, ToMM};
use super::m::{M, ToM};
use super::km::{KM, ToKM};
/// ToCM is the canonical trait to use for input in centimeters.
///
/// For example the millimeters type (MM) implements the ToCM trait and thus
/// millimeters can be given as a parameter to any input that... |
#[doc = "Register `C2ICR` reader"]
pub type R = crate::R<C2ICR_SPEC>;
#[doc = "Register `C2ICR` writer"]
pub type W = crate::W<C2ICR_SPEC>;
#[doc = "Field `ISC0` reader - Interrupt(N) semaphore n clear bit"]
pub type ISC0_R = crate::BitReader<ISC0R_A>;
#[doc = "Interrupt(N) semaphore n clear bit\n\nValue on reset: 0"]
... |
pub mod types;
pub mod config;
pub mod net;
pub mod errors;
pub mod momo;
pub mod parser;
pub mod threads;
|
/*
* TODO: show the gtk scrollbars instead of the Servo scrollbars?
* TODO: send CloseBrowser event (on tab close?).
*/
extern crate epoxy;
extern crate gdk;
extern crate gdk_sys;
extern crate glib_itc;
extern crate gtk;
extern crate servo;
extern crate shared_library;
mod convert;
mod eventloop;
pub mod view;
mod... |
pub mod interrupt;
pub mod timer;
pub mod ioregister;
use std::fmt;
use super::mem;
use super::util;
use super::debugger;
pub enum EventRequest {
BootstrapDisable,
DMATransfer(u8), //left nibble of address to be used.
HDMATransfer,
JoypadUpdate,
SpeedModeSwitch,
}
#[derive(Copy, Clone, PartialEq,... |
#![deny(warnings)]
extern crate env_logger;
#[macro_use]
extern crate log as irrelevant_log;
extern crate juniper;
extern crate juniper_warp;
extern crate warp;
use juniper::*;
use warp::{http::Response, log, Filter};
#[derive(GraphQLEnum)]
enum Episode {
NewHope,
Empire,
Jedi,
}
#[derive(GraphQLObject)... |
use std::collections::HashMap;
use std::time::Duration;
use chrono::{DateTime, Utc};
use reqwest::{Client, Method, Url};
use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT};
use crate::authentication::Authentication;
use crate::ClientError;
use crate::utils::{build_url, merge_headers};
pub struct CallContext {... |
use crate::ast;
use crate::{Parse, ParseError, ParseErrorKind, Parser, Spanned, ToTokens};
/// A single argument in a closure.
///
/// # Examples
///
/// ```rust
/// use rune::{parse_all, ast};
///
/// parse_all::<ast::FnArg>("self").unwrap();
/// parse_all::<ast::FnArg>("_").unwrap();
/// parse_all::<ast::FnArg>("abc... |
use error_chain::error_chain;
error_chain! {
errors {
ConnectionError {}
ChannelError {}
}
}
|
pub(crate) mod persistent_parameters;
#[cfg(test)]
mod tests;
use crate::connected_peers::{
Behaviour as ConnectedPeersBehaviour, Config as ConnectedPeersConfig,
Event as ConnectedPeersEvent,
};
use crate::peer_info::{
Behaviour as PeerInfoBehaviour, Config as PeerInfoConfig, Event as PeerInfoEvent,
};
use... |
//! Code related to mutation of generic [`crate::Kind`]s.
use crate::lens::Lens;
use dyn_clone::{clone_trait_object, DynClone};
use std::{fmt::Debug, marker::PhantomData};
/// Describes a mutation that should be applied to an object
pub trait Mutator<T>: Debug + Send + DynClone {
/// Apply the mutation to the giv... |
#[doc = "Register `MTLRxQDR` reader"]
pub type R = crate::R<MTLRX_QDR_SPEC>;
#[doc = "Register `MTLRxQDR` writer"]
pub type W = crate::W<MTLRX_QDR_SPEC>;
#[doc = "Field `RWCSTS` reader - MTL Rx Queue Write Controller Active Status"]
pub type RWCSTS_R = crate::BitReader;
#[doc = "Field `RWCSTS` writer - MTL Rx Queue Wri... |
use std::{
collections::{HashMap, HashSet, VecDeque},
fmt,
};
use uuid::Uuid;
pub struct CircularDependancyError;
impl fmt::Debug for CircularDependancyError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Error in toposort - circular dependency")
}
}
pub fn toposort(
... |
extern crate advent;
use advent::day5::*;
use std::thread;
const INPUT: &'static str = "ojvtpuvg";
pub fn main() {
let basic = thread::spawn(|| get_password(INPUT));
let indexed = thread::spawn(|| get_indexed_password(INPUT));
println!("{} (basic): {}", INPUT, basic.join().unwrap());
println!("{} (i... |
extern crate num;
pub mod err {
pub const USER_EXIT: &'static str = "Exit from user";
pub const TEXTURE_NOT_FOUND: &'static str = "Unable to find texture";
}
#[derive(Clone)]
pub struct Vec2D {
pub x: f32,
pub y: f32,
}
impl Vec2D {
pub fn new<T: num::cast::AsPrimitive<f32>>(x: T, y: T) -> Vec2D {... |
// Can build and run with:
// 1. cargo build
// 2. cargo run
fn main() {
let x = 7; // Rust has type inference
// x = 10; // And vars are immutable by default
let (y, z) = (1, 2); // And has pattern matching. Tuple deconstructing.
let mut a = 1; // This is mutable
a = 2;
let mut b: i32; // T... |
//! Save and restore manager state.
use crate::errors::Result;
use crate::Manager;
pub trait State {
/// Write current state to a file.
/// It will be used to restore the state after soft reload.
///
/// # Errors
///
/// Will return error if unable to create `state_file` or
/// if unable t... |
use crate::config::{MailConfig, SSL};
use rocket::State;
use rocket::response::content::Xml;
use serde::Serialize;
use uuid::Uuid;
#[derive(Serialize)]
#[serde(rename_all = "PascalCase")]
struct PayloadContent {
email_account_type: String,
email_address: String,
incoming_mail_server_authentication: String... |
#[macro_export]
macro_rules! tests_for_parser {
($parser: ident, $name: ident, $input: expr, $expected: expr) => {
paste::item! {
/// test roundtrip from source with unix line endings
#[test] fn [<$name __ $parser __ unix>]() {
let input = $input.replace("\r\n", "\n")... |
use std::io::ErrorKind;
use std::path::PathBuf;
use std::fs;
use errors::Result;
/// Directory for putting output files in. Will be created lazily when the first
/// file is created.
pub struct OutDir {
path: PathBuf,
created: bool,
}
impl OutDir {
pub fn new(path: PathBuf) -> Result<OutDir> {
Ok(... |
use atty::Stream;
use clap::Clap;
use std::error::Error;
use std::path::PathBuf;
use viuer::{print, print_from_file};
#[derive(Clap, Debug)]
#[clap(about = "View random anime fanart in your terminal")]
struct Cli {
/// Resize the image to a provided height
#[clap(short, long)]
height: Option<u32>,
///... |
fn main() {
for x in 1..101 {
match x % 15 {
0 => println!("fizzbuzz"),
i if i % 3 == 0 => println!("fizz"),
i if i % 5 == 0 => println!("buzz"),
_ => println!("{}", x),
}
}
}
|
use conformal_visualizer::create_gridlines;
use nannou::prelude::*;
use nannou::ui::prelude::*;
use num::Complex;
fn main() {
nannou::app(model).update(update).view(view).run();
}
struct Model {
ui: Ui,
ids: Ids,
scale: f32,
position: Point2,
apply_function: bool,
resolution: f32,
x_mi... |
use core::ops::Index;
use necsim_core_bond::{NonNegativeF64, PositiveF64};
use super::{Habitat, LineageReference, OriginSampler};
use crate::{
landscape::{IndexedLocation, Location},
lineage::{GlobalLineageReference, Lineage},
};
#[allow(clippy::inline_always, clippy::inline_fn_without_body)]
#[contract_trai... |
extern crate serde_yaml;
mod tag;
use serde_yaml::Value;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::process;
fn main() {
let args: Vec<String> = env::args().collect();
let filename = match args.get(1) {
Some(path) => path,
None => {
eprintln!("no file speci... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - control register"]
pub ctr: CTR,
}
#[doc = "CTR (rw) register accessor: control register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`ctr::R`]. You can [`reset`](crate::generic::Reg::reset), [`write`](cra... |
use dirs::config_dir;
use serde::{Deserialize, Serialize};
use std::env;
use std::collections::HashMap;
use std::fs;
use std::path::{Path, PathBuf};
use tempdir::TempDir;
#[derive(Debug, Deserialize, Serialize)]
pub struct RegistryConfig {
token: String,
}
impl PartialEq for RegistryConfig {
fn eq(&self, other:... |
#[doc = "Reader of register TEMP_ITR1"]
pub type R = crate::R<u32, super::TEMP_ITR1>;
#[doc = "Writer for register TEMP_ITR1"]
pub type W = crate::W<u32, super::TEMP_ITR1>;
#[doc = "Register TEMP_ITR1 `reset()`'s with value 0"]
impl crate::ResetValue for super::TEMP_ITR1 {
type Type = u32;
#[inline(always)]
... |
// Copyright (c) 2017 Chef Software Inc. and/or applicable contributors
//
// 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 ... |
// Copyright (c) 2017 The Noise-rs Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT
// or http://opensource.org/licenses/MIT>, at your option. All files in the
// project carrying such notice may not be cop... |
use super::*;
use std::collections::HashMap;
use std::path::Path;
pub fn traverse_reduce(path: impl AsRef<Path>) -> Result<String, Error> {
use std::path::Component::*;
let path = path.as_ref();
let mut input = String::new();
if path.parent().is_none() {
input.push_str(&path.to_string_lossy()... |
use crate::{imp, io};
use io_lifetimes::OwnedFd;
#[cfg(any(
linux_raw,
all(
libc,
not(any(target_os = "ios", target_os = "macos", target_os = "wasi"))
)
))]
pub use imp::io::PipeFlags;
/// `pipe()`—Creates a pipe.
///
/// This function creates a pipe and returns two file descriptors, for t... |
#[macro_use]
extern crate cached;
extern crate pathfinding;
use failure::Error;
use pathfinding::prelude::{absdiff, astar};
// Should be large enough to find the best path...
const GRID_SIZE: usize = 2048;
// Example input.
// const DEPTH: usize = 510;
// const TARGET: (usize, usize) = (10, 10);
// Puzzle input.
co... |
use std::collections::HashMap;
use std::fs::read_dir;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use fluent_bundle::concurrent::FluentBundle;
use fluent_bundle::{FluentResource, FluentValue};
use crate::error::LoaderError;
pub use unic_langid::{langid, langids, LanguageIdentifier};
/// A builder pattern st... |
//https://ptrace.fefe.de/wp/wpopt.rs
// gcc -o lines lines.c
// tar xzf llvm-8.0.0.src.tar.xz
// find llvm-8.0.0.src -type f | xargs cat | tr -sc 'a-zA-Z0-9_' '\n' | perl -ne 'print unless length($_) > 1000;' | ./lines > words.txt
//#![feature(impl_trait_in_bindings)]
use std::fmt::Write;
use std::io;
use std::iter::... |
//! Utility to transliterate texts into ascii characters.
//! This utility depends of the iconv utility installed in the SO.
//! You want to have glibc with the correct locales installed.
//!
//! For example. If you want to transliterate from german, you need to
//! have install the "de_DE.UTF-8" locale in your SO.
//!... |
use std::{mem, time};
use std::io::{Error, ErrorKind, Result};
use crate::kv::storage::crc64::{as_ne_bytes, kv_crc64};
use crate::kv::storage::kvdb::kvdb_s;
fn usage() {
println!("{}{}{}{}{}{}{}{}", " kv help -- this message \n",
" kv get <key> -- get a key\n",
... |
extern crate dmbc;
extern crate exonum;
extern crate exonum_testkit;
extern crate hyper;
extern crate iron;
extern crate iron_test;
extern crate mount;
extern crate serde_json;
pub mod dmbc_testkit;
use dmbc_testkit::{DmbcTestApiBuilder, DmbcTestKitApi};
use exonum::crypto;
use exonum::messages::Message;
use hyper::s... |
use crate::components::transistor::Transistor;
use crate::components::wire::wiring;
pub struct AndGate {
t1: Transistor,
t2: Transistor,
pub input1: wiring::Wire,
pub input2: wiring::Wire,
pub output: wiring::Wire,
}
impl Default for AndGate {
fn default() -> Self {
let mut t1 = Transi... |
use serde_json::{
json,
Value as JsonValue,
};
use crate::lib::{
types::Result,
constants::TOOL_VERSION,
};
pub fn get_tool_version_info() -> Result<JsonValue> {
Ok(json!({"version": TOOL_VERSION }))
}
|
#[no_mangle]
fn clear_screen() {}
#[no_mangle]
fn draw_player(_: f64, _: f64, _: f64) {}
#[no_mangle]
fn draw_bullet(_: f64, _: f64) {}
#[no_mangle]
fn draw_player_bullet(_: f64, _: f64) {}
#[no_mangle]
fn draw_particle(_: f64, _: f64, _: f64, _: i32) {}
#[no_mangle]
fn draw_ufo(_: f64, _: f64) {}
#[no_mangle]
f... |
/*!
An implementation of the
[Longest increasing subsequence algorithm](https://en.wikipedia.org/wiki/Longest_increasing_subsequence).
# Examples
The main trait exposed by this crate is [`LisExt`], which is implemented for,
inter alia, arrays:
```
use lis::LisExt;
assert_eq!([2, 1, 4, 3, 5].longest_increasing_subseq... |
use jsonrpc_core::{Error as RpcError, Params, Result as RpcResult, Value};
use log::debug;
use serde::de::DeserializeOwned;
use serde_json::from_value;
pub fn parse_params<D: DeserializeOwned + std::fmt::Debug + 'static>(
param: Params,
) -> RpcResult<D> {
debug!("In-> {:?}", param);
let value = match para... |
use std::fs::File;
use std::io::{Error, BufReader, BufRead};
use std::path::Path;
fn main() {
match solve() {
Ok((sum1, sum2)) => println!("Part 1: {} | Part 2: {}", sum1, sum2),
Err(err) => println!("/!\\ Error! {}", err.to_string()),
}
}
fn solve() -> Result<(usize, usize), Error> {
let... |
use serde::Deserialize;
use super::super::{Operation, RunOn};
use crate::{
bson::{Bson, Document},
options::ClientOptions,
test::FailPoint,
};
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct TestFile {
pub(crate) run_on: Option<Vec<RunOn>>,
pub(crate) data: Vec<D... |
use serde::{Deserialize, Serialize};
/// Wikipedia category label.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Category(pub String);
impl Category {
/// Get the fully qualified name of a category.
pub fn fqn(&self) -> String {
format!("Category:{}", self.0)
}
}
|
extern crate colored;
extern crate termion;
extern crate ultrastar_txt;
mod errors {
error_chain!{}
}
use crate::errors::*;
use colored::*;
use pitch_calc::*;
pub fn generate_screen(
line: &ultrastar_txt::Line,
beat: f32,
dominant_note: Option<LetterOctave>,
) -> Result<String> {
let (term_width,... |
#[macro_use]
extern crate from_repr_enum_derive;
#[repr(u8)]
#[derive(FromReprEnum, Debug, PartialEq)]
enum Foo {
X = 1,
Y = 2,
Unknown = 255,
}
#[test]
fn test_from() {
let x = Foo::from(1);
assert_eq!(Foo::X, x);
let y = Foo::from(2);
assert_eq!(Foo::Y, y);
let u = Foo::from(99);
... |
fn main() {
println!("Hello, world!");
use std::thread;
use std::time::Duration;
let handle = thread::spawn(|| {
for i in 11..50 {
println!("{}", i);
thread::sleep(Duration::from_millis(1));
}
});
for i in 6..10 {
println!("{}", i);
thread... |
extern crate connect_4;
use connect_4::Connect4;
use connect_4::Player;
use connect_4::State;
#[test]
fn it_starts_blank() {
let game = Connect4::new();
assert_eq!("\n | | | | | | \n | | | | | | \n | | | | | | \n | | | | | | \n | | | | | | \n | | | | | | \n1|2|3|4|5|6|7\n",
game.to_string());
}... |
#![allow(unused)]
use crate::openxr_module::OpenXR;
use crate::parser::*;
use crate::SCALE;
use glium::texture::{DepthFormat, DepthTexture2d, MipmapsOption, UncompressedFloatFormat};
use glium::{vertex::VertexBufferAny, Display, DrawParameters, Frame, Program, Surface, Texture2d};
use nalgebra::{Matrix4, Translation3,... |
use ast_types::Path as RacerPath;
use ast_types::{
self, GenericsArgs, ImplHeader, PathAlias, PathAliasKind, PathSearch, TraitBounds, Ty,
};
use core::{self, BytePos, ByteRange, Match, MatchType, Scope, Session, SessionExt};
use nameres::{self, resolve_path_with_str};
use scopes;
use typeinf;
use std::path::Path;
... |
pub mod primes;
pub mod fibonacci;
pub mod euclid;
pub mod pythagorean_triples;
|
use std::{rc::Rc, sync::{Arc, RwLock}};
use coingecko_requests::data::{Coin, VsCurrency};
use iced::{Button, Clipboard, Column, Command, HorizontalAlignment, Length, PickList, Row, Scrollable, Text, TextInput, button, pick_list, scrollable, text_input};
pub struct Flags {
pub coins: Rc<Vec<coingecko_requests::data... |
pub mod recursive;
pub mod tagsfile;
use std::path::PathBuf;
use anyhow::Result;
use itertools::Itertools;
use structopt::StructOpt;
use crate::app::Params;
use crate::paths::AbsPathBuf;
const EXCLUDE: &str = ".git,*.json,node_modules,target,_build";
/// Generate ctags recursively given the directory.
#[derive(Str... |
pub struct PascalsTriangle {
num_rows: u32
}
impl PascalsTriangle {
pub fn new(row_count: u32) -> Self {
PascalsTriangle{ num_rows: row_count }
}
pub fn rows(&self) -> Vec<Vec<u32>> {
(0..self.num_rows).map(
|n| (0..n + 1).map(
|k| combination(n, k)
... |
use std::rc::Rc; // shared pointer
use std::cell::RefCell; // mutability
type NodePtr<T> = Rc<RefCell<Node<T>>>;
struct Node<T> {
value: T,
prev: Option<NodePtr<T>>,
next: Option<NodePtr<T>>
}
pub struct DoublyLinkedList<T> {
first: Option<NodePtr<T>>,
last: Option<NodePtr<T>>,
curr_iter: ... |
// This file is part of Substrate.
// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// 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
//
// ht... |
// i8 i16 i32 i64 isize
// u8 u16 u32 u64 usize
// bool
// str --- more later
#[derive(Debug, PartialEq, Clone)]
pub struct Point {
x: i32,
y: i32,
}
#[derive(Debug, PartialEq)]
pub struct Ship {
location: Point,
status: ShipStatus,
}
#[derive(Debug, PartialEq)]
pub enum ShipStatus {
Engaged,
... |
#[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::CFGG {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut ... |
extern crate iptables;
use std::panic;
#[test]
fn test_new() {
nat(iptables::new(false).unwrap(), "NATNEW", "NATNEW2");
filter(iptables::new(false).unwrap(), "FILTERNEW");
}
#[test]
fn test_old() {
nat(
iptables::IPTables {
cmd: "iptables",
has_wait: false,
has... |
use aoc2019::intcode::IntCodeCpu;
use std::fs;
use std::io;
fn main() -> io::Result<()> {
let code = fs::read_to_string("./input/day09.in")?;
let mut cpu = IntCodeCpu::from_code(&code);
cpu.input.push_back(1);
cpu.run();
println!("p1: {}", cpu.output.pop_back().unwrap());
cpu = IntCodeCpu::fr... |
use crate::prelude::*;
use poly::*;
/// Constant-time extended euclidean algorithm to compute the inverse of x in yℤ\[x\]
/// x.len() and degree of y are assumed to be public
/// See recipx in Figure 6.1 of https://eprint.iacr.org/2019/266
#[inline]
#[cfg_attr(feature = "use_attributes", unsafe_hacspec)]
pub(crate) f... |
#[doc = "Register `HWCFGR1` reader"]
pub type R = crate::R<HWCFGR1_SPEC>;
#[doc = "Field `NUM_DMA_STREAMS` reader - number of DMA request line multiplexer (output) channels"]
pub type NUM_DMA_STREAMS_R = crate::FieldReader;
#[doc = "Field `NUM_DMA_PERIPH_REQ` reader - number of DMA request lines from peripherals"]
pub ... |
//! [Graceful Shutdown and Cleanup]
//!
//! [graceful shutdown and cleanup]: https://doc.rust-lang.org/book/ch20-03-graceful-shutdown-and-cleanup.html
use std::{
env,
error::Error,
fmt::Debug,
fs,
io::{self, Read, Write},
net::{TcpListener, TcpStream, ToSocketAddrs},
thread,
time::Durati... |
use core::cell::UnsafeCell;
use core::mem::MaybeUninit;
use core::sync::atomic::{AtomicBool, Ordering};
use futures::task::AtomicWaker;
pub struct Oneshot<T> {
message: UnsafeCell<MaybeUninit<T>>,
waker: AtomicWaker,
has_message: AtomicBool,
}
pub struct Sender<'a, T>(&'a Oneshot<T>);
pub struct Receiver<... |
//!
// mod admin;
mod conn;
mod dialer;
mod listener;
mod node;
mod ports;
mod services;
// #[doc(inline)]
// pub use admin::Admin;
#[doc(inline)]
pub use conn::Conn;
#[doc(inline)]
pub use dialer::Dialer;
#[doc(inline)]
pub use listener::Listener;
#[doc(inline)]
pub use node::Node;
#[doc(inline)]
pub use ports::*;
#... |
use crate::prelude::*;
use crate::requests::*;
use azure_core::HttpClient;
use azure_storage::core::clients::StorageClient;
use std::sync::Arc;
pub trait AsPopReceiptClient {
/// Implement this trait to convert the calling client into a
/// `PopReceiptClient`. This trait is used to make sure the
/// return... |
// Copyright 2017 pdb Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to tho... |
use common_failures::Result;
use std::convert::From;
use std::io::Read;
pub trait TokenStream<T> {
fn next(&mut self) -> Result<Option<T>>;
}
pub struct ByteStream<R: Read> {
read: R,
buffer: [u8; 1],
}
impl<R: Read> From<R> for ByteStream<R> {
fn from(from: R) -> ByteStream<R> {
ByteStream {... |
use std::fmt::{Display, Result, Formatter};
#[derive(Debug, Clone)]
pub struct Position {
line: usize,
pub col: usize,
file: String
}
impl Position {
pub fn new(file: String) -> Position {
Position {
line: 1,
col: 1,
file: file
}
}
pub fn next_line(&mut self) {
self.line += 1;
self.col = 1;... |
use std::fmt;
use castnow::KeyCommand;
#[derive(Debug, Clone, Copy)]
pub enum State {
Initial,
Loading,
Loaded,
Playing,
Stopping,
Stopped,
Pausing,
Paused,
Error
}
impl State {
pub fn next(current: &State, success: bool) -> State {
if !success {
return Stat... |
use std::default::Default;
use test::{Bencher, black_box};
use super::utils::Countable;
use StdQueue = std::collections::PriorityQueue;
// Gotta make our own trait since libcollections doesn't yet!
pub trait PriorityQueue <T> : Mutable {
fn push (&mut self, val: T);
fn pop (&mut self) -> Option<T>;
fn peek... |
#![no_std]
extern crate alloc;
mod consts;
#[cfg(not(feature = "minimal"))]
mod default;
#[cfg(feature = "minimal")]
mod minimal;
#[cfg(not(feature = "minimal"))]
pub use default::Md2;
#[cfg(feature = "minimal")]
pub use minimal::Md2;
#[cfg(test)]
mod tests {
use super::Md2;
use dev_util::impl_test;
co... |
pub mod rcc;
pub mod gpioa;
pub mod gpiob;
pub mod usart1;
pub mod flash;
pub mod stk;
pub mod spi1;
pub mod afio;
pub mod adc1; |
#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;
#[macro_use]
extern crate inherit;
fn main() {}
trait Node {
fn source_location(&self) -> (usize, usize);
}
struct Expr {
source_location: (usize, usize),
}
impl Node for Expr {
fn source... |
extern crate whenever;
use std::env;
use whenever::parser;
fn main() {
let args: Vec<String> = env::args().collect();
let arg = match args.len() {
2 => args[1].clone(),
_ => "today".to_string(),
};
let dt = parser::parse_date(&arg);
match dt {
Some(d) => println!("{}", d),
... |
use std::io::{self, Write};
use std::process;
use std::process::Command;
fn main() {
if !cfg!(target_os = "windows") {
println!("Incompatible target os, need Microsoft Windows 10");
process::exit(0); }
let output = {
Command::new("x410.exe")
.args(&["/desktop"])
... |
use crate::*;
use rider_themes::predef::*;
use rider_themes::Theme;
use std::fs;
use std::path::PathBuf;
pub fn create(directories: &Directories) -> std::io::Result<()> {
fs::create_dir_all(directories.themes_dir.clone())?;
for theme in default_styles() {
write_theme(&theme, directories)?;
}
Ok... |
// The problem_factory module is a class implementing a classic factory pattern
// to instantiate problem solutions
// get_solution is the factory method for creating a solution to each problem
pub fn get_solution(problem_number: i32) -> String {
match problem_number {
1 => super::multiple_3or5::comput... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use anyhow::{format_err, Result};
use libra_types::{
account_config::{account_struct_tag, AccountResource},
language_storage::StructTag,
};
use vm_runtime_types::{
loaded_data::{struct_def::StructDef, types::Type},
v... |
use aoc_lib::{Input, Solver};
#[derive(Debug)]
pub(crate) struct Day1 {}
impl Day1 {
fn get_sorted(input: Input) -> Vec<u32> {
let mut x = input.lines.iter().fold(vec![0], |mut acc, x| {
if x.is_empty() {
acc.push(0_u32);
acc
} else {
... |
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
fn log(s: &str);
}
#[wasm_bindgen]
pub fn greet(name: &str) {
log(&format!("Hello, {}!", name));
}
|
use specs::prelude::*;
use types::*;
use component::flag::IsMissile;
use component::reference::PlayerRef;
use component::time::*;
use airmash_protocol::server::{PlayerFire, PlayerFireProjectile};
use airmash_protocol::{to_bytes, ServerPacket};
use websocket::OwnedMessage;
pub struct MissileFireHandler;
#[derive(Sys... |
use actix_cors::Cors;
use actix_web::{web, App, HttpServer};
use chrono::prelude::*;
use config::Config;
use lazy_static;
use serde_json;
use std::collections::HashMap;
use std::thread;
use std::time::Duration;
mod event;
mod order;
mod utils;
pub const ADDR: &str = "0.0.0.0:9004";
lazy_static::lazy_static! {
static... |
//! Registry authentication support.
use crate::sources::CRATES_IO_REGISTRY;
use crate::util::{config, CargoResult, Config};
use anyhow::{bail, format_err, Context as _};
use cargo_util::ProcessError;
use std::io::{Read, Write};
use std::path::PathBuf;
use std::process::{Command, Stdio};
use super::RegistryConfig;
e... |
// Copyright 2015 The GeoRust Developers
//
// 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... |
//! File-based cache for `DirEntry` structures.
//!
//! The cache persists scan results between `userscan` invocations so that unchanged files don't
//! need to be scanned again. It is currently saved as compressed MessagePack file.
use super::{Lookup, StorePaths};
use crate::cachemap::*;
use crate::errors::*;
use cra... |
#![allow(non_snake_case)]
use failure::{
ensure,
Fallible,
};
use iota_lib_rs::prelude::iota_client;
use iota_streams::app::{
message::HasLink
};
use iota_streams::app::transport::{
Transport,
tangle::client::*
};
use iota_streams::app_channels::{
api::tangle::{
Address,
Autho... |
fn main() {
println!("cargo:rerun-if-changed=lib/jlinker/bin/libjlinker.a");
println!("cargo:rustc-link-search=./lib/jlinker/bin/");
println!("cargo:rustc-link-search=./lib/keystone/build/llvm/lib");
println!("cargo:rustc-link-lib=jlinker");
println!("cargo:rustc-link-lib=keystone");
println!("c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.