text stringlengths 8 4.13M |
|---|
pub mod filesystem;
pub mod prelude;
use crate::core::Client;
use azure_core::No;
pub trait Filesystem<C>
where
C: Client,
{
fn create_filesystem<'a>(&'a self) -> filesystem::requests::CreateFilesystemBuilder<'a, C, No>;
fn delete_filesystem<'a>(&'a self) -> filesystem::requests::DeleteFilesystemBuilder<'... |
use crate::{
client::Binance,
error::Error,
model::{
AccountInformation, AssetDetail, Balance, DepositAddressData, DepositHistory, Order,
OrderCanceled, TradeHistory, Transaction,
},
};
use chrono::prelude::*;
use failure::Fallible;
use futures::prelude::*;
use serde_json::json;
use std:... |
// #![feature(plugin, custom_derive)]
// #![feature(proc_macro_hygiene, decl_macro)] should I use this new api?
#![feature(proc_macro_hygiene, decl_macro, plugin, custom_derive)]
#![plugin(rocket_codegen)]
#[macro_use] // rocket application for query string in the next version
extern crate rocket;
extern crate rocket_... |
/// # Safety
/// Unsafe method which casts immutable reference to mutable reference without any checks.
#[allow(clippy::mut_from_ref)]
pub unsafe fn as_mut<T>(reference: &T) -> &mut T {
let const_ptr = reference as *const T;
let mut_ptr = const_ptr as *mut T;
&mut *mut_ptr
}
|
// Copyright 2017-2021 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 ... |
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
pub mod context;
pub mod filters;
pub mod handlers;
pub mod runtime;
#[cfg(any(test))]
pub(crate) mod tests;
|
use juice_sdk_rs::{client, transports};
#[tokio::main]
async fn main() -> juice_sdk_rs::Result<()> {
let transport = transports::http::Http::new("http://10.1.1.40:7009")?;
let client = client::Client::new(transport, true);
let number = client.block_number(String::from("sys")).await?;
println!("{}", nu... |
use rand;
use rand::prelude::IteratorRandom;
use rand::Rng;
use std::ops::Add;
use std::thread;
use std::thread::JoinHandle;
use std::time::{Duration, Instant};
use wkvstore;
use wkvstore::KVStore;
const START_KEYS: u32 = 6_000_000;
const SAMPLES: u32 = 100_000;
fn spawn_run(
num: u16,
store: &KVStore<Vec<u8>... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - TIM4 control register 1"]
pub tim4_cr1: TIM4_CR1,
_reserved1: [u8; 0x02],
#[doc = "0x04 - TIM4 control register 2"]
pub tim4_cr2: TIM4_CR2,
#[doc = "0x08 - TIM4 slave mode control register"]
pub tim4_smcr: TIM4_... |
fn main() {
let x = " ";
let x = x.len();
println!("Hello, world! {}", x);
}
|
use serde::Deserialize;
use super::media::MediaBase;
use super::user::UserBase;
use crate::utils::{na_long_str, synopsis};
#[derive(Clone, Deserialize, Debug)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ActivityType {
Text,
AnimeList,
MangaList,
Message,
MediaList,
}
#[derive(Clone, D... |
use std::{
any::Any, borrow::Cow, collections::HashMap, convert::Infallible, marker::PhantomData,
path::Path, sync::Arc, u8,
};
use async_trait::async_trait;
#[cfg(feature = "keyvalue")]
use bonsaidb_core::kv::{KeyOperation, Kv, Output};
use bonsaidb_core::{
connection::{AccessPolicy, Connection, QueryKey,... |
/*
* Copyright 2017 Eldad Zack
*
* 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
* limitation the rights to use, copy, modify, merge, publish, dis... |
#![feature(const_generics)]
trait Foo {}
impl<const N: usize> Foo for [(); N]
where
Self:FooImpl<{N==0}>
{}
trait FooImpl<const IS_ZERO: bool>{}
fn main() {}
|
use cgmath::{perspective, EuclideanSpace, Matrix4, Point3, Rad, Vector3, Vector4, Quaternion, Rotation3};
use gl::types::GLuint;
use glow::HasContext;
pub trait IsCamera {
fn get_proj(&self, width: u32, height: u32) -> Matrix4<f32>;
fn get_view(&self) -> Matrix4<f32>;
fn upload_fields(&self, gl: &glow::C... |
pub mod compiler;
mod form;
mod processor;
use std::str;
use actix_web::{post, web, HttpResponse, Responder};
use serde::Deserialize;
use serde_json::Value;
use crate::data::Data;
use crate::services::{self, WsError};
pub fn config(cfg: &mut web::ServiceConfig) {
cfg.service(compile_documents);
}
#[derive(Des... |
//! Functions and utilities for the [`Diff`](`crate::opt::Diff`) command
//! and [`Diff`](`punktf_lib::visit::diff::Diff`) visitor.
use crate::opt::DiffFormat;
use console::{style, Style};
use punktf_lib::visit::diff::Event;
use similar::{ChangeTag, TextDiff};
use std::{fmt, path::Path};
/// Processes diff [`Event`s]... |
#[doc = "Register `OR` reader"]
pub type R = crate::R<OR_SPEC>;
#[doc = "Register `OR` writer"]
pub type W = crate::W<OR_SPEC>;
#[doc = "Field `SWP_TBYP` reader - SWP transceiver bypass"]
pub type SWP_TBYP_R = crate::BitReader;
#[doc = "Field `SWP_TBYP` writer - SWP transceiver bypass"]
pub type SWP_TBYP_W<'a, REG, con... |
// Copyright 2019 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause
//! General definition of public-private key pairs for use in Tari. The traits and structs
//! defined here are used in the Tari domain logic layer exclusively (as opposed to any specific
//! implementation of ECC curve). The idea being that w... |
#![no_std]
#![feature(llvm_asm)]
#![feature(const_fn)]
#![feature(const_raw_ptr_to_usize_cast)]
#![allow(clippy::identity_op)]
pub mod address;
pub mod x86;
/// Imitate C99's designated initializer
#[macro_export]
macro_rules! assigned_array {
($default:expr; $len:expr; $([$idx:expr] = $val:expr),*) => {{
... |
use {
http::{Response, StatusCode},
serde_json::json,
tsukuyomi::{
error::{Error, HttpError}, //
future::{Async, Poll, TryFuture},
handler::{Handler, ModifyHandler},
input::Input,
output::IntoResponse,
util::Either,
},
};
#[derive(Debug, failure::Fail)]
p... |
//! # Parser methods for the general types
use super::types::{ObjectID, ObjectTemplate, Quaternion, Vector3f, WorldID};
//use encoding::{all::UTF_16LE, DecoderTrap, Encoding};
use nom::{
bytes::complete::take,
combinator::{map, map_opt, map_res},
error::FromExternalError,
multi::length_data,
sequenc... |
//! Simple bootstrap node implementation
#![feature(type_changing_struct_update)]
use clap::Parser;
use libp2p::identity::ed25519::Keypair;
use libp2p::{identity, Multiaddr, PeerId};
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::fmt::{Display, Formatter};
use std::sync::Arc;
use subspace_networ... |
use std::borrow::Borrow;
use std::collections::hash_map::*;
use std::collections::HashMap;
use std::hash::Hash;
use std::iter::{FromIterator, IntoIterator};
use std::ops::{Index, IndexMut};
/// A `HashMap` that returns a default when keys are accessed that are not present.
#[derive(PartialEq, Eq, Clone, Debug)]
#[cfg_... |
const INPUT: &str = include_str!("../input.txt");
const SAMPLE_INPUT: &str = include_str!("../sample_input.txt");
fn solve_part_1(input: &str) -> u32 {
let mut escape_hex = 0u32;
let mut escape_slash = 0u32;
let mut escape_quote = 0u32;
let mut number_quotes = 0u32;
for line in input.trim().l... |
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::str::FromStr;
fn inputs_directory<'a>() -> &'a Path {
Path::new("src/inputs/")
}
// load file
pub fn load_input_file<S>(name: &str) -> Result<S, ()>
where
S: FromStr,
{
let input_file = inputs_directory().join(name);
let mut contents ... |
use crate::util::{char_to_i32, lines_from_file, vec_to_string};
pub fn day3() {
println!("== Day 3 ==");
let input = lines_from_file("src/day3/input.txt");
let a = part_a(&input);
println!("Part A: {}", a);
let b = part_b(&input);
println!("Part B: {}", b);
}
fn part_a(input: &Vec<String>) -> ... |
/* If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000: */
use std::{u32};
fn main() {
println!("{}", sum_of_multiples(3, 5));
}
fn sum_of_multiples(x: u32, y: u32) -> u32 {
const... |
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*/
#[cfg(test)]
mod e2e_test {
#[repr(C, align(32))]
pub struct F32Slice104([f32; 104]);
#[repr(C, align(32))]
pub struct F16Slice104([Half; 104]);
use approx::assert_abs_diff_eq;
use crate::h... |
extern crate piston_window;
use piston_window::*;
use crate::circbuf::CircBuf;
use std::time::SystemTime;
// use graphics::glyph_cache::rusttype::GlyphCache;
const SIZE: [f64; 2] = [1280., 720.];
const BUFFERED_SECS: usize = 10;
pub fn run<I>(mut data: I)
where I: Iterator<Item=(f32, f32, f32, f32)> {
let frequenc... |
//To use this, please install zfs-fuse
use redox::*;
pub mod nvpair;
pub mod nvstream;
pub mod xdr;
#[repr(packed)]
pub struct VdevLabel {
pub blank: [u8; 8 * 1024],
pub boot_header: [u8; 8 * 1024],
pub nv_pairs: [u8; 112 * 1024],
pub uberblocks: [Uberblock; 128],
}
impl VdevLabel {
pub fn from(d... |
#[macro_use]
extern crate serde_derive;
extern crate libc;
use libc::{c_char, c_int};
use std::ffi::{CStr, CString};
#[link(name = adm_engine)]
extern "C" {
fn renderAdmContent(input: *mut *const c_char,
destination: *mut *const c_char,
element_gains_cstr: *mut *con... |
//! The `plan` module provides a domain-specific language for payment plans. Users create Budget objects that
//! are given to an interpreter. The interpreter listens for `Witness` transactions,
//! which it uses to reduce the payment plan. When the plan is reduced to a
//! `Payment`, the payment is executed.
use chro... |
use hacl_star_sys as ffi;
use crate::And;
pub const KEY_LENGTH: usize = 32;
pub const NONCE_LENGTH: usize = 12;
pub const BLOCK_LENGTH: usize = 64;
pub type ChaCha20<'a> = And<&'a Key, &'a Nonce>;
define!{
pub struct Key/key(pub [u8; KEY_LENGTH]);
pub struct Nonce/nonce(pub [u8; NONCE_LENGTH]);
}
impl Key ... |
use std::{
env,
env::{VarError, Vars},
net::SocketAddr,
};
#[derive(Debug)]
pub struct Env {}
mod default {
pub const ASSET_PATH: &str = "assets";
pub const DEBUG_MODE: &str = "false";
pub const LISTEN_ADDR: &str = "127.0.0.1";
pub const LISTEN_PORT: &str = "3000";
pub const METRIC_LIS... |
use engine::Event;
pub trait Output {
fn receive_event(&mut self, evt: &Event);
} |
use luminance::shader::program::Program;
use super::{
ShaderInterface,
UniformType
};
use std::collections::HashMap;
use regex::Regex;
use crate::VertexSemantics;
pub trait IsShader {
fn program(&self) -> &Program<VertexSemantics, (), ShaderInterface>;
}
pub struct ShaderSource {
pub vertex_shader... |
// u512 division
use super::u512;
use std::convert::TryInto;
/*
This is an attempt at Knuth's algorithm D for division.
The code is terrible but I'm to lazy to refactor it
It passes tests and is fast enough for now
*/
impl u512 {
fn divide_with_remainder(&self, other: &u512) -> (u512, u512) /* (result... |
struct Solution;
impl Solution {
pub fn trap(height: Vec<i32>) -> i32 {
// 动态编程。
if height.is_empty() {
return 0;
}
let mut ans = 0;
let n = height.len();
let mut left_max = vec![0; n];
left_max[0] = height[0];
for i in 1..n {
... |
use cgmath::Point3;
/// Uses spherical coordinates to represent the cameras location relative to a target.
/// https://en.wikipedia.org/wiki/Spherical_coordinate_system
/// https://threejs.org/docs/#api/en/math/Spherical
pub(crate) struct Camera {
pub target: Point3<f32>,
/// radius from the target to the came... |
use alloc::{sync::Arc, vec::Vec};
use hashbrown::HashMap;
use crate::{buffer::Buffer, Renderer, Shader, ShaderBindingType, Texture};
pub struct Material {
pub(crate) vertex_shader: Arc<Shader>,
pub(crate) fragment_shader: Arc<Shader>,
pub(crate) pipeline_layout: wgpu::PipelineLayout,
pub(crate) bind_... |
#![feature(test)]
extern crate cgmath;
extern crate shred;
#[macro_use]
extern crate shred_derive;
extern crate test;
use std::ops::{Index, IndexMut};
use cgmath::Vector3;
use shred::*;
use test::{black_box, Bencher};
#[derive(Debug)]
struct VecStorage<T> {
data: Vec<T>,
}
impl<T: Clone> VecStorage<T> {
fn... |
extern crate rafy;
use rafy::Rafy;
fn main() {
let content = Rafy::new("https://www.youtube.com/watch?v=DjMkfARvGE8").unwrap();
println!("{}", content.videoid);
println!("{}", content.title);
println!("{}", content.rating);
println!("{}", content.viewcount);
} |
// Definition for singly-linked list.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
impl ListNode {
#[inline]
fn new(val: i32) -> Self {
ListNode { next: None, val }
}
}
pub fn add_two_numbers(
l1: Option<Box<ListNode>>,
... |
// Copyright 2017-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate 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 License, or
// (at your option) a... |
use thiserror::Error;
use solana_program::program_error::ProgramError;
#[derive(Error, Debug, Copy, Clone)]
pub enum BackgammonError {
#[error("Invalid Instruction")]
InvalidInstruction,
#[error("Invalid State")]
InvalidState,
#[error("Unauthorized Action")]
UnauthorizedAction,
#[error(... |
$NetBSD: patch-library_core_src_ffi_mod.rs,v 1.1 2023/07/10 12:01:24 he Exp $
NetBSD/riscv64 also has unsigned chars.
--- library/core/src/ffi/mod.rs.orig 2023-05-31 19:28:10.000000000 +0000
+++ library/core/src/ffi/mod.rs
@@ -132,7 +132,12 @@ mod c_char_definition {
),
all(
... |
#[doc = "Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n... |
extern crate bytes;
use std::net::SocketAddr;
#[derive(Debug)]
pub struct Props {
pub host: String,
pub port: i32
}
impl Props {
fn to_address(&self) -> SocketAddr {
let address = format!("{}:{}", self.host, self.port);
address.parse().expect("Unable to parse socket address")
}
}
p... |
pub fn is_armstrong_number(num: u32) -> bool {
// let digits = num
// .to_string()
// .chars()
// .map(|d| d.to_digit(10).unwrap())
// .collect::<Vec<_>>();
// if digits.len() >= 10 {
// false
// } else {
// digits
// .iter()
// .fold(... |
use std::collections::{HashMap, HashSet};
use crate::utils::file2vec;
pub fn day7(filename:&String){
let contents = file2vec::<String>(filename);
let contents:Vec<String> = contents.iter().map(|x| x.to_owned().unwrap()).collect();
let mut contained_in_map: HashMap<String,Vec<String>> = HashMap::new();
... |
use diesel::query_dsl::methods::{LimitDsl, OffsetDsl};
use juniper::GraphQLInputObject;
#[derive(GraphQLInputObject)]
pub struct Pagination {
pub take: Option<i32>,
pub skip: Option<i32>,
}
#[allow(clippy::module_name_repetitions)]
pub trait PaginateDsl {
type Output;
fn paginate(self, pagination: Opt... |
//! # Structures related to the downloaded game files and the log
//!
//!
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum IsoCode {
#[serde(rename = "en-US")]
EnUS,
#[serde(other)]
Other,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct DataLoc {
#[serde(rename = "isoCode")]
pub iso_c... |
use std::fs;
use std::error::Error;
use std::io;
struct Operation {
opcode: u32,
param_mode_1: u32,
param_mode_2: u32,
param_mode_3: u32,
}
fn parse_opcode(opcode: i32) -> Operation {
let mut args = [0,0,0,0,0];
let arg_len = args.len();
for (i, c) in opcode.to_string().chars().rev().enume... |
//! Bounding volume hierarchy module.
use std::sync::Arc;
use crate::aabb::Aabb;
use crate::hittable::{HitRecord, Hittable, HittableList};
/// Bounding volume hierarchy node.
#[derive(Clone)]
pub struct BvhNode {
/// Child to the left.
pub left: Option<Arc<dyn Hittable + Send + Sync>>,
/// Child to the r... |
//! Defines types for registering controllers with runtime.
use crate::{operator::Operator, store::Store};
pub mod tasks;
use tasks::{controller_tasks, OperatorTask};
pub mod controller;
use controller::{Controller, ControllerBuilder};
mod watch;
/// Coordinates one or more controllers and the main entrypoint for st... |
extern crate aoc2017;
use aoc2017::days::day10;
fn main() {
let input = aoc2017::read_trim("input/day10.txt").unwrap();
let value = day10::part1::parse(256, &input);
println!("Day 10 part 1 value: {}", value);
let value = day10::part2::parse(&input);
println!("Day 10 part 2 value: {}", value);
}... |
#[doc = "Register `ALRMAR` reader"]
pub type R = crate::R<ALRMAR_SPEC>;
#[doc = "Register `ALRMAR` writer"]
pub type W = crate::W<ALRMAR_SPEC>;
#[doc = "Field `SU` reader - Second units in BCD format."]
pub type SU_R = crate::FieldReader;
#[doc = "Field `SU` writer - Second units in BCD format."]
pub type SU_W<'a, REG,... |
use mlvalues;
use memory;
use mlvalues::{is_block, Value, empty_list};
use alloc;
use tag::Tag;
use error::Error;
pub struct Tuple(Value, usize);
impl From<Tuple> for Value {
fn from(t: Tuple) -> Value {
t.0
}
}
impl Tuple {
pub unsafe fn new(n: usize) -> Tuple {
let val = alloc::caml_all... |
pub use lib::bitboard::BitBoard;
pub use lib::player::Player;
pub use lib::board::Board;
|
use std::io::BufRead;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
struct Region {
name: String,
population: i64,
south_edge: f64,
}
fn tally(file: std::fs::File, regions: &mut Vec<Region>) -> Result<()> {
// Tally.
for maybe_line in std::io::BufReader::new(file).lines() {... |
extern crate introsort;
fn main() {
let mut ss = vec!["Introsort", "or", "introspective", "sort", "is",
"a", "hybrid", "sorting", "algorithm", "that",
"provides", "both", "fast", "average",
"performance", "and", "(asymptotically)", "optimal",
... |
use crate::components::Token;
use crate::root::{AppAnchor, AppRoute, DataState};
use crate::{
data::{MealPlans, MealPlansItem, MealPlansItemRecipesItem},
date::next_seven_days,
services::{Error, MealPlansService, RecipeService},
};
use yew::{prelude::*, services::fetch::FetchTask, Properties};
use yew_state... |
#[derive(Serialize, Deserialize, Default, Clone, Debug)]
pub struct FacetRequest {
pub field: String,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "default_top")]
pub top: Option<usize>,
}
fn default_top() -> Option<usize> {
Some(10)
}
|
#[doc = "Reader of register INIT_WINDOW_TIMER_CTRL"]
pub type R = crate::R<u32, super::INIT_WINDOW_TIMER_CTRL>;
#[doc = "Writer for register INIT_WINDOW_TIMER_CTRL"]
pub type W = crate::W<u32, super::INIT_WINDOW_TIMER_CTRL>;
#[doc = "Register INIT_WINDOW_TIMER_CTRL `reset()`'s with value 0"]
impl crate::ResetValue for ... |
// pub mod owner;
pub fn function() {
// owner::owner();
let mut greet = String::from("hello");
greet.push_str(", world!");
println!(" {}", greet);
}
|
use super::board::{ Board , BOARD_SIZE };
use super::cell::Cell;
use super::cell::Position;
/*
at a high level, solving is applying a set of strategies, repeatedly
in a round-robin-ish way until, either, puzzle is solved or out of
options
we'll try to provide a hind based solving, at each step,
the global logic will ... |
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
#[derive(FromRow, Deserialize, Serialize)]
pub struct State {
pub id: i16,
pub name: String,
}
|
use aoc_2020::day_02::*;
use std::io::prelude::*;
use criterion::{criterion_group, criterion_main, Criterion};
pub fn benchmark(c: &mut Criterion) {
let file = std::fs::File::open("input/day-02.txt").expect("Couldn't open input file");
let input: Vec<String> = std::io::BufReader::new(file)
.lines()
... |
#[doc = "Reader of register NPCTCFG3"]
pub type R = crate::R<u32, super::NPCTCFG3>;
#[doc = "Writer for register NPCTCFG3"]
pub type W = crate::W<u32, super::NPCTCFG3>;
#[doc = "Register NPCTCFG3 `reset()`'s with value 0xfcfc_fcfc"]
impl crate::ResetValue for super::NPCTCFG3 {
type Type = u32;
#[inline(always)]... |
use std::error;
fn main() {
sample();
result();
}
type Result<T> = std::result::Result<T, Box<dyn error::Error>>;
fn double(num: &str) -> Result<i32> {
let n = num.parse::<i32>()?;
Ok(n * 2)
}
fn sample() {
let tuple: Vec<_> = vec![(1, "foo"), (2, "bar"), (3, "baz")];
assert_eq!(tuple[1].0, ... |
#[doc = "Register `SR` reader"]
pub type R = crate::R<SR_SPEC>;
#[doc = "Field `RXP` reader - Rx-Packet available"]
pub type RXP_R = crate::BitReader<RXP_A>;
#[doc = "Rx-Packet available\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RXP_A {
#[doc = "0: Rx buffer empty"]
Empty = 0,... |
use crate::engine::board;
use crate::engine::enums;
pub fn main_heuristic(board: &board::Board, player: enums::Player) -> i16 {
if board.state == enums::State::End {
let tiles = count_tiles(board, player);
if tiles > 0 {
return 30000;
} else if tiles == 0 {
return 0;... |
#![allow(dead_code)]
// 标准库中常见的 trait
// Display Debug
pub fn learn_display_debug() {
use std::fmt::{Display, Formatter, Result};
#[derive(Debug)]
struct T {
field1: i32,
field2: i32,
}
impl Display for T {
fn fmt(&self, f: &mut Formatter) -> Result {
write!(f... |
pub mod watch_face;
pub use watch_face::{WatchFace, WatchFaceResources};
// some trait, ScreenExt: Drawable
// on_focus
// off_focus
//
// update(Self::Resources)
//
// (use eg::ContainsPoint trait)
// handle_event(Event) -> Forward/SomeAction (like switch to ScreenFoo)
// touch/gesture
// button press
// enum Sc... |
use common::*;
use gl;
use gl::types::*;
use glw::gl_context::GLContext;
use glw::shader::Shader;
use glw::texture::BufferTexture;
use glw::texture::TextureUnit;
use id_allocator::IdAllocator;
use nalgebra::{Pnt3, Vec3};
use state::EntityId;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
#[der... |
use std::{env, io};
use objdump::Elf;
use std::process::exit;
use crate::simulator::Simulator;
use std::io::{Error, BufReader, BufRead};
use std::fs::File;
use crate::cache::{CacheOp, Storage, CacheConfig};
mod memory;
mod simulator;
mod register;
mod instruction;
mod action;
mod statistic;
mod cache;
fn lab2_pipelin... |
use iota_client::{Client};
#[tokio::main]
async fn main() {
let balance = Balance{ };
balance.balance().await;
}
struct Balance {}
impl Balance {
async fn balance(&self)
{
let iota = Client::builder()
.with_node("https://chrysalis-nodes.iota.org")
.unwrap()
.... |
use std::io;
fn main(){
println!("Enter something");
let mut input_string = String::new();
io::stdin().read_line(&mut input_string).expect("Failed to read input");
let integer_input:i32 = input_string.trim().parse().unwrap();//converting string into mentioned datatype
println!("You entered {}",integer_input... |
pub fn binary_tree() {
println!("Here's a binary tree!")
}
|
use criterion::{black_box, Criterion};
use common::storage_trait::StorageTrait;
use common::testutil::get_random_vec_of_byte_vec;
use heapstore::storage_manager::StorageManager;
use heapstore::testutil::bench_sm_insert;
pub fn sm_ins_bench(c: &mut Criterion) {
let to_insert = get_random_vec_of_byte_vec(1000, 80, ... |
mod regs;
pub use self::regs::{
Register,
Scale,
Disp,
RegSize,
parse_reg,
parse_512bit_reg,
parse_256bit_reg,
parse_128bit_reg,
parse_64bit_reg,
parse_32bit_reg,
parse_16bit_reg,
parse_8bit_reg,
parse_mmx_reg,
parse_x87_reg,
parse_vec_reg,
parse_long_ptr_reg,
parse_scale,
parse_con... |
use serde::de::{self, Visitor};
use crate::de::{Deserializer, Error};
pub struct MapAccess<'a, 'b>
{
de: &'a mut Deserializer<'b>,
first: bool,
}
impl<'a, 'b> MapAccess<'a, 'b> {
pub(crate) fn new(de: &'a mut Deserializer<'b>) -> Self {
MapAccess { de, first: true }
}
}
impl<'a, 'de> de::Map... |
use bevy::{ecs::entity::EntityMap, prelude::*, utils::HashSet};
use thiserror::Error;
use crate::{
de::PrefabDeserializer,
loader::PrefabLoader,
registry::{
ComponentDescriptorRegistry, ComponentEntityMapperRegistry, PrefabDescriptorRegistry,
},
Prefab, PrefabConstruct, PrefabError, PrefabE... |
#[cfg(feature = "parsec")]
use parsec::{self, Entity};
use std::iter::repeat;
use std::mem;
use super::{TrieLayer, Trie, TrieIter};
use super::shift::*;
#[derive(Clone)]
pub struct BitSet {
layer2: u64,
layer1: Vec<u64>,
layer0: Vec<u64>,
}
impl BitSet {
pub fn new() -> BitSet {
BitSet {
... |
use crate::*;
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum IntegerBits {
Eight,
Sixteen,
ThirtyTwo,
SixtyFour,
OneTwentyEight,
Arch,
}
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum FloatBits {
ThirtyTwo,
SixtyFour,
}
#[derive(PartialEq, Clone, Debug)]
pub enum Type {
Stri... |
use std::{
collections::HashMap,
fmt::{Display, Formatter},
iter::FromIterator,
};
// Generic expression evaluation automaton and expression formatting support
#[derive(Clone, Debug)]
pub enum EvaluationError<T> {
NoResults,
TooManyResults,
OperatorFailed(T),
}
pub trait Operator<T> {
... |
// 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 super::super::super::super::super::{awesome, btn, color_picker, modeless, text};
use super::super::state::{Modal, Modeless};
use super::Msg;
use crate::{
block::{self, BlockId},
model::{self},
resource::Data,
Color, Resource,
};
use kagura::prelude::*;
use wasm_bindgen::JsCast;
pub fn render(
b... |
#[doc = "Register `HMONR` reader"]
pub type R = crate::R<HMONR_SPEC>;
#[doc = "Field `HITMON` reader - cache hit monitor counter"]
pub type HITMON_R = crate::FieldReader<u32>;
impl R {
#[doc = "Bits 0:31 - cache hit monitor counter"]
#[inline(always)]
pub fn hitmon(&self) -> HITMON_R {
HITMON_R::new... |
pub mod chat {
tonic::include_proto!("chat");
}
use chat::{chat_server::Chat, Empty, Message, Reply, User};
use std::{collections::HashMap, sync::Arc};
use tokio::sync::{mpsc, RwLock};
use tokio_stream::wrappers::ReceiverStream;
use tonic::{Request, Response, Status};
type SenderId = i32;
#[derive(Debug, Default)]
st... |
use anyhow::Result;
use async_std::sync::{Arc, Mutex, RwLock, RwLockReadGuard};
use blake2_rfc::blake2b::Blake2b;
use ed25519_dalek::{PublicKey, SecretKey};
use futures::channel::mpsc;
use futures::sink::SinkExt;
use hypercore::{storage_disk, Feed};
use hypercore_replicator::discovery_key;
use log::*;
use rand::rngs::{... |
fn main() {
// Examples for various data representation
// Decimal 98_222
// Hex 0xff
// Octal 0o77
// Binary 0b1111_0000
// Byte (u8 only) b'A
// two data type subsets: scalar and compound
// compiler can usually infer what type we want to use based on the value and how we use it
//... |
use nix::unistd::{execvp, fork, ForkResult, Pid};
use std::convert::Infallible;
use std::env;
use std::ffi::CString;
use std::process;
fn tracee() -> Infallible {
let args: Vec<CString> = env::args()
// Skip the path of this file.
.skip(1)
.map(|a| CString::new(a).expect("Invalid string arg... |
use cranelift::codegen::write_function;
use cranelift::prelude::*;
use cranelift_module::{FuncId, Linkage, Module};
use cranelift_preopt::optimize;
use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder};
use jetski::SchemeExpression;
use jetski::{jit::Tag, parser::parse_datum, ErrorKind, Object, Result};
use rus... |
#![allow(unused_imports)]
use {
crate::{
config::CONFIG,
models::{
monitor::Monitor, rect::*, window_type::WindowType, windowwrapper::*, HandleState,
},
state::State,
wm,
xlibwrapper::action,
xlibwrapper::core::*,
xlibwrapper::util::*,
... |
use hydroflow::{assert_graphvis_snapshots, hydroflow_syntax};
use multiplatform_test::multiplatform_test;
#[multiplatform_test]
pub fn test_reduce_tick() {
let (items_send, items_recv) = hydroflow::util::unbounded_channel::<u32>();
let (result_send, mut result_recv) = hydroflow::util::unbounded_channel::<u32>(... |
enum Foo {
Bar,
}
fn abc(x: &Foo) {
let mut p = x;
while let Foo::Bar = *p {
p = x;
}
}
fn main() {}
/*
thread 'rustc' panicked at 'no entry found for key', prusti-viper/src/encoder/procedure_encoder.rs:5876:10
stack backtrace:
0: rust_begin_unwind
at /rustc/8007b506ac5da629f2... |
use crate::lc3::{consts::Register, LC3};
use std::io::{self, Read};
/// Implementations of the trap routines in the LC3 architecture.
///
/// Every method has the same type: `fn(&mut LC3)`, which makes it easy to create function dispatch
/// tables for trap codes.
pub fn puts(vm: &mut LC3) {
// build up a string ... |
/*
Copyright (C) 2018-2019 de4dot@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 limitation the rights to use, copy, modify, merge, publish,
distr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.