text stringlengths 8 4.13M |
|---|
//! Generic implementation of Cipher-based Message Authentication Code (CMAC),
//! otherwise known as OMAC1.
//!
//! # Usage
//! We will use AES-128 block cipher from [aes](https://docs.rs/aes) crate.
//!
//! To get the authentication code:
//!
//! ```rust
//! extern crate cmac;
//! extern crate aes;
//!
//! use aes::A... |
//https://leetcode.com/problems/replace-elements-with-greatest-element-on-right-side/submissions/
impl Solution {
pub fn replace_elements(mut arr: Vec<i32>) -> Vec<i32> {
let mut max_right = -1;
for i in (0..arr.len()).rev() {
let tmp = arr[i];
arr[i] = max_right;
... |
pub(crate) mod systems;
mod action;
mod config;
mod cursor;
mod plugin;
pub use action::*;
pub use config::*;
pub use cursor::*;
pub use plugin::*;
game_lib::fix_bevy_derive!(game_lib::bevy);
|
//! Contains the ffi-safe equivalent of `std::cmp::Ordering`.
use std::cmp::Ordering;
/// Ffi-safe equivalent of `std::cmp::Ordering`.
///
/// # Example
///
/// This defines an extern function, which compares a slice to another.
///
/// ```rust
///
/// use abi_stable::{
/// sabi_extern_fn,
/// std_types::{RCm... |
// 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 ... |
// Copyright 2023 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 ag... |
use std::fmt;
use crate::utils::get_timestamp;
use chrono::{prelude::*, Local};
use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct TimeStamp(i64);
impl TimeStamp {
pub fn now() -> Self {
Self(get_timestamp())
}
pub fn touch(&mut self) {
... |
//! Asynchronous ARDOP TNC backend
//!
//! This module contains the "meat" of the ARDOP TNC
//! interface. This object is asynchronous and returns
//! futures for all blocking operations. It also includes
//! management of ARQ connections.
//!
//! Higher-level objects will separate control functions
//! and ARQ connect... |
// 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.
#![warn(missing_docs)]
use failure::{bail, format_err, Error, ResultExt};
use fidl::endpoints::{create_proxy, ServerEnd};
use fidl_fuchsia_io::{DirectoryP... |
#![allow(nonstandard_style)]
use libc::{c_int, c_void, uintptr_t};
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum _Unwind_Reason_Code {
_URC_NO_REASON = 0,
_URC_FOREIGN_EXCEPTION_CAUGHT = 1,
_URC_FATAL_PHASE2_ERROR = 2,
_URC_FATAL_PHASE1_ERROR = 3,
_URC_NORMAL_STOP = 4,
_URC_END_... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type CastingConnection = *mut ::core::ffi::c_void;
pub type CastingConnectionErrorOccurredEventArgs = *mut ::core::ffi::c_void;
#[repr(transparent)]
pub str... |
pub mod fields;
pub mod subfield;
use std::{fmt, str};
use self::subfield::{subfields::Subfields, Subfield};
use crate::{errors::*, Identifier, Indicator, Tag, MAX_FIELD_LEN, SUBFIELD_DELIMITER};
/// View into a field of a MARC record
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Field<'a> {
tag: Tag,
da... |
/// A type that can be treated as a pixel.
///
/// Types implementing `Pixel` are able to be used
/// as a pixel in [`source`](crate::source)s and [`surface`](crate::surface)s.
pub trait Pixel: Sized {
/// Blend two pixels at a specified opacity
/// The `self` pixel should be under the `other` pixel.
/// In... |
extern crate rustc_serialize as serialize;
use serialize::base64::{self, ToBase64};
use serialize::hex::FromHex;
fn main() {
let input = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";
let result = input.from_hex().unwrap().to_base64(base64::STANDARD);
p... |
pub(crate) mod shader;
|
use hyper::{Body, Method, Request, StatusCode};
use hyper::Client;
use hyper_tls::HttpsConnector;
use isahc::prelude::*;
use isahc::prelude::Request as SyncRequest;
#[derive(Clone)]
pub struct LocalHttpClient {
target_uri: String,
local_uri: String
}
impl LocalHttpClient {
pub fn new(target_uri: String,... |
use std::{io, fmt};
use super::{
Serialize, Deserialize, Error,
Uint8, VarUint32, CountedList, BlockType,
Uint32, Uint64, CountedListWriter,
VarInt32, VarInt64,
};
/// Collection of opcodes (usually inside a block section).
#[derive(Debug, PartialEq, Clone)]
pub struct Opcodes(Vec<Opcode>);
impl Opcodes {
/// Ne... |
use super::VarResult;
use crate::ast::syntax_type::{FunctionType, FunctionTypes, SimpleSyntaxType, SyntaxType};
use crate::helper::err_msgs::*;
use crate::helper::str_replace;
use crate::helper::{
move_element, pine_ref_to_bool, pine_ref_to_color, pine_ref_to_f64, pine_ref_to_i64,
pine_ref_to_string,
};
use cra... |
//! This file contains all necessary information needed to construct a SMB2 packet.
/// Protocol id with fixed value
const PROTOCOL_ID: &[u8; 4] = b"\xfe\x53\x4d\x42";
/// SMB head size of 64 bytes
const STRUCTURE_SIZE: &[u8; 2] = b"\x40\x00";
/// All commands that could be in the command field.
#[derive(Debug, Parti... |
use ggez::graphics;
use components::*;
use sprite::*;
#[derive(Debug)]
pub struct Renderable {
pub pos: Position,
pub render: EntityRender,
}
impl Renderable {
pub fn new(pos: Position, render: EntityRender) -> Self {
Renderable { pos, render }
}
}
impl SpriteComponent for Renderable {
f... |
use std::collections::HashMap;
use rbatis_core::Error;
use crate::ast::node::node_type::NodeType;
pub trait ToResult<T> {
fn to_result<F>(&self, fail_method: F) -> Result<&T, Error>
where F: Fn() -> String;
}
impl<T> ToResult<T> for Option<&T> {
#[inline]
fn to_result<F>(&self, fail_method: F) -... |
//! Tests for `#[derive(GraphQLInterface)]` macro.
pub mod common;
use std::marker::PhantomData;
use juniper::{
execute, graphql_object, graphql_value, graphql_vars, DefaultScalarValue, FieldError,
FieldResult, GraphQLInterface, GraphQLObject, GraphQLUnion, IntoFieldError, ScalarValue, ID,
};
use self::comm... |
//给定一个整数 n,求以 1 ... n 为节点组成的二叉搜索树有多少种?
//
// 示例:
//
// 输入: 3
//输出: 5
//解释:
//给定 n = 3, 一共有 5 种不同结构的二叉搜索树:
//
// 1 3 3 2 1
// \ / / / \ \
// 3 2 1 1 3 2
// / / \ \
// 2 1 2 3
// Related Topic... |
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::GString;
use glib_sys;
use libc;
us... |
use cw::{BLOCK, Crosswords, Dir, Point};
/// An element representing a part of a crosswords grid: an element of the cell's borders, a cell
/// and its contents or a line break. It should be converted to a textual or graphical
/// representation.
///
/// The variants specifying borders contain a boolean value specifyin... |
// edition:2018
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
#![allow(non_snake_case)]
use std::pin::Pin;
struct Struct { }
impl Struct {
// Test using `&mut Struct` explicitly:
async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 {
f
//[base]~... |
use std::{io::{ErrorKind, Read}, str::FromStr};
use mysql::chrono::{NaiveDate, Utc};
use mysql_common::bigdecimal::BigDecimal;
use toml::Value;
#[derive(Debug)]
pub struct Config {
pub key: String,
pub mysql_url: String,
pub img_width: i32,
pub img_height: i32,
pub stocks: Vec<String>,
pub sta... |
use std::convert::TryFrom;
use super::crypto;
use super::SessionCrypto;
pub const PACKET_MAX_MESSAGE_LEN: usize = 1024;
const PACKET_MESSAGE_LEN_LEN: usize = 4; // u32
const PACKET_MESSAGE_ENCRYPTED_LEN: usize = PACKET_MAX_MESSAGE_LEN + PACKET_MESSAGE_LEN_LEN;
pub const PACKET_MAC_LEN: usize = 256 / 8; // 32
pub cons... |
use std::{fmt::Debug, num::NonZeroUsize, sync::Arc};
use client_util::{connection::HttpConnection, namespace_translation::split_namespace};
use futures_util::{future::BoxFuture, FutureExt, Stream, StreamExt, TryStreamExt};
use crate::{
connection::Connection,
error::{translate_response, Error},
};
use reqwest... |
use crate::proxy_addr::ProxyAddr;
use crate::crawlers::build_headers;
use tokio::time::Duration;
use reqwest::Proxy;
use crate::storages;
use serde::Deserialize;
const TEST_ANONYMOUS: bool = true;
const TEST_TIMEOUT: u64 = 10;
const TEST_BATCH: u32 = 20;
#[derive(Debug, Deserialize, PartialEq)]
struct Ip {
origin: S... |
use std::cmp::Ordering::*;
use rand::prelude::*;
use wasm_bindgen::prelude::*;
use crate::factor::{any_factor_in, factor_list_in};
use crate::iif;
use crate::is_factor;
use crate::util::{is_even, sqrt};
const MAX_PRIME: u32 = 4294967291;
#[wasm_bindgen]
pub struct PrimeNumber;
#[wasm_bindgen]
impl PrimeNumber {
... |
pub mod meta;
pub mod parser;
pub mod render; |
use super::Part;
use crate::codec::{Decode, Encode};
use crate::{remote_type, RemoteObject};
remote_type!(
/// An experiment. Obtained by calling `Part::experiment().`
object SpaceCenter.Experiment {
properties: {
{
Part {
/// Returns the part object for this experiment.
... |
use flate2::Compression;
use flate2::read::GzDecoder;
use flate2::write::GzEncoder;
use std::fs::{create_dir_all, rename, File};
use std::path::Path;
use tar::{Builder, Archive};
use uuid::Uuid;
use crate::error::Error;
pub fn to_tar_gz(src: &Path, dest: &Path) -> Result<(), Error> {
let file_name = format!(".{}"... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtCore/qscopedpointer.h
// dst-file: /src/core/qscopedpointer.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block be... |
extern crate ncurses;
extern crate gui_lib;
use std::collections::HashMap;
use std::sync::mpsc::{Sender, Receiver};
use ncurses::*;
use crate::shared::Event;
use crate::protocol::NewWindow;
use gui_lib::*;
#[derive(Clone, Debug)]
pub enum GuiEvent{
CreateWindow(NewWindow),
DestroyWindow(String),
Log(S... |
use winapi::shared::windef::{HBITMAP, HBRUSH};
use winapi::um::winuser::{WS_VISIBLE, WS_DISABLED, WS_TABSTOP};
use winapi::um::commctrl::{
LVS_ICON, LVS_SMALLICON, LVS_LIST, LVS_REPORT, LVS_NOCOLUMNHEADER, LVCOLUMNW, LVCFMT_LEFT, LVCFMT_RIGHT, LVCFMT_CENTER, LVCFMT_JUSTIFYMASK,
LVCFMT_IMAGE, LVCFMT_BITMAP_ON_RI... |
use amcl::{
bls381::{big::Big, bls381::utils},
errors::AmclError,
};
use log::trace;
pub const SIG_SIZE: usize = 48;
const DST: &[u8] = b"MEROS-V00-CS01-with-BLS12381G1_XMD:SHA-256_SSWU_RO_";
#[derive(Clone)]
pub struct SecretKey(Big);
impl SecretKey {
pub fn new(bytes: &[u8]) -> Result<SecretKey, AmclE... |
use super::*;
#[derive(Default)]
pub struct Blockchain {
pub blocks: Vec<Block>,
index: usize,
}
impl Blockchain {
pub fn new() -> Self {
Blockchain {
blocks: Vec::new(),
index: 0,
}
}
pub fn add_block(&mut self, payload: String, difficulty: u128) {
... |
use atoms::{Location, Token};
use ast::Type;
use ast::expressions::Expression;
use traits::HasLocation;
use std::fmt;
#[derive(Debug)]
pub struct DeclAssignStmt {
pub identifier: Token,
pub colon: Token,
///
/// The type of the binding being declared
/// (optional, will be inferred if not specified... |
// 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 agre... |
use std::iter::FromIterator;
fn scan_polymer(input: String) -> String {
let mut units: Vec<_> = input.chars().collect();
let mut idx = 0;
let mut current = *units.get(0).unwrap();
while idx + 1 < units.len() {
let next = *units.get(idx + 1).unwrap();
if reacts(current, next) {
... |
// 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.
//
// Code generated by tools/fidl/gidl-conformance-suite/regen.sh; DO NOT EDIT.
use fidl::{
encoding::{Context, Decodable, Decoder, Encoder},
Erro... |
#[doc = "Reader of register INI1_FN_MOD_AHB"]
pub type R = crate::R<u32, super::INI1_FN_MOD_AHB>;
#[doc = "Writer for register INI1_FN_MOD_AHB"]
pub type W = crate::W<u32, super::INI1_FN_MOD_AHB>;
#[doc = "Register INI1_FN_MOD_AHB `reset()`'s with value 0x04"]
impl crate::ResetValue for super::INI1_FN_MOD_AHB {
typ... |
use std::fmt;
#[derive(Clone, PartialEq)]
struct SpinLock {
buf: Vec<u64>,
num: u64,
cur: usize,
step: usize,
}
impl fmt::Debug for SpinLock {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "{}", self.buf.iter().enumerate().map(|(ref i, ref s)| {
if *i == se... |
#[path = "with_reference/with_monitor.rs"]
pub mod with_monitor;
test_stdout!(without_monitor_returns_true, "true\n");
|
// 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 ... |
// # The Rust Programing Language
//
// You made it! That was a sizable chapter: you learned about variables, scalar and compound data
// types, functions, comments, if expressions, and loops! If you want to practice with the concepts
// discussed in this chapter, try building programs to do the following:
//
// - Co... |
use crate::utils::print_updates;
use crate::*;
use std::path::Path;
fn get_file_list(opt: &Opt) -> Vec<String> {
let mut files = Vec::<String>::new();
for item in opt.input.iter() {
if opt.recursive && item.is_dir() {
let mut tmp = match scope_dir(&item.to_path_buf()) {
Ok(... |
#[doc = "Writer for register C2IFCR"]
pub type W = crate::W<u32, super::C2IFCR>;
#[doc = "Register C2IFCR `reset()`'s with value 0"]
impl crate::ResetValue for super::C2IFCR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Write proxy for field `CTEIF2`"]
pub ... |
use crate::{app::AppContextPointer, gui::control_area::BOX_SPACING};
use gtk::{self, gdk::RGBA, prelude::*, Frame, ScrolledWindow};
use std::rc::Rc;
pub fn make_active_readout_frame(ac: &AppContextPointer) -> ScrolledWindow {
let f = Frame::new(None);
f.set_hexpand(true);
f.set_vexpand(true);
// Layou... |
#[doc = "Reader of register OR"]
pub type R = crate::R<u32, super::OR>;
#[doc = "Writer for register OR"]
pub type W = crate::W<u32, super::OR>;
#[doc = "Register OR `reset()`'s with value 0"]
impl crate::ResetValue for super::OR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
extern crate chrono;
extern crate serde;
extern crate serde_json;
extern crate sha2;
extern crate rsa;
use super::wt;
pub mod block;
pub mod chain;
pub mod digest;
pub mod miner;
pub mod transaction;
pub mod wallet;
pub mod system;
pub mod system_persistence;
|
use dotenv::dotenv;
use ojichat::ojichat;
use serenity::{
async_trait,
client::bridge::gateway::ShardManager,
framework::standard::{
help_commands,
macros::{command, group, help, hook},
Args, CommandGroup, CommandResult, DispatchError, HelpOptions, StandardFramework,
},
http:... |
#[doc = "Reader of register PPUART"]
pub type R = crate::R<u32, super::PPUART>;
#[doc = "Reader of field `P0`"]
pub type P0_R = crate::R<bool, bool>;
#[doc = "Reader of field `P1`"]
pub type P1_R = crate::R<bool, bool>;
#[doc = "Reader of field `P2`"]
pub type P2_R = crate::R<bool, bool>;
#[doc = "Reader of field `P3`"... |
use std::collections::HashMap;
use crate::ast::*;
use crate::object::*;
pub trait Evaluation {
fn evaluate(self, env: &mut Environment) -> Result<Object, String>;
}
impl Evaluation for Program {
fn evaluate(self, env: &mut Environment) -> Result<Object, String> {
match self {
Program {
... |
// 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 ... |
#[macro_use]
extern crate nom;
extern crate num;
mod parser;
use nom::IResult;
use num::{Complex, Zero};
use std::collections::HashSet;
use std::io::{self, Read};
use parser::road;
#[derive(Copy, Clone, Debug)]
enum Direction {
Left,
Right,
}
#[derive(Copy, Clone, Debug)]
pub struct Walk {
direction: ... |
//! GraphQL support for [`chrono-tz`] crate types.
//!
//! # Supported types
//!
//! | Rust type | Format | GraphQL scalar |
//! |-----------|--------------------|----------------|
//! | [`Tz`] | [IANA database][1] | `TimeZone` |
//!
//! [`chrono-tz`]: chrono_tz
//! [`Tz`]: chrono_tz::Tz
//! [1]: htt... |
#[doc = "Reader of register TAMPCR"]
pub type R = crate::R<u32, super::TAMPCR>;
#[doc = "Writer for register TAMPCR"]
pub type W = crate::W<u32, super::TAMPCR>;
#[doc = "Register TAMPCR `reset()`'s with value 0"]
impl crate::ResetValue for super::TAMPCR {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
#[repr(C)]
#[derive(Copy,Clone,PartialEq,Eq)]
/// EFI Status type
pub struct Status(u64);
impl Status
{
#[inline]
pub fn new(val: u64) -> Status {
Status(val)
}
#[inline]
pub fn err_or<T>(self, v: T) -> Result<T,Status> {
if self.0 == 0 {
Ok(v)
}
else {
Err(self)
}
}
#[inline]
pub fn err_or_el... |
use std::cell::RefCell;
use std::rc::Rc;
use wasm_bindgen::prelude::*;
use web_sys::*;
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use web_sys::WebGl2RenderingContext as GL;
use std::borrow::Borrow;
mod dom;
mod controls;
mod ecs;
use crate::texture;
use crate::render::WebRenderer;
use crate::app::{App, Msg}... |
pub type IDummyHICONIncluder = *mut ::core::ffi::c_void;
pub type IThumbnailExtractor = *mut ::core::ffi::c_void;
|
use super::*;
mod with_heap_binary;
mod with_subbinary;
#[test]
fn without_non_negative_integer_position_errors_badarg() {
run!(
|arc_process| {
(
Just(arc_process.clone()),
strategy::term::is_bitstring(arc_process.clone()),
strategy::term::is_no... |
// 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 super::lexer::Lexer;
use std::io::{BufRead, Write};
const PROMPT: &[u8] = b">> ";
pub fn start<R, W>(mut reader: R, mut writer: W)
where
R: BufRead,
W: Write,
{
loop {
writer.write(PROMPT).unwrap();
writer.flush().unwrap();
let mut line = String::new();
if let Ok(_) = ... |
mod decimal;
mod multi_btreemap;
pub mod top_sort {
use std::num::ParseIntError;
use topsort::decimal::Decimal;
use topsort::multi_btreemap::MBTreeMap;
use csv::ByteRecord;
#[derive(Clone)]
pub enum OrderType {
DEFAULT,
REVERSE,
}
pub struct TopSortEntry<'a> {
key: Decimal,
byte_record: &'a ByteRecor... |
pub mod beta;
pub mod cek;
pub mod cps;
#[derive(Clone, Debug, PartialEq)]
pub enum Term {
Var(usize),
Abs(Box<Term>),
App(Box<Term>, Box<Term>),
}
impl Term {
fn whnf(&self) -> bool {
match self {
Term::Abs(e) => e.whnf(),
Term::App(e, _) => e.whnf(),
_ => ... |
// Copyright 2021 Chiral Ltd.
// Licensed under the Apache-2.0 license (https://opensource.org/licenses/Apache-2.0)
// This file may not be copied, modified, or distributed
// except according to those terms.
//! Case breakable
use crate::core;
use super::mapping_ops;
fn is_neighbour_breakable<T: core::graph::Vertex... |
use std::io::{self, Write};
fn main() {
print!("空白区切りで最小公倍数を求めたい2数を入力してください。 >> ");
let _ = io::stdout().flush();
let mut input = String::new();
io::stdin().read_line(&mut input).
expect("読み取りに失敗しました。");
let list: Vec<&str> = input.split_whitespace().collect();
let mut a:u32 = list[0].pa... |
use juniper::GraphQLInterface;
#[derive(GraphQLInterface)]
struct Character {
id: String,
#[graphql(name = "id")]
id2: String,
}
fn main() {}
|
// 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,
fidl_fuchsia_media::AudioRenderUsage,
fidl_fuchsia_settings::{
AudioInput, AudioProxy, AudioSettings, AudioStream... |
#[path = "without_options/with_monitor.rs"]
pub mod with_monitor;
test_stdout!(without_monitor_returns_true, "true\n");
|
use super::heuristics::*;
use super::types::*;
use crate::game::*;
pub fn minimax(game: &Game, depth: usize, maximizing_player: Player, ai_config: &AIConfig) -> AlgorithmRes {
if depth == ai_config.tree_depth || game.game_over() {
let eval = evaluate_game_state(&game, maximizing_player, &ai_config);
return A... |
use winapi::shared::windef::HWND;
use winapi::shared::minwindef::{WPARAM, LPARAM};
use winapi::um::winuser::{LBS_MULTIPLESEL, LBS_NOSEL, WS_VISIBLE, WS_DISABLED, WS_TABSTOP};
use crate::win32::window_helper as wh;
use crate::win32::base_helper::{to_utf16, from_utf16, check_hwnd};
use crate::{Font, NwgError};
use super:... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Comparator control/status register"]
pub comp_c1csr: COMP_C1CSR,
#[doc = "0x04 - Comparator control/status register"]
pub comp_c2csr: COMP_C2CSR,
#[doc = "0x08 - Comparator control/status register"]
pub comp_c3csr: ... |
//! A universal means of representing location in a Falcon program
//!
//! We have two basic types of locations in Falcon:
//!
//! `RefProgramLocation`, and its companion `RefFunctionLocation`. These are program locations,
//! "Applied," to a program.
//!
//! `ProgramLocation`, and its companion, `FunctionLocation`. Th... |
#![allow(non_snake_case)]
#![cfg(test)]
use problem1::{distinct, filter, sum};
// use problem2::mat_mult;
// use problem3::sieve;
// use problem4::{hanoi, Peg};
//
// Problem 1
//
// Part 1
#[test]
fn Can_compute_sum_on_empty_slice() {
let array = [];
let default = 10;
let res = sum(&array, default);
... |
use sea_orm::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "Text")]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Eq)]
pub enum Feed {
#[sea_orm(string_value = "Category")]
Category,
#[sea_orm(string_value = "Tag")]
Tag,
}... |
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
#[derive(Debug)]
struct Rule {
min: usize,
max: usize,
check_letter: char
}
fn main() {
//test();
if let Ok(lines) = read_lines("./input") {
let mut count = 0;
for line in lines {
if let Ok(rule_passw... |
#[doc = "Writer for register ICACHE_FCR"]
pub type W = crate::W<u32, super::ICACHE_FCR>;
#[doc = "Register ICACHE_FCR `reset()`'s with value 0"]
impl crate::ResetValue for super::ICACHE_FCR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Write proxy for field... |
mod retina_map;
use self::retina_map::generate_retina_map;
use gfx;
use gfx::traits::FactoryExt;
use gfx::Factory;
use gfx_device_gl::CommandBuffer;
use gfx_device_gl::Resources;
use crate::devices::*;
use crate::pipeline::*;
gfx_defines! {
pipeline pipe {
u_stereo: gfx::Global<i32> = "u_stereo",
... |
use crate::structs::message_types::{parse_dhcpv6_message_type, DHCPv6MessageType};
use crate::structs::options::{parse_dhcpv6_options, DHCPv6Option};
use nom::number::complete::{be_u24, be_u8};
use nom::sequence::tuple;
use nom::IResult;
use std::net::Ipv6Addr;
use crate::utils::parse_ipv6_address;
#[derive(Debug, Cl... |
use std::path::PathBuf;
use std::str::FromStr;
use clap::ArgMatches;
use crate::config::options::{invalid_value, required_option_missing};
use crate::config::{OptionInfo, ParseOption};
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum LdImpl {
Lld,
}
impl FromStr for LdImpl {
type Err = ();
fn from_s... |
use std::ops::{Deref, DerefMut};
pub fn copy_memory(input: &[u8], out: &mut [u8]) -> usize {
for count in 0..input.len() {out[count] = input[count];}
input.len()
}
/// Toggle is similar to Option, except that even in the Off/"None" case, there is still
/// an owned allocated inner object. This is useful for h... |
use std::fs;
fn main() {
part1();
part2();
}
fn part1() {
let map = fs::read_to_string("./input").expect("Couldn't open input");
let slope = (3,1);
println!("part1: hit {} trees", hit_trees(&map as &str, slope));
}
fn part2() {
let map = fs::read_to_string("./input").expect("Couldn't open inp... |
#[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::_3_INTEN {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R,... |
use chrono::prelude::*;
use jsonwebtoken::{DecodingKey, EncodingKey, Header, Validation};
use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct Claims {
pub sub: String,
pub company: String,
#[serde(with = "jwt_numeric_date")]
pub exp: DateTime<Utc>,
}
imp... |
use super::Request;
use crate::error::NotpResult;
use crate::store::DataStore;
pub(crate) fn delete<T: DataStore>(request: Request<'_, T>) -> NotpResult<()> {
let store = request.store;
let name = request.key.unwrap_or_default();
store.delete(String::from(name))
}
#[cfg(test)]
mod tests {
use super::... |
#[allow(unused_imports)]
use proconio::{marker::*, *};
#[fastout]
fn main() {
input! {
n: i32,
}
println!("{}", n * n);
}
|
//! This module contains the definition of a "FieldList" a set of
//! records of (field_name, field_type, last_timestamp) and code to
//! pull them from RecordBatches
use std::{collections::BTreeMap, sync::Arc};
use arrow::{
self,
array::TimestampNanosecondArray,
datatypes::{DataType, SchemaRef},
recor... |
fn main() {
println!("Hello to carol printer!");
let header = [
"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eight", "ninth",
"10th", "11th", "12th",
];
let lyrics = [
"A partridge in a pear tree",
"Two turtle doves, and",
"Three french hens... |
// 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 ... |
/**
* Calculate the "hamming" distance between two strings and return as a Result
*/
pub fn hamming_distance(a: &str, b: &str) -> Result<i32, i32> {
// Basic error handling
if a.len() != b.len() {
return Err(0);
}
let mut ham_count = 0;
for (key, character) in a.chars().enumerate() {
... |
use crate::{
sr::constants::Constant,
sr::instructions,
sr::ops::{self, Op},
sr::storage::*,
sr::types::Type,
};
#[derive(Debug)]
pub struct EntryPoint {
pub execution_model: spirv::ExecutionModel,
pub function: Token<Function>,
pub name: String,
//pub interface: Vec<spirv::Word>,
}... |
// buat trait Summary dengan default implementasi dari method `summarize`
trait Summary {
fn summarize(&self) -> String {
String::from("(Read more...)")
}
}
struct News;
// karena struk News tidak mendetilkan fungsi `summarize` maka akan
// menggunakan default implementasi dari trait `Summary`
impl Su... |
#![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 IMidiChannelPressureMessage(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IMidiChannelPressureMessage {
typ... |
use binary_search::BinarySearch;
use input_i_scanner::InputIScanner;
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.scan::<$t>() as $... |
struct Foo<'a> {
x: &'a i32
}
impl<'a> Foo<'a> {
fn x(&self) -> &'a i32 { self.x }
}
fn main() {
let a = 5;
let _y = double(a);
println!("{}", a);
let b = true;
// _y = change_truth(b) will fail
// _y = double(10) will fail either
// but let _y = change_truth(b) will success
let _y = cha... |
use crate::cairo::ext_py;
use crate::gas_price;
use crate::SyncState;
use pathfinder_common::ChainId;
use pathfinder_storage::Storage;
use starknet_gateway_types::pending::PendingData;
use std::sync::Arc;
type SequencerClient = starknet_gateway_client::Client;
#[derive(Copy, Clone, Default)]
pub enum RpcVersion {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.