text stringlengths 8 4.13M |
|---|
// https://leetcode.com/problems/to-lower-case/submissions/
impl Solution {
pub fn to_lower_case(s: String) -> String {
s.to_lowercase()
}
} |
extern crate ansi_term;
extern crate rusqlite;
extern crate serde;
#[macro_use]
extern crate serde_derive;
use rusqlite::NO_PARAMS;
use rusqlite::{Connection, Result};
use ansi_term::Colour;
use text_io::read;
#[derive(Serialize, Deserialize, Debug)]
struct Card {
question: String,
answer: String,
}
fn ent... |
mod data;
mod languages;
mod templates;
mod utils;
use actix_web::{get, web, App, HttpRequest, HttpResponse, HttpServer};
use dotenv::dotenv;
use std::env;
#[get("/")]
async fn home(page_url: web::Data<String>, req: HttpRequest) -> actix_web::Result<HttpResponse> {
templates::render("home", page_url, req)
}
#[ge... |
use super::Context;
use crate::projects::mutations::MutationProjects;
use crate::stories::mutations::MutationStories;
use crate::users::mutations::MutationUsers;
pub struct MutationRoot;
#[juniper::graphql_object(Context = Context)]
impl MutationRoot {
fn users(&self) -> MutationUsers {
MutationUsers
}... |
use embedded_hal::digital::v2::InputPin;
use core::convert::Infallible;
pub struct Encoder<CHA: InputPin, CHB: InputPin> {
channel_a: CHA,
channel_b: CHB,
position: i32,
}
pub enum Channel {
A,
B
}
impl<CHA, CHB> Encoder<CHA, CHB>
where
CHA: InputPin<Error = Infallible>,
CHB: InputPin<Er... |
use rendering::camera::Camera;
use rendering::colors::Color;
#[derive(Debug, Clone)]
pub enum RenderMode {
WIREFRAME,
DEFAULT,
}
struct Renderer {
camera: &'static Camera,
clear_color: Color,
// passes: Vec<RenderPass>,
mode: RenderMode,
}
|
use crate::attributes::*;
use glam::{vec2, vec3, Vec3, Mat3};
use image::{RgbaImage, Rgba};
pub struct Program {
pub vertex_shader: Box<dyn FnMut(VertexAttributes, UniformAttributes) -> VertexAttributes>,
pub fragment_shader: Box<dyn FnMut(VertexAttributes, UniformAttributes) -> FragmentAttributes>,
pub bl... |
use sdl2::rect::{Point, Rect};
pub fn update_pos_x(r1: &mut Rect, r2: &Rect, x: i32) {
if x != 0 && r1.has_intersection(*r2) {
if x > 0 {
r1.set_right(r2.x);
} else {
r1.set_x(r2.right());
}
}
}
pub fn update_pos_y(r1: &mut Rect, r2: &Rect, y: i32) {
if y !... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtWidgets/qgraphicsitem.h
// dst-file: /src/widgets/qgraphicsitem.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main bloc... |
use clap::App;
mod config;
mod lib;
fn main() {
let _matches = App::new("cale")
.version("0.1")
.subcommand(App::new("now").about("shows current activity"))
.subcommand(App::new("today").about("shows today plan"))
.get_matches();
if let Some(_matches) = _matches.subcommand_matc... |
use winapi::um::winuser::{WS_VISIBLE, WS_DISABLED, WS_TABSTOP, WS_EX_CONTROLPARENT};
use std::cell::RefCell;
use std::rc::Rc;
use crate::win32::window_helper as wh;
use crate::win32::base_helper::check_hwnd;
use crate::{NwgError, Font, RawEventHandler, bind_raw_event_handler_inner, unbind_raw_event_handler};
use super... |
use std::collections::HashMap;
use crate::lexer::{self, LexValue, Lexer};
use crate::{Result, Error};
macro_rules! gimme {
($x:expr) => {
match $x {
Ok(e) => e,
Err(e) => return Err(e),
};
};
}
#[derive(Debug, Clone)]
pub(crate) enum BinaryOps {
Assign,
Add,
... |
fn what_is_it<T>(x: T) {
match x {
123 => println!("i32"),
123.0 => println!("f64"),
}
}
fn main() {
let x: Option<i32> = Some(5);
match x {
Some(x1) => println!("{}", x1),
None => println!("nothing"),
}
what_is_it(5);
what_is_it(5.55);
}
|
use std;
use std::path::PathBuf;
use itertools::Itertools;
use thiserror::Error;
use firefly_diagnostics::*;
use firefly_intern::Symbol;
use firefly_parser::SourceError;
use crate::lexer::{LexicalError, LexicalToken, TokenConvertError};
use crate::parser::ParserError;
use super::directive::Directive;
use super::dir... |
/// Asynchronously calls
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{sync_channel, Receiver, SyncSender, TryRecvError};
use std::thread;
use common::scene::Scene;
use common::simulation::LightSegment;
use tracer::job::{Job, JobProducer};
/// Each `Tracer` runs on its own thread. The `Simulator` interacts with... |
// 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 crate::{
common::*,
list::{Cons, List, Nil},
};
pub use base::*;
pub use ops::*;
mod base {
use super::*;
pub trait BitSet
where
Self: List,
{
}
impl<B, Tail> BitSet for Cons<B, Tail>
where
B: Bit,
Tail: BitSet,
{
}
impl BitSet for Nil {}
... |
//!
//! Channels lite
//!
pub mod channel_author;
pub mod channel_subscriber;
pub mod utils;
use iota_streams::app::transport::tangle::client::SendTrytesOptions;
///
/// Network Urls
///
/// Pre-defined iota network urls
///
pub enum Network {
/// Main network
///
Main,
/// Dev network
///
Dev... |
mod place;
mod stmt;
mod term;
mod operand;
mod value;
mod cast;
mod ratio;
use crate::{FunctionCtx, Error};
use lowlang_syntax as syntax;
use syntax::layout::TyLayout;
use cranelift_module::{Backend, Module, Linkage, FuncId, DataId};
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
use cranelift_cod... |
pub use gl::types::*;
use std::ffi::CString;
use std::{fs, ptr, str};
pub enum ShaderKind {
Vertex,
Fragment,
Geometry,
TessellationControl,
TessellationEvaluation,
Compute,
}
impl Default for ShaderKind {
fn default() -> Self {
ShaderKind::Vertex
}
}
#[derive(Default)]
pub st... |
use std::net::{TcpListener, ToSocketAddrs};
use std::path::Path;
use anyhow::{Context, Error};
use clap::{App, Arg};
use fehler::throws;
use threadpool::ThreadPool;
use isner::connection_handler::run;
use isner::file_handler::FileHandler;
const DEFAULT_HOST: &str = "127.0.0.1";
const DEFAULT_PORT: &str = "8000";
con... |
/*
* @lc app=leetcode.cn id=32 lang=rust
*
* [32] 最长有效括号
*
* https://leetcode-cn.com/problems/longest-valid-parentheses/description/
*
* algorithms
* Hard (25.50%)
* Total Accepted: 6.9K
* Total Submissions: 27K
* Testcase Example: '"(()"'
*
* 给定一个只包含 '(' 和 ')' 的字符串,找出最长的包含有效括号的子串的长度。
*
* 示例 1:
*
*... |
extern crate common;
extern crate serde_cbor;
pub mod cluster_api;
pub mod cluster_communication;
|
//! Data structures and functionality for `animanager` manifests.
#![deny(missing_docs,
missing_debug_implementations,
trivial_casts, trivial_numeric_casts,
unsafe_code)]
#![warn(dead_code)]
#![cfg_attr(test, feature(plugin))]
#![cfg_attr(test, plugin(clippy))]
#[macro_use]
extern crate log;
... |
use super::*;
mod with_async_false;
mod with_async_true;
mod with_invalid_option;
mod without_async;
fn async_option(value: bool, process: &Process) -> Term {
option("async", value, process)
}
fn option(key: &str, value: bool, process: &Process) -> Term {
process.tuple_from_slice(&[Atom::str_to_term(key), va... |
#[derive(Clone, Debug)]
pub struct LllPanel {
pub win: ncurses::WINDOW,
pub panel: ncurses::PANEL,
pub rows: i32,
pub cols: i32,
// coords (y, x)
pub coords: (usize, usize),
}
impl std::ops::Drop for LllPanel {
fn drop(&mut self) {
ncurses::del_panel(self.panel);
ncurses::de... |
pub mod androidsurfacecreateinfokhr;
pub mod descriptorupdatetemplateentrykhr;
pub mod displaymodecreateinfokhr;
pub mod displaymodeparameterkhr;
pub mod displaymodepropertieskhr;
pub mod displaypresentinfokhr;
pub mod displaysurfacecreateinfokhr;
pub mod formatproperties2khr;
pub mod imageformatproperties2khr;
pub mod... |
use serde_json::{Result, Value};
fn main() {
println!("Hello, world!");
}
|
use std::io::{self, Read};
use std::fs::File;
use crate::advent::Day;
pub fn read_input(d: Day) -> io::Result<String> {
let filename = match d {
1..=9 => format!("inputs/0{}.txt", d),
_ => format!("inputs/{}.txt",d),
};
let mut tmp = String::new();
let mut file = File::open(filename)... |
#[macro_export]
macro_rules! errno {
($errno_expr: expr, $error_msg: expr) => {{
let inner_error = {
let errno: Errno = $errno_expr;
let msg: &'static str = $error_msg;
(errno, msg)
};
let error =
$crate::Error::embedded(inner_error, Some(Error... |
//! Circuit Lab Simulation software, developed by Sleep Ibis LLC and funded by Northwestern University,
//! is circuit simulation software specifically designed to assist teachers in designing and
//! deploying circuit labs for beginning physics/engineering students.
//! The program runs on Windows, MacOs and Linux op... |
use std::sync::Arc;
fn main() {
let x = Arc::new(5);
let y = x.clone();
println!("{}", x);
println!("{}", y);
let a = Arc::new("hi");
let b = a.clone();
println!("{}", a);
println!("{}", b);
let h = Arc::new(1.5);
let i = h.clone();
println!("{}", h);
println!("... |
extern crate handlebars;
use crate::data::{VisualizationData, Visualizable, ExternalEvent, ResourceAccessPoint_extract};
use crate::svg_frontend::{code_panel, timeline_panel, utils};
use handlebars::Handlebars;
use serde::Serialize;
use std::cmp;
use std::collections::BTreeMap;
#[derive(Serialize)]
struct SvgData {
... |
// RISCV
#[cfg(feature = "board_qemu")]
pub const KERNEL_OFFSET: usize = 0xFFFF_FFFF_8000_0000;
#[cfg(feature = "board_qemu")]
pub const MEMORY_OFFSET: usize = 0x8000_0000;
#[cfg(feature = "board_qemu")]
pub const MEMORY_END: usize = 0x8800_0000; // TODO: get memory end from device tree
#[cfg(feature = "board_d1")]
p... |
use anyhow::Error;
use log::{error, info, warn};
use serde::{Deserialize, Serialize};
use std::result::Result;
use yew::format::Binary;
use yew::services::websocket::{WebSocketService, WebSocketStatus, WebSocketTask};
use yew::services::Task;
use yew::worker::*;
use yew::Callback;
use state_history::{Handler as ShipHa... |
pub use super::super::super::{Rocket, Stage, Engine};
use crate::runtime::renderer::views::deep_dive::dict::Fuel;
pub fn wiki() -> Rocket {
Rocket {
name: "Falcon 9 Block 5".to_string(),
stages: vec![
Stage {
name: "Booster".to_string(),
engines: vec![
... |
//! ```elixir
//! # label 1
//! # pushed to stack: ()
//! # returned from call: {:ok, document}
//! # full stack: ({:ok, document})
//! # returns: {:ok, body} | :error
//! body_tuple = Lumen.Web.Document.body(document)
//! Lumen.Web.Wait.with_return(body_tuple)
//! ```
use std::convert::TryInto;
use liblumen_alloc::e... |
/* This is a Rust program to read integer input from the user and print it */
use std::io;
use std::process;
// process::exit(1) function is available in std::process
fn main() {
let mut a = String::new();
println!("Enter a number:");
// Reading the input from user
io::stdin()
.read_line(&mut a)
.expect("Una... |
#![feature(test)]
extern crate test;
use std::hint::black_box;
use test::Bencher;
use wasabi_leb128::{ReadLeb128, WriteLeb128};
const VALUES: [i64; 13] = [
-100000, -10000, -1000, -100, -10, -1, 0, 1, 10, 100, 1000, 10000, 100000,
];
const ITERATIONS: usize = 10_000;
// Use the gimli.rs leb128 crate as a basel... |
use crate::io::read_bytes;
use std::io::Read;
use std::result::Result;
pub fn read_varint<R>(reader: &mut R) -> Result<u8, ()>
where R: Read,
{
let mut result = 0;
let mut pos = 0;
loop {
let bytes = read_bytes(reader, 1);
if bytes.is_empty() {
assert_ne!(pos, 0);
... |
#[macro_use]
extern crate lazy_static;
pub mod commands;
pub mod events;
pub mod jitqueue;
mod socket;
pub mod stats;
|
/*
* Firecracker API
*
* RESTful public-facing API. The API is accessible through HTTP calls on specific URLs carrying JSON modeled data. The transport medium is a Unix Domain Socket.
*
* The version of the OpenAPI document: 0.25.0
* Contact: compute-capsule@amazon.com
* Generated by: https://openapi-generator.t... |
use crate::Error;
use std::time::Duration;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ClientConfig {
pub(crate) bootstrap_servers: String,
pub(crate) request_timeout: Duration,
pub(crate) tcp_write_timeout: Duration,
pub(crate) tcp_read_timeout: Duration,
pub(crate) client_id: String,
}
imp... |
use std::num::Float;
use std::old_io::fs::File;
use std::old_io::stdio;
use image::*;
use vec::{ Vec3, rotate, dot };
use ray::{ Ray, Inter };
use material::Color;
use object::{ Object, Objects };
use light::{ Light, Lights };
pub struct Picture {
pub w: u32,
pub h: u32,
pub path: Path,
bounce: ... |
use gl::types::*;
// BUFFER TYPES
pub trait BufferType {
fn value() -> GLenum;
}
pub struct ElementArrayBuffer();
pub struct ArrayBuffer();
impl BufferType for ArrayBuffer {
fn value() -> GLenum {
gl::ARRAY_BUFFER
}
}
impl BufferType for ElementArrayBuffer {
fn value() -> GLenum {
gl... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtGui/qimage.h
// dst-file: /src/gui/qimage.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <= main ... |
use crate::impl_pnext;
use crate::prelude::*;
use std::os::raw::c_void;
use std::ptr;
#[repr(C)]
pub struct VkPhysicalDeviceProperties2KHR {
pub sType: VkStructureType,
pub pNext: *const c_void,
pub properties: VkPhysicalDeviceProperties,
}
impl VkPhysicalDeviceProperties2KHR {
pub fn new(properties:... |
/// Score of base matching algorithm(fzy, skim, etc).
pub type Score = i32;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum RankCriterion {
/// Matching score.
Score,
/// Char index of first matched item.
Begin,
/// Char index of last matched item.
End,
/// Length of raw text.
Len... |
use std::io::{self, Read};
fn parse_input(input: &String) -> Vec<i64> {
input
.split("\n")
.map(|line| line.parse::<i64>().unwrap())
.collect::<Vec<i64>>()
}
fn find_sum(sum: i64, numbers: &Vec<i64>, start: usize, end: usize) -> bool {
for i in numbers[start..end].iter() {
for j in numbers[start..... |
#[doc = "Reader of register SYNC"]
pub type R = crate::R<u32, super::SYNC>;
#[doc = "Writer for register SYNC"]
pub type W = crate::W<u32, super::SYNC>;
#[doc = "Register SYNC `reset()`'s with value 0"]
impl crate::ResetValue for super::SYNC {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Typ... |
use numeral::*;
use ops::*;
#[derive(Clone, PartialEq, Debug)]
pub enum Expr {
Time,
Num(Numeral),
UnExpr(UnOp, Box<Expr>),
BinExpr(Box<Expr>, BinOp, Box<Expr>),
}
|
// Copyright (c) 2021 ESRLabs
//
// 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 agre... |
pub struct Graph {
size: usize,
vertexes: Vec<u32>,
edges: Vec<Box<Vec<usize>>>,
}
#[allow(dead_code)]
impl Graph {
pub fn new(size: usize) -> Graph {
Graph {
size,
vertexes: vec![99; size],
edges: vec![Box::new(vec![]); size],
}
}
pub fn ad... |
use criterion::{criterion_group, criterion_main, Criterion};
use day11::{part1, part2};
fn part1_benchmark(c: &mut Criterion) {
c.bench_function("part1", move |b| b.iter(|| part1(9306, 300, 300)));
}
fn part2_benchmark(c: &mut Criterion) {
c.bench_function("part2", move |b| b.iter(|| part2(9306, 300)));
}
cr... |
extern crate log;
use std::env;
use std::process;
use std::time::Instant;
use anyhow::{anyhow, bail};
use firefly_compiler as driver;
use firefly_util::time;
pub fn main() -> anyhow::Result<()> {
// Handle unexpected panics by presenting a user-friendly bug report prompt;
// except when we're requesting deb... |
// Copyright 2011 Google Inc. All Rights Reserved.
// Copyright 2017 The Ninja-rs Project Developers. All Rights Reserved.
//
// 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:/... |
#[doc = "Reader of register CR0"]
pub type R = crate::R<u32, super::CR0>;
#[doc = "Writer for register CR0"]
pub type W = crate::W<u32, super::CR0>;
#[doc = "Register CR0 `reset()`'s with value 0"]
impl crate::ResetValue for super::CR0 {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
#![allow(unused_must_use)]
// use std::fs;
// use std::path;
fn main() {
// use std::env;
// let out_dir = env::var("OUT_DIR").unwrap();
// let path = path::Path::new(&out_dir);
// let deps_dir = path.parent().unwrap().parent().unwrap().parent().unwrap().join("deps");
// let new_name = deps_d... |
pub fn do_a_struct() {
#[derive(Debug)]
struct MyStruct {
foo: String,
bar: bool,
tup: (u32, u32),
}
let a_struct = MyStruct {
foo: String::new(),
bar: false,
tup: (7, 8),
};
println!("I made a struct: {:?}.", a_struct.foo);
}
pub fn generics() {... |
//! # Special Topics
//!
//! These are short recipes for accomplishing common tasks.
//!
//! - [Why `winnow`?][why]
//! - Formats:
//! - [Elements of Programming Languages][language]
//! - [Arithmetic][arithmetic]
//! - [s-expression][s_expression]
//! - [json]
//! - [INI][ini]
//! - [HTTP][http]
//! - Spec... |
extern crate glium;
extern crate runic;
const FRAG: &str = include_str!("fancy.frag");
use glium::*;
use glutin::*;
use glium::uniforms::*;
fn main() {
// Create the events loop, and display as per normal
let mut events_loop = EventsLoop::new();
let window = glutin::WindowBuilder::new()
.with_di... |
use unicycle::pin_slab::PinSlab;
struct Foo(u32);
struct Bar(Vec<u32>);
#[global_allocator]
static ALLOCATOR: checkers::Allocator = checkers::Allocator::system();
#[checkers::test]
fn test_pin_slab_memory_leak() {
let mut copy = PinSlab::new();
copy.insert(Foo(42));
let mut non_copy = PinSlab::new();
... |
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use std::fmt::{Display, Formatter, Result};
/// This struct represents the strongly typed equivalent of the json body
/// from vsock related requests.
#[derive(Clone, Debug, Deserialize, PartialEq, Serial... |
// Copyright (c) 2016 The Rouille 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. All files in the project carrying such
// notice may not be co... |
use futures::TryFutureExt;
use log::*;
use serde::Serialize;
use sqlx::pool::PoolConnection;
use sqlx::{Connect, Connection};
use tide::{Error, IntoResponse, Request, Response, ResultExt};
use crate::api::model::*;
use crate::api::util::*;
use crate::db::model::*;
use crate::db::Db;
#[derive(Serialize)]
struct Profil... |
//! Tests auto-converted from "sass-spec/spec/parser/interpolate/06_space_list_complex"
#[allow(unused)]
use super::rsass;
#[allow(unused)]
use rsass::precision;
/// From "sass-spec/spec/parser/interpolate/06_space_list_complex/01_inline"
#[test]
fn t01_inline() {
assert_eq!(
rsass(
".result {\... |
//use: cargo run --example rpi
extern crate linux_embedded_hal as hal;
extern crate pi_rmf69;
use hal::spidev::SpidevOptions;
use hal::Spidev;
use hal::Pin;
use hal::sysfs_gpio::Direction;
use hal::Delay;
use pi_rmf69::{radio, FreqencyBand};
fn main() {
let cs = Pin::new(8);
cs.export().unwrap();
cs.set_... |
use join::Join;
use proconio::input;
fn main() {
input! {
n: usize,
m: usize,
edges: [(usize, usize); m],
};
let mut adj = vec![vec![]; n + 1];
for (a, b) in edges {
adj[a].push(b);
adj[b].push(a);
}
for i in 1..=n {
adj[i].sort();
if ad... |
use crate::{Manager, Batteries, Battery};
/// Creates new batteries manager instance.
///
/// Returns opaque pointer to it. Caller is required to call [battery_manager_free](fn.battery_manager_free.html)
/// to properly free memory.
#[no_mangle]
pub extern fn battery_manager_new() -> *mut Manager {
Box::into_raw(B... |
use crate::compiling::v1::assemble::prelude::*;
/// Compile an expression.
impl Assemble for ast::ExprIndex {
fn assemble(&self, c: &mut Compiler<'_>, needs: Needs) -> CompileResult<Asm> {
let span = self.span();
log::trace!("ExprIndex => {:?}", c.source.source(span));
let guard = c.scopes... |
#![allow(clippy::derive_partial_eq_without_eq)]
#![allow(clippy::needless_late_init)]
#[doc(hidden)]
#[macro_use]
pub mod macros;
#[doc(hidden)]
pub mod gen_params_in;
#[doc(hidden)]
pub mod to_token_fn;
#[doc(hidden)]
pub mod datastructure;
#[doc(hidden)]
pub mod utils;
#[doc(hidden)]
pub mod parse_utils;
#[doc... |
pub mod command;
pub mod deploy;
pub mod ls_stages;pub mod run_stage;
|
// Copyright 2017 Dasein Phaos aka. Luxko
//
// 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 a... |
mod audio;
use audio::{Audio, Msg};
extern crate gl;
extern crate glfw;
extern crate gouache;
extern crate nfd;
extern crate portaudio;
extern crate sendai;
use gouache::*;
use sendai::*;
use std::rc::Rc;
#[derive(Clone)]
pub struct Song {
tracks: usize,
length: usize,
samples: Vec<Vec<f32>>,
notes... |
use futures::Future;
use influxdb_iox_client::connection::Connection;
use snafu::prelude::*;
mod build_catalog;
mod parquet_to_lp;
mod print_cpu;
mod schema;
mod skipped_compactions;
mod wal;
#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(context(false))]
#[snafu(display("Error in schema subcommand: {}", so... |
pub use VkImageCreateFlags::*;
#[repr(u32)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum VkImageCreateFlags {
VK_IMAGE_CREATE_SPARSE_BINDING_BIT = 0x0000_0001,
VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 0x0000_0002,
VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 0x0000_0004,
VK_IMAGE_CREATE_MUTABLE_FORMAT_B... |
use glium::Surface;
use glium::backend::glutin::glutin::event::{Event, WindowEvent};
fn main() {
println!("SuperLuminal Performance Enabled: {}", superluminal_perf::enabled());
// Set name of current thread for superluminal profiler
superluminal_perf::set_current_thread_name("Main Thread");
superlumi... |
#[macro_use] extern crate log;
extern crate structopt;
use structopt::StructOpt;
extern crate humantime;
extern crate embedded_spi;
use embedded_spi::hal::{HalInst, HalDelay};
extern crate radio;
use radio::{State as _};
extern crate radio_sx128x;
use radio_sx128x::prelude::*;
extern crate pcap_file;
mod option... |
use scanner_proc_macro::insert_scanner;
#[insert_scanner]
fn main() {
let (n, m) = scan!((usize, usize));
let mut a = scan!(u32; n);
let b = scan!(u32; m);
for b in b {
if let Some(index) = a.iter().position(|&a| a == b) {
a.swap_remove(index);
} else {
println!... |
#[doc = "Reader of register DC3"]
pub type R = crate::R<u32, super::DC3>;
#[doc = "Reader of field `PWM0`"]
pub type PWM0_R = crate::R<bool, bool>;
#[doc = "Reader of field `PWM1`"]
pub type PWM1_R = crate::R<bool, bool>;
#[doc = "Reader of field `PWM2`"]
pub type PWM2_R = crate::R<bool, bool>;
#[doc = "Reader of field... |
use crate::*;
pub fn load_program(state: &mut State, path: &str) {
let f = std::fs::read(path).expect("Couldn't read file");
let mut i = 0;
while i < f.len() {
state.memory[i + 0x200] = f[i];
state.memory[i + 0x201] = f[i + 1];
i += 2;
}
}
|
use std::fmt::Debug;
use async_trait::async_trait;
use crate::{
cache::Cacheable,
errors::CheckedError,
event_status::EventStatus,
};
#[derive(Default)]
pub struct CompletedEvents {
pub identities: Vec<(Vec<u8>, EventStatus)>,
}
impl CompletedEvents {
pub fn clear(&mut self) {
self.ident... |
use super::code::ExternCode;
use crate::ast;
use crate::code::{CodeData, DataFromIR};
use crate::context::CloneSafe;
use crate::error::Result;
use crate::graph::RefGraph;
use crate::seed::Seed;
use crate::tensor::IRData;
use crate::variable::CloneValue;
#[derive(Debug, PartialEq)]
pub struct ExternIR {
pub ty: ast... |
#![allow(dead_code)]
/// Buat latihan tapi masih error saat dikompile
///
/// agar bisa dikompile maka pake pattern matching pada
/// parameter function pd kasus ini adalah `xs`
///
/// macro `#![allow(dead_code)]` mengijinkan kode yang tidak digunakan tanpa peringatan
///
struct NonCopy;
// kode lama:
// `... |
//! Interrupt description and set-up code.
use core::fmt;
use bits64::segmentation::SegmentSelector;
use shared::descriptor::*;
use shared::paging::VAddr;
use shared::PrivilegeLevel;
/// An interrupt gate descriptor.
///
/// See Intel manual 3a for details, specifically section "6.14.1 64-Bit Mode
/// IDT" and "Figu... |
//! Type definitions and `dodrio::Render` implementation for a collection of
//! todo items.
use crate::controller::Controller;
use crate::todo::{Todo, TodoActions};
use crate::visibility::Visibility;
use crate::{keys, utils};
use fxhash::FxHashMap;
use dodrio::{bumpalo, Node, Render, RenderContext, RootRender, VdomWe... |
use http::header::HeaderName;
use structopt::StructOpt;
use tonic::body::BoxBody;
use tonic::client::GrpcService;
use tonic::transport::Server;
use tonic::transport::{Identity, ServerTlsConfig};
use tonic_interop::{server, MergeTrailers};
#[derive(StructOpt)]
struct Opts {
#[structopt(name = "use_tls", long)]
... |
use crate::error::{Error, LexerError, LexerErrorKind};
use crate::iter::CharsWithPosition;
use crate::position::Position;
use std::char;
use std::str::Chars;
use TokenKind as TK;
#[derive(Debug, PartialEq)]
pub struct Token {
pub kind: TokenKind,
pub position: Position,
}
#[derive(Debug, PartialEq)]
pub enum ... |
#[doc = "Reader of register PLL1FRACR"]
pub type R = crate::R<u32, super::PLL1FRACR>;
#[doc = "Writer for register PLL1FRACR"]
pub type W = crate::W<u32, super::PLL1FRACR>;
#[doc = "Register PLL1FRACR `reset()`'s with value 0"]
impl crate::ResetValue for super::PLL1FRACR {
type Type = u32;
#[inline(always)]
... |
use super::super::super::exec::vm::Inst;
#[derive(Debug, Clone)]
pub struct AttributeInfo {
pub attribute_name_index: u16,
pub attribute_length: u32,
pub info: Attribute,
}
#[derive(Debug, Clone)]
pub struct CodeAttribute {
pub max_stack: u16,
pub max_locals: u16,
pub code_length: u32,
pub... |
use serde_json::json;
use actix_web::http::StatusCode;
mod common;
#[actix_rt::test]
async fn get_documents_from_unexisting_index_is_error() {
let mut server = common::Server::with_uid("test");
let (response, status) = server.get_all_documents().await;
assert_eq!(status, StatusCode::NOT_FOUND);
assert... |
// Definition for singly-linked list.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>
}
impl ListNode {
#[inline]
fn new(val: i32) -> Self {
ListNode {
next: None,
val
}
}
}
struct Solution;
impl So... |
//! This is used as the `init_fn` for `Scheduler::spawn_module_function_arguments`, as the spawning
//! code can only pass at most 1 argument and `erlang:apply/3` takes three arguments
use anyhow::anyhow;
use liblumen_alloc::erts::exception::{badarity, Exception};
use liblumen_alloc::erts::process::ffi::ErlangResult;
... |
use crate::prelude::*;
use std::os::raw::c_void;
use std::ptr;
#[repr(C)]
#[derive(Debug)]
pub struct VkDescriptorPoolCreateInfo {
pub sType: VkStructureType,
pub pNext: *const c_void,
pub flags: VkDescriptorPoolCreateFlagBits,
pub maxSets: u32,
pub poolSizeCount: u32,
pub pPoolSizes: *const V... |
use tokio::sync::mpsc;
use std::net::SocketAddr;
use std::time::Duration;
use tokio::time::{Instant, timeout_at};
use super::{Event, SendLANEvent, log_err, log_warn};
use super::frame::{ForwarderFrame, Parser};
struct PeerInner {
rx: mpsc::Receiver<Vec<u8>>,
addr: SocketAddr,
event_send: mpsc::Sender<Event... |
#[cfg(not(target_os = "windows"))]
pub use std::os::unix::ffi::OsStrExt;
#[cfg(target_os = "windows")]
use std::ffi::OsStr;
#[cfg(target_os = "windows")]
pub trait OsStrExt {
fn from_bytes(b: &[u8]) -> &Self;
fn as_bytes(&self) -> &[u8];
}
#[cfg(target_os = "windows")]
impl OsStrExt for OsStr {
fn from_b... |
pub struct Solution;
impl Solution {
pub fn is_valid_serialization(preorder: String) -> bool {
let mut depth: i32 = 1;
for value in preorder.split(',') {
if depth == 0 {
return false;
}
if value == "#" {
depth -= 1;
} e... |
use scanner_proc_macro::insert_scanner;
#[insert_scanner]
fn main() {
let (n, k) = scan!((usize, usize));
let a = scan!(usize; n);
const B: usize = 40;
let mut count = vec![vec![0; n]; B];
for i in 0..n {
count[0][i] = a[i];
}
for b in 0..(B - 1) {
for i in 0..n {
... |
// This file is part of linux-epoll. 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/linux-epoll/master/COPYRIGHT. No part of linux-epoll, including this file, may be copied, modified, propagated, or distri... |
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::FAULTVAL {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.