text stringlengths 8 4.13M |
|---|
use gl;
use imgui;
use imgui::*;
use imgui_opengl_renderer;
use imgui_sdl2;
use sdl2;
use sdl2::audio::{AudioCallback, AudioSpec, AudioSpecDesired};
use std;
pub const SAMPLE_FREQUENCY: i32 = 44_100;
pub const SAMPLE_COUNT: usize = 256;
pub const CHANNEL_COUNT: usize = 2;
pub const SAMPLE_BUFFER_SIZE: usize = SAMPLE_C... |
pub enum OfficialClient {
android,
iphone,
ipad,
windows,
windows_phone,
google,
mac
}
pub const ANDROID_CK: &'static str = "3nVuSoBZnx6U4vzUxf5w";
pub const ANDROID_CS: &'static str = "Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys";
pub const IPHONE_CK: &'static str = "IQKbtAYlXLripLGPWd0HU... |
use std::collections::HashMap;
use petgraph::{Graph, Directed, EdgeDirection};
use petgraph::graph::NodeIndex;
fn dfs<N, E>(
graph: &Graph<N, E, Directed>,
layers: &mut HashMap<NodeIndex, usize>,
u: NodeIndex,
depth: usize,
) {
for v in graph.neighbors(u) {
if layers.contains_key(&v) {
... |
mod subclient;
pub fn client() -> &'static str {
subclient::subclient()
}
|
use dlal_component_base::{component, serde_json, CmdResult};
enum Stage {
A,
D,
S,
R,
}
impl Default for Stage {
fn default() -> Self {
Stage::R
}
}
component!(
{"in": ["midi"], "out": ["audio"]},
[
"uni",
"check_audio",
"run_size",
{"name": "fi... |
use std::io;
use std::io::Read;
use std::fs::File;
use std::io::ErrorKind;
fn main() {
let f = File::open("hello.txt");
let f = match f {
Ok(file) => file,
Err(error) => match error.kind() {
ErrorKind::NotFound => match File::create("hello.txt") {
Ok(fc) => fc,
... |
use super::models::NewBlock;
use super::schema::blocks;
use diesel::pg::PgConnection;
use diesel::prelude::*;
use massbit_chain_substrate::data_type::SubstrateBlock;
use plugin::core::{BlockHandler, InvocationError};
use std::env;
use index_store::core::IndexStore;
#[derive(Debug, Clone, PartialEq)]
pub struct BlockIn... |
pub fn is_armstrong_number(num: u32) -> bool {
let digits_string = num.to_string();
let power: u32 = digits_string.len() as u32;
let sum: u32 = digits_string
.chars()
.map(|c| c.to_digit(10).unwrap())
.map(|d| d.pow(power))
.sum();
sum == num
}
|
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Generating C constants from bind programs
#![allow(dead_code)]
use crate::instruction::{Condition, Instruction};
fn c_macro_invocation(macro_name: &... |
// Audio utility functions -- basically nice to have
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use cpal::{SupportedStreamConfigRange, StreamConfig};
use std::sync::mpsc;
// Store information about available audio devices for easy switching
pub struct AudioDevice {
pub index: usize,
pub name: String,... |
use std::fs;
use std::time::Instant;
use std::collections::HashSet;
fn process_automaton(questions: Vec<String>, error:bool) -> isize {
let mut set: HashSet<usize> = HashSet::new();
let mut i: i64 = 0;
let mut acc: i64 = 0;
while i < questions.len() as i64 && !set.contains(&(i as usize)) {
let ... |
use std::fmt::Debug;
use cgmath::prelude::*;
use cgmath::BaseFloat;
use collision::dbvt::{DynamicBoundingVolumeTree, TreeValue};
use collision::prelude::*;
use shrev::EventChannel;
use specs::prelude::{
BitSet, Component, ComponentEvent, Entities, Entity, Join, ReadStorage, ReaderId, World,
System, Tracked, Wr... |
//!
//! A DeltaLayer represents a collection of WAL records or page images in a range of
//! LSNs, for one segment. It is stored on a file on disk.
//!
//! Usually a delta layer only contains differences - in the form of WAL records against
//! a base LSN. However, if a segment is newly created, by creating a new relat... |
fn main() {
println!("🔓 Challenge 21");
println!("Code in 'prng/src/mt19937.rs'");
}
|
use stopwatch::Stopwatch;
use futures::Future;
use chrono::Duration;
pub fn stopwatch<F, I, E>(future: F) -> impl Future<Item = (I, Duration), Error = E>
where F: Future<Item = I, Error = E>
{
let sw = Stopwatch::start_new();
future.then(move |res| {
res.map(move |x| {
(x, Duration::fro... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
#[repr(transparent)]
pub struct AutoLoadedDisplayPropertyKind(pub i32);
impl AutoLoadedDisplayPropertyKind {
pub const None: Self = Self(0i32);
pub cons... |
// 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 ... |
use std::io;
use std::error::Error;
use mio::EventLoop;
use mio::util::Slab;
use config::{create_slab, create_loop};
use handler::{create_handler};
use scope::{early_scope, EarlyScope, Scope};
use {Machine, Config, Handler, SpawnError};
use SpawnError::NoSlabSpace;
/// An object that is used to construct a loop
///... |
#![allow(dead_code, unused_imports)]
extern crate assembler;
extern crate hardware;
extern crate vm_translator;
use assembler::parser::Parser;
use hardware::computer::Computer;
use vm_translator::vm_translator::VmTranslator;
use std::fs::File;
use std::io::Write;
use std::process;
use std::{
net::{TcpListener, Tcp... |
use std::fs;
fn main() {
let result = solve_puzzle("input");
println!("And the result is {}", result);
}
fn solve_puzzle(file_name: &str) -> u32 {
let file = read_data(file_name);
let mut data = file.lines();
let earliest = data.next().unwrap().parse::<u32>().unwrap();
let bus_ids = data
... |
// xfail-stage0
use std;
import std._vec;
import std.bitv;
fn test_0_elements() {
auto act;
auto exp;
act = bitv.create(0u, false);
exp = _vec.init_elt[uint](0u, 0u);
// FIXME: why can't I write vec[uint]()?
check (bitv.eq_vec(act, exp));
}
fn test_1_element() {
auto act;
act = bitv.create(1u, false... |
use ::{TypeVariant, TypeData, Type, WeakTypeContainer, Result, TypeContainer, CompilerError};
use ::ir::TargetType;
use ::ir::variant::{Variant, VariantType};
use ::FieldReference;
use std::rc::Rc;
use std::cell::RefCell;
#[derive(Debug)]
pub struct UnionVariant {
pub union_name: String,
pub match_field_ref:... |
#[path = "./engine/renderer.rs"]
pub mod my_renderer;
#[path = "./engine/loaders.rs"]
pub mod my_loaders;
use std::thread;
use std::sync::mpsc;
use cgmath::Matrix4;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize,Ordering};
use crate::my_game_engine::my_game_logic::my_renderer::{Renderer,Cam,ModelRst,MyVert... |
use core::cmp;
use core::fmt;
use core::mem;
use core::ptr;
use num_bigint::Sign;
use crate::erts::term::prelude::*;
use liblumen_core::sys::Endianness;
#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(transparent)]
pub struct BinaryPushFlags(usize);
impl BinaryPushFlags {
const FLAG_ALIGNED: usize = 1; /* Field is... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor 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 ... |
use std::{
convert::Infallible,
task::Poll
};
use tokio::sync::broadcast::Receiver;
pub struct Polling {
receiver: Option<Receiver<()>>,
}
impl Polling {
pub fn new(receiver: Receiver<()>) -> Self {
Polling {
receiver: Some(receiver),
}
}
}
impl http_body::Body for Polling {
type Data... |
use bintree::Tree;
use P56::*;
pub fn main() {
let tree = Tree::node('a', Tree::leaf('b'), Tree::leaf('c'));
println!(
"{} is {}.",
tree,
if is_symmetric(&tree) {
"symmetric"
} else {
"not symmetric"
}
);
let tree = Tree::node(
'a... |
// Legend:
// // pxyz -> problem xyz
// // hxyz -> helper for function xyz
use crate::solutions::Solution;
mod problems {
use super::Solution;
#[test]
#[ignore]
fn p1_two_sum() {
let (nums, target) = (vec![2, 7, 11, 15], 9);
assert_eq!(Solution::two_sum(nums, target), vec![0, 1]);
... |
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern {
fn alert(s: &str);
}
#[wasm_bindgen]
pub fn greet(name: &str) {
alert(&format!("Hello, {}!", name));
}
#[wasm_bindgen]
pub fn add(a: i32, b: i32) -> i32 {
return a + b
}
|
extern crate rapier2d as rapier; // For the debug UI.
use bevy::prelude::*;
use bevy::render::pass::ClearColor;
use bevy_rapier2d::physics::{RapierPhysicsPlugin, RapierPhysicsScale};
use bevy_rapier2d::render::RapierRenderPlugin;
use rapier2d::dynamics::RigidBodyBuilder;
use rapier2d::geometry::ColliderBuilder;
use ra... |
include!(concat!(env!("OUT_DIR"), "/audio.rs"));
impl Sound {
pub fn play(&self) {
let id = self.clone() as u32;
js! { audio.play_sound(@{id}); }
}
}
impl Music {
pub fn play(&self) {
let id = self.clone() as u32;
js! { audio.play_music(@{id}); }
}
}
|
use super::hint;
#[derive(Hash, Eq, PartialEq, Debug, Clone, Copy)]
pub enum RuleCode {
Unsafe,
UseUnsafe,
Unwrap,
Expect,
IndexExpression,
}
impl ToString for RuleCode {
fn to_string(&self) -> String {
format!("{:?}", self)
}
}
#[derive(Debug, Copy, Clone)]
pub struct Rule {
... |
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
use glam::Vec2;
use itertools::Itertools;
use legion::Entity;
use parking_lot::RwLock;
type Cell = Vec<(Vec2, Entity)>;
const U32_SIZE: u32 = (std::mem::size_of::<u32>() as u32) * 8;
fn log_2(x: u32) -> u32 {
debug_assert!(x > 0);
U32_SIZE - x.leading_zeros() - 1
}
pub struct DenseGrid {
/// log2(ncells... |
extern crate stdweb;
#[macro_use]
extern crate yew;
use yew::prelude::*;
pub struct Model {
message: String,
}
pub enum Msg {}
impl Component for Model {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
Model {
message: ... |
use std::collections::HashMap;
use ring_queue::Ring;
const INPUT: &str = include_str!("../../input/09");
fn parse_input(input: &str) -> (usize, usize) {
let inputs = input.split(" ").collect::<Vec<&str>>();
let mut out = inputs.iter().filter_map(|v| v.parse().ok());
(out.next().unwrap(), out.next().unw... |
// Here is an implementation to return mutable pointers to the structure's fields since we saw that was not possible to do
// using mutable references.
use std::iter::IntoIterator;
use std::iter::Iterator;
pub struct NewStruct<T> {
field1: T,
field2: T,
field3: T,
field4: T,
field5: T,
}
pub s... |
use crate::ast::Node;
use crate::lexer::{Lexer, Token, TokenKind};
pub struct Parser<'a> {
lexer: Lexer<'a>,
}
impl<'a> Parser<'a> {
pub fn new(lexer: Lexer<'a>) -> Parser<'a> {
Parser { lexer }
}
pub fn bp(&self, t: &Token) -> usize {
match t.kind {
TokenKind::RParen => 0,
TokenKind::Plus... |
mod env_page;
mod env_entry_page;
pub use env_page::{EnvMsg, EnvPage};
pub use env_entry_page::*; |
mod content_hasher;
mod directory_scanner;
mod extent_hasher;
mod file_deduper;
pub use self::content_hasher::*;
pub use self::directory_scanner::*;
pub use self::extent_hasher::*;
pub use self::file_deduper::*;
// ex: noet ts=4 filetype=rust
|
//! HTTP Versions enum
//!
//! Instead of relying on typo-prone Strings, use expected HTTP versions as
//! the `HttpVersion` enum.
use std::fmt;
use self::HttpVersion::{Http09, Http10, Http11, H2, H2c};
/// Represents a version of the HTTP spec.
#[derive(PartialEq, PartialOrd, Copy, Clone, Eq, Ord, Hash, Debug)]
pub ... |
#[macro_use]
extern crate afl;
extern crate vedirect;
use vedirect::{Events, VEError};
struct Listener;
impl Events<vedirect::Bmv700> for Listener {
fn on_complete_block(&mut self, block: vedirect::Bmv700) {
println!("Mapped data {:#?}", &block);
}
fn on_parse_error(&mut self, error: VEError, _p... |
// 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 ... |
use crate::{
app::{
config::{self, HelicityType, Rgba, StormMotionType},
sample::Sample,
AppContext, AppContextPointer, ZoomableDrawingAreas,
},
coords::{SDCoords, ScreenCoords, ScreenRect, XYCoords},
errors::SondeError,
gui::{
plot_context::{GenericContext, HasGeneri... |
use futures_core::future::BoxFuture;
use std::borrow::{Borrow, BorrowMut};
use std::ops::{Deref, DerefMut};
use std::sync::Arc;
use std::time::Instant;
use super::inner::{DecrementSizeGuard, SharedPool};
use crate::connection::{Connect, Connection};
/// A connection checked out from [`Pool`][crate::pool::Pool].
///
/... |
use crate::prelude::*;
pub fn load_renderables(mut renderables: Models<Renderables>) -> Models<Renderables> {
use CreatureRenderables::*;
renderables.insert(Some("Player"), Some(Renderables::Creatures(Player)), load_scene("Player"), Template::ASprite(AnimSprite::default()));
renderables.insert(Some("Enemy... |
use collections::{Array, EntityMap, EntitySet};
use ecs::*;
use scene::Scene;
use std::cell::RefCell;
use std::fmt::{Debug, Error, Formatter};
use std::intrinsics::type_name;
use std::ops::*;
const MAX_COMPONENTS: usize = 1_000;
struct MessageMap<T: Component>(EntityMap<Vec<T::Message>>);
impl<T: Component> MessageM... |
fn main() {
let reference_to_nothing = dangle();
println!("{}", reference_to_nothing)
}
fn dangle() -> String {
//fn dangle() -> &String { this will dangle
let s = String::from("hello");
//&s this will dangle; return the String instead
s //this moves ownership out; underlying value isn't deallocat... |
//! This is copy of [sync/mpsc/](https://github.com/rust-lang/futures-rs)
use std::{
fmt,
hash::{Hash, Hasher},
pin::Pin,
sync::{
atomic::{
AtomicBool, AtomicUsize,
Ordering::{Relaxed, SeqCst},
},
Arc, Weak,
},
task::{self, Poll},
thread,
};
... |
fn main() {
let mut count = 0;
// goes to infinity
loop {
count += 1;
if count == 3 {
println!("Three!");
continue;
}
println!("count: {count}");
if count == 5 {
println!("Ok enough.");
break;
}
}
let ... |
extern crate rapier2d as rapier; // For the debug UI.
use bevy::prelude::*;
use bevy::render::pass::ClearColor;
use bevy_rapier2d::physics::{JointBuilderComponent, RapierPhysicsPlugin, RapierPhysicsScale};
use bevy_rapier2d::render::RapierRenderPlugin;
use nalgebra::Point2;
use rapier::dynamics::{BallJoint, BodyStatus... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtWidgets/qfontdialog.h
// dst-file: /src/widgets/qfontdialog.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block be... |
/*
ifvms-decompiler - core library
===============================
Copyright (c) 2020 Dannii Willis
MIT licenced
https://github.com/curiousdannii/ifvms.js
*/
use fnv::*;
pub mod zvm;
// Function safety refers to whether or not a function can be compiled and run without worrying about its locals and stack being pa... |
pub mod score_controller;
pub mod score_service;
use crate::context::{generate_context, Ctx};
use crate::scores::score_controller::{create_score, delete_score, get_score, update_score};
use thruster::{middleware, App, MiddlewareChain, MiddlewareReturnValue, Request};
pub fn init() -> App<Request, Ctx> {
let mut s... |
#![feature(async_await)]
#![deny(
missing_debug_implementations,
missing_copy_implementations,
elided_lifetimes_in_paths,
rust_2018_idioms,
clippy::fallible_impl_from,
clippy::missing_const_for_fn,
intra_doc_link_resolution_failure
)]
use std::{
io::{self, Result, Write},
process::{... |
use aoc_runner_derive::{aoc, aoc_generator};
type Map = Vec<Vec<u8>>;
#[aoc_generator(day3)]
fn input_parse(input: &str) -> Map {
input
.lines()
.map(|l| {
l.chars()
.map(|c| match c {
'.' => 0,
'#' => 1,
_ => ... |
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate needletail;
use needletail::parser::{FastaReader, FastxReader};
use std::io::Cursor;
fuzz_target!(|data: &[u8]| {
let cursor = Cursor::new([b">", data].concat());
let mut reader = FastaReader::new(cursor);
while let Some(rec) = reader.next(... |
//! This module contains the I/O types used by the clients.
use futures::Future;
/// A [`mqtt::IoSource`] implementation used by the clients.
pub struct IoSource {
iothub_hostname: std::sync::Arc<str>,
iothub_host: std::net::SocketAddr,
certificate: std::sync::Arc<Option<(Vec<u8>, String)>>,
timeout: ... |
use fuzzcheck::mutators::integer::U8Mutator;
use fuzzcheck::mutators::vector::VecMutator;
#[test]
fn test_vector_mutator() {
let m = VecMutator::new(VecMutator::new(U8Mutator::default(), 0..=usize::MAX), 0..=usize::MAX);
fuzzcheck::mutators::testing_utilities::test_mutator(m, 500.0, 500.0, false, true, 100, 150... |
use std::collections::HashMap;
// c=0 -> ぴったり
// c=1 -> 繰り上がりあり
fn solve(
a: &[usize],
i: Option<usize>,
c: usize,
memo: &mut HashMap<(usize, usize), usize>,
) -> usize {
match i {
None => c,
Some(i) => {
if let Some(&res) = memo.get(&(i, c)) {
return res... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
_reserved0: [u8; 56usize],
#[doc = "0x38 - OPAMP1 control register"]
pub opamp1_csr: OPAMP1_CSR,
#[doc = "0x3c - OPAMP2 control register"]
pub opamp2_csr: OPAMP2_CSR,
#[doc = "0x40 - OPAMP3 control register"]
pub opamp3_csr: OP... |
/*
* @lc app=leetcode.cn id=104 lang=rust
*
* [104] 二叉树的最大深度
*
* https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/description/
*
* algorithms
* Easy (71.39%)
* Likes: 433
* Dislikes: 0
* Total Accepted: 115.4K
* Total Submissions: 160.4K
* Testcase Example: '[3,9,20,null,null,15,7]'
*
... |
use itertools::Itertools;
use std::fs::File;
use std::path::Path;
use regex::{Captures, Regex};
use std::io::{BufRead, BufReader, Error, ErrorKind, Read};
use std::ops::{Add, Mul};
pub fn day_two() -> Result<(), Error> {
let re = Regex::new(r"^(\d+)-(\d+)\s*(\w):\s(\w+)$").unwrap();
// use `vec` for whatever... |
use std::ops::{Add, Sub, Mul, Div, Neg};
#[derive(Clone,Copy,Debug)]
pub struct Vec3 {
pub x: f32,
pub y: f32,
pub z: f32,
}
impl Vec3 {
pub fn new(x: f32, y: f32, z: f32) -> Vec3 {
Vec3 {x: x, y: y, z: z}
}
pub fn squared_length(&self) -> f32 {
self.x*self.x + self.y*self.y +... |
//! A full-fledged tool to read data from Electres Plus-485 energy meters.
#[macro_use]
extern crate error_chain;
extern crate clap;
pub mod errors;
pub mod constants;
pub mod data;
mod num_utils;
|
#![deny(warnings)]
mod add_two_numbers;
mod combine;
mod count_bits;
mod count_substrings;
mod daily_temperatures;
mod generate_parenthesis;
mod increasing_bst;
mod inorder_traversal;
mod invert_tree;
mod is_same_tree;
mod is_symmetric;
mod longest_substring_without_repeating_characters;
mod maximum_depth_of_binary_tr... |
/**
* Copyright © 2019
* Sami Shalayel <sami.shalayel@tutamail.com>,
* Carl Schwan <carl@carlschwan.eu>,
* Daniel Freiermuth <d_freiermu14@cs.uni-kl.de>
*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published... |
use crate::*;
use byteorder::{LittleEndian, ReadBytesExt};
struct SizeUnit {
value: f64,
unit: char,
}
struct UpdateUnit {
partial: SizeUnit,
total: SizeUnit,
percent: f64,
}
pub fn print_updates(received: f64, header: &TeleportInit) {
let units = update_units(received as f64, header.filesize... |
use super::VecMutator;
use crate::mutators::mutations::{Mutation, RevertMutation};
use crate::{Mutator, SubValueProvider};
pub struct InsertElement;
#[derive(Clone)]
pub struct InsertElementRandomStep;
#[derive(Clone)]
pub struct InsertElementStep<A> {
arbitrary_steps: Vec<(usize, A)>,
}
pub struct ConcreteInser... |
use liblumen_alloc::erts::term::prelude::*;
#[native_implemented::function(lumen:is_small_integer/1)]
pub fn result(term: Term) -> Term {
term.is_smallint().into()
}
|
use geometry::Size;
use models::Dot;
use models::Mouse;
use std::collections::HashSet;
use models::Line;
#[derive(PartialEq)]
pub enum ActivePlayer {
A,
B,
}
impl ActivePlayer {
pub fn is_a(&self) -> bool {
*self == ActivePlayer::A
}
}
/// A model that contains the other models and renders th... |
use crate::file_util::read_non_blank_lines;
use std::str::FromStr;
#[allow(dead_code)]
pub fn run_day_ten() {
let mut input = read_non_blank_lines("assets/day_ten")
.filter_map(|x| usize::from_str(x.as_str()).ok())
.collect::<Vec<usize>>();
input.sort_unstable();
let result = find_jolt_diff... |
//! Error handling interface.
//!
//! This module holds the generic error and result types to interface with `ctru_sys` and the [`ctru-rs`](crate) safe wrapper.
use std::borrow::Cow;
use std::error;
use std::ffi::CStr;
use std::fmt;
use std::ops::{ControlFlow, FromResidual, Try};
use ctru_sys::result::{R_DESCRIPTION,... |
//! Core of SQLx, the rust SQL toolkit.
//! Not intended to be used directly.
#![recursion_limit = "512"]
#![warn(future_incompatible, rust_2018_idioms)]
#![allow(clippy::needless_doctest_main, clippy::type_complexity)]
// See `clippy.toml` at the workspace root
#![deny(clippy::disallowed_method)]
//
// Allows an API b... |
//! Support to handle animations for sprites.
use amethyst::{
core::timing::Time,
ecs::prelude::{Join, Read, System, WriteStorage},
ecs::{Component, DenseVecStorage},
renderer::SpriteRender,
};
/// Component which holds a sprite animation
///
/// This includes the sprite indices for the animation, the... |
fn main() {
let _ = 1;
println!("{}", _);
}
// $rustc ./reserved_identifier.rs
// error: expected expression, found reserved identifier `_`
// --> ./reserved_identifier.rs:3:20
// |
// 3 | println!("{}", _);
// | ^ expected expression
//
// error: aborting due to previous error
|
/*-------------------------------
etc.rs
カテゴリ分けに困る、
細々とした関数をひとまとめにする
* impl File
* empty_dir_remove(): エラーを吐かせないためにわざわざフォルダ内を確認する。これいる?
* read_to_string : stringとしてファイルを読み取る
* read_to_vec : Vec<u8>としてファイルを読み取る
* unused_dir_remove(): ggezが自動生成するフォルダを削除
* easy_path_set() : c... |
/// Check error returned by the Flight API.
pub fn check_flight_error(
err: influxdb_iox_client::flight::Error,
expected_error_code: tonic::Code,
expected_message: Option<&str>,
) {
if let Some(status) = err.tonic_status() {
check_tonic_status(status, expected_error_code, expected_message);
... |
pub mod templates;
use reqwest;
use serde_json::{json, Value};
use templates::MailTemplate;
use crate::app_env::get_env;
fn form_data(to: &String, template: MailTemplate) -> Value {
json!({
"personalizations": [
{
"to": [{ "email": to }],
"dynamic_template_data": template.data
... |
fn puzzle1(input: String, iterations: usize) -> String {
let mut digits: Vec<u128> = input.chars()
.map(|char| char.to_string().parse::<u128>().unwrap())
.collect();
for iteration_count in 0..iterations {
let mut iteration_digits = vec![0u128; digits.len()];
for output_di... |
use crate::arrow2::error::Result;
use crate::arrow2::ffi::FFIArrowTable;
use arrow2::io::ipc::read::{read_file_metadata, FileReader as IPCFileReader};
use arrow2::io::parquet::write::{FileWriter as ParquetFileWriter, RowGroupIterator};
use std::io::Cursor;
/// Internal function to write a buffer of data in Arrow IPC F... |
//! A module providing a CLI command for regenerating line protocol from a WAL file.
use std::fs::{create_dir_all, File, OpenOptions};
use std::future::Future;
use std::path::PathBuf;
use std::sync::Arc;
use data_types::{NamespaceId, TableId};
use hashbrown::HashMap;
use influxdb_iox_client::connection::Connection;
us... |
use crate::riscv_csr::CsrAddr;
use crate::riscv_tracer::RiscvTracer;
use crate::riscv32_core::AddrT;
use crate::riscv32_core::InstT;
use crate::riscv32_core::UXlenT;
use crate::riscv32_core::XlenT;
use crate::riscv64_core::UXlen64T;
use crate::riscv64_core::Xlen64T;
use crate::riscv32_core::PrivMode;
use crate::ris... |
use std::any::TypeId;
use std::collections::HashSet;
use std::marker::PhantomData;
use accessors::Accessor;
use crate::bitset::BitSet;
use crate::ecs::Components;
use crate::query::ComponentTypeId::{OptionalComponentTypeId, RequiredComponentTypeId};
use crate::EntityIndex;
pub trait Query<'a> {
type ResultType: ... |
// 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... |
use std::collections::VecDeque;
use unicode_width::UnicodeWidthChar;
use alacritty_terminal::grid::Dimensions;
use crate::display::SizeInfo;
pub const CLOSE_BUTTON_TEXT: &str = "[X]";
const CLOSE_BUTTON_PADDING: usize = 1;
const MIN_FREE_LINES: usize = 3;
const TRUNCATED_MESSAGE: &str = "[MESSAGE TRUNCATED]";
/// ... |
// 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 ... |
// Given an input string, "123456", converts it to a Vec<u32> whose elements are the parsed chars: [1,2,3,4,5,6]
// Will skip invalid base 10 digits: "123ab456" -> [1,2,3,4,5,6]
// If the input string is > 11, it will be right truncated: "1234567890123" -> [1,2,3,4,5,6,7,8,9,0,1]
fn to_upc(input: &'_ str) -> Vec<u32> {... |
use crate::authenticate;
use crate::security::keystore::{calculate_hash, KeyManager};
use crate::timestamp_in_sec;
use crate::types::sensor_data::SensorData;
use std::sync::{Arc, Mutex};
use crate::iota_channels_lite::channel_author::Channel;
use crate::iota_channels_lite::utils::payload::json::PayloadBuilder;
type G... |
fn click_ana(start_cat: Category,
end_cat: Category,
clicks: &mut Vec<(UID, Category, Time)>) -> i32 {
let stream = HashMap::new();
let distances = for (uid, cat, _) in clicks {
let prev = stream.get(uid);
if cat == start_cat {
stream.insert(uid, 0);
... |
use crate::errors::ServiceError;
use crate::models::msg::Msg;
use crate::schema::option;
use crate::utils::validator::{re_test_name, Validate};
use actix::Message;
use actix_web::error;
use actix_web::Error;
use uuid::Uuid;
#[derive(Deserialize, Serialize, Debug, Message, Insertable)]
#[rtype(result = "Result<Msg, S... |
use log::LevelFilter;
use serde::Deserialize;
use alacritty_config_derive::ConfigDeserialize;
/// Debugging options.
#[derive(ConfigDeserialize, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Debug {
pub log_level: LevelFilter,
pub print_events: bool,
/// Keep the log file after quitti... |
#![allow(dead_code)]
pub const KEY_RESERVED: u8 = 0;
pub const KEY_ESC: u8 = 1;
pub const KEY_1: u8 = 2;
pub const KEY_2: u8 = 3;
pub const KEY_3: u8 = 4;
pub const KEY_4: u8 = 5;
pub const KEY_5: u8 = 6;
pub const KEY_6: u8 = 7;
pub const KEY_7: u8 = 8;
pub const KEY_8: u8 = 9;
pub const KEY_9: u8 = ... |
use regex_syntax::ParserBuilder;
/// A common set of configuration options that apply to the syntax of a regex.
///
/// This represents a group of configuration options that specifically apply
/// to how the concrete syntax of a regular expression is interpreted. In
/// particular, they are generally forwarded to the
... |
//! This module contains the main event loop for the linux operating system.
//!
//! This application, on linux, uses x11 for window management. This module includes basic
//! input event gathering, keyboard and mouse events. The primary functions of
//! interest are `make_window` and `update_screen`.
//! `make_win... |
#![allow(dead_code)]
use chrono::NaiveDate;
use regex::Regex;
use std::io;
use std::fs::File;
use std::io::BufRead;
use std::collections::BTreeMap;
use crate::gen;
use util_rust::parse;
const FILE_IMPORT_BOOKS_PERSONAL: &str = r"E:\ConnectedText Restructure 2020-10-17\Audible Books Personal.txt";
const FILE_IMPORT_PU... |
use test_winrt::Windows::Foundation::GuidHelper;
use windows::core::GUID;
#[test]
fn guid_helper() -> windows::core::Result<()> {
let a = GuidHelper::CreateNewGuid()?;
let b = GuidHelper::CreateNewGuid()?;
assert!(!GuidHelper::Equals(&a, &b)?);
assert!(GuidHelper::Equals(&a, &a)?);
Ok(())
}
#[te... |
// 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 math::traits::ToIterator;
use crate::plink_bed::{
geno_to_lowest_two_bits, get_num_people_last_byte, lowest_two_bits_to_geno,
usize_div_ceil,
};
pub struct PlinkSnps {
bytes: Vec<u8>,
num_snps: usize,
}
impl PlinkSnps {
pub fn new(bytes: Vec<u8>, num_snps: usize) -> PlinkSnps {
assert... |
use std::cell::Cell;
use std::collections::{HashMap,BTreeSet};
use std::sync::mpsc::{Receiver,Sender};
use std::sync::{Arc,Barrier};
use std::ffi::CString;
use libc::{c_char,c_int,c_void,ssize_t,size_t};
use crate::device::Device;
use crate::quick_io::{append_to_file_at_path,slurp_file_at_path,fd_poll_read};
use crate:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.