text stringlengths 8 4.13M |
|---|
pub struct Solution;
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: List,
}
type List = Option<Box<ListNode>>;
impl Solution {
pub fn add_two_numbers(l1: List, l2: List) -> List {
let mut head = None;
let mut current = &mut head;
let mut l1 = ... |
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
#[allow(deprecated)]
fn read_line_from_stdin() -> String {
let mut buffer = String::new();
std::io::stdin().read_line(&mut buffer).unwrap();
buffer.trim_right().to_owned()
}
#[allow(dead_code)]
#[allow(deprecated)]
fn parse_line_to_single<T>(... |
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::MICSTATUS {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = "Possible values of the field `MICSTATUS`"]
#[der... |
//! Definitions of security and leakage measures.
//!
//! In the documentation, we write R* to indicate the Bayes risk,
//! and G to indicate the error of random guessing (i.e., 1 - max priors).
//!
//! # References
//! [1] M. S. Alvim et al. "Additive and multiplicative notions of leakage,
//! and their capacitie... |
use console::{strip_ansi_codes, AnsiCodeIterator};
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
use std::{fs, path::Path};
pub fn parse_throughput(c: &mut Criterion) {
let session_log_path = Path::new("tests")
.join("data")
.join("sample_zellij_session.log");... |
//! This module contains algebra-based calculations for optimizing replica assignmnt.
use crate::{Error, Result};
use nalgebra::{DMatrix, DVector};
use ordered_float::OrderedFloat;
use rand::seq::SliceRandom;
use rand::Rng;
use std::cmp::Reverse;
use std::collections::HashSet;
use std::iter::repeat;
/// It consists o... |
/*
By default, random numbers are generated with uniform distribution.
To generate numbers with other distributions you instance a distribution, then
sample from that distribution using `Independent Sample::ind_sample
with help of a random-number generator rand::Rng.
An example using the Normal distribution is shown ... |
import middle::trans;
import trans::decl_cdecl_fn;
import middle::trans_common::T_f32;
import middle::trans_common::T_f64;
import middle::trans_common::T_fn;
import middle::trans_common::T_bool;
import middle::trans_common::T_i8;
import middle::trans_common::T_i32;
import middle::trans_common::T_int;
import middle::tr... |
/*
* Copyright 2020 Fluence Labs Limited
*
* 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 a... |
use super::async_connection::{BrokerConnection, Managed};
use crate::Error;
use log::{debug, error, info, log_enabled};
use rskafka_proto::{apis::metadata::MetadataRequestV2, BrokerId, KafkaRequest};
use std::collections::HashMap;
use tokio::sync::{Mutex, MutexGuard};
pub struct AsyncClusterClient {
conns: HashMap... |
#[doc = "Reader of register FMC_PATT"]
pub type R = crate::R<u32, super::FMC_PATT>;
#[doc = "Writer for register FMC_PATT"]
pub type W = crate::W<u32, super::FMC_PATT>;
#[doc = "Register FMC_PATT `reset()`'s with value 0xfcfc_fcfc"]
impl crate::ResetValue for super::FMC_PATT {
type Type = u32;
#[inline(always)]... |
use juniper::GraphQLInterface;
#[derive(GraphQLInterface)]
#[graphql(for = Node2Value)]
struct Node1 {
id: String,
}
#[derive(GraphQLInterface)]
#[graphql(impl = Node1Value, for = Node3Value)]
struct Node2 {
id: String,
}
#[derive(GraphQLInterface)]
#[graphql(impl = Node2Value)]
struct Node3 {
id: String... |
use crate::{
node, BrokerRequest, Dispatch, NodeId, NodeQueue, NodeQueueEntry, NodeRequest, NodeResponse,
NodeStatus, Query, QueryLog, QueryRequest, QueryResponse, RequestId, ShardId,
};
use std::cell::RefCell;
use std::cmp::Reverse;
use std::collections::{hash_map::Entry, HashMap};
use std::rc::Rc;
use std::t... |
use cid::Cid;
use futures::future::{pending, select, Either, FutureExt};
use futures::future::{AbortHandle, Abortable};
use ipfs::Node;
use tokio::{
task,
time::{sleep, timeout},
};
use std::{
convert::TryFrom,
future::Future,
time::{Duration, Instant},
};
async fn bounded_retry<Fun, Fut, F, T>(
... |
use time::PreciseTime;
use std::fs::File;
use std::io::Read;
use std::fmt::Display;
pub fn load_input(name: &str) -> String {
let mut buf = String::with_capacity(2048);
match File::open(format!("./input/{}.txt", name)) {
Ok(mut file) => {
file.read_to_string(&mut buf).unwrap();
}
... |
use input_i_scanner::InputIScanner;
use join::Join;
use std::collections::HashSet;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
macro_rules! scan {
(($($t: ty),+)) => {
($(scan!($t)),+)
};
($t: ty) => {
_i_i.sca... |
// 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.
use failure::Error;
use fidl_fuchsia_sys::FileDescriptor;
use fuchsia_async as fasync;
use fuchsia_component::client::{launch_with_options, launcher, Launc... |
#[doc = "Reader of register PSR"]
pub type R = crate::R<u32, super::PSR>;
#[doc = "Writer for register PSR"]
pub type W = crate::W<u32, super::PSR>;
#[doc = "Register PSR `reset()`'s with value 0"]
impl crate::ResetValue for super::PSR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
// Copyright 2017 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 crate::ToHana;
use serde::ser::Error as _;
use std::str::FromStr;
use time::{format_description::FormatItem, macros::format_description, Date};
/// Wraps a `time::Date`, helps with serializing from and deserializing into `time::Date`.
///
/// # Example for serialization
/// ```rust, no_run
/// use hdbconnect::ToHa... |
#[macro_use]
extern crate graphic_backend;
extern crate image;
use std::fs::File;
use std::path::Path;
use image::GenericImage;
use graphic_backend::*;
static VS_SRC: &'static str = r#"
#version 150
in vec3 position;
in vec2 coord;
out vec2 coord0;
void main() {
coord0 = coord;
g... |
use std::io::{Read, Result as IOResult, Error as IOError, ErrorKind};
use crate::{PrimitiveRead, StringRead};
use nalgebra::Vector3;
use crate::lump_data::leaf::ColorRGBExp32;
pub struct StaticPropDict {
pub names: Box<[String]>,
pub leaves: Box<[u16]>,
pub props: Box<[StaticProp]>
}
impl StaticPropDict {
pub... |
use std::collections::HashMap;
use std::fs::File;
use std::io::{self, BufReader, Read};
use std::path::{Path, PathBuf};
#[cfg(feature = "handlebars")]
use handlebars::TemplateRenderError;
#[cfg(feature = "reqwest")]
use reqwest::{Url, UrlError};
use toml::{self, de};
use quick_error::ResultExt;
use var_os_or;
#[cfg(f... |
use std::marker::PhantomData;
use futures::future::{ok, FutureResult};
use futures::IntoFuture;
use crate::{Apply, IntoTransform, Service, Transform};
pub struct FnTransform<F, S, In, Out, Err>
where
F: FnMut(In, &mut S) -> Out + Clone,
Out: IntoFuture,
{
f: F,
_t: PhantomData<(S, In, Out, Err)>,
}
... |
#[doc = "Writer for register RGCFR"]
pub type W = crate::W<u32, super::RGCFR>;
#[doc = "Register RGCFR `reset()`'s with value 0"]
impl crate::ResetValue for super::RGCFR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Write proxy for field `COF0`"]
pub struct... |
use crate::stmt::Stmt;
use crate::utils;
use crate::env::Env;
use crate::val::Val;
#[derive(Debug, Clone,PartialEq)]
pub(crate) struct Block {
pub(crate) stmts: Vec<Stmt>,
}
impl Block {
pub(super) fn new(s: &str) -> Result<(&str, Self), String> {
let s = utils::tag("{", s)?;
let (s, _) = util... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Comparator status register"]
pub comp1_sr: COMP1_SR,
#[doc = "0x04 - Comparator interrupt clear flag register"]
pub comp1_icfr: COMP1_ICFR,
#[doc = "0x08 - Comparator option register"]
pub comp1_or: COMP1_OR,
#[... |
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
let mut next = || { iter.next().unwrap() };
input_inner!{next, $($r)*}
};
($($r:tt)*) => {
let stdin = std::io::stdin();
... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[repr(transparent)]
#[doc(hidden)]
pub struct INotePlacementChangedPreviewEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for INotePlacementChangedPrevie... |
#[doc = "Reader of register PP"]
pub type R = crate::R<u32, super::PP>;
#[doc = "Reader of field `WAKENC`"]
pub type WAKENC_R = crate::R<bool, bool>;
#[doc = "Reader of field `TAMPER`"]
pub type TAMPER_R = crate::R<bool, bool>;
impl R {
#[doc = "Bit 0 - Wake Pin Presence"]
#[inline(always)]
pub fn wakenc(&s... |
// Copyright (C) 2019, Cloudflare, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list... |
// Copyright 2018 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.
use serde_derive::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum NetAddress {
V4([u8; 4], u32),
V6([u8; 16], u... |
#![warn(missing_docs)]
//! Main fie for Migrate
//! A simple database migrator written in Rust
#[macro_use]
extern crate log;
extern crate clap;
extern crate ini;
extern crate postgres;
mod commands;
mod models;
use models::command::Command;
//use std::io::{self, Write};
use clap::{Arg, App, SubCommand};
fn main()... |
use proconio::input;
use proconio::marker::Usize1;
fn main() {
input! {
n: usize,
mut p: [Usize1; n],
};
let mut ans = Vec::new();
macro_rules! swap_a {
($i: expr) => {
assert!($i + 1 < n);
p.swap($i, $i + 1);
ans.push(('A', $i));
};... |
//! Parsing of s-expressions.
use asexp::{Atom, Sexp};
use cell_gc::HeapSession;
use std::rc::Rc;
use vm::{Pair, Value};
/// Top level entry point to s-expression parsing. Takes a source string and
/// returns a `Value` which can contain `Pair`s allocated in the GC heap.
pub fn parse<'h>(hs: &mut HeapSession<'h>, sou... |
#![feature(test)]
extern crate test;
use std::collections::HashMap;
use test::{Bencher, black_box};
#[derive(Debug, PartialEq)]
pub enum JsonValue {
Null,
Bool(bool),
Str(String),
Num(f64),
Array(Vec<JsonValue>),
Object(HashMap<String,JsonValue>)
}
#[bench]
fn pom(b: &mut Bencher) {
let ... |
pub struct Solution;
impl Solution {
pub fn remove_invalid_parentheses(s: String) -> Vec<String> {
Solver::new(s).solve()
}
}
struct Solver {
bytes: Vec<u8>,
a: Vec<i32>, // a[i] equals to the number of extra '('s in bytes[i..]
b: Vec<i32>, // b[i] equals to the number of extra ')'s in byt... |
use serde::{Deserialize, Serialize};
#[repr(u8)]
#[derive(Serialize, Deserialize, Debug)]
pub enum ResourceAction {
Get,
Set,
Update,
}
#[derive(Serialize, Deserialize, Debug)]
pub enum ResourceType {
Nodes,
}
pub trait ClusterApi {
fn cluster_request(&self, req: ClusterRequest);
}
#[derive(Seria... |
use super::super::batch::{Batch, BatchConfig, BatchError, BatchSettings, BatchSize, PushResult};
#[derive(Clone)]
pub struct VecBuffer<T> {
batch: Vec<T>,
max_events: usize,
}
impl<T> VecBuffer<T> {
pub fn new(settings: BatchSize<Self>) -> Self {
Self::new_with_max(settings.events)
}
fn n... |
use crate::crawlers::get_html;
use scraper::{Html, Selector};
use crate::proxy_addr::ProxyAddr;
pub async fn crawl() -> Result<Vec<ProxyAddr>, anyhow::Error> {
let url = "https://www.kuaidaili.com/free/inha/";
let page = 5usize;
let mut ret = vec![];
for i in 1..=page {
let url = format!("{}{}", url, i);
let h... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Access control register"]
pub acr: ACR,
_reserved_1_bank1: [u8; 96usize],
_reserved2: [u8; 156usize],
#[doc = "0x100 - Access control register"]
pub acr_: ACR_,
_reserved_3_bank2: [u8; 96usize],
}
impl RegisterB... |
use libc;
use crate::x::*;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct clistcell {
pub data: *mut libc::c_void,
pub previous: *mut clistcell,
pub next: *mut clistcell,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct clist {
pub first: *mut clistcell,
pub last: *mut clistcell,
pub count: libc:... |
// Copyright (c) 2020 DarkWeb Design
//
// 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... |
use vgtk::lib::gtk::*;
use vgtk::{gtk, Component, Callback, UpdateAction, VNode};
use super::model::{Task};
#[derive(Clone, Debug, Default)]
pub struct TaskRow {
pub task: Task,
pub on_changed: Callback<()>,
pub on_deleted: Callback<()>,
}
#[derive(Clone, Debug)]
pub enum TaskMessage {
Changed,
De... |
//asl.rs arithmetic shift left
use super::flags::*;
use super::shift_addr::*;
use crate::memory::*;
pub fn asl_accumulator(
pc_reg: &mut u16,
accumulator: &mut u8,
status_flags: &mut u8,
cycles_until_next: &mut u8,
) {
if (*accumulator & 0x80) != 0 {
set_carry(status_flags);
} else {
... |
// 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 ... |
#[allow(dead_code)]
mod encryption;
#[cfg(test)]
mod tests {
use crate::encryption::RSAEncryptionManager;
const PRIV_KEY: &str = r#"
-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEAn60JHWwejvHSmnN2sTbk511wgYj9TdTroS+buMIKjAtW4UNq
JTEuSc3whZKH7qzLYWa2VLctG8Yx0N2aVwZc7kWyyq0QHEdDaeNA/IuSd7KJaHw/
dOegXwWjMkdnJcLY... |
use regex::Regex;
mod utils;
fn main() {
let data = utils::load_input("./data/day_2.txt").unwrap();
let re =
Regex::new(r"(?P<min>\d+)-(?P<max>\d+) (?P<letter>[a-z]): (?P<password>[a-z]*)").unwrap();
let mut valid_password_count = 0;
for cap in re.captures_iter(&data) {
let letter_occ... |
// 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 ... |
//!
pub use crate::raw_int::sign::{Signed, Unsigned};
use crate::raw_int::RawInt;
/// Structure for creating wide integer
///
/// # Template parameters
///
/// T should be a based type for representing number. It is should be unsigned for correct overflow
/// (u8, u16, u32, u64).
///
/// S for representing signed or u... |
use tetris::{Tetris, TetrisBuilder, Randomizer, TetrisAction, MoveDirection, RotationDirection};
use rand::{Rng, rngs::ThreadRng};
trait Renderable {
fn render(&self);
}
impl Renderable for Tetris {
fn render(&self) {
let mut playfield = self.playfield.borrow().clone();
for _ in 0..self.dim.width + 2 {
... |
use grass_formats::{FileFormat, FileKind};
use quote::quote;
use std::fmt::{Debug, Formatter, Result as FmtResult};
use syn::{
parenthesized,
parse::{Parse, ParseStream},
punctuated::Punctuated,
Error, Ident, LitStr, Result, Token,
};
use super::{open_impl, CodeGenerator, CodeGeneratorContext, Operator... |
use regex::Regex;
use std::collections::HashMap;
use std::error::Error;
use std::io::Read;
use std::fs::File;
#[derive(Clone, Debug)]
enum Wire {
Value(u16),
VAnd(u16, String),
And(String, String),
Or(String, String),
LShift(String, u8),
RShift(String, u8),
Not(String),
Id(String),
}
f... |
// The microcall project is under MIT License.
// Copyright (c) 2018 Tzu-Chiao Yeh
use std::collections::HashMap;
use std::error::Error;
use std::sync::{Arc, RwLock};
use futures;
use futures::{Future, Stream};
use hyper;
use hyper::{Body, Client, Get, Post, Request, Response, StatusCode};
use hyper::header::{Content... |
use spec::{self, Laziness, SpecBuilder, TypeSpec, TypeSum};
use weedle::common::Identifier;
use weedle::types::*;
use weedle::*;
fn nullable<T: std::fmt::Debug>(src: &MayBeNull<T>, dst: TypeSpec) -> spec::Type {
if src.q_mark.is_some() {
dst.optional()
.unwrap_or_else(|| panic!("This type could... |
mod repr;
mod cost;
use std::collections::{HashMap, HashSet, BTreeMap};
use std::error::Error;
use std::fmt::Display;
use std::io::Write;
use std::ops::Add;
use crate::cost::DVValue;
use crate::repr::{HtmlFormula, DistanceCalculationLine, HtmlFiles};
use std::path::Path;
#[derive(Debug, Clone)]
struct Neighbor<W: Ord... |
#[path = "cancel_timer_2/with_reference_timer_reference.rs"]
mod with_reference_timer_reference;
test_stdout!(without_reference_timer_reference_errors_badarg, "{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, ... |
use std::fs;
use std::collections::HashMap;
fn get_num_questions(s: &String) -> usize {
let mut num = 0;
let mut map: HashMap<char, i32> = HashMap::new();
for line in s.trim().split("\n") {
for c in line.chars() {
*map.entry(c).or_insert(0) += 1;
}
}
for (_, n) in &map {... |
use crate::{Error, SignatureScheme};
use algebra::{
bytes::ToBytes,
fields::{Field, PrimeField},
groups::Group,
to_bytes, ToConstraintField, UniformRand,
};
use digest::Digest;
use rand::Rng;
use std::{
hash::Hash,
io::{Result as IoResult, Write},
marker::PhantomData,
};
pub mod field_based... |
use std::thread;
use std::process::{Command, Stdio};
use std::io::{self, Write};
#[derive(Debug)]
enum CmdType {
Nginx,
Php,
Redis,
}
struct Cmd {
name: &'static str,
env: &'static str,
args: Vec<&'static str>,
cmd_type: CmdType,
}
impl Cmd {
fn run(&self) {
println!("{}", format!("Memu... |
use std::{collections::BTreeMap, ops::Range};
use proconio::{input, marker::Usize1};
trait Seq {
type Output;
fn len(&self) -> usize;
fn push_front(&mut self, i: usize);
fn push_back(&mut self, i: usize);
fn pop_front(&mut self, i: usize);
fn pop_back(&mut self, i: usize);
fn output(&self... |
//! # WAL
//!
//! This crate provides a local-disk WAL for the IOx ingestion pipeline.
#![deny(rustdoc::broken_intra_doc_links, rust_2018_idioms)]
#![warn(
missing_copy_implementations,
missing_debug_implementations,
clippy::explicit_iter_loop,
clippy::use_self,
clippy::clone_on_ref_ptr,
unused... |
//! Day 23
use std::{collections::HashMap, hash::Hash};
use itertools::{iterate, Itertools};
use num_traits::{FromPrimitive, Num, NumAssignOps};
trait Solution {
fn part_1(&self) -> String;
fn part_2(&self) -> u32;
}
impl Solution for &str {
fn part_1(&self) -> String {
let mut game = Game::new(p... |
use crate::token::token::{Token, TokenType};
use crate::parser::error::ParseError;
pub struct TokenStream<'a> {
pub tokens: &'a [Token],
pub size: usize,
pub position: usize
}
impl<'a> TokenStream<'a> {
pub fn new(vec: &'a Vec<Token>) -> TokenStream<'a> {
let tok_slice: &[Token] = vec.as_slice... |
#![no_std]
#![no_main]
psp::module!("PSP-RUST TEST", 1, 0);
mod gfx;
use psp::sys::{SceCtrlData, CtrlButtons, CtrlMode};
pub fn psp_main(){
psp::enable_home_button();
// psp::dprintln!("Hello world from Rust!");
unsafe{
psp::sys::sceCtrlSetSamplingCycle(0);
psp::sys::sceCtrlSetSamplingMo... |
//! # Succinct.rs
//!
//! Succinct.rs is a library to provide succinct data structures with _simple API_ and _high performance_.
//!
//! See [README](https://github.com/laysakura/succinct.rs/blob/master/README.md) for more about usage and features.
pub use bit_string::BitString;
pub use louds::{Louds, LoudsBuilder, Lo... |
// export through sliceable module, not slice.
use crate::{
builtins::{int::PyInt, slice::PySlice},
PyObject, PyResult, VirtualMachine,
};
use malachite_bigint::BigInt;
use num_traits::{Signed, ToPrimitive};
use std::ops::Range;
pub trait SliceableSequenceMutOp
where
Self: AsRef<[Self::Item]>,
{
type I... |
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct Chat {
#[serde(default)]
pub id: u64,
#[serde(alias = "participantIds")]
pub participant_ids: [u64; 2],
}
#[derive(PartialEq, Eq, Serialize, Deserialize, Clone, Debug)]
pub struct Message {
pub i... |
use crate::adapters::VIOLATIONS_CAP;
use crate::comms::CommsVerifier;
use crate::manager::AccountStatus;
use crate::primitives::{
Account, AccountType, Challenge, ChallengeStatus, NetworkAddress, Result, Signature,
};
use crate::Database;
use schnorrkel::sign::Signature as SchnorrkelSignature;
use std::fmt;
const ... |
use super::Role;
use anyhow::Result;
use serde::{Deserialize, Serialize};
/// A module registration.
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
#[must_use]
#[repr(C)]
pub struct Registration {
/// The role of the module.
///
/// The host will also define this, and the registration will ... |
use crate::headers::ContentLength;
use crate::headers::ContentType;
use crate::http::{bad_request, body_from_stream, response, Request, Result};
use crate::random::rng;
use futures::prelude::*;
use rand::Rng;
use serde_derive::Deserialize;
use std::iter::ExactSizeIterator;
#[derive(Deserialize)]
pub struct BytesQueryP... |
mod fs_helper;
mod parser;
extern crate dirs;
use clap::Clap;
use clipboard_win::{formats, get_clipboard, set_clipboard};
use fs_helper::AppContext;
/*
private String myString;
/**
* javadoc
*/
public int myNumber;
@DynamoDBRangeKey(attributeName = "SK")
protected Currency curr;
//comment... |
#[cfg(feature = "Win32_Security_AppLocker")]
pub mod AppLocker;
#[cfg(feature = "Win32_Security_Authentication")]
pub mod Authentication;
#[cfg(feature = "Win32_Security_Authorization")]
pub mod Authorization;
#[cfg(feature = "Win32_Security_ConfigurationSnapin")]
pub mod ConfigurationSnapin;
#[cfg(feature = "Win32_Sec... |
use futures::FutureExt;
use influxdb_iox_client::table::generated_types::{Part, PartitionTemplate, TemplatePart};
use test_helpers_end_to_end::{maybe_skip_integration, MiniCluster, Step, StepTest, StepTestState};
#[tokio::test]
async fn create_tables() {
test_helpers::maybe_start_logging();
let database_url = ... |
type Name = String;
fn main() {
let x: Name = "Hello".to_string();
println!("Nama saya: {}", x);
}
|
use super::grid::Grid;
use super::Direction;
use super::Point;
mod recursive_backtracker;
mod binary_tree;
mod prims_algorithm;
pub use self::recursive_backtracker::RecursiveBacktracker;
pub use self::prims_algorithm::Prim;
pub use self::binary_tree::BinaryTree;
pub trait MazeGenerator
{
fn generate<T: Grid>(&mu... |
use serde::Deserialize;
use serde_json::Value;
use crate::apis::flight_provider::raw_models::airport_instance_raw::AirportInstanceRaw;
#[derive(Deserialize, Debug)]
pub struct AirportRaw {
pub real: Option<Value>,
pub origin: Option<AirportInstanceRaw>,
pub destination: Option<AirportInstanceRaw>,
} |
#[macro_use]
extern crate domain_derive;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate snafu;
pub mod errors;
// Re-publish because of requirement by derive that Error be published to root.
pub use errors::Error;
pub mod app_services;
pub mod survey;
pub mod dtos;
pub mod value_objects;
#[cfg(t... |
// 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 state::*;
use storyboard::*;
pub fn quit_state() -> Story {
return Story::Start(Box::new(QuitState));
}
struct QuitState;
impl State<StoryboardContext> for QuitState {
fn state_name(&self) -> String {
return "QuitState".to_owned();
}
fn on_start(&mut self, ctx: StateData<StoryboardContext... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct CustomMapTileDataSource(pub ::windows::core::I... |
use std::path::PathBuf;
use std::sync::mpsc::SyncSender;
use std::sync::Arc;
use actix_web::{HttpRequest, Responder, fs, HttpResponse,
Either as EitherResponder};
use actix_web::http::StatusCode;
use actix_web::http::header::{ContentDisposition, DispositionType,
Dispositio... |
#[doc = "Reader of register CHASGN"]
pub type R = crate::R<u32, super::CHASGN>;
#[doc = "Writer for register CHASGN"]
pub type W = crate::W<u32, super::CHASGN>;
#[doc = "Register CHASGN `reset()`'s with value 0"]
impl crate::ResetValue for super::CHASGN {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
use clap::{App, Arg};
use std::process::{exit, Command};
fn main() -> std::io::Result<()> {
let matches = App::new("archive")
.version("0.1")
.arg(
Arg::with_name("project-name")
.long("project-name")
.short("p")
.required(true)
... |
//! Temporary data.
use varisat_formula::Lit;
/// Temporary data used by various parts of the solver.
///
/// Make sure to check any documented invariants when using this. Also make sure to check all
/// existing users when adding invariants.
#[derive(Default)]
pub struct TmpData {
pub lits: Vec<Lit>,
pub lits... |
//! Loki sink
//!
//! This sink provides downstream support for `Loki` via
//! the v1 http json endpoint.
//!
//! https://github.com/grafana/loki/blob/master/docs/api.md
//!
//! This sink does not use `PartitionBatching` but elects to do
//! stream multiplexing by organizing the streams in the `build_request`
//! phase... |
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use tokio::sync::RwLock;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Vm {
pub name: String,
pub pid: u32,
}
pub type State = Arc<RwLock<Vec<Vm>>>;
pub type StatePtr = Arc<State>;
pub async fn get_vms(state_ptr: StatePtr) -> Vec<Vm> {
... |
fn gcd(a: i32, b: i32) -> i32 {
// if as a expression and expression as a implicit return statement
if b == 0 {
a
} else {
gcd(b, a % b) // support for direct recursion
}
}
fn main() {
let a: i32 = 12;
let b: i32 = 90;
printf("GCD(%d, %d) = %d\n", a, b, gc... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtCore/qfileinfo.h
// dst-file: /src/core/qfileinfo.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// ... |
use actix_web::{middleware, App, HttpServer};
use clap;
use r2d2;
use r2d2_sqlite;
mod db;
mod handlers;
use std::env;
use std::fs;
use std::path::PathBuf;
use tracing::debug;
use tracing_subscriber;
fn create_database(path: &PathBuf) -> Result<(), std::io::Error> {
const SQL: &str = r#"
CREATE TABLE tasks (
... |
pub struct Solution;
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: List,
}
type List = Option<Box<ListNode>>;
impl Solution {
pub fn delete_duplicates(head: List) -> List {
let mut head = head;
let mut cur = &mut head;
while cur.is_some() && ... |
#[doc = "Reader of register HUFFBASE15"]
pub type R = crate::R<u32, super::HUFFBASE15>;
#[doc = "Writer for register HUFFBASE15"]
pub type W = crate::W<u32, super::HUFFBASE15>;
#[doc = "Register HUFFBASE15 `reset()`'s with value 0"]
impl crate::ResetValue for super::HUFFBASE15 {
type Type = u32;
#[inline(always... |
enum Member {
name(String),
value(Value)
}
enum Value {
Nil,
Boolean(bool),
Int(i32),
Double(f64),
String(String),
DateTime,
Base64(Vec<u8>),
Array(Vec<Value>),
Struct(Vec<Member>)
}
|
use prost::Message;
use std::env;
use std::io::Cursor;
use std::io::Read;
use std::io::Write;
use std::net::TcpListener;
use std::net::TcpStream;
use std::process;
fn exit_early(msg: String) -> i16 {
println!("{}", msg);
process::exit(1);
}
fn set_ctrlc_handler() {
ctrlc::set_handler(move || {
pri... |
use crate::{
cairo::ext_py::{
types::{
EntryPointType, FeeEstimate, FunctionInvocation, MsgToL1, TransactionSimulation,
TransactionTrace,
},
CallFailure,
},
context::RpcContext,
v02::{
method::call::FunctionCall,
types::{reply, request::Bro... |
// 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 ... |
//! Errorand Result types.
use crate::database::Database;
use crate::types::Type;
use std::any::type_name;
use std::error::Error as StdError;
use std::fmt::{self, Debug, Display};
use std::io;
#[allow(unused_macros)]
macro_rules! decode_err {
($s:literal, $($args:tt)*) => {
crate::Error::Decode(format!($s... |
#![no_std]
mod util;
mod data;
pub enum AudioFormat {
PCM,
IEEEFloat,
EightBitALaw,
EightBitMuLaw,
Invalid
}
impl AudioFormat {
pub fn to_code(&self) -> u8 {
match *self {
AudioFormat::PCM => 1,
AudioFormat::IEEEFloat => 3,
AudioFor... |
fn main() {
println!("Mutantes");
let mut x = 12;
let y: i32 = 1;
x = x + y;
println!("x = {}", x);
}
|
pub mod fieldlist;
pub mod seriesset;
pub mod stringset;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.