text stringlengths 8 4.13M |
|---|
use std::{cmp::Ordering, fs};
use nom::{
branch::alt,
character::complete::{char, digit1, line_ending},
combinator::{map, opt},
multi::{many1, separated_list0},
sequence::{terminated, tuple},
IResult,
};
#[derive(Clone, Debug)]
enum Value {
Number(u64),
List(List),
}
#[derive(Clone, D... |
//! Chia proof of space reimplementation in Rust
mod constants;
mod table;
mod tables;
#[cfg(test)]
mod tests;
mod utils;
use crate::chiapos::table::metadata_size_bytes;
pub use crate::chiapos::table::TablesCache;
use crate::chiapos::tables::TablesGeneric;
use crate::chiapos::utils::EvaluatableUsize;
type Seed = [u8... |
//! Implements [`FuncEnv`]. Used for managing data of running `Transaction`s.
use wasmer::Memory;
use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};
use svm_storage::account::AccountStorage;
use svm_types::{Address, Context, Envelope, ReceiptLog, TemplateAddr};
/// [`FuncEnv`] is a container for the a... |
#[doc = "Register `VCTR30` reader"]
pub type R = crate::R<VCTR30_SPEC>;
#[doc = "Register `VCTR30` writer"]
pub type W = crate::W<VCTR30_SPEC>;
#[doc = "Field `B960` reader - B960"]
pub type B960_R = crate::BitReader;
#[doc = "Field `B960` writer - B960"]
pub type B960_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG... |
fn main() {
let x = 5;
x = 3; //error
let mut y = 99;
y = 88; // ok
}
|
use crate::lexing::lexer::Lexer;
use crate::lexing::token::Token;
use crate::parsing::ast::{Ast, TypeSpec, Variable};
use crate::parsing::parser::Parser;
#[test]
fn test_simple() -> anyhow::Result<()> {
assert_eq!(
Parser::new(vec![Ok(Token::IntegerConstant(4)), Ok(Token::Eof)].into_iter())
.pa... |
fn main() {
assert_eq!(vec![1, 2, 4, 5, 10, 10, 20, 25, 50, 100], factor(100)); // asserts that two expressions are equal to each other
assert_eq!(vec![1, 101], factor(101));
}
fn factor(num: i32) -> Vec<i32> {
let mut factors: Vec<i32> = Vec::new(); // creates a new vector for the factors of the number... |
//! Traits which expose underlying image crate's types
mod image;
pub use self::image::*;
|
table! {
pastes (id) {
id -> Int8,
title -> Varchar,
body -> Text,
created_at -> Timestamp,
modified_at -> Timestamp,
}
}
|
//! The LLVM intermediate representation.
pub use self::context::Context;
pub use self::module::Module;
pub use self::attribute::Attribute;
pub use self::ty::*;
pub use self::value::*;
// Reexports
pub use sys::{Linkage, SynchronizationScope, AtomicOrdering,
ThreadLocalMode, FloatPredicateKind, IntegerP... |
use crate::net::SignerID;
use std::str::FromStr;
use tapyrus::{PrivateKey, PublicKey};
pub struct TestKeys {
pub key: [PrivateKey; 5],
}
lazy_static! {
pub static ref TEST_KEYS: TestKeys = TestKeys::new();
}
impl TestKeys {
pub fn new() -> TestKeys {
// private keys for testing with WIF. These ke... |
// 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 ... |
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
#![allow(bare_trait_objects)]
#![allow(missing_docs)]
use ::libra_types::proto::*;
pub mod mempool {
tonic::include_proto!("mempool");
}
pub mod mempool_client {
use super::mempool::{
mempool_client::MempoolClient, C... |
use serde_json::Value;
use crate::validator::{scope::ScopedSchema, state::ValidationState};
pub fn validate_as_string(scope: &ScopedSchema, data: &Value) -> ValidationState {
let string = match data.as_str() {
Some(x) => x,
None => {
return ValidationState::new_with_error(scope.error(
... |
//use std::process::Command;
use std::env;
use std::fs;
#[cfg(windows)]
fn main() {
let profile = env::var("PROFILE").unwrap();
let deps_dir = format!("target/{}/deps/freetype.dll", profile);
fs::copy(".cargo/extern/freetype/x86_64/freetype.dll", deps_dir).unwrap();
}
|
#[derive(Debug)]
pub enum VhdError {
FileTooSmall,
InvalidHeaderCookie,
InvalidHeaderChecksum,
InvalidSparseHeaderCookie,
InvalidSparseHeaderChecksum,
InvalidSparseHeaderOffset,
DiskSizeTooBig,
UnknownVhdType(u32),
InvalidBlockIndex(usize),
UnexpectedBlockId(usize, u32), // the v... |
use pendulum::Pendulum;
pub use fcfs::FirstComeFirstServeScheduler;
pub use hrrn::HighestResponseRatioNextScheduler;
pub use ljf::LongestJobFirstScheduler;
pub use lrjf::LongestRemainingJobFirstScheduler;
pub use mlfq::MultilevelFeedbackQueueScheduler;
pub use rr::RoundRobinScheduler;
pub use sjf::ShortestJobFirstSche... |
extern crate reqwest;
extern crate regex;
use std::io::{Write, BufReader, BufRead};
use std::net::{TcpListener, TcpStream};
use std::thread;
use reqwest::Url;
use regex::Regex;
fn main() {
let mut count = 0_i32;
let listener = TcpListener::bind("127.0.0.1:8080").unwrap();// TODO change back to port 8080 before bui... |
/**
This macro allows delegating the implementation of the Structural and field accessor traits.
This macro delegates the implementation of those traits for all fields,
it doesn't provide a way to do so for only a list of fields.
# Safety
The unsafety of implementing GetFieldMut with this macro comes from the method... |
#[allow(non_snake_case)]
#[allow(dead_code)]
pub mod Question1;
#[allow(non_snake_case)]
#[allow(dead_code)]
pub mod Question2;
#[allow(non_snake_case)]
#[allow(dead_code)]
pub mod Question3;
#[allow(non_snake_case)]
#[allow(dead_code)]
pub mod Question4;
#[allow(non_snake_case)]
#[allow(dead_code)]
pub mod Qu... |
extern crate ted_interface;
use std::sync::mpsc::*;
use std::thread;
use std::net;
use std::io;
use ted_interface::*;
use std::str::FromStr;
pub struct Connection{
pub tcp_stream: net::TcpStream,
pub frame_sender: Sender<Frame>,
pub frame_receiver: Receiver<Frame>,
pub command_sender: Sender<Command>,
... |
extern crate pkg_config;
use std::fs;
use std::path::Path;
use std::env;
fn main() {
configure_snappy();
}
fn configure_snappy() {
// try pkg_config first
if pkg_config::find_library("snappy").is_ok() {
return;
}
match env::var_os("SNAPPY_STATIC") {
Some(_) => {
print... |
use std::path;
use clap;
use std::fs;
use egg::Repository;
fn main() {
println!("Hello, world!");
let matches = parse_arguments();
// You can also match on a sub-command's name
match matches.subcommand() {
("init", Some(init_matches)) => {
// Value is either set or is a default
... |
extern crate dotenv;
extern crate base64_stream;
mod commands;
mod tts;
use tts::{
google_tts::*,
models::Voice,
};
use regex::Regex;
use dotenv::dotenv;
use std::{env, sync::Arc};
use serenity::client::bridge::voice::ClientVoiceManager;
use serenity::{client::Context, prelude::Mutex};
use serenity::{
as... |
// 引入package,使用`extern crate`
extern crate crater;
extern crate config;
use crater::adder;
fn main(){
config::os_check();
config::my_name();
add();
}
fn add() {
let sum = adder::exec(2, 3);
assert_eq!(sum, 5);
}
|
//! Staking epoch transition for domain
use crate::pallet::{
DomainStakingSummary, LastEpochStakingDistribution, Nominators, OperatorIdOwner, Operators,
PendingDeposits, PendingNominatorUnlocks, PendingOperatorDeregistrations,
PendingOperatorSwitches, PendingOperatorUnlocks, PendingSlashes, PendingStakingO... |
use std::io::Result;
use std::pin::Pin;
use std::task::{Context, Poll};
use crate::{AsyncReadAll, AsyncWriteAll, Request, Response};
use protocol::Protocol;
/// 这个只支持ping-pong请求。将请求按照固定的路由策略分发到不同的dest
/// 并且AsyncRoute的buf必须包含一个完整的请求。
pub struct AsyncRoute<B, R> {
backends: Vec<B>,
router: R,
idx: usize,
}... |
use hlist::*;
use self::pos::{
Pos,
};
use ty::{
_0,
_1,
Eval,
Eval1,
Infer,
infer,
};
/// Type-level positive natural numbers (binary)
pub mod pos;
/// Type-level successor for natural numbers
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Succ {}
/// ```ign... |
use rdkafka::error::KafkaError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum EventStreamError {
#[error("Kafka error: {0}")]
Kafka(#[from] KafkaError),
#[error("Missing metadata")]
MissingMetadata,
#[error("Cloud event error: {0}")]
CloudEvent(#[from] cloudevents::message::Error),
}
|
#[doc = "Register `CICR` reader"]
pub type R = crate::R<CICR_SPEC>;
#[doc = "Register `CICR` writer"]
pub type W = crate::W<CICR_SPEC>;
#[doc = "Field `LSIRDYC` reader - LSI ready interrupt clear Set by software to clear LSIRDYF. Reset by hardware when clear done."]
pub type LSIRDYC_R = crate::BitReader;
#[doc = "Field... |
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// 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>,... |
fn main() {
// loop is an infinite loop (until you break out of it)
println!("3.5.1 loop");
loop {
println!("repeat this code forever");
break;
}
// loops can have lables (starting with an ')
println!("\n3.5.2 breaking out of a loop");
let mut count = 0;
'counting_up_loo... |
#[derive(Debug, PartialEq)]
pub enum Error {
InvalidInputBase,
InvalidOutputBase,
InvalidDigit(u32),
}
///
/// Convert a number between two bases.
///
/// A number is any slice of digits.
/// A digit is any unsigned integer (e.g. u8, u16, u32, u64, or usize).
/// Bases are specified as unsigned integers.
/... |
use log::trace;
use parking_lot::Mutex;
use prometheus_endpoint::{register, Gauge, PrometheusError, Registry, U64};
use sc_service::Arc;
use sp_runtime::traits::Header;
use std::{collections::HashMap, time::Instant};
#[derive(Clone)]
struct Inner<H: Header> {
keys: [Checkpoint; 6],
prev: HashMap<Checkpoint, Ch... |
use crate::assembunny::*;
use crate::prelude::*;
pub fn pt1(input: Vec<Instruction>) -> Result<i64> {
let mut prog = Program::new(input)?;
let mut reg = Registers::default();
reg[0] = 7;
prog.run_to_end(&mut reg, |_| {});
Ok(reg[0])
}
pub fn pt2(input: Vec<Instruction>) -> Result<i64> {
let mu... |
use std::collections::VecDeque;
use std::fmt;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum InParam {
Position(i64),
Immediate(i64),
Relative(i64),
}
impl InParam {
fn with_mode(mode: i8, value: i64) -> Result<Self, &'static str> {
match mode {
0 => Ok(Self::Position(value)),
... |
use failure::ResultExt;
use crate::{
tc::{nlas::TcNla, TcBuffer, TC_HEADER_LEN},
traits::{Emitable, Parseable},
DecodeError,
};
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct TcMessage {
header: TcHeader,
nlas: Vec<TcNla>,
}
impl TcMessage {
pub fn new() -> Self {
TcMessage::from_p... |
use std::env;
use std::fs;
fn main() {
let args: Vec<String> = env::args().collect();
let filename = &args[1];
let contents = fs::read_to_string(filename)
.expect("Something went wrong reading the file");
let split_contents = contents.lines();
let seats: Vec<&str> = split_contents.collect();
let mu... |
//! # Chain
//!
//! This modules defines the tendermock chain. The chain is a vector of light blocks, which are
//! stripped down versions of 'real' tendermint blocks.
use std::sync::RwLock;
use ibc::Height;
use tendermint::Block as TmBlock;
use tendermint_testgen::light_block::TmLightBlock;
use tendermint_testgen::{G... |
use sudo_test::{Command, Env, TextFile};
use crate::{Result, USERNAME};
#[test]
fn arguments_are_passed_to_shell() -> Result<()> {
let shell_path = "/tmp/my-shell";
let shell = r#"#!/bin/sh
echo $0; echo $1; echo $2"#;
let env = Env("")
.user(USERNAME)
.file(shell_path, TextFile(shell).chm... |
#![recursion_limit = "1024"]
extern crate proc_macro;
mod able_to;
mod as_into;
mod has;
mod maybe;
mod on;
mod define;
mod custom_code_block;
#[proc_macro]
pub fn able_to(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
able_to::make(item)
}
#[proc_macro]
pub fn has_reacted_set(ite... |
#![feature(proc_macro_hygiene, decl_macro)]
extern crate avocado;
extern crate base64;
extern crate mongodb;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate url;
extern crate uuid;
#[macro_use] extern crate avocado_derive;
#[macro_use] extern crate failure;
#[macro_use] extern crate ro... |
use diesel::prelude::*;
#[cfg(any(feature = "sqlite", feature = "postgres", feature = "mysql"))]
use crate::common::get_connection;
#[derive(Debug, PartialEq, diesel_derive_enum::DbEnum)]
#[PgType = "Stylized_External_Type"]
#[DieselType = "Stylized_Internal_Type"]
#[DbValueStyle = "PascalCase"]
pub enum StylizedEnum... |
use std::iter::{FromIterator, IntoIterator};
use std::marker::PhantomData;
use super::{ffi, Bitmap};
pub struct BitmapIterator<'a> {
iterator: *mut ffi::roaring_uint32_iterator_s,
phantom: PhantomData<&'a ()>,
}
impl<'a> BitmapIterator<'a> {
fn new(bitmap: &Bitmap) -> Self {
BitmapIterator {
... |
use analysis::*;
use analysis::analysis_location::AnalysisLocation::*;
use il;
use std::collections::{BTreeMap, BTreeSet};
pub fn def_use(
reaching_definitions: &BTreeMap<AnalysisLocation, Reaches>,
control_flow_graph: &il::ControlFlowGraph
) -> Result<BTreeMap<AnalysisLocation, BTreeSet<AnalysisLocation>>> {... |
use crate::codegen::{AatbeModule, ValueTypePair};
use parser::ast::PrimitiveType;
use llvm_sys_wrapper::LLVMValueRef;
pub fn codegen_eq_ne(
module: &AatbeModule,
op: &String,
lhs: LLVMValueRef,
rhs: LLVMValueRef,
) -> ValueTypePair {
(
match op.as_str() {
"==" => module.llvm_bu... |
fn main() {
// Create budget and job.
let mut my_budget = patina::Budget::new();
let mut my_job = patina::income::Job::new();
my_budget.misc_params.age = 22;
// Set job parameters and push job into budget.
my_job.pay = patina::income::Pay::Hourly(35.0);
my_job.overtime_after = Some(45.0);
... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: support@datadoghq.com
* Generated by: https://openapi-generator.tech
*/
/// LogsSort : Time-ascending `asc` or time-descending `desc`results.
/// Time-ascending `asc` or time-... |
pub mod cp_directx12;
pub mod cp_default_value; |
mod foo {
const X: i32 = 1;
mod bar {
const Y: i32 = 1;
}
}
|
// Copyright 2021 The Matrix.org Foundation C.I.C.
//
// 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... |
use super::rmux::init_rmux_client;
use crate::config::ChannelConfig;
use crate::rmux::{get_channel_session_size, routine_all_sessions};
use chrono::{Local, Timelike};
use futures::FutureExt;
use rand::Rng;
use std::sync::atomic::{AtomicU32, Ordering};
use std::time::{Duration, SystemTime};
use tokio::time;
pub async f... |
use crate::solutions::Solution;
pub struct Day01 {}
impl Solution for Day01 {
fn part_one(&self, input: &str) -> String {
eval(input, |i| FuelSequence::new(i).nth(1).unwrap_or(0))
}
fn part_two(&self, input: &str) -> String {
eval(input, |i| FuelSequence::new(i).skip(1).sum::<i32>())
... |
// Un exemple d'ownership
// Jusqu'ici, les données étaient gardées dans le stack, peu complexes.
// Les données textes comme "Hello world!" étaient des LITERALS, non modifiables.
// Une fois utilisées, elles étaient enlevées du stack (popped off the stack).
// Comment mettre de la données dans le heap ? Voyons avec le... |
#[cfg(test)]
extern crate lib_image;
pub mod image{
use std::path::Path;
use std::fs::File;
use std::io::prelude::*;
use crate::lib_pixel::pixel::*;
#[derive(Debug)]
pub struct Image{ // structure image
format: String, // format, par exemple : P3
width: usize,
height: usize,
max: u8, // va... |
use cache_line_size::CacheAligned;
use crossbeam_queue::{ArrayQueue, SegQueue};
use std::cell::Cell;
use std::collections::HashMap;
//use std::sync::atomic::{AtomicUsize, Ordering};
/// 无锁,支持并发更新offset,按顺序读取offset的数据结构
pub struct SeqOffset {
l2: ArrayQueue<(usize, usize)>,
l3: SegQueue<(usize, usize)>,
//... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use super::star_chain_client::ChainClient;
use anyhow::Result;
use atomic_refcell::AtomicRefCell;
use libra_state_view::StateView;
use libra_types::{access_path::AccessPath, account_address::AccountAddress, transaction::Version};
us... |
pub fn myfunc()
{
println!("hello from myfunc!");
} |
use super::error::{Error, Result};
use super::*;
use crate::config::{Config, IDMap};
use nix::unistd::{Gid, Uid};
fn get_host_id_from_mapping(container_id: u64, mapping: &Vec<IDMap>) -> Option<u64> {
for m in mapping.iter() {
if container_id >= m.container_id && container_id <= m.container_id + m.size - 1 ... |
use std::fmt;
use volatile::prelude::*;
use volatile::{Volatile};
use console::kprintln;
use propertytag::{send_tags, PropertyTag, PropertyId};
use stack_vec::StackVec;
// Many thanks to
// https://elinux.org/RPi_Framebuffer
// and
// https://github.com/raspberrypi/firmware/wiki/Mailbox
// for info on address locati... |
extern crate embedded_hal;
use embedded_hal::blocking::spi::Write;
use embedded_hal::digital::v2::OutputPin;
use crate::{Command, PinError, MAX_DISPLAYS};
/// Describes the interface used to connect to the MX7219
pub trait Connector {
fn devices(&self) -> usize;
///
/// Writes data to given register as ... |
use magic;
use libc::{c_void};
#[test]
fn issue_override_code() {
unsafe {
magic::override_reset_state();
magic::issue_override_code(1);
assert!(magic::poll_override_code() == 1);
assert!(magic::poll_override_error() == 0);
}
}
#[test]
fn issue_privileged_code() {
unsafe {
magic:... |
pub mod lobby;
pub mod websocket_client;
|
use std::cmp::{Eq, PartialEq};
use std::str::FromStr;
#[derive(Debug)]
pub struct Particle {
pub x: isize,
pub y: isize,
pub z: isize,
v_x: isize,
v_y: isize,
v_z: isize,
a_x: isize,
a_y: isize,
a_z: isize,
}
impl Particle {
pub fn step(&mut self) {
self.v_x += self.a... |
use cgmath::{Point3, Vector3};
pub struct Ray {
pub origin: Point3<f64>,
pub direction: Vector3<f64>,
}
impl Ray {
pub fn new(origin: Point3<f64>, direction: Vector3<f64>) -> Self {
Self { origin, direction }
}
pub fn at(&self, t: f64) -> Point3<f64> {
self.origin + self.direction... |
use crate::bus::Bus;
use crate::devtree::DeviceIdent;
use twz::device::Device;
pub trait Driver {
fn start(&mut self, bus: &Box<dyn Bus>, device: Device, ident: &DeviceIdent);
fn supported() -> Vec<DeviceIdent>
where
Self: Sized;
fn new() -> Self
where
Self: Sized + Default,
{
std::default::Default::defaul... |
//! TODO: Sx127x FSK/OOK mode RF implementation
//!
//! This module implements FSK and OOK radio functionality for the Sx127x series devices
//!
//! Copyright 2019 Ryan Kurte
use radio::State as _;
use crate::{Error, Mode, Sx127x};
use crate::base::Base as Sx127xBase;
use crate::device::fsk::*;
use crate::device::fs... |
fn main() {
// borrowing a reference
let s1 = String::from("hello");
let len = calculate_length(&s1);
println!("The length of '{}' is {}", s1, len);
// borrowing and mutating a reference
let mut s2 = String::from("hello");
change(&mut s2);
// let r1 = &mut s2; <-- BOOM! (cannot borrow m... |
use chrono::{DateTime, Utc};
use serde_json::Value as JsonValue;
use sqlx::postgres::PgConnection;
use svc_agent::AgentId;
use uuid::Uuid;
use crate::db::{self, class::KeyValueProperties, recording::Segments};
////////////////////////////////////////////////////////////////////////////////
#[derive(Debug)]
pub struc... |
// Copyright 2016 FullContact, Inc
// Copyright 2017, 2018 Jason Lingle
//
// 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. This file may not be copied, modifi... |
mod request;
use std::{
error::Error,
fs::File,
io::{prelude::*, BufReader, BufWriter},
};
use request::request_n;
pub fn fuzz(
url: &str,
source: &str,
num_parallel: Option<&str>,
out: Option<&str>,
) -> Result<(), Box<Error>> {
println!("running fuzz");
let ou... |
use core::{
iter::{Product, Sum},
ops::{
Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div,
DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
},
};
use crate::GF;
// implements the unary operator "op &T"
// based on "op T" where T is exp... |
use core::iter::FusedIterator;
use crate::uses::*;
use crate::util::IMutex;
use crate::config::*;
#[derive(Debug)]
pub struct CpuMarker {
marks: IMutex<[bool; MAX_CPUS]>,
}
impl CpuMarker {
pub const fn new() -> Self {
CpuMarker {
marks: IMutex::new([false; MAX_CPUS]),
}
}
pub fn mark(&self) {
self.mar... |
//! We're actually treating inodes as filehandles, because fuse doesn't expose
//! any filehandle stuff to us?
use std::convert::TryFrom;
use std::io;
use std::io::Read;
use std::io::Seek;
use std::io::SeekFrom;
use std::path::Path;
use ext4::SuperBlock;
use ext4::{Inode, ParseError};
use positioned_io::ReadAt;
fn i... |
#[doc = "Register `DDRPERFM_IER` reader"]
pub type R = crate::R<DDRPERFM_IER_SPEC>;
#[doc = "Register `DDRPERFM_IER` writer"]
pub type W = crate::W<DDRPERFM_IER_SPEC>;
#[doc = "Field `OVFIE` reader - OVFIE"]
pub type OVFIE_R = crate::BitReader;
#[doc = "Field `OVFIE` writer - OVFIE"]
pub type OVFIE_W<'a, REG, const O: ... |
mod deque_reader;
mod short;
pub use deque_reader::DequeReader;
pub use short::ShortRead;
|
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub mod services {
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub async fn ... |
//! An implementation of the [Fowler–Noll–Vo hash function][chongo].
//!
//! ## About
//!
//! The FNV hash function is a custom `Hasher` implementation that is more
//! efficient for smaller hash keys.
//!
//! [The Rust Standard Library documentation][docs] states that while the default
//! `Hasher` implementation, Sip... |
use git2::{Repository, BranchType, Branch, RepositoryOpenFlags};
use chrono::{Utc, TimeZone, DateTime};
use std::option::Option as Option;
use colored::*;
use std::env;
use std::process::exit;
use std::ffi::OsStr;
struct BranchCommitTime {
branch_name: String,
last_commit: DateTime<Utc>,
hash: String
}
fn... |
#![allow(dead_code)]
use crate::graphics::CurrentFrame;
pub struct RenderPass<'a> {
// pub(super) current_frame: &'a mut CurrentFrame<'a>,
pub(super) render_pass: wgpu::RenderPass<'a>,
}
impl<'a> RenderPass<'a> {
pub fn new(current_frame: &'a mut CurrentFrame<'a>) -> Self {
let render_pass = curr... |
use parity_scale_codec::{MaxEncodedLen};
#[derive(MaxEncodedLen)]
struct NotEncode;
fn main() {}
|
use std::collections::{Map, MutableMap};
use std::default::Default;
use std::iter::FromIterator;
use utils::unordered_sequence;
pub fn test_insert <M: MutableMap<uint, uint> + Default> () {
let mut map:M = Default::default();
//inserting empty
assert!(map.insert(1, 1));
assert_eq!(map.len(), 1);
//... |
use std::sync::atomic::{AtomicU16, AtomicU64, Ordering};
static TXN_COUNTER: AtomicU64 = AtomicU64::new(0);
/// Permissions for locks.
pub enum Permissions {
ReadOnly,
ReadWrite,
}
/// Implementation of transaction id.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct TransactionId {
/// Id o... |
//! IT8.7 / CGATS.17-200x handling.
// TODO
|
use std::sync::Arc;
use crate::{
notification,
notification::event::PresenceListener,
notification::DataListener,
server::session::TraceId,
server::ControlChanMsg,
server::{
controlchan::{error::ControlChanError, middleware::ControlChanMiddleware},
Event, Reply,
},
};
use a... |
#![allow(dead_code)]
pub const ROUTE_RXPEN: u32 = 0x1 << 0;
pub const ROUTE_TXPEN: u32 = 0x1 << 1;
pub const ROUTE_LOCATION_LOC0: u32 = 0x0 << 8;
pub const ROUTE_LOCATION_LOC1: u32 = 0x1 << 8;
pub const ROUTE_LOCATION_LOC2: u32 = 0x2 << 8;
pub const ROUTE_LOCATION_LOC3: u32 = 0x3 << 8;
pub const ROUTE_LOCATION_LOC4: ... |
use lazy_static::lazy_static;
use std::collections::HashMap;
#[derive(Clone, Copy)]
pub enum IngredientCategory {
Boucherie,
Poissonerie,
Charcuterie,
Boulangerie,
Patisserie,
Cremerie,
Fromagerie,
FruitEtLegumes,
Epicerie,
}
impl std::fmt::Display for IngredientCategory {
fn f... |
//
// Part of Roadkill Project.
//
// Copyright 2010, 2017, Stanislav Karchebnyy <berkus@madfire.net>
//
// Distributed under the Boost Software License, Version 1.0.
// (See file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt)
//
use byteorder::ReadBytesExt;
use crate::support::{self, resource::Chun... |
#[repr(C)]
union QuickFloorUnion {
val: f64,
halves: [i32; 2],
}
/// Fast floor conversion logic. Thanks to Sree Kotay and Stuart Nixon
///
/// Note than this only works in the range ..-32767...+32767 because
/// mantissa is interpreted as 15.16 fixed point.
/// The union is to avoid pointer aliasing overoptim... |
extern crate rand;
mod player;
mod game_state;
mod unit_base;
mod combat_action;
mod enemy;
mod battle_coordinator;
mod player_actions;
mod enemy_actions;
mod parsing;
use std::io;
use player::Player;
use game_state::*;
use battle_coordinator::BattleCoordinator;
use enemy::Enemy;
fn main() {
let starting_opti... |
mod front_of_house; // 在 mod front_of_house 后使用分号, 而不是代码块, 这将告诉 Rust 在另一个与模块同名的文件中加载模块的内容
// mod 关键字声明了模块, Rust 会在与模块同名的文件中查找模块的代码
pub use crate::front_of_house::hosting; // ( pub use -> re-exportings(重导出) )
pub fn eat_at_restaurant() {
hosting::add_to_waitlist();
hosting::add_to_waitlist(... |
#[doc = "Register `ETH_MACMDIODR` reader"]
pub type R = crate::R<ETH_MACMDIODR_SPEC>;
#[doc = "Register `ETH_MACMDIODR` writer"]
pub type W = crate::W<ETH_MACMDIODR_SPEC>;
#[doc = "Field `GD` reader - GD"]
pub type GD_R = crate::FieldReader<u16>;
#[doc = "Field `GD` writer - GD"]
pub type GD_W<'a, REG, const O: u8> = c... |
fn main() {
let numbers = vec![1, 2, 3, 4, 5];
let value = get_value(&numbers);
println!("value: {}", value);
}
fn get_value() -> &i32 {
let x = 4;
&x
}
|
// Copyright 2015-2016 Joe Neeman.
//
// 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. This file may not be copied, modified, or distributed
// except accordin... |
// Copyright 2019 The Grin 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 agree... |
use std::marker::PhantomData;
use std::mem;
use std::time::Instant;
use bitop::bitop::BitOp;
use bitop::bitop::BitOpBase;
use crate::nodeman::NodeMan;
use crate::nodelet::Nodelet;
pub struct Board<T> {
node_count : u64,
final_result : i32,
initial_nodelet : Nodelet,
final_nodelet : Nodelet,
elapsed... |
use crate::memory::*;
use crate::log;
use std::{cell::RefCell, sync::{Arc,Mutex}};
const PIXELS_PER_SCANLINE: u16 = 256;
const VISIBLE_SCANLINES : u16 = 224;
const OVERSCAN: u16 = 240;
const VLBANKEND: u16 = VISIBLE_SCANLINES + 20;
const VBlankBit: u8 = 0b10000000;
const Sprite0Occ: u8 = 0b01000000;
const ScanSpr... |
#[macro_use]
mod utils;
#[macro_use]
extern crate nom;
mod eval;
mod parse;
mod prop;
mod state;
mod test;
use eval::eval;
use parse::parse;
fn main() {
let id1 = uuid::Uuid::new_v4();
let id2 = uuid::Uuid::new_v4();
let hh = hashmap![id1 => true, id2 => true];
let s = state::State { state: hh };
... |
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
#[derive(FromRow, Deserialize, Serialize)]
pub struct DataCategory {
pub id: i32,
pub name: String,
}
|
extern crate hacl_star;
use hacl_star::nacl;
const MSG: [u8; 104] = [
// 32 bytes zero.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.