text stringlengths 8 4.13M |
|---|
//! CPU-level input/output instructions, including `inb`, `outb`, etc., and
//! a high level Rust wrapper.
#![feature(asm)]
#![feature(const_fn)]
#![no_std]
use core::marker::PhantomData;
#[cfg(any(target_arch="x86", target_arch="x86_64"))]
pub use x86::{inb, outb, inw, outw, inl, outl};
#[cfg(any(target_arch="x86... |
use std::boxed::Box;
use diesel::{self, prelude::*};
use diesel::pg::PgConnection;
use job_juggler::{ExecutableJob, JobResult, LoggableJob};
#[derive(Serialize, Deserialize, LoggableJob)]
#[LogName = "log_data"]
pub struct CreateImageThumbnail {
pub image_id: String,
pub image_data: Vec<u8>,
pub log_data... |
use std::sync::Arc;
use vulkano::buffer::{CpuAccessibleBuffer, BufferUsage};
use vulkano::command_buffer::AutoCommandBufferBuilder;
use vulkano::descriptor::descriptor_set::{DescriptorSet, PersistentDescriptorSet};
use vulkano::descriptor::pipeline_layout::PipelineLayoutAbstract;
use vulkano::device::DeviceOwned;
use ... |
use nu_protocol::{
ast::Call,
engine::{Command, EngineState, Stack},
Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError,
Signature, Span, Value,
};
use std::cmp::Ordering;
#[derive(Clone)]
pub struct Sort;
impl Command for Sort {
fn name(&self) -> &str {
... |
#[doc = "Register `ISR0` reader"]
pub type R = crate::R<ISR0_SPEC>;
#[doc = "Register `ISR0` writer"]
pub type W = crate::W<ISR0_SPEC>;
#[doc = "Field `AE0` reader - Acknowledge error 0"]
pub type AE0_R = crate::BitReader;
#[doc = "Field `AE0` writer - Acknowledge error 0"]
pub type AE0_W<'a, REG, const O: u8> = crate:... |
use std::mem;
use random;
use glsl::icosahedron;
use chunk::{IntCoord, Chunk, Cell, CellPos, Root, ROOT_QUADS};
use nalgebra;
use nalgebra::{Point2, Point3, Vector3};
use rand;
type Pt2 = Point2<f64>;
type Pt3 = Point3<f64>;
pub struct Spec {
seed: usize,
radius: f64,
cells_per_chunk: IntCoord,
chunks... |
extern crate cryptopals_lib;
extern crate rusty_aes;
use crate::cryptopals_lib::base64;
use crate::cryptopals_lib::utils::file_io_utils;
use crate::rusty_aes::decrypt::Decrypt;
use crate::cryptopals_lib::hex;
pub fn main() {
let file_name = "challenge_files/7.txt";
//read file to string
let input = fi... |
use rand::random;
pub const CHIP8_SCREEN_WIDTH: usize = 64;
pub const CHIP8_SCREEN_HEIGHT: usize = 32;
// Only included for documentation purposes
//pub const CHIP8_NUM_PIXELS: usize = CHIP8_SCREEN_WIDTH * CHIP8_SCREEN_HEIGHT;
pub const SCHIP8_SCREEN_WIDTH: usize = 128;
pub const SCHIP8_SCREEN_HEIGHT: usize = 64;
pub... |
extern crate pest;
#[macro_use]
extern crate pest_derive;
use std::collections::HashMap;
use pest::iterators::Pair;
use std::fs;
use pest::Parser;
#[derive(Parser)]
#[grammar = "grammar/sgf.pest"]
pub struct SgfParser;
///
/// Represents the FOO[BAR]
/// A property can have multiple values like AW[][][]
///
#[deriv... |
//! This file contains automated tests, but they require virtual ports and therefore can't work on Windows or Web MIDI ...
#![cfg(not(any(windows, target_arch = "wasm32")))]
extern crate midir;
use std::thread::sleep;
use std::time::Duration;
use midir::os::unix::{VirtualInput, VirtualOutput};
use midir::{Ignore, Mid... |
use crate::errors::*;
use hyper::body::Body as HyperBody;
use hyper::http::Response as HyperResponse;
use hyper::{header::HeaderValue, HeaderMap};
// Extends HyperResponse
pub struct RhodResponse {
res: Option<HyperResponse<HyperBody>>, // Is allways Some(..)
}
impl RhodResponse {
pub fn new(res: HyperRespons... |
extern crate futures;
extern crate grpcio;
extern crate grpc_rs;
use std::io::Read;
use std::sync::Arc;
use std::{io, thread};
use futures::Future;
use futures::sync::oneshot;
use grpcio::{Environment, RpcContext, ServerBuilder, UnarySink};
use grpc_rs::user::{UserRequest, UserResponse};
use grpc_rs::user_grpc::{sel... |
//
// 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... |
/*
MIT License
Copyright (c) 2021 Philipp Schuster
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, publis... |
#![allow(unused)]
#[allow(non_camel_case_types)]
#[cfg(test)]
mod test_toplevel {
use arc_runtime::prelude::*;
declare_functions!(f);
#[rewrite]
fn f(a: i32) -> i32 {
a + a
}
#[rewrite(main)]
#[test]
fn test() {
let x: function!((i32) -> i32) = function!(f);
... |
pub struct JoinMapIterator<A, B> {a: A, b: B}
pub fn join_maps<KEY: Ord, DataA, DataB, IterA: Iterator<(KEY, DataA)>, IterB: Iterator<(KEY, DataB)>>
(a: IterA, b: IterB) -> JoinMapIterator<IterA, IterB>
{
JoinMapIterator {a: a, b: b}
}
impl<KEY: Ord, DataA, DataB, IterA: Iterator<(KEY, DataA)>, IterB: Iter... |
//! Crate `ruma_events_macros` provides a procedural macro for generating
//! [ruma-events](https://github.com/ruma/ruma-events) events.
//!
//! See the documentation for the individual macros for usage details.
#![deny(missing_copy_implementations, missing_debug_implementations, missing_docs)]
extern crate proc_macr... |
pub mod auth;
pub mod login;
pub mod logout;
|
use std::fs::File;
use std::io;
// use std::io::ErrorKind;
use std::io::Read;
fn main() {
// panic!("crash and burn");
// let v = vec![1, 2, 3, 4];
// v[99];
let f = read_username_from_file();
let f = match f {
Ok(file) => file,
Err(error) => panic!("There was a problem opening the... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - RIDR register"]
pub ddrphyc_ridr: DDRPHYC_RIDR,
#[doc = "0x04 - PIR register"]
pub ddrphyc_pir: DDRPHYC_PIR,
#[doc = "0x08 - PGCR register"]
pub ddrphyc_pgcr: DDRPHYC_PGCR,
#[doc = "0x0c - PGSR register"]
pu... |
use std::env;
use aoc_2020::*;
// use fmt::write;
use std::time::{Instant};
fn main() {
let args: Vec<String> = env::args().collect();
let start = Instant::now();
let fname = format!("src/day{}.txt", args[1]);
match &args[1][..]{
"1" => day1(&fname),
"2" => day2(&fname),
"3" =... |
#[derive(Debug, Deserialize, PartialEq, Eq)]
pub struct ButtonSettings {
pub name: String,
pub gpio: u8
}
|
#[macro_use] extern crate colorify;
extern crate ocl;
use ocl::{Result as OclResult, Platform, Device, Context, Image, Queue};
use ocl::enums::MemObjectType;
use ocl::core::{OclPrm};
fn img_formats() -> OclResult<()> {
for (p_idx, platform) in Platform::list().into_iter().enumerate() {
for (d_idx, device) ... |
#[doc = "Register `MDMA_C13ESR` reader"]
pub type R = crate::R<MDMA_C13ESR_SPEC>;
#[doc = "Field `TEA` reader - TEA"]
pub type TEA_R = crate::FieldReader;
#[doc = "Field `TED` reader - TED"]
pub type TED_R = crate::BitReader;
#[doc = "Field `TELD` reader - TELD"]
pub type TELD_R = crate::BitReader;
#[doc = "Field `TEMD... |
//! Live window rendering.
use crate::{
input::Shader,
output::Data,
parts::{Camera, Scene, Tracer},
run::engine::paint,
};
use arctk::{
err::Error,
math::Vec3,
ord::{BLUE, GREEN, RED},
tools::{ProgressBar, SilentProgressBar},
};
use minifb::{Scale, Window, WindowOptions};
use palette::... |
use serde::{Deserialize, Serialize};
use std::collections::hash_map::Entry;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::{collections::HashMap, io::BufReader};
use super::compression;
const BLOCK_SIZE: usize = 128;
#[derive(Serialize, Deserialize, Debug)]
struct Compressed {
block_map: Vec<u... |
use aoc2019::io::slurp_stdin;
#[derive(Clone, Copy)]
enum Step {
Right(i32),
Left(i32),
Up(i32),
Down(i32),
}
fn parse_entry(s: &str) -> Step {
let n: i32 = s[1..].parse().unwrap();
match &s[0..1] {
"R" => Step::Right(n),
"L" => Step::Left(n),
"U" => Step::Up(n),
... |
use enum_kinds::EnumKind;
use enum_map::Enum;
use crate::pos::Spanned;
#[derive(Debug, Clone, EnumKind)]
#[enum_kind(TokenKind, derive(Enum))]
pub enum TokenData {
// Values
String(String),
Integer(isize),
Identifier(String),
// Paired Tokens
OpenBrace,
CloseBrace,
OpenParen,
Clos... |
#[doc = "Register `CR` reader"]
pub type R = crate::R<CR_SPEC>;
#[doc = "Register `CR` writer"]
pub type W = crate::W<CR_SPEC>;
#[doc = "Field `PG` reader - Programming"]
pub type PG_R = crate::BitReader;
#[doc = "Field `PG` writer - Programming"]
pub type PG_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
#[do... |
use crate::attr;
use proc_macro2::{Ident, Span, TokenStream};
use quote::{ToTokens, TokenStreamExt};
use syn::Attribute;
#[derive(Debug, Clone, Default)]
pub struct SchemaMetadata {
pub title: Option<String>,
pub description: Option<String>,
pub read_only: bool,
pub write_only: bool,
pub default: O... |
use crate::data::{self, SharedDataBridge, SharedDataOps};
use drogue_cloud_service_api::endpoints::Endpoints;
use patternfly_yew::*;
use serde_json::json;
use yew::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ExampleData {
pub app_id: String,
pub device_id: String,
pub password: String,
... |
fn main() {
let add_one = |x| { 1i + x };
println!("The sum of 5 plus 1 is {}", add_one(5i));
let x = 5i;
let printer = || { println!("x is: {}", x); };
printer();
let p = proc() { x * x };
println!("{}", p());
let square = |x: int| { x * x };
assert_eq!(50i, twice(5i, square)... |
use std::fs::File;
fn main() {
let device_path = std::env::args().nth(1).unwrap();
let device = File::open(&device_path).unwrap();
println!("Reading {}", device_path);
let fs = fal_backend_btrfs::filesystem::Filesystem::mount(device);
println!("Superblock: {:?}", fs.superblock);
}
|
#[doc = "Register `OTG_GCCFG` reader"]
pub type R = crate::R<OTG_GCCFG_SPEC>;
#[doc = "Register `OTG_GCCFG` writer"]
pub type W = crate::W<OTG_GCCFG_SPEC>;
#[doc = "Field `PDET` reader - PDET"]
pub type PDET_R = crate::BitReader;
#[doc = "Field `SDET` reader - SDET"]
pub type SDET_R = crate::BitReader;
#[doc = "Field `... |
use crate::context::Context;
use crate::data::convert_reflexive;
use crate::data::garbage::alloc_identity;
use crate::data::strings::String;
use crate::data::Alloc;
use crate::data::DynSendable;
use crate::data::DynSharable;
use macros::rewrite;
pub use bool;
pub use char;
pub use f32;
pub use f64;
pub use i128;
pub u... |
#[doc = "Reader of register SW_DSI_SEL"]
pub type R = crate::R<u32, super::SW_DSI_SEL>;
#[doc = "Writer for register SW_DSI_SEL"]
pub type W = crate::W<u32, super::SW_DSI_SEL>;
#[doc = "Register SW_DSI_SEL `reset()`'s with value 0"]
impl crate::ResetValue for super::SW_DSI_SEL {
type Type = u32;
#[inline(always... |
use crate::days::day12::{Movement, parse_input, default_input};
use direction::{Direction, Coord};
use std::ops::{Add, Mul};
pub fn run() {
println!("{}", ship_str(default_input()).unwrap())
}
pub fn ship_str(input : &str) -> Result<u32, ()> {
ship(parse_input(input))
}
pub fn ship(input: Vec<Movement>) -> R... |
use config::{Config, File};
use dirs::home_dir;
use failure::{err_msg, Error};
#[derive(Debug, Deserialize, Clone)]
pub struct Configuration {
kindle_email: String,
gmail_username: String,
gmail_application_password: String,
mercury_token: String,
}
impl Configuration {
pub fn new() -> Result<Self... |
extern crate td_revent;
extern crate psocket;
use psocket::{ToSocketAddrs};
use td_revent::*;
use self::psocket::TcpSocket;
fn client_read_callback(
_ev: &mut EventLoop,
buffer: &mut EventBuffer,
_data: Option<&mut CellAny>,
) -> RetValue {
println!("client_read_callback");
let len = buffer.read.... |
use crate::uses::*;
use core::sync::atomic::{AtomicUsize, Ordering};
use alloc::sync::Arc;
use crate::cap::{CapObject, CapObjectType, Capability, CapFlags};
static NEXT_KEY: AtomicUsize = AtomicUsize::new(0);
#[derive(Debug)]
pub struct Key(usize);
impl Key {
pub fn new() -> Capability<Self> {
let id = NEXT_KEY.f... |
mod socket_read;
mod socket_write;
mod socket_write_vectored;
mod tcp_listener_accept;
mod tcp_stream_connect;
mod udp_recv_from;
mod udp_send_to;
mod unix_listener_accept;
mod unix_recv_from;
mod unix_send_to;
mod unix_stream_connect;
pub use self::socket_read::SocketRead;
pub use self::socket_write::SocketWrite;
pub... |
//! Shader utilities of game engine.
/// Default shaders which are used in game engine.
pub mod default {
/// Default vertex shader utilities.
pub mod vertex {
vulkano_shaders::shader! {
ty: "vertex",
path: "src/graphics/shader/default.vert",
}
}
/// Default fra... |
use hydroflow::hydroflow_syntax;
pub fn main() {
let mut flow = hydroflow_syntax! {
source_iter(0..10) -> for_each(|n| println!("Hello {}", n));
};
flow.run_available();
}
|
struct Solution;
impl Solution {
pub fn kth_smallest(matrix: Vec<Vec<i32>>, k: i32) -> i32 {
let num_rows = matrix.len();
let (mut min, mut max) = (matrix[0][0], matrix[num_rows - 1][num_rows - 1]); // 左上角和右下角
while min < max {
let mid = (max - min) / 2 + min;
println... |
use std::error::Error;
use std::fmt;
use rustc::mir;
use rustc::ty::{FnSig, Ty, layout};
use memory::MemoryPointer;
use rustc_const_math::ConstMathErr;
use syntax::codemap::Span;
#[derive(Clone, Debug)]
pub enum EvalError<'tcx> {
FunctionPointerTyMismatch(FnSig<'tcx>, FnSig<'tcx>),
NoMirFor(String),
Unterm... |
// Copyright 2014 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 ... |
//! Provides some operations on items of slices.
pub mod ops;
|
use super::util::sightglass_cli;
use assert_cmd::prelude::*;
#[test]
fn help() {
sightglass_cli().arg("help").assert().success();
}
|
use crate::extensions::NodeExt;
use gdnative::api::{AnimatedSprite, RigidBody2D};
use gdnative::prelude::*;
use rand::seq::SliceRandom;
#[derive(Copy, Clone, Debug)]
/// Mob types.
enum MobType {
Walk,
Swim,
Fly,
}
impl MobType {
/// Return the mob type name.
pub fn to_string(self) -> String {
format!("... |
#[doc = "Register `FMC_BCHIER` reader"]
pub type R = crate::R<FMC_BCHIER_SPEC>;
#[doc = "Register `FMC_BCHIER` writer"]
pub type W = crate::W<FMC_BCHIER_SPEC>;
#[doc = "Field `DUEIE` reader - DUEIE"]
pub type DUEIE_R = crate::BitReader;
#[doc = "Field `DUEIE` writer - DUEIE"]
pub type DUEIE_W<'a, REG, const O: u8> = cr... |
use crate::player::PLAYER_SIZE;
use crate::world::{
BounceMarker, CharType, Counter, DefaultSize, Location, MaterialResource, ObjectMarker,
Velocity,
};
use bevy::prelude::*;
const SIZE: f32 = 7.5f32;
const BULLET_VELOCITY: f32 = 275f32;
const TIME: f32 = 5f32;
#[derive(Bundle)]
pub struct BulletBundle {
... |
use std::fmt;
use serde_bencode::{de, Error};
use serde_bytes::ByteBuf;
use std::ops::Deref;
use byteorder::{ByteOrder, BigEndian};
const BYTES_PER_PEER: usize = 6;
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub struct Peer {
host: String,
port: u16,
}
impl Peer {
pub fn from(chunk: &[u8]) -> Result<Sel... |
//! Implementations of various traits.
mod std_ttable;
mod std_ttable_entry;
mod dummy_hash_table;
mod simple_search;
mod std_search_node;
mod std_qsearch;
mod std_move_generator;
mod std_time_manager;
mod simple_evaluator;
mod deepening;
pub use self::std_ttable::*;
pub use self::std_ttable_entry::*;
pub use self::d... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use actix::prelude::*;
use anyhow::{format_err, Result};
use futures::executor::block_on;
use starcoin_config::{ChainNetwork, NodeConfig, StarcoinOpt};
use starcoin_consensus::{argon::ArgonConsensus, dev::DevConsensus};
use starcoin... |
use crate::boards::*;
use actix_web::{get, post, delete, put, web, HttpResponse, Responder};
use sqlx::{Postgres, Pool, Error};
#[get("/boards/")]
async fn get_all_boards(db_pool: web::Data<Pool<Postgres>>) -> impl Responder {
let result = Board::find_all_visible_boards(db_pool.get_ref()).await;
match result ... |
#[doc = "Register `PCR` reader"]
pub type R = crate::R<PCR_SPEC>;
#[doc = "Register `PCR` writer"]
pub type W = crate::W<PCR_SPEC>;
#[doc = "Field `PWAITEN` reader - PWAITEN"]
pub type PWAITEN_R = crate::BitReader<PWAITEN_A>;
#[doc = "PWAITEN\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ... |
#[doc = "Register `M5SEAR` reader"]
pub type R = crate::R<M5SEAR_SPEC>;
#[doc = "Field `ESEA` reader - ECC single error address When the ALE bit is set in the RAMCFG_MxCR register, this field is updated with the address corresponding to the ECC single error."]
pub type ESEA_R = crate::FieldReader<u32>;
impl R {
#[d... |
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
mod domain;
mod domain_tx_pre_validator;
pub mod providers;
pub mod rpc;
pub use self::domain::{new_full, DomainOperator, DomainParams, FullPool, NewFull};
use futures::channel::oneshot;
use futures::{FutureExt, StreamExt};
use... |
//! Get info on your team's User Groups.
use rtm::Usergroup;
/// Create a User Group
///
/// Wraps https://api.slack.com/methods/usergroups.create
#[derive(Clone, Debug, Serialize, new)]
pub struct CreateRequest<'a> {
/// A name for the User Group. Must be unique among User Groups.
pub name: &'a str,
///... |
use aoc_runner_derive::*;
struct Rule {
a1: u16,
b1: u16,
a2: u16,
b2: u16,
}
impl Rule {
fn new(ranges: &str) -> Rule {
let mut split_or = ranges.split(" or ");
let first_range = split_or.next().unwrap().trim();
let second_range = split_or.next().unwrap().trim();
... |
//! This module contains the logic for the main `safety` binary.
use crate::safety::{SafetyGame, SafetyGameSolver};
use aiger::Aiger;
use bosy::specification::Semantics;
use clap::{App, Arg};
use cudd::{CuddManager, CuddReordering};
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
pub struct Config ... |
use proc_macro2::TokenStream;
use quote::{format_ident, quote, quote_spanned};
use syn::punctuated::Punctuated;
use syn::spanned::Spanned as _;
use syn::{
Attribute, Data, DeriveInput, Field, Fields, Generics, Ident, PredicateType, TraitBound,
TraitBoundModifier, Type, TypeParamBound, WherePredicate,
};
use cr... |
//
// 0 1 0 Mnemosyne: a functional systems programming language.
// 0 0 1 (c) 2015 Hawk Weisman
// 1 1 1 hi@hawkweisman.me
//
// Mnemosyne is released under the MIT License. Please refer to
// the LICENSE file at the top-level directory of this distribution
// or at https://github.com/hawkw/mnemosyne/.
//
use... |
use anyhow::Result;
use edif::netlist;
use std::fs;
#[test]
fn parse() -> Result<()> {
let s = fs::read_to_string(format!("{}/tests/test.edf", env!("CARGO_MANIFEST_DIR")))?;
let n = netlist::from_str(&s)?;
n.verify_references()?;
Ok(())
}
|
#[doc = "Reader of register FM_MEM_DATA[%s]"]
pub type R = crate::R<u32, super::FM_MEM_DATA>;
#[doc = "Reader of field `DATA32`"]
pub type DATA32_R = crate::R<u32, u32>;
impl R {
#[doc = "Bits 0:31 - Sense amplifier and cloumn multiplexer structure Bytes. The read data is dependent on FM_CTL.IF_SEL: - IF_SEL is '0'... |
use clap::{Arg, App};
const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
fn main() {
let matches = App::new("thing")
.version(VERSION.unwrap_or("unknown version"))
.arg(...)
...
.get_matches();
}
}
|
// This file is part of rdma-core. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/rdma-core/master/COPYRIGHT. No part of rdma-core, including this file, may be copied, modified, propagated, or distributed ... |
use std::ops::{Index, IndexMut};
use crate::ast::Expression;
#[derive(Debug, Clone)]
pub struct Pipeline {
pub expressions: Vec<Expression>,
}
impl Default for Pipeline {
fn default() -> Self {
Self::new()
}
}
impl Pipeline {
pub fn new() -> Self {
Self {
expressions: vec... |
pub mod automatic_queryable_encryption;
pub mod explicit_encryption;
pub mod explicit_encryption_auto_decryption;
pub mod explicit_queryable_encryption;
pub mod local_rules;
pub mod server_side_enforcement;
|
//! zser.rs: Implementation of the zcred serialization format
#![deny(missing_docs)]
#![cfg_attr(not(test), no_std)]
#![cfg_attr(feature = "bench", feature(test))]
extern crate byteorder;
#[cfg(all(feature = "bench", test))]
extern crate test;
// For competitive benchmarking
#[cfg(all(feature = "bench", test))]
ex... |
#[doc = "Reader of register TX_CTRL"]
pub type R = crate::R<u32, super::TX_CTRL>;
#[doc = "Writer for register TX_CTRL"]
pub type W = crate::W<u32, super::TX_CTRL>;
#[doc = "Register TX_CTRL `reset()`'s with value 0x21"]
impl crate::ResetValue for super::TX_CTRL {
type Type = u32;
#[inline(always)]
fn reset... |
#[doc = "Reader of register SATURATE_INTR_MASKED"]
pub type R = crate::R<u32, super::SATURATE_INTR_MASKED>;
#[doc = "Reader of field `SATURATE_MASKED`"]
pub type SATURATE_MASKED_R = crate::R<u16, u16>;
impl R {
#[doc = "Bits 0:15 - Logical and of corresponding request and mask bits."]
#[inline(always)]
pub ... |
use crate::geometry::{Point, Rect, Size};
/// Texture coordinates (in [0, 1] range).
#[derive(Debug, Clone, Copy, PartialEq, Default)]
#[repr(C)]
pub struct TexCoord {
pub u: f32,
pub v: f32,
}
impl TexCoord {
pub const TOP_LEFT: TexCoord = TexCoord::new(0.0, 0.0);
pub const TOP_RIGHT: TexCoord = TexC... |
// Copyright © 2019 Bart Massey
// [This program is licensed under the "MIT License"]
// Please see the file LICENSE in the source
// distribution of this software for license terms.
//! Synthesizer MIDI input.
use std::error::Error;
use std::io;
use std::sync::mpsc;
use midir::MidiInput;
use wmidi::*;
use wmidi::Mi... |
///Describ the size of a register
#[repr(u8)]
#[derive(Copy,Clone,Debug,PartialEq,Eq,PartialOrd,Ord)]
pub enum RegSize {
Bit8,
Bit16,
Bit32,
Bit64,
Bit80,
BitMMX,
Bit128,
Bit256,
Bit512
}
impl RegSize {
#[inline(always)]
pub fn byte_size(&self) -> usize {
match self {
&RegSize::Bit8 =>... |
//! [Generic Types], Traits, and Lifetimes
//!
//! # Examples
//!
//! ```
//! use the_book::ch10::sec00::largest;
//!
//! let list = vec![1, 2, 3, 4, 5];
//! assert_eq!(5, largest(&list));
//!
//! let list = vec![5, 4, 3, 2, 1];
//! assert_eq!(5, largest(&list));
//!
//! let list = vec![-1, -2, -3, -4, -5];
//! assert_... |
use libmdbx::*;
use std::borrow::Cow;
use tempfile::tempdir;
type Database = libmdbx::Database<NoWriteMap>;
#[test]
fn test_get() {
let dir = tempdir().unwrap();
let db = Database::new().open(dir.path()).unwrap();
let txn = db.begin_rw_txn().unwrap();
let table = txn.open_table(None).unwrap();
a... |
use mongodb::bson::{document::Document, oid::ObjectId};
use serde::Serialize;
#[derive(Serialize, Clone)]
pub struct Source {
#[serde(skip)]
id: Option<ObjectId>,
name: Option<String>,
url: Option<String>,
}
impl From<&Document> for Source {
fn from(doc: &Document) -> Self {
Self {
... |
use super::Expression;
use super::BinaryOp;
impl Expression
{
pub fn width(&self) -> Option<usize>
{
match self
{
&Expression::BinaryOp(_, _, BinaryOp::Concat, ref lhs, ref rhs) =>
{
let lhs_width = lhs.width();
let rhs_width = rhs.width();
if lhs_width.is_none() || rhs_width.is_none()
... |
use pretty_assertions::assert_eq;
use super::*;
use crate::ast::tests::Locator;
#[test]
fn function_call_with_unbalanced_braces() {
let mut p = Parser::new(r#"from() |> range() |> map(fn: (r) => { return r._value )"#);
let parsed = p.parse_file("".to_string());
let loc = Locator::new(&p.source[..]);
a... |
fn main() {
os_check();
#[cfg(feature = "name")]
my_name();
println!("this line out of `cfg` scope.");
}
// 这个函数仅当目标系统是 Linux 的时候才会编译
#[cfg(target_os = "linux")]
fn are_you_on_linux() {
println!("You are running linux!");
}
// 而这个函数仅当目标系统 **不是** Linux 时才会编译
#[cfg(not(target_os = "linux"))]
fn are_... |
use std::io::stdin;
fn main() {
let mut input = String::new();
stdin().read_line(&mut input).unwrap();
// read_line leaves a trailing newline, which trim removes
let command = input.trim();
Command::new(command).spawn().unwrap();
}
|
extern crate hyper;
extern crate rustc_serialize;
pub mod sg_client;
pub mod mail;
|
pub mod solutions;
mod intcode;
|
use crate::{
keypair::PublicKey,
result::{anyhow, Result},
};
use helium_proto::*;
pub trait TxnPayer {
fn payer(&self) -> Result<Option<PublicKey>>;
}
impl TxnPayer for BlockchainTxn {
fn payer(&self) -> Result<Option<PublicKey>> {
let maybe_payer = |v: &[u8]| {
if v.is_empty() {
... |
#[doc = "Reader of register OSCLK_DR1"]
pub type R = crate::R<u32, super::OSCLK_DR1>;
#[doc = "Reader of field `ADDER_MSB`"]
pub type ADDER_MSB_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:6 - These bits return the upper 7 bits of the oscillator locking circuits adder output."]
#[inline(always)]
pub fn ad... |
#[doc = "Register `CIFR` reader"]
pub type R = crate::R<CIFR_SPEC>;
#[doc = "Field `LSIRDYF` reader - LSI ready interrupt flag"]
pub type LSIRDYF_R = crate::BitReader;
#[doc = "Field `LSERDYF` reader - LSE ready interrupt flag"]
pub type LSERDYF_R = crate::BitReader;
#[doc = "Field `HSIRDYF` reader - HSI ready interrup... |
pub mod health;
pub mod position;
use crate::{component::Component, component::Health, component::Size, entity::Entity};
#[allow(dead_code)]
pub fn get_health(entity: &mut Entity) -> &Health {
let entity_health = match entity
.get_component(|c| {
if let Component::Health(_) = c {
... |
/*pub enum Result<T, E> {
Ok(T),
Err(E),
}*/
use std::env::args;
use std::fs::File;
use std::io;
use std::io::Read;
#[derive(Debug)]
pub enum MyErr {
IOErr(std::io::Error),
}
// if there were many Error types in being joined into this one type then each From means you can
// just use into and all the err... |
use core::ops::{Add, Sub};
/// Trait defined over generic 2D points P which themselves are generic over F
/// Many libraries already provide Point-types and the mathematical operations
/// that we need for working with curves, so that implementing methods requires mostly wrapping.
/// Keeping the trait as minimal as ... |
use std::collections::HashMap;
use lazy_static::lazy_static;
use rand::{seq::SliceRandom, thread_rng, Rng};
use regex::Regex;
use reqwest::{Client, Url};
use serde::Deserialize;
use serde_json::Value as JsonValue;
use strum_macros::{EnumString, ToString};
lazy_static! {
static ref CLIENT: Client = Client::builder().... |
use super::*;
pub fn do_chown(path: &str, uid: u32, gid: u32) -> Result<()> {
println!("chown: path: {:?}, uid: {}, gid: {}", path, uid, gid);
let inode = {
let current = current!();
let fs = current.fs().lock().unwrap();
fs.lookup_inode(path)?
};
let mut info = inode.metadata()... |
use std::mem;
#[derive(Debug)]
#[derive(PartialEq)]
pub struct List {
head: Link,
}
#[derive(Debug)]
#[derive(PartialEq)]
enum Link {
Empty,
More(Box<Node>),
}
#[derive(Debug)]
#[derive(PartialEq)]
struct Node {
elem: i32,
next: Link,
}
impl List {
pub fn new() -> Self {
List { head: L... |
#![feature(asm)]
#![no_main]
#![no_std]
extern crate panic_halt;
use cortex_m_rt::{entry, exception};
use spin::Mutex; // spin = "0.5.0"
static TO: Mutex<&'static (dyn Foo + Sync)> = Mutex::new(&Bar);
#[entry]
#[inline(never)]
fn main() -> ! {
// trait object dispatch
(*TO.lock()).foo();
Quux.foo();
... |
#![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 ComputeDiagnosticsList {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub value: Vec<ComputeDia... |
// Copyright 2018 Steven Bosnick
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE-2.0 or
// http://www.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 accord... |
use clap::{crate_description, crate_name, crate_version, App, AppSettings, Arg, SubCommand};
use moebius::{
instruction::{initialize, update_data},
state::Moebius,
};
use rand::RngCore;
use solana_clap_utils::{
fee_payer::fee_payer_arg,
input_parsers::{pubkey_of, pubkey_of_signer, signer_of},
input_... |
//! A Rust client for the `open.189.cn` API.
#![feature(proc_macro)]
#![recursion_limit = "1024"]
#![deny(missing_docs)]
#![deny(warnings)]
extern crate chrono;
extern crate crypto;
#[macro_use]
extern crate error_chain;
extern crate hyper;
#[macro_use]
extern crate lazy_static;
extern crate rand;
extern crate rustc_... |
use crate::{InputValueError, InputValueResult, ScalarType, Value};
use async_graphql_derive::Scalar;
use chrono::{DateTime, FixedOffset, Utc};
/// Implement the DateTime<FixedOffset> scalar
///
/// The input/output is a string in RFC3339 format.
#[Scalar(internal, name = "DateTimeFixedOffset")]
impl ScalarType for Dat... |
use std::{io, process};
#[derive(thiserror::Error, Debug)]
pub enum InstallError {
#[error("Payload error")]
Payload(#[from] crate::repo::PayloadError),
#[error("Wrong payload type")]
WrongPayloadType,
#[error("Package not found in cache (not downloaded?)")]
PackageNotInCache,
#[error("I... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.