text stringlengths 8 4.13M |
|---|
use std::fmt;
pub const DISPLAY_EMPTY: &str = "{ }";
pub const DISPLAY_BLANK: &str = " ";
pub const DISPLAY_CARD_BACK: &str = "{###}";
#[derive(Debug)]
#[derive(PartialEq)]
pub enum Suit {
Heart,
Diamond,
Club,
Spade,
}
#[derive(Debug)]
#[derive(PartialEq)]
pub enum Color {
Red,
Black,
}
#[derive(... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use air::EvaluationFrame;
use math::{log2, polynom, FieldElement, StarkField};
use utils::{collections::Vec, iter};
#[cfg(feature = "conc... |
#[macro_use]
extern crate serde_json;
extern crate xi_core_lib;
extern crate xi_rpc;
#[macro_use]
extern crate log;
extern crate chrono;
extern crate fern;
#[macro_use]
extern crate clap;
extern crate dirs;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate failure;
#[macro_use]
exter... |
use serde::{Deserialize, Serialize};
/// A actor or actress for a movie or TV show
#[derive(Serialize, Deserialize, Debug)]
pub struct Cast {
/// Whether this is an adult film actor/actress
pub adult: bool,
/// The gender of this person represented as a int (0 = M, 1 = F, 2 = N/A)
pub gender: Option<i6... |
pub mod error;
pub mod event_loop;
pub mod session;
#[cfg(target_arch = "wasm32")]
pub mod stomp_client_wasm {
use std::future::Future;
use crate::error::StompClientError;
pub fn spawn<F: Future<Output = ()> + Send + 'static>(task: F) {
wasm_bindgen_futures::futures_0_3::spawn_local(task);
}... |
use ckb_jsonrpc_types::{AlertMessage, ChainInfo, PeerState};
use ckb_network_alert::notifier::Notifier as AlertNotifier;
use ckb_shared::shared::Shared;
use ckb_sync::Synchronizer;
use ckb_traits::BlockMedianTimeContext;
use ckb_util::Mutex;
use jsonrpc_core::Result;
use jsonrpc_derive::rpc;
use std::sync::Arc;
#[rpc(... |
use std::fs;
use itertools::iproduct;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Direction {
East,
SouthEast,
SouthWest,
West,
NorthWest,
NorthEast,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Color {
White,
Black,
}
#[derive(Debug, Clone, PartialEq, Eq)]
struct DirectionSe... |
pub
fn convert() {
println!("{}_i8 is in range of {}_u16", 10_i8 as u16, 10_u16);
println!("{}", 2525_u16 as i16);
println!("{}", -1_i16 as i32);
println!("{}", 65535_u16 as i32);
println!("1000_i16 as u8 is {}", 1000_i16 as u8);
println!("65535_u32 as i16 is {}", 65535_u32... |
#[doc = "Register `SPI_I2S_HWCFGR` reader"]
pub type R = crate::R<SPI_I2S_HWCFGR_SPEC>;
#[doc = "Field `TXFCFG` reader - TXFCFG"]
pub type TXFCFG_R = crate::FieldReader;
#[doc = "Field `RXFCFG` reader - RXFCFG"]
pub type RXFCFG_R = crate::FieldReader;
#[doc = "Field `CRCCFG` reader - CRCCFG"]
pub type CRCCFG_R = crate:... |
#[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::OUTCFG2 {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w m... |
mod api;
mod config;
mod entity;
mod run;
mod ui;
mod utils;
pub use config::Config;
pub use run::run;
|
use crate::camera::{Camera, CameraConfig};
use crate::color::color;
use crate::hittable::{
bvh::BvhNode, hittable_list::HittableList, rect::XyRect, sphere::Sphere, Hittables,
};
use crate::material::{diffuse::Diffuse, lambertian::Lambertian};
use crate::scenes::Scene;
use crate::texture::{marble::MarbleTexture, sol... |
use assert_cmd::prelude::*; // Add methods on commands
use std::{env, process::Command};
fn run_test(file_name: &str, output: Option<&str>) {
let mut cmd = Command::cargo_bin("cargo-hacspec").expect("Error getting cargo hacspec command");
cmd.envs(env::vars());
if let Some(f) = output {
cmd.args(&[... |
use unsafe_hacspec_examples::ec::{p384::*, Affine};
use hacspec_dev::prelude::*;
// TODO: this is duplicating a lot of code from test_p256!
create_test_vectors!(
P384TestVector,
algorithm: String,
generatorVersion: String,
numberOfTests: usize,
header: Vec<Value>, // not used
notes: Option<V... |
extern crate iron;
extern crate router;
extern crate rustc_serialize;
extern crate petstore;
#[macro_use]
extern crate slog;
extern crate slog_term;
use slog::*;
use iron::prelude::*;
use router::Router;
use std::sync::{Arc, Mutex};
use std::net::SocketAddr;
use std::net::ToSocketAddrs;
use std::net::IpAddr;
use st... |
extern crate parity_wasm;
#[macro_use]
extern crate log;
extern crate rustc_demangle;
mod gc;
mod error;
mod bitvec;
use std::any::Any;
use std::mem;
use std::path::Path;
use parity_wasm::elements::{
Module,
Serialize,
Deserialize
};
pub use error::Error;
pub struct Config {
demangle: bool,
kee... |
extern crate time;
use std::io;
use parse::non_optimal;
use parse::optimal;
mod parse;
static ITERATIONS: int = 50000i;
pub fn main() {
// let str: Vec<u8> = " cache-control:private, max-age=0
//content-encoding:gzip
//content-type:text/html; charset=UTF-8
//date:Wed, 19 Nov 2014 12:... |
pub mod module {
use crate::ray::module::*;
use crate::hittable::module::*;
use crate::vec3::module::*;
use crate::rand::module::*;
pub trait Material {
fn scatter(
&self,
r_in: &Ray,
record: &HitRecord,
attenuation: &mut Vec3,
scattered: &mut Ray) -> bool;
fn get_idx(... |
use std::fs::{self, File};
use std::io::BufWriter;
use std::env;
use std::error::Error;
use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D};
use pathfinder_geometry::vector::Vector2F;
use pathfinder_geometry::transform2d::Transform2F;
use pathfinder_export::{Export, FileFormat};
use font::{Font, parse}... |
use std::collections::HashMap;
pub fn word_count(words: &str) -> HashMap<String, u32> {
let vector = words.to_lowercase()
.chars()
.filter(|ch| ch.is_alphanumeric() || *ch == '\'' || *ch == ' ' || *ch == '\n' || *ch == '\t' || *ch == ',')
.collect::<String>();
let mut hm: HashMap<Strin... |
/*
use propagators::network::{ Network };
use propagators::cell_tms::{ TruthManagementStore };
use propagators::tms::{ TruthManagementSystem };
use propagators::cell_interval::{ Interval };
use propagators::cell::{ Cell };
use std::cell::RefCell;
use std::rc::{Rc};
type Content = TruthManagementStore<Interval>;
#[tes... |
use core::cell::Cell;
use core::cmp;
use kernel::common::cells::{OptionalCell, TakeCell};
use kernel::common::registers::{register_bitfields, ReadOnly, ReadWrite};
use kernel::common::StaticRef;
use kernel::hil;
use kernel::hil::gpio::Output;
use kernel::hil::spi::{self, ClockPhase, ClockPolarity, SpiMasterClient};
us... |
use crate::simple::env::SimpleEnv;
use super::*;
use guion::{widget::{Widget, WidgetMut, cast::Statize}, widget::{resolved::{ResolvedMut, Resolved}, root::{resolve_in_root, resolve_in_root_mut}}, widget::resolvable::{ResolvableMut, Resolvable}, util::bounds::Dims, layout::StdGonstraints, layout::Gonstraints};
use ctx::... |
use std::time::Duration;
use crate::animation::{MaybeTerminatingAnimation, Animation};
pub mod bounce;
pub mod lines;
pub mod sine_thing;
pub mod waves;
mod utils;
#[cfg(feature = "visual")]
type Anim = impl MaybeTerminatingAnimation + bevy_inspector_egui::Inspectable;
#[cfg(not(feature = "visual"))]
type Anim = imp... |
//! # Key-Value Store
//!
//! This module contains the key-value store through which guest modules access
//! the currently bound `wascap:keyvalue` capability provider
use codec::keyvalue::*;
use codec::{deserialize, serialize};
use wapc_guest::host_call;
use wascc_codec as codec;
use crate::HandlerResult;
const CAP... |
#[doc = "Register `COMP_CFGR2` reader"]
pub type R = crate::R<COMP_CFGR2_SPEC>;
#[doc = "Register `COMP_CFGR2` writer"]
pub type W = crate::W<COMP_CFGR2_SPEC>;
#[doc = "Field `INPSEL0` reader - COMP non-inverting input selection This bit is set and cleared by software (only if LOCK not set). They select which input is ... |
fn main() {
//Bloque limita el scope de una variable
let mensaje = "Hola, soy una variable del bloque main";
println!("Bloque 1: {}", mensaje);
{ //Bloque 2
let mensaje = "Hola, soy una variable del bloque 2";
println!("Bloque 2: {}", mensaje);
{ //Bloque 3 -> el alcance de... |
use std::cmp::min;
use vec::{ToVec2, Vec2};
/// Location of the view on screen
#[derive(PartialEq,Debug,Clone)]
pub struct Position {
pub x: Offset,
pub y: Offset,
}
impl Position {
pub fn new(x: Offset, y: Offset) -> Self {
Position { x: x, y: y }
}
pub fn center() -> Self {
Posi... |
use ::core;
// A file of relevant constants and structures from libsel4
pub const PAGE_4K_BITS: u8 = 12;
pub const PAGE_4K_SIZE: usize = 1 << PAGE_4K_BITS;
pub const PAGE_2M_BITS: u8 = 21;
pub const PAGE_2M_SIZE: usize = 1 << PAGE_2M_BITS;
pub const SMALL_BITS: u8 = 4;
pub const FAN_OUT_LIMIT_BITS: u8 = 8;
pub cons... |
use super::Color;
use toml;
/// Color configuration for the application.
///
/// Assign each color role an actual color.
#[derive(Copy, Clone, Debug)]
pub struct Palette {
/// Color used for the application background.
pub background: Color,
/// Color used for View shadows.
pub shadow: Color,
/// C... |
extern crate alloc;
mod dfs;
mod kruskal;
pub mod renderer;
mod wilson;
use super::MazeAlgo;
use crate::utils::set_panic_hook;
use alloc::vec::Vec;
use bit_vec::BitVec;
use core::ops::Index;
use wasm_bindgen::prelude::*;
/// Struct representing a square maze. Indexing goes from left-to-right, then
/// top-to-bottom.... |
extern crate libc;
use std::ffi::CString;
use libc::types::os::arch::posix01::utimbuf;
use libc::funcs::posix88::unistd::utime;
fn main() {
let buf = utimbuf {
actime: 0,
modtime: 0,
};
let name = CString::new("utime").unwrap();
let ret = unsafe { utime(name.as_ptr(), &buf) };
if... |
//! HTTP header fields add information to messages.
//!
//! They are most likely the most complex construct of the protocol.
//! All header fields are key-value pairs: `Server: Apache/2.4.9 (Unix)`.
//! Some may contain multiple value separated by commas:
//! `Accept-Language: de-DE, de, en-US, en`.
//! Each header fie... |
pub mod binops;
pub mod package;
use crate::{
compile::numeral_to_lnum,
eval::{LNum, LuaErr},
};
use super::eval::{LuaResult, LuaRunState, LV};
/**
* helper struct to deal with arguments from lua
**/
pub struct LuaArgs {
pub args: Vec<LV>,
}
pub fn lua_coerce_lnum(v: &LV) -> Result<LNum, LuaErr> {
... |
//! Fetch API.
//!
//! Seed Fetch API is very similar to the browser [native one][fetch-mdn].
//!
//! There is one entry point: [`fetch`][fetch] function.
//! It can accept both string urls as well as [`Request`][request].
//!
//! To get a [`Response`][response] you need to `.await` fetch:
//! ```rust
//! let response ... |
mod integrate {
/// Computes an integral using the trapezoid rule.
///
/// Assumptions:
/// 1. That the data is evenly-spaced.
pub fn trapezoidal(data: &[(f64,f64)]) -> f64 {
if data.len() <= 1 {
return 0.0;
}
let last = data.len() - 1;
let h = data[1]... |
use std::collections::HashSet;
use std::fs;
type Result<T> = ::std::result::Result<T, Box<dyn ::std::error::Error>>;
fn main() -> Result<()> {
let contents = fs::read_to_string("src/input.txt").expect("Failed to open input.txt");
part1(&contents)?;
part2(&contents)?;
Ok(())
}
fn part1(input: &str) ->... |
pub fn reply(a: &str) -> String {
if a.len() == 0 {
"Fine. Be that way!".to_string()
} else if a.to_uppercase() == a {
"Whoa, chill out!".to_string()
} else if a.chars().last().unwrap() == '?' {
"Sure.".to_string()
} else {
"Whatever.".to_string()
}
} |
mod filer;
use std::io::prelude::*;
use std::thread;
use crossbeam_channel::Sender;
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
const REQUEST_FILER: &str = "filer";
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Message {
pub method: S... |
use maria::{self, Cradle};
fn main() {
let stdio = std::io::stdin();
let input = stdio.lock();
let mut c = Cradle::new(input);
c.assignment();
if c.look != '\n' {
maria::expected("Newline");
}
}
|
extern crate csv;
#[macro_use]
extern crate serde;
extern crate log;
use serde::de::{Deserialize, Deserializer};
use serde::ser::{Serialize, Serializer};
use sqlparser::ast;
use std::collections::HashMap;
use std::error::Error;
use std::fmt;
use std::io;
pub mod crusty_graph;
pub mod logical_plan;
pub use logical_plan... |
fn mod_inv(a: isize, module: isize) -> isize {
let mut mn = (module, a);
let mut xy = (0, 1);
while mn.1 != 0 {
xy = (xy.1, xy.0 - (mn.0 / mn.1) * xy.1);
mn = (mn.1, mn.0 % mn.1);
}
while xy.0 < 0 {
xy.0 += module;
}
xy.0
}
fn main() {
println!("{}", mod_inv(42, 2017))
}
|
use crate::demo::data::DemoTick;
use crate::demo::gameevent_gen::{ObjectDestroyedEvent, PlayerDeathEvent};
use crate::demo::gamevent::GameEvent;
use crate::demo::message::gameevent::GameEventMessage;
use crate::demo::message::packetentities::{EntityId, PacketEntity, UpdateType};
use crate::demo::message::Message;
use c... |
use rand::seq::SliceRandom;
use rocket_contrib::json::JsonValue;
use std::collections::HashMap;
use log::info;
use crate::{Battlesnake, Board, Coord, Game};
pub fn get_info() -> JsonValue {
info!("INFO");
// Personalize the look of your snake per https://docs.battlesnake.com/references/personalization
r... |
/*
* Copyright (C) 2019-2022 TON Labs. All Rights Reserved.
*
* Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use
* this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed... |
use iced_wgpu::wgpu;
use crate::assets::AssetError;
pub struct Texture {
pub size: wgpu::Extent3d,
pub mip_level_count: u32,
pub dimension: wgpu::TextureDimension,
pub format: wgpu::TextureFormat,
pub texture: wgpu::Texture,
pub view: wgpu::TextureView,
}
pub struct ArrayTextureLayer<'a> {
... |
//! Graph representation stages for Hydroflow graphs.
use std::borrow::Cow;
use std::hash::Hash;
use proc_macro2::{Ident, Span, TokenStream};
use quote::ToTokens;
use serde::{Deserialize, Serialize};
use slotmap::new_key_type;
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::{Expr, ExprPath, Gener... |
#![allow(non_snake_case)]
#[macro_use]
extern crate lazy_static;
extern crate serde_json;
extern crate vmtests;
use serde_json::Value;
use std::collections::HashMap;
use vmtests::{load_tests, run_test};
lazy_static! {
static ref TESTS: HashMap<String, Value> = load_tests("tests/vmLogTest/");
}
#[test]
fn test_l... |
#[doc = "Register `M2ICR` reader"]
pub type R = crate::R<M2ICR_SPEC>;
#[doc = "Register `M2ICR` writer"]
pub type W = crate::W<M2ICR_SPEC>;
#[doc = "Field `CSEDC` reader - Clear ECC single error detected and corrected Writing 1 to this flag clears the SEDC bit in the RAMCFG_MxISR register. Reading this flag returns the... |
pub mod builder;
pub mod server;
pub mod landing_template;
pub mod router;
pub mod helpers;
pub mod export {
pub mod serverless {
pub mod now {
pub use now_lambda::Request;
pub use now_lambda::IntoResponse;
pub use now_lambda::error::NowError;
}
}
}
pub mod sc... |
use actix_web::web::ServiceConfig;
mod auth;
mod bills;
mod depodraws;
mod money_nodes;
mod organisations;
mod persons;
mod products;
mod statement_of_accounts;
mod transaction_entities;
mod transactions;
mod finance;
pub fn endpoints(config: &mut ServiceConfig) {
auth::endpoints(config);
persons::endpoints(c... |
use crate::bus::Bus;
use crate::cpu::Cpu;
use crate::mapper::Mapper;
use crate::ppu::Ppu;
use crate::Result;
use std::cell::RefCell;
use std::ops;
use std::path::Path;
use std::rc::Rc;
#[derive(Debug, Clone)]
struct CpuBus {
wram: Vec<u8>,
mapper: Rc<RefCell<Box<dyn Mapper>>>,
ppu: Rc<RefCell<Ppu<PpuBus>>>... |
use crate::errors::EmuError;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FdaTable {
pub(crate) names: Vec<String>, // size of the fitment
pub(crate) ids: Vec<usize>,
pub(crate) energies: Vec<f64>,
pub(crate) table: Vec<Vec<f64>... |
#![no_std]
use core::mem;
use plain;
pub use self::big_endian::Be32;
mod big_endian;
pub use self::file::File;
mod file;
pub use self::fmap::Fmap;
mod fmap;
pub use self::header::Header;
mod header;
pub struct Rom<'a>(pub &'a [u8]);
impl<'a> Rom<'a> {
pub fn new(data: &'a [u8]) -> Self {
Self(data)
... |
#[doc = "Register `ISR` reader"]
pub type R = crate::R<ISR_SPEC>;
#[doc = "Field `LIF` reader - Line Interrupt flag"]
pub type LIF_R = crate::BitReader;
#[doc = "Field `FUIF` reader - FIFO Underrun Interrupt flag"]
pub type FUIF_R = crate::BitReader;
#[doc = "Field `TERRIF` reader - Transfer Error interrupt flag"]
pub ... |
// Copyright 2015 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 std::collections::HashMap;
use std::sync::Arc;
use futures::future::ok;
use futures::Future;
use super::Node;
use super::Sandbox;
use crate::libs::get_cache;
use crate::libs::HealthCache;
use crate::logging;
use shiplift::rep::ContainerDetails;
use shiplift::Docker;
struct ContainerMeta {
id: String,
run... |
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4)
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
// DO NOT EDIT
use Cancellable;
use Error;
use IOStream;
use TlsCertificate;
use TlsCertificateFlags;
use TlsDatabase;
use TlsInteraction;
use TlsRehandshakeMode;
use ffi;
use g... |
use specs::*;
use types::*;
use component::channel::*;
use systems::spectate::CommandHandler;
use protocol::server::GameSpectate;
use protocol::{to_bytes, ServerPacket};
use OwnedMessage;
use SystemInfo;
pub struct SendSpectatePacket {
reader: Option<OnPlayerSpectateReader>,
}
#[derive(SystemData)]
pub struct S... |
use cgmath::{Matrix3, Matrix4};
use util::bits::BitField;
use util::cur::Cur;
use util::fixed::{fix16, fix32};
use nitro::Name;
use nitro::rotation::{pivot_mat, basis_mat};
use std::ops::{Mul, Add};
use errors::Result;
pub struct Animation {
pub name: Name,
pub num_frames: u16,
pub objects_curves: Vec<TRSC... |
use std::collections::HashMap;
const INPUT: &str = include_str!("../input");
type Position = (isize, isize);
fn find_door_counts(regex: &str) -> HashMap<Position, usize> {
let s = ®ex[1..regex.len() - 1];
let mut door_counts = HashMap::new();
let mut stack = vec![vec![(0, (0, 0))]];
for c in s.cha... |
extern crate libc;
use std::os::raw::c_int;
use libc::{size_t, ssize_t, c_char, c_uint, c_float, c_void};
// Colors
pub const CACA_BLACK: c_uint = 0x00;
pub const CACA_BLUE: c_uint = 0x01;
pub const CACA_GREEN: c_uint = 0x02;
pub const CACA_CYAN: c_uint = 0x03;
pub const CACA_RED: c_uint... |
use parking_lot::Mutex;
use std::task::Waker;
#[derive(Default)]
pub(crate) struct Wakers(Mutex<Vec<Waker>>);
impl Wakers {
pub(crate) fn register(&self, waker: &Waker) {
let mut inner = self.0.lock();
for w in inner.iter() {
if w.will_wake(waker) {
return;
... |
use std::cell::{Ref, RefCell};
use chiropterm::{Brush, Brushable, Stamp};
use euclid::{rect, size2};
use crate::{InternalWidgetDimensions, UI, Widget, WidgetMenu, Widgetlike, widget::LayoutHacks};
pub type Label = Widget<LabelState>;
pub struct LabelState {
text: String,
stamp: RefCell<(isize, Stamp)>,
... |
#[macro_use] extern crate lazy_static;
extern crate clap;
extern crate regex;
use std::collections::HashSet;
use std::fs::OpenOptions;
use std::io::{BufRead, BufReader, BufWriter, Write};
use clap::{Arg, App, ArgMatches};
use regex::Regex;
fn read_blocklist<T: AsRef<str>>(filename: T) -> HashSet<String> {
let fi... |
use std::thread;
use std::time::Duration;
pub fn thread_simple_demo1() {
//spawn create a thread
let handle = thread::spawn(|| {
for i in 1..10 {
println!("hi number {} from the spawned thread1!", i);
thread::sleep(Duration::from_millis(1));
}
println!("thread 1 ... |
use crate::generate::{
grammars::{InlinedProductionMap, LexicalGrammar, Production, ProductionStep, SyntaxGrammar},
rules::SymbolType,
};
use anyhow::{anyhow, Result};
use std::collections::HashMap;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
struct ProductionStepId {
// A `None` value here means th... |
extern crate termion;
#[macro_use]
extern crate log;
use std::u8;
use std::cmp::max;
use std::{convert, fmt, iter};
use log::LogLevel;
use termion::color::{self, LightBlack, Reset, Fg};
pub mod error;
#[derive(Clone, Debug, Eq, PartialEq)]
/// Representation of a set of data `Point` values
struct Line<V> {
got_d... |
use crate::*;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum RiddleError {
#[cfg(feature = "riddle-audio")]
#[error(transparent)]
Audio(#[from] audio::AudioError),
#[cfg(feature = "riddle-font")]
#[error(transparent)]
Font(#[from] font::FontError),
#[error(transparent)]
Image(#[from] image::ImageErr... |
extern crate constantine;
use constantine::Router;
use constantine::renderer::StaticFile;
fn main() {
let mut app = Router::new();
app.get("/bla", |_, response| {
response.set_header("content-type", "text/html");
String::from("hello\n")
});
app.get("/1", |_, _| {
String::fro... |
use crate::{lexer::Token, syntax::SyntaxKind};
use text_unit::{TextRange, TextUnit};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Input<'t> {
text: &'t str,
tokens: Vec<Token>,
start_offsets: Vec<TextUnit>,
len: TextUnit,
}
impl<'t> Input<'t> {
pub fn new(text: &'t str, raw_tokens: &'t [Token... |
//pub const BIT_MATRIX: [u32; 256] = [
// 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1,
// 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
// 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0,... |
use self::petgraph::algo::DfsSpace;
use crate::info::Info;
use crate::{Consume, ConsumeDisplay};
use crossterm::style::{style, Color, Stylize};
use fnv::{FnvHashMap, FnvHashSet};
use prettytable::Table;
use solp::ast::{Conf, Solution};
use solp::msbuild;
use std::collections::BTreeSet;
use std::fmt;
use std::fmt::Displ... |
use std::{
fmt::Debug,
ops::{Deref, DerefMut},
};
use crate::util::{impl_deref_wrapped, impl_from_repeated};
use librespot_protocol as protocol;
use protocol::metadata::ContentRating as ContentRatingMessage;
#[derive(Debug, Clone)]
pub struct ContentRating {
pub country: String,
pub tags: Vec<String>... |
#[derive(serde::Deserialize)]
pub struct VerifyIntentRequestQuery {
#[serde(rename = "hub.challenge")]
challenge: String,
}
pub fn verify_intent(query: VerifyIntentRequestQuery) -> String {
tracing::debug_span!("pubsub_verify", challenge = %query.challenge);
query.challenge
}
|
#[doc = "Reader of register ADDR_ENDP13"]
pub type R = crate::R<u32, super::ADDR_ENDP13>;
#[doc = "Writer for register ADDR_ENDP13"]
pub type W = crate::W<u32, super::ADDR_ENDP13>;
#[doc = "Register ADDR_ENDP13 `reset()`'s with value 0"]
impl crate::ResetValue for super::ADDR_ENDP13 {
type Type = u32;
#[inline(... |
/// Environment variable name for enabling/disabling color
///
/// Whan a tty is attached to the environment and this environment variable is
/// either unset or truthy color will be used. Likewise if a tty exists and this
/// variable is set and falsy color will not be used.
pub const TERM_COLOR: &str = "TERM_COLOR";
... |
/*
chapter 4
syntax and semantics
*/
struct Circle {
h: f64,
v: f64,
r: f64,
}
impl Circle {
fn area(&self) -> f64 {
std::f64::consts::PI * (self.r * self.r)
}
}
fn main() {
let n = Circle { h: 0.0, v: 0.0, r: 2.0 };
println!("{}", n.area());
println!("h is {} and v is {}", n.h,... |
use std::iter::{Extend, FromIterator};
use thiserror::Error;
use derive_more::Deref;
#[macro_export]
macro_rules! report_wrapped {
($wraped: expr, $report: expr, $unwrap: pat => $error: expr) => {
{
let status = $wraped;
$report(&status);
match status {
$unwrap => $error,
other => panic!("wrap... |
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use clap::Clap;
mod bootstrap;
mod build;
mod cache;
mod canister;
mod config;
mod deploy;
mod identity;
mod language_service;
mod ledger;
mod new;
mod ping;
mod replica;
mod start;
mod stop;
mod toolchain;
mod upgrade;
mod wallet;
#[derive(... |
#[doc = "Register `ETH_MTLISR` reader"]
pub type R = crate::R<ETH_MTLISR_SPEC>;
#[doc = "Field `Q0IS` reader - Q0IS"]
pub type Q0IS_R = crate::BitReader;
#[doc = "Field `Q1IS` reader - Q1IS"]
pub type Q1IS_R = crate::BitReader;
impl R {
#[doc = "Bit 0 - Q0IS"]
#[inline(always)]
pub fn q0is(&self) -> Q0IS_R ... |
use super::error::ArrayIndexError;
use std::fmt::{self, Display, Formatter};
/// Array index to search for in a JSON document.
///
/// Represents a specific location from the front of the list in a json array.
/// Provides the [IETF-conforming index value](https://www.rfc-editor.org/rfc/rfc7493.html#section-2). Value... |
use std::ops::Deref;
use anyhow::Context;
/// Use with caution.
/// It makes wrapping type T to be Send + Sync.
/// Make sure T is semantically Send + Sync
#[derive(Copy, Clone)]
pub struct ForceSendSync<T>(T);
unsafe impl<T> Sync for ForceSendSync<T> {}
unsafe impl<T> Send for ForceSendSync<T> {}
impl<T> ForceSend... |
/// LeetCode Monthly Challenge problem for April 1st, 2021.
pub struct Solution {}
impl Solution {
/// Given the head node of a linked list, returns whether the nodes' values
/// form are a palindrome.
///
/// # Examples
/// ```
/// # use crate::palindrome_linked_list::{ListNode, Solution};
... |
use crate::z3::ast::Ast;
use std::ffi::CStr;
use std::fmt;
use z3_sys::*;
use crate::z3::Model;
use crate::z3::Optimize;
use crate::z3::Solver;
use crate::z3::Z3_MUTEX;
impl<'ctx> Model<'ctx> {
pub fn of_solver(slv: &Solver<'ctx>) -> Model<'ctx> {
Model {
ctx: slv.ctx,
z3_mdl: unsaf... |
use core::panic;
use std::{collections::VecDeque, sync::{mpsc::{Receiver, Sender}}, thread, usize};
use std::net::{UdpSocket, IpAddr};
use rand::Rng;
use super::{packet::{TransType, TransportPacket}, socket::SocketID};
use super::manager::TaskMsg;
const UDP_IN_PORT: usize = 8848;
const UDP_OUT_PORT: usize = 8888;
con... |
use async_trait::async_trait;
use common::cache::Cache;
use crate::domain::token::{Data, TokenId};
#[async_trait]
pub trait TokenRepository: Cache<TokenId, Data> + Sync + Send {}
|
//! Application image manipulation.
//!
//! This isn't technically part of the GBL container format, but can be very
//! useful nonetheless.
use crate::error::Error;
use crate::utils::Blob;
use crate::{crypto, P256KeyPair};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use num_traits::FromPrimitive;
use... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{get_available_port, BaseConfig, ChainNetwork, ConfigModule, StarcoinOpt};
use anyhow::Result;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(default, deny_unknown... |
extern crate bresenham;
extern crate cgmath;
extern crate rand;
mod object;
mod screen;
use cgmath::*;
use object::*;
use screen::*;
// TODO: fix comulative floating point arithmetic error
fn main() {
// let chars = vec!['░', '▒', '▓', '█'];
// looks great, performs worse in most terminal emulators
let c... |
use chrono::{NaiveDateTime};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Message {
pub id: String,
pub from_user_id: u16,
pub to_user_id: u16,
pub topic_id: String,
pub content: String,
pub status: u8,
pub create_time: NaiveDateTime
}
|
use crypto::identity::{DummyMixIdentityKeyPair, MixnetIdentityKeyPair, MixnetIdentityPublicKey};
use itertools::Itertools;
use log::{debug, error, warn};
use mix_client::MixClient;
use provider_client::ProviderClient;
use sphinx::header::delays::Delay;
use sphinx::route::{Destination, Node as SphinxNode};
use std::coll... |
//! @brief SHA256 Syscall test
extern crate solana_sdk;
use solana_sdk::{
hash::{hashv, Hasher},
info,
};
#[no_mangle]
pub extern "C" fn entrypoint(_input: *mut u8) -> u64 {
info!("sha256");
let vals = &["Gaggablaghblagh!".as_ref(), "flurbos".as_ref()];
let mut hasher = Hasher::default();
has... |
// This file is part of Substrate.
// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the F... |
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
#[derive(Serialize, Deserialize)]
pub struct CategoryInsert {
pub user_id: uuid::Uuid,
pub name: String,
pub description: String,
}
#[derive(Serialize, FromRow)]
pub struct Category {
pub id: uuid::Uuid,
pub user_ud: uuid::Uuid,
pub name:... |
pub fn run() {
let mut hello = String::from("Hello ");
//length of the string
println!("Length: {}", hello.len());
//Push a character into the String
// hello.push("W");
//push a strng
hello.push_str("orld!");
//Capacity o string
println!("Capacity {}", hello.capacity());
//C... |
pub mod module {
use crate::vec3::module::*;
// img[row][col]
pub type PPMColor = (u8, u8, u8);
pub type Color = Vec3;
pub type Image = Vec<Vec<PPMColor>>;
pub type Point = Vec3;
} |
//! read & write registers
/// CP0 control register
pub mod cp0;
pub mod general_purpose;
|
use diesel::prelude::*;
use diesel::{self, PgConnection};
use uuid::Uuid;
use std::str::FromStr;
use messages::query_parameters;
use messages::track::{CreateEvent, CreateRequest, CreateResponse, DeleteEvent, DeleteRequest,
DeleteResponse, ListRequest, ListResponse};
use messages::EventKind;
use ... |
use yatima_core::{
defs::{
Def,
Defs,
},
name::Name,
package::Entry,
parse::{
package::parse_entry,
span::Span,
term::{
parse_expression,
parse_name,
parse_space1,
},
},
term::Term,
};
use crate::file::{
error,
error::FileError,
};
use std::{
collections::... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.