text stringlengths 8 4.13M |
|---|
use js_function_promisify::Callback;
use wasm_bindgen_test::*;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
async fn readme_example() {
let future = Callback::new(|| Ok("Hello future!".into()));
web_sys::window()
.unwrap()
.set_timeout_with_callback_and_timeout_and... |
use crate::projections::conic;
use crate::projections::pseudoconic;
use crate::projections::cylindric;
use crate::projections::pseudocylindric;
use crate::projections::projection_types::Projection;
use crate::projections::projection_types::ProjectionType;
use crate::chart_and_js_exports::JSProjectionParams;
fn list_pr... |
use super::mem_map::{WRAM_END, WRAM_START};
pub struct Wram {
bytes: Box<[u8]>,
}
impl Wram {
pub fn new() -> Wram {
const LENGTH: usize = (WRAM_END - WRAM_START + 1) as usize;
Wram {
bytes: Box::new([0; LENGTH]),
}
}
pub fn read_byte(&self, addr: u16) -> u8 {
... |
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use thiserror::Error;
/// Defines the Logger configuration.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LoggerConfig {
// Todo: check if an enum can be used
/// The Logger level
/// Valid values: trace, debug, info, warn, error
... |
use std::{
alloc::Layout,
marker::PhantomData,
mem::{align_of, size_of},
ptr::{null_mut, NonNull},
};
use libc::{
c_void, mmap, mprotect, munmap, MAP_ANONYMOUS, MAP_PRIVATE, PROT_NONE, PROT_READ, PROT_WRITE,
};
const PAGE_SIZE: usize = 4096;
const MAX_ELEMENTS: usize = usize::MAX / 2;
pub struct ... |
use crate::rpc::kvs_service::WriteOp;
use chrono::prelude::*;
use std::{
fmt::Display,
str::FromStr,
time::{Duration, SystemTime},
};
pub enum Column {
Write,
Data,
Lock,
}
/// A Key struct used in percolator txn
#[derive(Clone)]
pub struct Key {
key: String,
ts: u64,
}
impl Key {
... |
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
//! Traits and structs for loading the device tree.
use vm_memory::{Bytes, GuestMemory};
use std::fmt;
use crate::configurator::{BootConfigurator, BootParams, Error as BootConfigurat... |
/*!
```rudra-poc
[target]
crate = "obstack"
version = "0.1.3"
[test]
cargo_flags = ["--release"]
[report]
issue_url = "https://github.com/petertodd/rust-obstack/issues/4"
issue_date = 2020-09-03
rustsec_url = "https://github.com/RustSec/advisory-db/pull/373"
rustsec_id = "RUSTSEC-2020-0040"
[[bugs]]
analyzer = "Manu... |
// unihernandez22
// https://atcoder.jp/contests/abc174/tasks/abc174_a
// implementation
use std::io::stdin;
fn main() {
let mut x = String::new();
stdin().read_line(&mut x).unwrap();
let x: i64 = x.trim().parse().unwrap();
println!("{}",
if x >= 30 { "Yes" }
else { "No" }
);
}
|
use std::collections::HashMap;
type Line = (i32, i32, i32, i32);
fn count_overlaps(lines: &[Line], diagonals: bool) -> usize {
let mut counts = HashMap::new();
for &(x0, y0, x1, y1) in lines {
if x0 == x1 {
for y in i32::min(y0, y1)..=i32::max(y0, y1) {
*counts.entry((x0, y... |
//! Frequently used imports.
// TODO: Reconsider this. Is this an anti-pattern?
pub use block::Block;
pub use cell::MoveCell;
pub use lazy_init::LazyInit;
pub use sync::Mutex;
pub use ptr::Pointer;
pub use vec::Vec;
|
use crate::Config;
use actix::clock::{interval_at, Instant};
use actix_web::{get, http::header::ContentType, web, web::Bytes, HttpResponse};
use drogue_client::{registry, Context};
use drogue_cloud_integration_common::stream::{EventStream, EventStreamConfig, IntoSseStream};
use drogue_cloud_service_api::{
auth::use... |
use crate::{
commands::osu::SnipeOrder,
custom_client::SnipeCountryPlayer,
embeds::Footer,
util::{
constants::OSU_BASE,
numbers::{with_comma_float, with_comma_int},
osu::flag_url,
CountryCode,
},
};
use std::fmt::Write;
pub struct CountrySnipeListEmbed {
thumbna... |
extern crate crypto;
use self::crypto::digest::Digest;
use self::crypto::md5::Md5;
use std::collections::HashMap;
pub struct Password {
door_id: String,
}
impl Password {
pub fn new(door_id: String) -> Password {
Password { door_id: door_id }
}
pub fn val(&self) -> String {
let mut re... |
#[macro_use] extern crate serde_json;
#[macro_use] extern crate serde_derive;
extern crate rmp_serde;
extern crate byteorder;
extern crate futures;
extern crate indyrs as indy;
#[macro_use]
use indy::metrics;
use indy::ErrorCode;
mod utils;
#[allow(unused_imports)]
use futures::Future;
#[cfg(test)]
mod collect {
... |
#![warn(missing_docs, clippy::pedantic)]
//! Generates strings are byte strings following rule of a regular expression.
//!
//! ```
//! # #[cfg(feature = "unicode")] {
//! use rand::{SeedableRng, Rng};
//!
//! let mut rng = rand_xorshift::XorShiftRng::from_seed(*b"The initial seed");
//!
//! // creates a generator for... |
use crate::io::*;
use crate::layers::loss_layer::SoftMaxWithLoss;
use crate::model::*;
use crate::optimizer::{AdaGrad, Adam, Optimizer, SGD};
use crate::trainer::*;
use crate::types::*;
use crate::util::*;
extern crate ndarray;
use ndarray::{Array, Axis, Slice};
pub fn train2() {
const PRINT_ITER_NUM: usize = 10;
... |
fn is_multiple_of(n: u64) -> impl Fn(&u64) -> bool {
move |m: &u64| *m % n == 0
}
pub fn is_multiple_of_5_or_3(n: &u64) -> bool {
is_multiple_of(5)(n) || is_multiple_of(3)(n)
}
pub fn solve(max: u64) -> u64 {
(1..max).into_iter().filter(is_multiple_of_5_or_3).sum()
}
|
//! ### Reverse Complement Problem
//!
//! Find the reverse complement of a DNA string.
//!
//! **Given:** A DNA string Pattern.
//!
//! **Return:** Pattern, the reverse complement of Pattern.
extern crate bio_algorithms as bio;
use std::fs::File;
use std::io::prelude::*;
use bio::bio_types::DNA_Sequence;
fn main()... |
#[doc = "Register `DFSDM_FLT3AWHTR` reader"]
pub type R = crate::R<DFSDM_FLT3AWHTR_SPEC>;
#[doc = "Register `DFSDM_FLT3AWHTR` writer"]
pub type W = crate::W<DFSDM_FLT3AWHTR_SPEC>;
#[doc = "Field `BKAWH` reader - Break signal assignment to analog watchdog high threshold event"]
pub type BKAWH_R = crate::FieldReader;
#[d... |
//! This example demonstrates creating a [`CompactTable`] `from()` a
//! multidimensional array.
//!
//! * Note how [`CompactTable::from()`] inherits the lengths of the nested arrays
//! as typed definitions through [const generics](https://practice.rs/generics-traits/const-generics.html).
use tabled::{settings::Style... |
extern crate algorithm;
use algorithm::genetic;
#[test]
fn test1() {
assert_eq!(2, genetic::test());
}
|
mod stm32f1xx;
#[cfg(feature = "stm32f1xx")]
use stm32f1xx as dev;
pub type GpioOutError = dev::GpioOutError;
pub type GpioInError = dev::GpioInError;
pub type TimerError = dev::TimerError;
pub type Pin = dev::Pin;
pub type Port = dev::Port;
pub type TimerID = dev::TimerID;
pub type Time = dev::Time;
#[inline]
pub(c... |
use chrono::{DateTime, Utc};
use eyre::Report;
use hashbrown::HashMap;
use rosu_v2::model::GameMode;
use serde_json::Value;
use sqlx::{types::Json, ColumnIndex, Decode, Error, FromRow, Row, Type};
use std::collections::HashMap as StdHashMap;
use twilight_model::id::{marker::ChannelMarker, Id};
#[derive(Debug)]
pub str... |
use serde::{Deserialize, Serialize};
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
pub(in super::super) struct SqlStateClass {
pub(in super::super) class: String,
pub(in super::super) class_text: String,
}
impl SqlStateClass {
pub(in super::super) fn new(class: &str... |
use renderer::{ Model, VertexFormat, VertexAttribute };
pub fn make_plane() -> Model {
let mut verts = [
0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0,
1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0,
0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0,
];
let inds = [
1, 0, 3, 3, 2, 1
];
l... |
// 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 ... |
use std::env;
use std::fs;
fn main(){
let args : Vec<String> = env::args().collect();
if args.len() < 2 {
return;
}
let lines = fs::read_to_string(&args[1]).unwrap();
let linelength = lines.split('\n').collect::<Vec<&str>>()[0].len();
let mut map : Vec<Vec<i32>> = Vec::new();
for ... |
fn main() {
println!("Hello, world!");
case_string_test();
create_a_new_string();
update_a_string();
concat_with_plus();
indexing_into_string();
}
fn case_string_test() {
let s = "Hello World";
let a = &s[0..1];
println!("{}", a);
let s = String::from("Hello World");
let a:... |
mod dedup;
mod manager;
mod page;
mod state_block;
|
#[doc = "Register `APB1LENR` reader"]
pub type R = crate::R<APB1LENR_SPEC>;
#[doc = "Register `APB1LENR` writer"]
pub type W = crate::W<APB1LENR_SPEC>;
#[doc = "Field `TIM2EN` reader - TIM2 peripheral clock enable Set and reset by software."]
pub type TIM2EN_R = crate::BitReader<TIM2EN_A>;
#[doc = "TIM2 peripheral cloc... |
#[test]
fn test_all() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/compile-fail/surface_*.rs");
}
|
use crate::functions::*;
use crate::layers::*;
use crate::math::Derivative;
use crate::params::*;
use crate::types::*;
use itertools::izip;
use ndarray::{s, Array1, Axis, Dimension, Ix2, Ix3, RemoveAxis};
#[derive(Default)]
struct Cache {
x: Arr2d,
h_prev: Arr2d,
h_next: Arr2d,
}
/// 外部入力 x: (b, c), wx: (... |
//! This crate was inspired by Python's input function. It allows easy reading of data from the terminal.
//!
//! A simple example of its use is:
//! ```
//! extern crate reader;
//! use reader::input;
//!
//! let name = input("Enter your name: ");
//! println!("Your name is: {}", name);
//! ```
use std::io::Write;
us... |
use crate::{DomainId, OperatorId, OperatorPublicKey, StakeWeight};
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_core::crypto::{VrfPublic, Wraps};
use sp_core::sr25519::vrf::{VrfOutput, VrfSignature, VrfTranscript};
use sp_std::vec::Vec;
use subspace_core_primitives::Blake2b256Hash;
const ... |
use std::{error, io, io::Write, path::Path, process};
pub fn run(args: &str) -> Result<(String, String, process::ExitStatus), Box<dyn error::Error>> {
let output = fake_tty::bash_command(&format!("{}; echo \"\n$PWD\"", args)).output()?;
let stdout = String::from_utf8(output.stdout)?;
let stderr = String::... |
pub enum ArchKeyboardAction
{
ArchKeyDown(u8),
ArchKeyUp(u8)
}
pub fn get_key() -> ArchKeyboardAction
{
let raw = unsafe { ::platform::io::inport(0x60) };
let key = raw & 0x7F;
match raw & 0x80
{
0 => ArchKeyDown(key),
_ => ArchKeyUp(key),
}
}
|
// Copyright 2020 The MWC 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 agreed... |
use std::fs::File;
use std::io::{BufWriter, Write};
use clap::{App, Arg};
fn main() -> std::io::Result<()> {
let args = App::new("json-sorter")
.version("0.1")
.about("sorts keys alphabetically in a JSON file")
.arg(Arg::with_name("input_file")
.help("The JSON file to sort keys... |
fn is_prime(n: i64) -> bool {
if n == 1 {
return false;
}
let mut i = 2;
while i * i <= n {
if n % i == 0 {
return false;
}
i += 1;
}
return true;
}
#[test]
fn test_is_prime() {
assert!(!is_prime(1));
assert!(is_prime(2));
assert!(is_prime(... |
#[doc = "Register `STGENR_PIDR6` reader"]
pub type R = crate::R<STGENR_PIDR6_SPEC>;
#[doc = "Field `PIDR6` reader - PIDR6"]
pub type PIDR6_R = crate::FieldReader<u32>;
impl R {
#[doc = "Bits 0:31 - PIDR6"]
#[inline(always)]
pub fn pidr6(&self) -> PIDR6_R {
PIDR6_R::new(self.bits)
}
}
#[doc = "ST... |
#[doc = "Reader of register MMMS_RX_PKT_CNTR"]
pub type R = crate::R<u32, super::MMMS_RX_PKT_CNTR>;
#[doc = "Reader of field `MMMS_RX_PKT_CNT`"]
pub type MMMS_RX_PKT_CNT_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:5 - Count of all packets in the RX FIFO in MMMS mode"]
#[inline(always)]
pub fn mmms_rx_pkt... |
//! `fitsio` - a thin wrapper around the [`cfitsio`][1] C library.
//!
//! * [HDU access](#hdu-access)
//! * [Header keys](#header-keys)
//! * [Reading file data](#reading-file-data)
//! * [Images](#images)
//! * [Tables](#tables)
//!
//! This library wraps the low level `cfitsio` bindings: [`fitsio-sys`][2] an... |
pub fn wiggle_sort(nums: &mut Vec<i32>) {
nums.sort();
let n = nums.len();
let mut result = vec![0; n];
if n % 2 == 0 {
for i in 0..n / 2 {
result[n - 2 - 2 * i] = nums[i];
result[n - 1 - 2 * i] = nums[n / 2 + i];
}
} else {
for i in 0..n / 2 {
... |
use sdl2::render::{Texture, TextureCreator, Canvas};
use sdl2::video::{WindowContext, Window};
use sdl2::pixels::{PixelFormatEnum};
use crate::nes::nes::NES;
use crate::gfx::render;
use super::window::RenderableWindow;
use crate::ppu::ppu;
use crate::ppu::ppu::{FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT};
use crate::gfx:... |
use crate::utils::asserts::meta::assert_meta;
use crate::utils::asserts::peer::{assert_peer_data, test_peer_array};
use crate::utils::mockito_helpers::{mock_client, mock_http_request};
use arkecosystem_client::api::models::peer::Peer;
use arkecosystem_client::api::models::shared::Response;
use arkecosystem_client::Conn... |
use std::cell::RefCell;
use std::rc::Rc;
pub trait Wrap<T> {
fn wrap(t: T) -> Self;
}
pub type SharedMut<T> = Rc<RefCell<T>>;
impl<T> Wrap<T> for SharedMut<T> {
fn wrap(t: T) -> Self {
Rc::new(RefCell::new(t))
}
}
pub use std::f64::consts::PI;
pub use std::ops;
pub type Time = f32;
/// A type al... |
pub mod autotransport;
mod serversenteventstransport;
mod longpollingtransport;
pub mod clienttransport;
pub mod httpbasedtransport;
|
/// An enum to represent all characters in the DevanagariExtended block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum DevanagariExtended {
/// \u{a8e0}: '꣠'
CombiningDevanagariDigitZero,
/// \u{a8e1}: '꣡'
CombiningDevanagariDigitOne,
/// \u{a8e2}: '꣢'
CombiningDevanagariDigitTwo,... |
// The heart of the Multi-sig orchestrator. All messages will be sent, received, and
// all actions triggered via event-driven methods within this module.
// SO FAR:
// Most of this is copy and pasted from the guide: https://ws-rs.org/guide
use ws::{listen, Handler, Sender, Result, Message, Handshake, CloseCode,... |
use std::time::Duration;
use std::io::Write;
use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
use super::super::config::{Tokens, Config, ClientRef};
use super::super::results::{BearerResult, BearerError};
use super::oauth2client;
fn url_encode(to_encode: &str) -> String {
to_encode.as_bytes().ite... |
use std::fs;
use std::collections::HashMap;
fn main() {
let lines : Vec<String> = fs::read_to_string("./in.in").expect("Smth went wrong smh").split("\n").map(|s| s.to_owned()).collect();
part1(lines.clone());
part2(lines);
}
fn part1(n : Vec<String>) {
let mut valid : u32 = 0;
for i in n {... |
use graphics::textures::TextureId;
#[derive(Copy, Clone)]
pub struct Sprite {
pub sprite: TextureId,
pub center: [f32; 2],
pub uv_rect: [f32; 4],
pub layer: f32,
pub flip_x: bool,
}
impl Sprite {
pub fn new(sprite: TextureId) -> Self {
Sprite {
sprite,
center: [... |
use super::*;
/**
Wraps a reference to a `String` representation of some type
The `String` can be accessed as if it were the type.
An `Adapter` can be made for any type that implements `FromStr` and `Display`.
An `Adapter` must be dropped before the `String` can be accessed again.
# Example
```
use kai::*;
// A `Ve... |
/// Convenience wrapper for making simple get calls.
macro_rules! cci_get_call {
($function:ident($($arg0:expr,)+ _: $type:ty $(, $arg1:expr)*$(,)*)) => ({
let mut value: $type = unsafe { ::std::mem::uninitialized() };
let error = unsafe { $function($($arg0,)* &mut value, $($arg1),* ) };
if ... |
/*=======================================
* @FileName: 18四数之和.rs
* @Description:
* @Author: TonyLaw
* @Date: 2021-09-01 23:10:39 Wednesday
* @Copyright: © 2021 TonyLaw. All Rights Reserved.
=========================================*/
/*=======================================
(题目难度:中等)
给你一个由 n 个整数组成的数组... |
//! Various methods of executing over Falcon IL
use error::*;
use il;
/// Swaps the bytes of an expression (swaps endianness)
pub fn swap_bytes(expr: &il::Expression) -> Result<il::Expression> {
match expr.bits() {
8 => Ok(expr.clone()),
16 => {
// isolate bytes
let b0 = i... |
#[doc = "Register `SDCR1` reader"]
pub type R = crate::R<SDCR1_SPEC>;
#[doc = "Register `SDCR1` writer"]
pub type W = crate::W<SDCR1_SPEC>;
#[doc = "Field `NC` reader - Number of column address bits These bits define the number of bits of a column address."]
pub type NC_R = crate::FieldReader;
#[doc = "Field `NC` write... |
extern crate libc;
use self::libc::*;
#[link(name = "opus")]
extern "C" {
pub fn opus_strerror(error: c_int) -> *const c_char;
pub fn opus_get_version_string() -> *const c_char;
pub fn opus_encoder_create(Fs: i32, channels: c_int,
application: c_int,
... |
//! Terminal handling.
use crate::error::Result;
use libc::{c_int, c_void, sigaction, sighandler_t, siginfo_t, termios, winsize};
use libc::{SA_SIGINFO, SIGWINCH, STDIN_FILENO, STDOUT_FILENO, TCSADRAIN, TIOCGWINSZ, VMIN, VTIME};
use std::io::{self, Bytes, Read, Stdin};
use std::mem::MaybeUninit;
use std::ptr;
use std:... |
#[doc = "Register `RCC_PLL4CFGR1` reader"]
pub type R = crate::R<RCC_PLL4CFGR1_SPEC>;
#[doc = "Register `RCC_PLL4CFGR1` writer"]
pub type W = crate::W<RCC_PLL4CFGR1_SPEC>;
#[doc = "Field `DIVN` reader - DIVN"]
pub type DIVN_R = crate::FieldReader<u16>;
#[doc = "Field `DIVN` writer - DIVN"]
pub type DIVN_W<'a, REG, cons... |
/*
use pymemprofile_api::oom::get_cgroup_available_memory;
use std::time::Instant;
*/
fn main() {
/*
let now = Instant::now();
for _ in 1..1_000 {
get_cgroup_available_memory();
}
let elapsed_secs = (now.elapsed().as_millis() as f64) / 1000.0;
println!("Calls/sec: {}", 1000.0 * (1.0 / el... |
use crate::ast;
use crate::{Parse, ParseError, ParseErrorKind, Parser, Peek, Spanned, ToTokens};
/// The unit literal `()`.
#[derive(Debug, Clone, ToTokens, Spanned)]
pub struct LitBool {
/// The token of the literal.
pub token: ast::Token,
/// The value of the literal.
#[rune(skip)]
pub value: boo... |
use super::*;
#[derive(PartialEq, Copy, Clone, Debug)]
pub struct Affine<T> {
pub m: Matrix2<T>,
pub t: Vector2<T>,
}
impl<T: BaseFloat> Default for Affine<T> {
#[inline]
fn default() -> Self {
Self::one()
}
}
impl<S: BaseFloat> Transform<Point2<S>> for Affine<S> {
#[inline]
fn on... |
// This file is part of lock-free-multi-producer-single-consumer-ring-buffer. 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/lock-free-multi-producer-single-consumer-ring-buffer/master/COPYRIGHT. No part o... |
#[doc = "Register `DCKCFGR2` reader"]
pub type R = crate::R<DCKCFGR2_SPEC>;
#[doc = "Register `DCKCFGR2` writer"]
pub type W = crate::W<DCKCFGR2_SPEC>;
#[doc = "Field `FMPI2C1SEL` reader - I2C4 kernel clock source selection"]
pub type FMPI2C1SEL_R = crate::FieldReader<FMPI2C1SEL_A>;
#[doc = "I2C4 kernel clock source se... |
pub const DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO: u64 = 54060;
pub const DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS: u64 = 54429;
pub const CLIENT_HELLO: u64 = 0;
pub const CLIENT_QUERY: u64 = 1;
pub const CLIENT_DATA: u64 = 2;
pub const CLIENT_CANCEL: u64 = 3;
pub const CLIENT_PING: u64 = 4;
pub ... |
#![allow(incomplete_features)]
#![feature(generic_associated_types, const_generics)]
pub mod app;
pub mod fields;
pub mod kinds;
pub mod lens;
pub mod message;
pub mod mutation;
mod pane_zone;
mod panes;
pub mod stores;
mod theme;
pub use app::App;
pub use iced::{Sandbox, Settings};
pub use kinds::{Field, Key, Kind};... |
use bindgen;
use cc;
use std::env;
use std::path::PathBuf;
use std::process::Command;
fn main() {
let v8_dir = match env::var("CUSTOM_V8") {
Ok(custom_v8_dir) => {
let custom_v8_dir = PathBuf::from(custom_v8_dir);
assert!(custom_v8_dir.exists());
custom_v8_dir
... |
use utils::vec3;
#[allow(dead_code)]
#[derive(Clone, Debug)]
pub struct Ray {
pub a: vec3::Vec3,
pub b: vec3::Vec3,
time: f32,
}
#[allow(dead_code)]
impl Ray {
pub fn new(a: &vec3::Vec3, b: &vec3::Vec3, ti: f32) -> Self {
Self {
a: a.clone(),
b: b.clone(),
t... |
#[doc = "Reader of register BSEC_OTP_CONFIG"]
pub type R = crate::R<u32, super::BSEC_OTP_CONFIG>;
#[doc = "Writer for register BSEC_OTP_CONFIG"]
pub type W = crate::W<u32, super::BSEC_OTP_CONFIG>;
#[doc = "Register BSEC_OTP_CONFIG `reset()`'s with value 0x0e"]
impl crate::ResetValue for super::BSEC_OTP_CONFIG {
typ... |
#[doc = "Reader of register DSI_VMCCR"]
pub type R = crate::R<u32, super::DSI_VMCCR>;
#[doc = "Reader of field `VMT`"]
pub type VMT_R = crate::R<u8, u8>;
#[doc = "Reader of field `LPVSAE`"]
pub type LPVSAE_R = crate::R<bool, bool>;
#[doc = "Reader of field `LPVBPE`"]
pub type LPVBPE_R = crate::R<bool, bool>;
#[doc = "R... |
// This file is part of Substrate.
// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// 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
//
// ht... |
#![no_std]
#![feature(lang_items, core_intrinsics)]
use core::intrinsics;
use core::panic::PanicInfo;
use core::alloc::{GlobalAlloc, Layout};
use core::fmt;
use core::fmt::Write;
extern {
fn malloc(size: usize) -> *mut u8;
fn free(ptr: *mut u8);
fn write(file: isize, buffer: *const u8, count: usize) -> usi... |
// -*- mode: rust; -*-
//
// To the extent possible under law, the authors have waived all copyright and
// related or neighboring rights to curve25519-dalek, using the Creative
// Commons "CC0" public domain dedication. See
// <http://creativecommons.org/publicdomain/zero/.0/> for full details.
//
// Authors:
// - Is... |
use crate::category::Category;
use crate::error::Error;
use crate::image::Image;
use crate::location::Location;
use crate::rating::Rating;
use crate::schema::TABLES;
use rusqlite::{params, Connection};
use std::path::Path;
#[derive(Debug)]
pub struct Store {
con: Connection,
}
impl Store {
pub fn create(path:... |
/*
* Copyright Stalwart Labs Ltd. See the COPYING
* file at the top-level directory of this distribution.
*
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
* https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
* <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
* optio... |
use flux::semantic::walk::Node as WalkNode;
use lspower::lsp;
pub struct ExperimentalDiagnosticVisitor {
namespaces: Vec<String>,
pub diagnostics: Vec<(Option<String>, lsp::Diagnostic)>,
}
impl Default for ExperimentalDiagnosticVisitor {
fn default() -> Self {
Self {
diagnostics: vec![... |
//! A simple Driver for the Waveshare E-Ink Displays via SPI
//!
//! This driver was built using [`embedded-hal`] traits.
//!
//! [`embedded-hal`]: https://docs.rs/embedded-hal/~0.1
//!
//! # Requirements
//!
//! ### SPI
//!
//! - MISO is not connected/available
//! - SPI_MODE_0 is used (CPHL = 0, CPOL = 0)
//! - 8 bit... |
struct Solution();
impl Solution {
pub fn climb_stairs(n: i32) -> i32 {
if n == 1{
return 1;
}
let n = n as usize;
let mut stairs=vec![1;n];
stairs[1]=2;
for i in 2..n{
stairs[i]=stairs[i-1]+stairs[i-2];
}
stairs[n-1]
}
}
fn... |
#![feature(concat_idents)]
mod app;
use app::{App, Status};
use log::{debug, warn};
use std::path::{Path, PathBuf};
use std::io::{self, Read, Write};
use std::sync::{Arc, RwLock, Mutex};
use std::thread;
use std::sync::mpsc;
use tui::{ backend::{CrosstermBackend, Backend}, Terminal };
use fern::colors::{Color, Color... |
impl Solution {
pub fn sum_odd_length_subarrays(mut arr: Vec<i32>) -> i32 {
let mut a = vec![0;1];
a.append(&mut arr);
let n = a.len();
for i in 1..n{
a[i] += a[i - 1];
}
let mut res = 0;
for i in 1..n{
for j in i..n{
if... |
use gdk::{
ModifierType,
keyval_to_unicode,
CONTROL_MASK,
META_MASK,
SHIFT_MASK,
SUPER_MASK,
};
use servo::msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER};
use gdk::enums::key as gdk_key;
use gdk_sys::{GDK_BUTTON_MIDDLE, GDK_BUTTON_PRIMARY, GDK_BUTTON_SECONDARY};
use servo::msg::constellati... |
fn main() {
proconio::input! {
n: usize,
a: [i32; n],
b: [i32; n],
}
let mut min = 100000000;
let mut max = 0;
for i in 0..n {
if min > b[i] {
min = b[i];
}
}
for i in 0..n {
if max < a[i] {
max = a[i];
}
}... |
use anyhow::{anyhow, bail};
use bikecleats_testsuite::{BatchTestCase, CheckerShell, ExpectedOutput};
use futures_util::{select, FutureExt as _};
use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};
use std::{
cmp,
collections::BTreeMap,
env,
ffi::{OsStr, OsString},
future:... |
use std::thread;
use std::time::Duration;
use anyhow::Result;
use rand;
use rand::Rng;
use super::{SensorId, Sensors};
use crate::{Global, drop::DropJoin};
pub fn poll_tmp_probes() -> Result<DropJoin<()>> {
let handle = thread::Builder::new()
.name("temp-sensor".into())
.stack_size(32 * 1024)
... |
mod tests{
use num_cpus; // 1.13.0
use std::time;
use threadpool::ThreadPool; // 1.8.0 // 0.7.2
use crossbeam; // 0.7.3
use futures::executor; // 0.3.4
use futures::Future;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use tokio::time::delay_for;
use tokio::runtime::Runti... |
use std::cell::RefCell;
use std::ops::RangeFrom;
// ------------------------------------------------------------------------------------------------
// Public Types
// ------------------------------------------------------------------------------------------------
///
/// A Step counter will simply return an increasi... |
use nom::bytes::complete::{is_a, take, take_while, take_while_m_n};
use nom::character::complete::anychar;
use nom::combinator::{map, map_res, opt, verify};
use nom::error::context;
mod parse;
#[derive(Debug, PartialEq)]
pub struct Genre<'s>(&'s str);
#[derive(Debug, PartialEq)]
pub struct Second(f64);
#[derive(Deb... |
use bevy::prelude::*;
use crate::{asset_loader, player, camera, level_collision, enemy, AppState, GameState,
follow_text, Kid, level_collision::CollisionShape, cutscene, cutscene::CutsceneSegment };
pub struct LevelReady(pub bool);
pub struct TheaterOutsidePlugin;
impl Plugin for TheaterOutsidePlugin {
... |
// Copyright 2018 PingCAP, Inc.
//
// 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 i... |
// Copyright 2015 The Gfx-rs 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 ag... |
use serde::Deserialize;
// fn deserialize_number_from_string<'de, D: Deserializer<'de>>(deserializer: D) -> Result<usize, D::Error> {
// use serde::de::Error;
// if let Ok(x) = usize::deserialize(deserializer) {
// return Ok(x);
// }
// let string = deserializer.deserialize_str()?;
// string.parse().map_err(|... |
use reqwest::Client;
use roxmltree::Document;
use sqlx::PgPool;
use tracing::{
field::{display, Empty},
Span,
};
use warp::{http::StatusCode, Rejection};
use crate::error::Error;
use crate::requests::{upload_file, youtube_streams, youtube_thumbnail};
use crate::vtubers::VTUBERS;
pub async fn publish_content(
... |
use List::*;
enum List {
//Cons: Tuple struct that wraps an element and a pointer to the next node
Cons(u32, Box<List>),
// Nil: signifies the the end of the list
Nil,
}
//Methods can be attached to an enum
impl List {
//Create a new List
fn new() -> List {
//Nil has the type list
... |
#[derive(Debug, Clone)]
pub struct Token {
pub token_type: TokenType,
pub lexeme: String,
pub literal: Option<Literal>,
pub line: u32,
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum TokenType {
// Single-character tokens.
LeftParen, RightParen, LeftBrace, RightBrace,
Comma, Dot, Minus, Plus, S... |
pub fn experiments() {
let rule_1: &str = "
Each object can used exactly once.
Once you use an object it is moved to the new location
and is no longer usable in the old.
";
println!("Rule 1: {}", rule_1);
// So the deeper question is what constitutes "using"
struct A;
... |
use lib::load_file;
use lib::setup::quick_setup::{initialize_demo, quick_demo};
use lib::types::buffer::ebo::EBO;
use lib::types::buffer::vao_builder::VAOBuilder;
use lib::types::buffer::vbo::VBO;
use lib::types::data::data_layout::DataLayout;
use lib::types::linalg::dimension::Dimension;
use lib::types::linalg::matrix... |
extern crate rs_munge;
use rs_munge::{encode, decode};
fn main() {
let orig_payload = b"abc";
let message = decode(&encode(Some(orig_payload)).unwrap()).unwrap();
let payload = message.payload().unwrap();
assert_eq!(payload, orig_payload);
assert!(message.uid() > 0);
assert!(message.gid()... |
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
//! Tests surrounding exit logic.
use std::sync::Mutex;
use reverie::syscalls;
use reverie::sysca... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.