text stringlengths 8 4.13M |
|---|
#![feature(btree_retain)]
#[macro_use]
extern crate log;
pub mod beatcount;
pub mod timestamp;
pub mod utils;
use std::{
collections::BTreeMap,
net::{SocketAddr, UdpSocket},
sync::{Arc, RwLock},
thread,
time::Duration,
};
use rand::{seq::IteratorRandom, thread_rng};
use serde::{Deserialize, Seri... |
use core::panic;
use std::cmp::{PartialOrd, Ordering};
pub(crate) enum Tree<T:PartialOrd> {
Node {
value: T,
left: Box<Tree<T>>,
right: Box<Tree<T>>,
},
Empty
}
impl<T:PartialOrd + Copy> Tree<T> {
#[allow(unused)]
pub fn new() -> Self{
Tree::Empty
}
pub fn cre... |
// Copyright 2019 The n-sql Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// ex... |
// Copyright 2012 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::error::Error;
use std::ffi::{CStr, CString};
use std::os::raw::{c_char, c_void};
use std::ptr::null_mut;
use crate::{get_turbo_ratio_limits, set_turbo_ratio_limits};
use crate::structures::TurboRatioLimits;
use crate::util::ToPtr;
use std::borrow::Borrow;
#[repr(C)]
pub struct Result {
pub ok: *mut c_voi... |
use proptest::prop_assert_eq;
use proptest::strategy::{Just, Strategy};
use crate::erlang::byte_size_1::result;
use crate::test::strategy;
#[test]
fn without_bitstring_errors_badarg() {
crate::test::without_bitstring_errors_badarg(file!(), result);
}
#[test]
fn with_heap_binary_is_byte_count() {
run!(
... |
use self::models::{NewPost, Post};
#[macro_use]
extern crate diesel;
extern crate dotenv;
use diesel::pg::PgConnection;
use diesel::prelude::*;
use dotenv::dotenv;
use std::env;
pub mod models;
pub mod schema;
pub fn establish_connection() -> PgConnection {
dotenv().ok();
let database_url = env::var("DATAB... |
use klt;
use std::ptr;
use std::os::raw;
use std::ffi::CString;
const REPLACE: bool = false;
pub unsafe fn unsafe_main() {
let n_features = 150;
let n_frames = 10;
let tc = klt::KLTCreateTrackingContext();
let fl = klt::KLTCreateFeatureList(n_features);
let ft = klt::KLTCreateFeatureTable(n_frame... |
// Copyright 2020-2021, The Tremor Team
//
// 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 agr... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
//! Suppose we have the following data structure in a smart contract:
//!
//! struct B {
//! Map<String, String> mymap;
//! }
//!
//! struct A {
... |
#[cfg(test)]
mod tests {
extern crate my_torrent_client_project;
use std::io::Read;
use bencode::FromBencode;
pub use my_torrent_client_project::metainfo_files::*;
const file_path: &str = "debian-10.3.0-amd64-netinst.iso.torrent";
#[test]
fn test_open_file() {
let reader = open_... |
use std::convert::TryFrom;
use std::fmt;
use std::io;
use std::mem::size_of;
use std::ops::Range;
use std::path::PathBuf;
use byteorder::NetworkEndian;
use bytes::Bytes;
use thiserror::Error;
use zerocopy::byteorder::{U32, U64};
use zerocopy::{FromBytes, LayoutVerified};
use crate::object::{Id, ShortId, ID_LEN};
use ... |
pub struct Config {
pub map_size: Vec<u32>,
pub player_number: u32,
pub starting_money: u32,
pub starting_nodes: u32, // per Player
pub starting_distance: u32,
pub starting_boarder_distance: u32,
pub starting_execs: u32 // per Player
}
impl Config {
pub fn new... |
use coordinate_compression::CoordinateCompression;
use fenwick_tree::FenwickTree;
use input_i_scanner::InputIScanner;
use std::iter::FromIterator;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
macro_rules! scan {
(($($t: ty),+)) => {
($(sca... |
use std::borrow::Cow;
use std::str::FromStr;
use crate::encode::{to_string_repr, StringStyle};
use crate::parser;
use crate::parser::key::is_unquoted_char;
use crate::repr::{Decor, Repr};
use crate::InternalString;
/// Key as part of a Key/Value Pair or a table header.
///
/// # Examples
///
/// ```notrust
/// [depen... |
use crate::block::Block;
pub struct BlockChain {
pub blocks: Vec<Block>,
}
impl BlockChain {
pub fn new() -> Self {
BlockChain {
blocks: vec![Block::new_genesis_block()],
}
}
pub fn add_block(&mut self, data: &str) {
let prev_block = self.blocks.last().expect("Shou... |
pub trait AudioEngine {
fn load_module(&self, file: &str);
fn mod_fade_in(&self, file: &str);
fn mod_fade_out(&self);
fn end_module(&self);
fn set_mod_order(&self, order: i32);
}
|
//! # Seraph
//!
//! Seraph is an idiomatic, async [Matrix](https://matrix.org) bot API library.
#![deny(clippy::all)]
#![deny(missing_docs)]
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
|
use std::{self,
env::VarError,
ffi::{OsStr,
OsString},
str::FromStr};
/// Fetches the environment variable `key` from the current process, but only it is not empty.
///
/// This function augments the `std::env::var` function from the standard library, only by
/// returning... |
use std::num::NonZeroUsize;
use crate::{span::RawSpan, syntax::SyntaxKind};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Event {
Enter {
kind: SyntaxKind,
preceded_by: Option<NonZeroUsize>,
},
Token {
kind: SyntaxKind,
span: RawSpan,
},
Exit,
Aban... |
pub fn sum_of_squares(x: u64) -> u64 {
(1..x+1).fold(0, |acc, num| num*num+acc)
}
pub fn square_of_sum(x: u64) -> u64 {
let sum = (1..x+1).fold(0, |acc, num| acc+num) ;
sum * sum
}
pub fn difference(x: u64) -> u64{
square_of_sum(x)-sum_of_squares(x)
}
|
use Print;
use action::{IFlagAction, ParseResult};
impl IFlagAction for Print {
fn parse_flag(&self) -> ParseResult {
if self.0.ends_with('\n') {
print!("{}", self.0);
} else {
println!("{}", self.0);
}
return ParseResult::Exit;
}
}
|
/*struct binOpC {
op: String,
left: Option<Box<EXCR3>>,
right: Option<Box<EXCR3>>
}
struct ifC {
test: Option<Box<EXCR3>>,
then: Option<Box<EXCR3>>,
els: Option<Box<EXCR3>>
}
struct appC {
fun: Option<Box<EXCR3>>,
args: Vec<Option<Box<EXCR3>>>
}
struct lamC {
body: Option<Box<EXCR3>>,
... |
use std::io::Error;
use std::path::{Path, PathBuf};
use bytes::{Bytes, BytesMut};
use futures::{task, Async, Future, Poll, Stream};
use mime::Mime;
use reqwest::r#async::multipart::Part;
use tokio_codec::{BytesCodec, FramedRead};
use tokio_fs::file::{File, OpenFuture};
use tokio_io::AsyncRead;
pub struct FileSource {... |
extern crate iron;
use super::Root;
use self::iron::prelude::*;
use self::iron::status;
use std::net::SocketAddrV4;
use std::net::SocketAddrV6;
pub struct Daemon {
settings: Settings
}
impl Daemon {
pub fn new(root: &Root) -> Daemon {
let settings = root.settings();
let address = settings.lookup("daem... |
use crate::prelude::*;
use std::os::raw::c_void;
use std::ptr;
#[repr(C)]
#[derive(Debug)]
pub struct VkImageCreateInfo {
pub sType: VkStructureType,
pub pNext: *const c_void,
pub flags: VkImageCreateFlagBits,
pub imageType: VkImageType,
pub format: VkFormat,
pub extent: VkExtent3D,
pub mi... |
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from ../gir-files
// DO NOT EDIT
#[cfg(any(feature = "v2_38", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_38")))]
use crate::Address;
use crate::Auth;
use crate::Message;
#[cfg(any(feature = "v2_42", feature = "dox"))]
#[cfg_... |
use crate::Day;
use crate::advent::Part;
use crate::advent::Solution;
use crate::advent::Part::Part1;
use crate::advent::Part::Part2;
use std::collections::HashMap;
use std::boxed::Box;
mod day01;
mod day02;
mod day03;
mod day04;
mod day05;
pub fn day_map() -> HashMap<Day,HashMap<Part,Box<dyn Solution>>> {
vec![
... |
pub struct Solution;
impl Solution {
pub fn min_distance(word1: String, word2: String) -> i32 {
let (s, t) = if word1.len() < word2.len() {
(word1.as_bytes(), word2.as_bytes())
} else {
(word2.as_bytes(), word1.as_bytes())
};
let mut distance = (0..=s.len()).... |
//! ```cargo
//! [dependencies]
//! serde = { version = "1.0", features = ["derive"] }
//! serde_json = "1.0"
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct Point {
x: i32,
y: i32,
}
fn main() {
let point = Point { x: 1, y: 2 };
let serialized = serde_json::to_string(&point).... |
// primitive_types3.rs
// Create an array with at least 100 elements in it where the ??? is.
// Execute `rustlings hint primitive_types3` for hints!
fn main() {
let a: [i32; 105] = [1,2,3,4,5,6,7,8,9,11,12,12,12,12,12,1,2,12,1,2,12,12,1,2,12,1,12,1,2,12,12,1,2,2,2,11,2,121,2,1,2,12,1,2,1,2,12,21,12,1,2,1,2,1,2,12... |
extern crate proc_macro;
use proc_macro2::{Ident, Span};
use quote::quote;
use quote::ToTokens;
use syn;
use crate::proc_macro::TokenStream;
#[proc_macro_derive(CRUDEnable)]
pub fn hello_macro_derive(input: TokenStream) -> TokenStream {
// 构建 Rust 代码所代表的语法树
// 以便可以进行操作
let ast = syn::parse(input).unwrap(... |
use std::ptr::NonNull;
use anyhow::*;
use liblumen_alloc::erts::exception::{self, badarity, Exception};
use liblumen_alloc::erts::process::ffi::ErlangResult;
use liblumen_alloc::erts::process::{trace::Trace, FrameWithArguments, Process};
use liblumen_alloc::erts::process::{Frame, Native};
use liblumen_alloc::erts::te... |
use std::{
cmp::{Ord, Ordering},
collections::BinaryHeap,
};
#[derive(Default, Debug, Eq)]
struct Elf {
total: i64,
snacks: Vec<i64>,
}
impl Elf {
fn add_snack(&mut self, snack: i64) {
self.total += snack;
self.snacks.push(snack);
}
}
impl Ord for Elf {
fn cmp(&self, other... |
use crate::config::PlatformConfiguration;
use crate::errors::*;
use crate::project::Project;
use crate::utils::contains_file_with_ext;
use crate::utils::destructure_path;
use crate::utils::file_has_ext;
use crate::utils::lib_name_from;
use crate::Platform;
use dinghy_build::build_env::append_path_to_target_env;
use din... |
use crate::prelude::*;
use crate::{Closest, Line, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon};
use num_traits::Float;
use std::iter;
/// Find the closest `Point` between a given geometry and an input `Point`.
/// The closest point may intersect the geometry, be a single
/// point, or be inde... |
extern crate huffman;
use std::env;
use std::fs::File;
use std::io::BufWriter;
use huffman::{compress_file, decompress_file, show_freq_and_dict};
fn main() {
let mut args = env::args();
// generate freq_table and the dict for homework
if args.len() == 2 {
let _ = args.next().unwrap();
le... |
use std::{fmt::Display, sync::Arc};
use compactor_scheduler::CompactionJob;
use futures::{stream::BoxStream, StreamExt};
use super::{super::compaction_jobs_source::CompactionJobsSource, CompactionJobStream};
#[derive(Debug)]
pub struct OnceCompactionJobStream<T>
where
T: CompactionJobsSource,
{
source: Arc<T... |
extern crate rayon;
extern crate semver;
use self::rayon::prelude::*;
use self::semver::{Version, VersionReq};
use cache::extract_tarball;
use reqwest;
use serde_json;
use std::collections::HashMap;
use Package;
use std::path::PathBuf;
use std::iter::Iterator;
use std::option::Option;
use std::cell::RefCell;
use std::... |
extern crate proc_macro;
extern crate proc_macro2;
use syn::{spanned::Spanned, Ident, TypePath};
macro_rules! or_return_compile_error {
($e:expr) => {
match $e {
Ok(x) => x,
Err(e) => return e.to_compile_error().into(),
}
};
}
mod field;
mod loaded_association;
#[proc... |
use std::rc::Rc;
macro_rules! todo {
() => {
panic!("Unimplemented!")
};
}
pub trait Monoid {
fn mempty() -> Self;
fn mappend(&self, &Self) -> Self;
}
pub trait Measured<V> where V: Monoid {
fn measure(&self) -> V;
}
macro_rules! measure {
( $x:expr ) => {
$x.measure()
};... |
use std::io;
use std::fmt;
/// Generic error used accross the libary.
/// Wraps around other errors for genericity.
///
/// Used by Result in main.rs. `use` super::Result
/// and the rest should work like magic.
#[derive(Debug)]
pub enum BenvError {
SplitError(&'static str),
IO(io::Error),
MissingProgram
}... |
// membolehkan kode yg tak terpakai tanpa ada peringatan
// ada 2 cara:
// 1. #[allow(dead_code)]
// menon-aktifkan kode tak terpakai untuk setiap fungsi. setiap fungsi
// harus ditambahkan jika tidak ingin ada peringatan.
// 2. #![allow(dead_code)]
// menon-aktifkan kode tak terpakai secara menyeluruh, tidak... |
//! Helper struct to build a `Function`.
use crate::device::Device;
use crate::helper::{AutoOperand, LogicalDim, MetaStatement, TilingPattern};
use crate::ir::{self, op, Parameter, Type};
use crate::ir::{AccessPattern, Function, InstId, Operand, Operator, Signature};
use crate::search_space::{Action, DimKind, InstFlag,... |
use rayon::prelude::*;
use std::collections::HashSet;
type Asteroid = (i32, i32);
type AsteroidField = Vec<Asteroid>;
struct Quadrants {
ne_quadrant: AsteroidField,
se_quadrant: AsteroidField,
sw_quadrant: AsteroidField,
nw_quadrant: AsteroidField,
}
fn parse_asteroids(input: &'static str) -> Asteroi... |
use super::{FiberId, FiberTracer, TracedFiberEnded, Tracer};
use crate::heap::{Heap, HirId, InlineObject};
use candy_frontend::{hir::Id, module::Module};
use rustc_hash::FxHashMap;
#[derive(Debug)]
pub struct EvaluatedValuesTracer {
module: Module,
evaluated_values: Option<FxHashMap<Id, InlineObject>>,
}
impl ... |
use serde::Serialize;
use std::time::SystemTime;
use std::collections::HashMap;
use sqlx::*;
pub struct DomainEventPublisher {
}
impl DomainEventPublisher {
pub async fn publish_event<T : Serialize<>, I : ToString>(&self, txn : &mut Transaction<'_, MySql>, aggregate_type : String, aggregate_id : I, event : &T) ->... |
extern crate cortex_m;
use super::PERIPH;
use boards::nrf51dk::LEDS;
pub struct Led {
pub i: usize,
}
impl Led {
pub fn init() {
cortex_m::interrupt::free(|cs| {
if let Some(p) = PERIPH.borrow(cs).borrow().as_ref() {
// the leds are stored in the stat... |
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate lazy_static;
mod android;
mod challenge;
mod config;
mod daily;
mod db;
mod local;
mod reader;
mod ui;
mod viewer;
use android::Xpath;
use std::collections::HashMap;
use std::env;
fn main() {
ui::run_ui();
}
fn xuexi(args: ui::ArgsState) {
#[cfg(featu... |
pub mod force;
pub mod grouping;
|
use scanner_proc_macro::insert_scanner;
#[insert_scanner]
fn main() {
let (mut x1, mut y1) = scan!((i32, i32));
let (mut x2, mut y2) = scan!((i32, i32));
let (mut x3, mut y3) = scan!((i32, i32));
if x1 != x2 {
if x2 == x3 {
std::mem::swap(&mut x1, &mut x3);
std::mem::sw... |
use amethyst::ecs::*;
pub enum TimeEvent {
Resume,
Stop,
SetSpeed(f32),
}
#[derive(new)]
pub struct TimeDriverRes {
reader: ReaderId<TimeEvent>,
#[new(value = "1.0")]
pub last_speed: f32,
}
system!(TimeDriver, |time: WriteExpect<'a, Time>,
events: Read<'a, EventChannel<TimeEvent>>,
... |
use proconio::input;
fn main() {
input! {
n: usize,
l: i64,
r: i64,
a: [i64; n],
};
let mut dp = vec![vec![0; 2]; n];
dp[0][0] = a[0];
dp[0][1] = l;
for i in 1..n {
dp[i][0] = dp[i - 1][0].min(dp[i - 1][1]) + a[i];
dp[i][1] = dp[i - 1][1] + l;
... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Com_StructuredStorage"))]
#[inline]
pub unsafe fn ClearPropVariantArray(rgpropvar: *mut super::su... |
/*
Copyright (c) 2015, 2016 Saurav Sachidanand
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, di... |
#[macro_use]
extern crate log;
extern crate num;
extern crate simple_logging;
extern crate image;
extern crate nalgebra as na;
extern crate num_traits;
use log::LogLevelFilter;
use num_traits::Float;
//use num_traits::identities::Zero;
mod graphics;
use graphics::GraphicsContext;
mod shape;
use shape::Shape;
mod tf;... |
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
use super::TypeDeclarator... |
fn main() {
let age :i32 = "22".parse().expect("not found");
println!("Hello, world! {}", age);
}
|
//! Interfacing the on-board LSM303DLHC (accelerometer + compass)
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_std]
#![no_main]
extern crate panic_semihosting;
use cortex_m_rt::entry;
use cortex_m_semihosting::hprintln;
use f3::{
hal::{i2c::I2c, delay::Delay, prelude::*, stm32f30x},
Lsm303dlhc,
};
#[entry]... |
//! Actors registry
//!
//! An Actor can register itself as a service. A Service can be defined as an
//! `ArbiterService`, which is unique per arbiter, or a `SystemService`, which
//! is unique per system.
use std::{
any::{Any, TypeId},
cell::RefCell,
collections::HashMap,
default::Default,
rc::Rc,... |
use std::{
convert::TryFrom,
ops::{BitAnd, Mul, Sub},
};
use serde::{Deserialize, Serialize};
use crow_ecs::{Entity, SparseStorage, Storage};
use crow_anim::{AnimationHandle, AnimationState, Sprite};
#[derive(Default)]
pub struct Components {
pub count: usize,
pub deleted: Vec<Entity>,
pub posit... |
//
// See Rust Language Specific Instructions
// below normal exercise description.
//
pub fn encode(mut num: i32) -> String {
if num < 0 {
return "won't compile".to_string(); // Returns "won't compile" string
}
else {
let mut result = String::new(); // For the result
let places: [&str; 4] = [... |
trait T {
}
struct S0 {
}
struct S1 {
}
struct S2 {
}
impl T for S0 {
}
impl T for S1 {
}
impl T for S2 {
}
fn a(_a: Vec<impl T>) {
}
fn main() {
a(vec![S0{}]);
a(vec![S1{}]);
a(vec![S2{}]);
a(vec![S0{}, S1{}, S2{}]);
}
|
// Copyright 2022 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... |
//! # Embedded Graphics Web Simulator
//!
//! 
//!
//! The Web Simulator allows you to use a browser to test embedded-graphics cod... |
// Set direktori saat ini
//
// 8/12/2019 04:46
//
use std::env;
use std::path::Path;
fn main() {
getcwd();
let root = Path::new("/home/susilo");
let _ = env::set_current_dir(&root);
getcwd();
}
fn getcwd() {
let path = env::current_dir().unwrap();
println!("{}", path.display());
}
|
mod configuration;
mod service_registry;
use crate::service_registry::ServiceRegistry;
use api::run_server;
async fn run_create_post_command(sr: ServiceRegistry) {
let create_post_command = sr.get_create_post_command();
create_post_command.run().await.expect("failed");
}
#[tokio::main]
async fn m... |
// Copyright 2018 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 ... |
#![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate diesel;
extern crate r2d2;
extern crate r2d2_diesel;
extern crate rocket;
use rocket::Rocket;
use rocket::request::{Form, FlashMessage};
use rocket::response::{Flash, Redirect};
extern crate meet;
mod db {
use std::ops::Deref;
use r2d2;
use d... |
#[doc = "Reader of register APB1_FZ"]
pub type R = crate::R<u32, super::APB1_FZ>;
#[doc = "Writer for register APB1_FZ"]
pub type W = crate::W<u32, super::APB1_FZ>;
#[doc = "Register APB1_FZ `reset()`'s with value 0"]
impl crate::ResetValue for super::APB1_FZ {
type Type = u32;
#[inline(always)]
fn reset_va... |
mod js_path;
mod js_path_impl_property;
pub use js_path::JsPath;
mod js_value_heq;
pub use js_value_heq::JsValueHEq;
#[cfg(test)]
mod js_path_tests;
pub mod std;
mod serde_support;
pub use serde_support::parse_ruleset;
#[cfg(test)]
mod tests;
|
use oxygengine::prelude::*;
use serde::{Deserialize, Serialize};
pub mod speed;
// component that tags entity as moved with keyboard.
#[derive(Debug, Default, Copy, Clone, Serialize, Deserialize)]
pub struct KeyboardMovementTag;
impl Component for KeyboardMovementTag {
// tag components are empty so they use `Nu... |
#[doc = "Reader of register IER3"]
pub type R = crate::R<u32, super::IER3>;
#[doc = "Writer for register IER3"]
pub type W = crate::W<u32, super::IER3>;
#[doc = "Register IER3 `reset()`'s with value 0"]
impl crate::ResetValue for super::IER3 {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Typ... |
use rand::Rng;
use crate::battle_snake::structs::{POSSIBLE_MOVES, Point, GameEnvironment, Move, Snake};
use crate::battle_snake::map::{generate_map, get_valid_moves, move_toward};
pub fn is_occupied(snakes: &Vec<Snake>, location: &Point) -> bool {
for snake in snakes.iter() {
for body_part in snake.body.iter() ... |
use crate::prelude::*;
use crate::textures::Texture;
use std::collections::{HashMap, HashSet, VecDeque};
use crate::sounds::{SoundId, Sounds};
#[derive(Clone, Default)]
pub struct Level {
old_events: Option<Events>,
pub n_tile_changes: u32,
entity_id_ctr: u32,
pub has_won: bool,
pub data: LevelData,
pub undo... |
use super::raw_path::string_or_struct;
pub(crate) use super::raw_path::RawPath;
use crate::rule::rule_path::RulePath;
use crate::severity::Severity;
use serde::Deserialize;
/// "raw" Rule
#[derive(Debug, Clone, Deserialize, PartialOrd, PartialEq)]
pub(crate) struct RawRule {
name: String,
#[serde(deserialize_w... |
//use crate::render::TextureUnit;
use std::cell::RefCell;
use std::rc::Rc;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use web_sys::HtmlImageElement;
use web_sys::WebGl2RenderingContext;
pub fn load_texture_image(context: &WebGl2RenderingContext, src: &str) {
// let image = Rc::new(RefCell::new(HtmlImag... |
// 字母
pub fn is_alpha(c: &char) -> bool {
match *c {
'A'...'Z' => true,
'a'...'z' => true,
'_' => true,
_ => false,
}
}
// 数字
pub fn is_number(c: &char) -> bool {
match *c {
'0'...'9' => true,
_ => false,
}
}
pub fn is_space(c: &char) -> bool {
match *... |
# ! [ doc = "Reset and clock control" ]
# [ doc = r" Register block" ]
# [ repr ( C ) ]
pub struct Rcc {
# [ doc = "0x00 - Clock control register" ]
pub cr: Cr,
# [ doc = "0x04 - Clock configuration register (RCC_CFGR)" ]
pub cfgr: Cfgr,
# [ doc = "0x08 - Clock interrupt register (RCC_CIR)" ]
pu... |
use std::collections::{HashMap, HashSet};
use std::sync::{Arc, mpsc, Mutex, RwLock, RwLockReadGuard};
use std::thread;
use crate::component::Component;
use crate::event::Event;
use crate::event::component::{AddComponentEvent, ComponentEvent, RemoveComponentEvent};
use crate::event::core::ShutdownEvent;
use crate::even... |
use crate::ui::Refresh;
use gtk::prelude::*;
use sysinfo::SystemExt;
pub struct Load {
pub container: gtk::Box,
pub label: gtk::Label,
pub values: gtk::Label,
}
impl Load {
pub fn new() -> Self {
let container = gtk::BoxBuilder::new()
.expand(true)
.spacing(4)
... |
/// The Stack trait represents a last-in-first-out (LIFO) stack of objects
pub trait Stack<T>{
fn push(&mut self, T);
fn pop(&mut self) -> T;
fn top(&self) -> &T;
}
/// Thread unsafe implementation of a stack on heap-allocated
/// a linked list.
///
/// # Example
/// ```rust
///
/// use collections::stack... |
#![feature(asm)]
#![feature(core_intrinsics)]
#![feature(lang_items)]
#![no_std]
#[macro_use]
mod board;
pub mod kernel;
mod mmio;
mod time;
|
use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Result;
use std::io::stdin;
/**
* @brief Cell enumuration:
* enumuration of the states each cell that
* comprise the board
*/
#[derive(PartialEq)]
enum Cell {
Empty, //cell is empty
O, //cell is occupied by player O
X //cell... |
// Copyright 2022 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... |
table! {
score (sha256) {
sha256 -> Text,
mode -> Integer,
clear -> Integer,
epg -> Integer,
lpg -> Integer,
egr -> Integer,
lgr -> Integer,
egd -> Integer,
lgd -> Integer,
ebd -> Integer,
lbd -> Integer,
epr -> Integer,... |
use int::LargeInt;
use int::Int;
macro_rules! mul {
($(#[$attr:meta])+ |
$abi:tt, $intrinsic:ident: $ty:ty) => {
/// Returns `a * b`
$(#[$attr])+
pub extern $abi fn $intrinsic(a: $ty, b: $ty) -> $ty {
let half_bits = <$ty>::bits() / 4;
let lower_mask = !0 >> hal... |
use chrono::{DateTime, Utc};
use diesel::{ExpressionMethods, PgConnection, QueryDsl, RunQueryDsl};
use serde::{Deserialize, Serialize};
use auth::{create_jwt, PrivateClaim, Role};
use errors::Error;
use crate::schema::users;
#[derive(Debug, Queryable, Identifiable, Serialize, Deserialize)]
pub struct User {
pub ... |
/// an enum of all defined messages in the Fit SDK
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum MessageType {
AccelerometerData,
Activity,
AntChannelId,
AntRx,
AntTx,
AviationAttitude,
BarometerData,
BikeProfile,
BloodPressure,
CadenceZone,
CameraEvent,
Capabilities,... |
use semver::Version;
#[cfg(docsrs)]
pub fn gdal_version_info(_key: &str) -> String {
"GDAL 3.2.0, released 2222/02/22".to_string()
}
#[cfg(not(docsrs))]
pub fn gdal_version_info(key: &str) -> String {
let c_key = std::ffi::CString::new(key.as_bytes()).unwrap();
unsafe {
let res_ptr = gdal_sys::GD... |
use std::ptr::NonNull;
use anyhow::*;
use liblumen_alloc::erts::apply::{find_symbol, DynamicCallee};
use liblumen_alloc::erts::exception;
use liblumen_alloc::erts::process::ffi::ErlangResult;
use liblumen_alloc::erts::process::trace::Trace;
use liblumen_alloc::erts::process::{Frame, Native};
use liblumen_alloc::erts:... |
//! A batteries included runtime for applications using Tokio.
//!
//! Applications using Tokio require some runtime support in order to work:
//!
//! * A [reactor] to drive I/O resources.
//! * An [executor] to execute tasks that use these I/O resources.
//! * A [timer] for scheduling work to run after a set period of... |
#![feature(proc_macro_hygiene)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
mod per_frame;
mod utils;
#[skyline::main(name = "SpikesOnlyGamemode")]
pub fn main() {
per_frame::install();
}
|
use crate::error::DownloadError;
use reqwest;
use std::fs::OpenOptions;
use std::io::prelude::*;
use std::io::{SeekFrom, Write as fsWrite};
use std::sync::{Arc, RwLock};
use tokio::{self, sync::mpsc};
pub struct Write {
file: FileInfo,
offset: u64,
data: Vec<u8>,
}
#[derive(Debug, Clone)]
pub struct FileI... |
#[cfg(feature = "Win32_System_Com")]
::windows_targets::link ! ( "oleaut32.dll""system" #[doc = "*Required features: `\"Win32_System_Ole\"`, `\"Win32_System_Com\"`*"] fn BstrFromVector ( psa : *const super::Com:: SAFEARRAY , pbstr : *mut ::windows_sys::core::BSTR ) -> ::windows_sys::core::HRESULT );
#[cfg(all(feature =... |
use crate::filter::with_table;
use crate::TableData;
use model::TablesFormat;
use warp::filters::BoxedFilter;
use warp::path;
use warp::{Filter, Rejection, Reply};
pub fn route(tables: &TableData) -> BoxedFilter<(impl Reply,)> {
warp::get()
.and(path("tables"))
.and(with_table(tables))
.and... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type IOpcCertificateEnumerator = *mut ::core::ffi::c_void;
pub type IOpcCertificateSet = *mut ::core::ffi::c_void;
pub type IOpcDigitalSignature = *mut ::co... |
//! Error types produced when manipulating a storage resource.
use openssl::error::ErrorStack;
use uuid::Uuid;
use std::error::Error;
use std::fmt;
use std::io;
/// The main error type.
#[derive(Debug)]
pub enum StorageError {
/// An error originating in the standard library's IO module.
StdIo(io::Error),
... |
// Copyright 2021 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... |
use crate::math::{Color, Point};
use super::{Texture, utils::Perlin};
pub struct PerlinTexture {
noise: Perlin,
scale: f64,
}
impl PerlinTexture {
pub fn new() -> Self {
let noise: Perlin = Default::default();
PerlinTexture {
noise,
scale: 1.0
}
}
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.