text stringlengths 8 4.13M |
|---|
use crate::spec::opcode::{instruction_lookup, Instruction};
use crate::util::byte_ops::{extract_lhs, extract_rhs};
use crate::spec::mnemonic::Mnemonic;
use std::convert::TryFrom;
use std::fmt;
pub mod decoder;
#[derive(Debug)]
pub enum DasmError {
InvalidRom(String),
DecoderError(&'static str),
PartialD... |
use actix::prelude::*;
use kosem_webapi::handshake_messages::*;
use kosem_webapi::Uuid;
use crate::internal_messages::connection::{ConnectionClosed, SetRole};
use crate::protocol_handlers::websocket_jsonrpc::WsJrpc;
use crate::role_actors::{JoinerActor, ProcedureActor};
pub struct NotYetIdentifiedActor {
con_act... |
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
mod post;
mod registered_proof;
mod seal;
mod serde;
pub use self::post::*;
pub use self::registered_proof::*;
pub use self::seal::*;
use crate::ActorID;
use ::serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use num_bigint... |
use std::collections::{BTreeMap, VecDeque};
#[cfg(test)]
use std::fs::File;
use std::io::{self, BufRead, BufReader, Read, Write};
use std::net::{TcpStream, ToSocketAddrs};
#[allow(unused_imports)]
use log::{debug, error, info, trace};
use bitcoin::blockdata::block;
use bitcoin::blockdata::transaction::Transaction;
us... |
pub mod aabb;
pub mod encoder;
pub mod ffi;
pub mod mesh;
pub mod parser;
pub mod picture;
pub mod rasterbackend;
pub mod zbuffer;
|
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
//! This crate contains cryptographic primitives used in STARK proof generation and verification.
//! These include:
//!
//! * **Hash func... |
fn main() {
let age: i32 =20;
if age >= 18 {
println!("majeur !");
} else {
println!("mineur! ");
}
}
|
use crate::figure::{FigureImpl, Figure};
use crate::state::State;
use crate::canvas::{CairoCanvas, Canvas};
use crate::transformations::TransformMatrix;
use crate::view::View;
use std::cmp::min;
use std::cell::Ref;
use std::f64::consts::PI;
fn to_radians(angle: f64) -> f64 {
angle / 180.0 * PI
}
pub fn handle_dr... |
use log::*;
use linefeed;
use std::io;
use std::io::Write;
use std::sync::Arc;
use linefeed::{Interface, Prompter, ReadResult};
// use linefeed::chars::escape_sequence;
use linefeed::command::COMMANDS;
use linefeed::complete::{Completer, Completion};
// use linefeed::inputrc::parse_text;
use linefeed::terminal::Term... |
#[doc = "Register `MPCBB2_VCTR31` reader"]
pub type R = crate::R<MPCBB2_VCTR31_SPEC>;
#[doc = "Register `MPCBB2_VCTR31` writer"]
pub type W = crate::W<MPCBB2_VCTR31_SPEC>;
#[doc = "Field `B992` reader - B992"]
pub type B992_R = crate::BitReader;
#[doc = "Field `B992` writer - B992"]
pub type B992_W<'a, REG, const O: u8... |
fn main() {
proconio::input! {
n: usize,
m: usize,
ab: [(usize, usize); m],
}
let mut graph: Vec<Vec<usize>> = vec![vec![]; n];
for i in 0..m {
graph[ab[i].0-1].push(ab[i].1-1);
graph[ab[i].1-1].push(ab[i].0-1);
}
for i in 0..n {
if graph[i].len() > 2{
println... |
#![no_main]
#[macro_use]
extern crate libfuzzer_sys;
extern crate gbl;
use gbl::Gbl;
#[rustfmt::skip] // FIXME: https://github.com/rust-lang/rustfmt/issues/3234
fuzz_target!(|data: &[u8]| {
if let Ok(gbl) = Gbl::parse(data) {
gbl.to_bytes();
}
});
|
#![allow(dead_code)]
#![allow(unused_variables)]
fn main() {
// let ip_type = IpAddrKind::V4;
// let home = IpAddr {
// kind: IpAddrKind::V4,
// address: String::from("127.0.0.1"),
// };
// let loopback = IpAddr {
// kind: IpAddrKind::V6,
// address: String::from("::1"),... |
struct Peer;
impl Peer {
fn new() -> Peer {
Peer
}
}
|
use crate::grammar::ast::{BinaryOp, Expression};
use crate::grammar::model::WrightInput;
use crate::grammar::parsers::expression::binary_expression::primary::arithmetic::{
arithmetic1, arithmetic1_primary,
};
use crate::grammar::parsers::expression::binary_expression::primary::parser_left;
use crate::grammar::traci... |
pub mod eye;
pub mod texture_cache;
pub use self::eye::Eye;
use cgmath::{PerspectiveFov, Rad, Matrix4};
use db::Database;
use glium::{VertexBuffer, IndexBuffer, Frame, Surface, Program, Display};
use nitro::Model;
use primitives::{Primitives, DrawCall, Vertex};
use self::texture_cache::{TextureCache, ImageId};
use su... |
use amethyst::ecs::{Component, NullStorage};
#[derive(Debug, Default)]
pub struct Init;
impl Component for Init {
type Storage = NullStorage<Self>;
}
|
use fopply::read_fpl;
fn check_math() -> Result<(), ()> {
Ok(read_fpl(&std::fs::read_to_string("fpl/math.fpl").map_err(|_| println!("can't read `math.fpl`"))?)?)
}
fn main() {
if let Ok(_) = check_math() {
println!("`math.fpl` is OK");
}
}
|
pub struct WordProblem;
#[derive(Debug, PartialEq)]
pub enum Op {
Add,
Subtract,
Multiply,
Divide,
Power,
Unknown,
None
}
pub const MAX: i32 = i32::max_value(); // 2_147_483_647i32
pub fn answer(command: &str) -> Option<i32> {
let filtered_command = command.replace("?", "")
.r... |
extern crate sdl2;
mod entity;
use rand::Rng;
use sdl2::pixels::Color;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::image::{LoadTexture, InitFlag};
use sdl2::gfx::framerate::FPSManager;
use sdl2::rect::Rect;
use std::collections::HashMap;
use entity::player::Player;
use entity::velocity::Velocity;
... |
use std::env;
use std::process;
use connectz::Config;
fn main() {
let config = Config::new(env::args()).unwrap_or_else(|err| {
eprintln!("Problem parsing arguments: {}", err);
process::exit(1);
});
match connectz::run(config) {
Ok(outcome) => println!("{}", outcome),
Err(e... |
//! Contains code pertaining to the setup options that can be given to the [`Server`](crate::Server)
use bitflags::bitflags;
use std::time::Duration;
use std::{
fmt::Formatter,
fmt::{self, Debug, Display},
net::{IpAddr, Ipv4Addr},
ops::Range,
};
// Once we're sure about the types of these I think its ... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct OperationListResult {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub value: Vec<OperationValu... |
use xml::Element;
use ::{ElementUtils, NS, Person, ViaXml};
/// [The Atom Syndication Format § The "atom:author" Element]
/// (https://tools.ietf.org/html/rfc4287#section-4.2.1)
#[derive(Default)]
pub struct Author(pub Person);
impl ViaXml for Author {
fn to_xml(&self) -> Element {
let mut elem = Eleme... |
// <arc>
use actix_web::{get, web, App, HttpServer, Responder};
use std::cell::Cell;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
#[derive(Clone)]
struct AppState {
local_count: Cell<usize>,
global_count: Arc<AtomicUsize>,
}
#[get("/")]
async fn show_count(data: web::Data<AppState>) -> ... |
use crate::structure::*;
use crate::validation::validation::{ValidationResult, ValidationError, Context};
use crate::validation::types::{validate_table_type, validate_function_type, validate_memory_type, validate_global_type};
use crate::validation::instructions::{validate_expression, validate_constant_expression};
/... |
#![allow(non_snake_case)]
#[macro_use]
extern crate lazy_static;
extern crate serde_json;
extern crate vmtests;
use serde_json::Value;
use std::collections::HashMap;
use vmtests::{load_tests, run_test};
lazy_static! {
static ref TESTS: HashMap<String, Value> = load_tests("tests/vmBlockInfoTest/");
}
#[test]
fn ... |
// On va étudier l'intérêt de la boucle for en partant de la boucle while.
// CE QU'ON PEUT FAIRE
// Utiliser la boucle while pour passer un tableau en revue.
// fn main() {
// // définition du tableau (array) et de l'index (on commence à zéro)
// let a = [10, 20, 30, 40, 50];
// let mut index = 0;
... |
use anyhow::{Context, Result};
use rusoto_ec2::{filter, DescribeInstancesRequest, Ec2, Ec2Client};
use std::collections::HashMap;
pub struct Handler<'a> {
client: &'a Ec2Client,
}
impl<'a> Handler<'a> {
pub fn new(client: &'a Ec2Client) -> Self {
Self { client }
}
pub async fn list(self) -> R... |
use std::collections::HashSet;
use std::iter::FromIterator;
fn is_unique(s: String) -> bool {
let hash: HashSet<char> = HashSet::from_iter(s.chars());
s.len() == hash.len()
}
fn is_unique_no_data_structure(s: String) -> bool {
let mut check_duplicate = String::new();
for c in s.chars() {
if ch... |
// Stub definitions to make things *compile*.
use std::path::PathBuf;
use BaseDirs;
use UserDirs;
use ProjectDirs;
pub fn base_dirs() -> Option<BaseDirs> { None }
pub fn user_dirs() -> Option<UserDirs> { None }
pub fn project_dirs_from_path(project_path: PathBuf) -> Option<ProjectDirs> { None }
pub fn project_dirs_f... |
#[macro_use]
extern crate bencher;
#[macro_use]
extern crate chomp;
use bencher::{black_box, Bencher};
use chomp::{or, token, take_while1, take_till, string, many, many1, Input, U8Result};
use chomp::buffer::{Stream, IntoStream};
#[derive(Debug)]
struct Request<'a> {
method: &'a [u8],
uri: &'a [u8],
... |
#[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::CTRL5 {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut... |
#![allow(proc_macro_derive_resolution_fallback)]
use schema::users;
#[derive(Queryable, AsChangeset, Serialize, Deserialize)]
#[table_name = "users"]
pub struct User {
pub id: i32,
pub email: String,
pub password: String,
}
|
// Copyright 2016 Urban Hafner
//
// 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 according to... |
use crate::support::*;
pub fn test() {
let mut server = server::udp();
let mut sock = udp::sock();
// Split a message into 2 chunks
let msg_chunks = net_chunks!(2, {
"host": "foo",
"short_message": "bar"
});
assert_eq!(2, msg_chunks.len());
sock.send(net_chunks![
... |
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*/
use std::mem;
use logger::logger::indexlog::DiskIndexConstructionCheckpoint;
use vector::FullPrecisionDistance;
use crate::common::{ANNResult, ANNError};
use crate::index::{InmemIndex, ANNInmemIndex};
use crate::ins... |
fn main() {
// The code bellow works like an "const char* " in C++
let s = "hello";
println!("The string is {}", s);
// Due to the behavior of be an type implemented at stack, will not allows you to push
// The code bellow works like an actual string in C++, i.e., will allocate in heap
// let m... |
#[doc = "Register `DDRPHYC_DTAR` reader"]
pub type R = crate::R<DDRPHYC_DTAR_SPEC>;
#[doc = "Register `DDRPHYC_DTAR` writer"]
pub type W = crate::W<DDRPHYC_DTAR_SPEC>;
#[doc = "Field `DTCOL` reader - DTCOL"]
pub type DTCOL_R = crate::FieldReader<u16>;
#[doc = "Field `DTCOL` writer - DTCOL"]
pub type DTCOL_W<'a, REG, co... |
use crate::{CursorContext, text_buffer::TextBuffer, Cursor};
#[derive(Debug, Clone)]
pub struct Transaction {
pub transaction_number: usize,
pub parent_pointer: usize,
pub action: EditAction,
}
#[derive(Debug, Clone)]
pub struct TransactionManager {
pub transactions: Vec<Transaction>,
pub current... |
use specs::*;
use types::*;
use component::channel::*;
use component::flag::*;
use consts::timer::*;
use systems::TimerHandler;
use SystemInfo;
use protocol::server::PlayerRespawn;
use protocol::Upgrades as ProtocolUpgrades;
use protocol::{to_bytes, ServerPacket};
use OwnedMessage;
pub struct PlayerRespawnSystem {... |
pub enum PivotMethod {
First,
Last,
MedianOfThree,
}
// return (index, value) of first element
fn choose_pivot_median_of_three(arr: &mut Vec<u64>, n: usize) -> (usize, u64) {
// TEMP
// bookkeeping
(0, arr[0])
}
// assumes first element is the pivot
// i is partition cutoff
// j is element being comp... |
use clap::{Arg, ArgAction, ArgMatches, Command};
use colored::Colorize;
use git2::{self, Repository, StatusOptions};
use itertools::join;
use std::env;
use std::path::PathBuf;
fn tico(path: &str, home_dir: Option<&str>) -> String {
let tico = match home_dir {
Some(dir) => path.replace(dir, "~"),
No... |
mod solution {
pub fn range_extraction(a: &[i32]) -> String {
let mut s = String::new();
let mut i = 0; let mut i_before = 0; let mut j = 0;
while i < a.len() {
s.push_str(&a[i].to_string());
j = i + 1; i_before = i;
if j < a.len() && a[i] == a[j]-1 {
... |
// This file is part of rdma-core. 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/rdma-core/master/COPYRIGHT. No part of rdma-core, including this file, may be copied, modified, propagated, or distributed ... |
use criterion::{criterion_group, criterion_main, Criterion};
use std::time::Duration;
extern crate image_utils;
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("read_image_and_create_two_variants", |b| {
b.iter(|| image_utils::read_image_and_create_two_variants())
});
}
criterion_gro... |
use crate::parser::{
ast::{ExprKind, If},
parser::SyntaxObject,
tokens::TokenType,
tryfrom_visitor::TryFromExprKindForSteelVal,
};
use crate::rerrs::{ErrorKind, SteelErr};
use crate::rvals::{Result, SteelVal};
use crate::{
compiler::compiler::OptLevel,
parser::{
ast::{Atom, Begin, Define... |
use serde::Deserialize;
use serde::Serialize;
use crate::api::models::timestamp::Timestamp;
use crate::common::deserialize_as_u64_from_number_or_string;
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Lock {
pub lock_id: String,
#[serde(deseria... |
#[macro_export]
macro_rules! vector2_impl {
($impl_type:ty) => {
impl std::ops::Add<&Vector2<$impl_type>> for &Vector2<$impl_type> {
type Output = Vector2<$impl_type>;
fn add(self, rhs: &Vector2<$impl_type>) -> Self::Output {
Vector2 {
x: self.x +... |
use aes::Aes128;
use block_modes::block_padding::Pkcs7;
use block_modes::{BlockMode, Cbc};
use hkdf::Hkdf;
use sha2::Sha256;
use rand::rngs::OsRng;
use rand::RngCore;
use colored::*;
use std::io::{self, Write};
pub mod adversary;
pub mod oracle;
pub mod ui;
use adversary::Adversary;
use oracle::Oracle;
type Aes12... |
use crate::{Device, Display};
use js_sys::Error;
use zerocopy::{AsBytes, FromBytes};
#[repr(align(16), C)]
#[derive(AsBytes, FromBytes, Debug, Default)]
pub struct DisplayData {
exposure: f32,
saturation: f32,
padding: [f32; 2],
}
impl Device {
pub(crate) fn update_display(&mut self, display: &Display... |
use crate::grid::config::Position;
#[cfg(feature = "std")]
use crate::grid::records::vec_records::{CellInfo, VecRecords};
/// A [`Records`] representation which can modify cell by (row, column) index.
///
/// [`Records`]: crate::grid::records::Records
pub trait RecordsMut<Text> {
/// Sets a text to a given cell by... |
//simple iterator
struct RangeIterator {
current: i32,
stop: i32,
step: i32
}
impl RangeIterator {
pub fn new(start: i32, stop: i32, step: i32) -> Self {
RangeIterator {
current: start,
stop,
step
}
}
}
impl Iterator for RangeIterator {
type ... |
use SafeWrapper;
use ir::{User, Instruction, Type};
use sys;
/// A landing pad.
pub struct LandingPadInst<'ctx>(Instruction<'ctx>);
impl<'ctx> LandingPadInst<'ctx>
{
/// Creates a landing pad instruction.
pub fn new(ret_ty: &Type) -> Self {
unsafe {
let inner = sys::LLVMRustCreateLandingPa... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub mod workspace_collections {
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
... |
#[doc = "Register `SYSCFG_ITLINE27` reader"]
pub type R = crate::R<SYSCFG_ITLINE27_SPEC>;
#[doc = "Field `USART1` reader - USART1 interrupt request pending, combined with EXTI line 25"]
pub type USART1_R = crate::BitReader;
impl R {
#[doc = "Bit 0 - USART1 interrupt request pending, combined with EXTI line 25"]
... |
use libc;
use libsolv_sys;
#[cfg(feature = "ext")]
use libsolvext_sys;
pub mod errors;
pub mod chksum;
pub mod pool;
pub mod queue;
pub mod repo;
pub mod solver;
pub mod sys;
pub mod transaction;
mod ownership;
pub use libsolv_sys::{solv_knownid, Id};
#[cfg(feature = "ext")]
pub mod ext;
#[cfg(test)]
mod tests {
... |
use crate::keywords::model::Keyword;
use crate::keywords::schema::keyword;
use diesel::result::Error;
use diesel::{MysqlConnection, RunQueryDsl};
pub fn save_keyword<'a>(conn: &MysqlConnection, id: i64, keyword: &'a str) -> Result<(), Error> {
let new_keyword = Keyword {
id,
keyword_str: keyword,
... |
/*
* Copyright 2019-2023 Didier Plaindoux
=======
* Copyright 2019-2021 Didier Plaindoux
>>>>>>> 45ec19c (Manage compiler warnings and change License header)
*
* 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 co... |
extern crate toml;
use errors::OtakuError;
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
#[derive(Debug)]
pub struct Config {
pub data_path: PathBuf,
}
impl Config {
pub fn from_file(config_file_path: &PathBuf) -> Result<Config, OtakuError> {
let mut raw_config = String::new();... |
use aoc_utils::prelude::*;
use std::env;
use std::time::Instant;
fn get_dist(p1: (i32, i32), p2: (i32, i32)) -> i32 {
return (p1.0 - p2.0).abs() + (p1.1 - p2.1).abs();
}
fn part1(input: &str) {
let mut input_buf = String::new();
let lines: Vec<Vec<(i32, i32, i32, i32)>> = read_lines(input, &mut input_buf,... |
use crate::species::Species;
///
/// Trait required for all animals in the petshop
pub trait Animal: std::fmt::Display {
fn name(&self) -> Option<String>;
fn set_name(&mut self, new_name: Option<String>);
fn species(&self) -> Box<dyn Species>;
}
|
// This file is part of Bit.Country.
// Copyright (C) 2020-2021 Bit.Country.
// 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
//
// http://www.apache... |
// Copyright 2018 Mozilla
//
// 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 in writing, software... |
//! Types and functions for manipulating SNES ROM binaries.
//!
//! The SNES uses various methods for mapping a contiguous ROM image onto its
//! address space. The [`Rom`] trait provides a common interface for accessing a
//! ROM through its mapped addresses.
//!
//! Retro Game Mechanics Explained has a
//! [good vide... |
extern crate base64;
extern crate reqwest;
use std::error::Error;
use std::io::{self, Cursor, Read};
use std::str;
use log::info;
use multipart::server::Multipart;
use reqwest::header::{HeaderMap, CONTENT_TYPE};
use rocket::data::{self, FromDataSimple};
use rocket::http::Status;
use rocket::{Data, Outcome::*, Request... |
// This file is part of rdma-core. 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/rdma-core/master/COPYRIGHT. No part of rdma-core, including this file, may be copied, modified, propagated, or distributed ... |
/* CAN (Controller Area Network) Wago I/O Device */
/* https://www.wago.com/us/controllers-bus-couplers-i-o/fieldbus-coupler-canopen/p/750-337#downloads */
/*
750_337 Communication Module - CANOpen
750_403 Discrete Module In PNP (24v Sensing)
750_408 Discrete Module In NPN (24v Sourcing)
750_504 Discre... |
mod agents;
mod components;
mod route;
use agents::WebSocketAgent;
use yew::prelude::*;
use yew_router::prelude::*;
use route::{switch, Route};
struct App {
// Keeps WebSocket connection alive
_ws_agent: Box<dyn Bridge<WebSocketAgent>>,
}
impl Component for App {
type Message = ();
type Properties =... |
use super::DbIterator;
use super::tuple::Tuple;
#[derive(Debug, Clone)]
pub struct Selection<I,P> {
pub input: I,
pub predicate: P,
}
impl <I: DbIterator, P> DbIterator for Selection<I,P>
where P: FnMut(&Tuple) -> bool,
{
fn next(&mut self) -> Option<Tuple> {
while let Some(x) = self.input.nex... |
use crate::commands::override_config;
use crate::config::persistence::pathfinder::ProviderPathfinder;
use clap::{App, Arg, ArgMatches};
use config::NymConfig;
use crypto::encryption;
use pemstore::pemstore::PemStore;
pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
App::new("init")
.about("Initialise t... |
/// Module to attack Vigenere cipher texts.
///
/// This module uses two approaches: a dictionary brute force method to guess probable word key used to cipher
/// a text using Vigenere algorithm and a frequency analysis attack.
///
/// You should be aware that to be successful charset used for attack should be the
/// ... |
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate seq_io;
extern crate criterion;
use std::io::Cursor;
use seq_io::fastq::{Reader, Record};
fuzz_target!(|data: &[u8]| {
let mut reader = Reader::with_capacity(data, 3);
let mut count: usize = 0;
while let Some(result) = reader.next() {
... |
use crate::application::events;
use crate::application::state::{AppData, State};
use crate::maths;
/// a layer, this is an artificial way of seperating code out into modules,
/// for example you may have a ui layer, a background layer, and a scene layer
/// ## Example
/// TODO: write usage example
#[allow(unused_varia... |
use std::time::Duration;
use tokio_cron_scheduler::{Job, JobScheduler};
#[tokio::main]
async fn main() {
let mut sched = JobScheduler::new();
let five_s_job = Job::new("1/5 * * * * *", |_uuid, _l| {
println!("{:?} I run every 5 seconds", chrono::Utc::now());
})
.unwrap();
let five_s_job_gu... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Operation {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serd... |
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("illegal USI command syntax")]
IllegalSyntax,
#[error("illegal USI command syntax")]
IllegalNumberFormat(#[from] std::num::ParseIntError),
#[error("the engine already started listening")]
IllegalOperation,
#[error("IO... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: support@datadoghq.com
* Generated by: https://openapi-generator.tech
*/
/// UsageComplianceHour : Compliance Monitoring usage for a given organization for a given hour.
#[de... |
use crossbeam_utils::{Backoff, CachePadded};
use smallvec::SmallVec;
use crate::atomic::{AtomicPtr, AtomicUsize};
use std::cell::UnsafeCell;
use std::cmp;
use std::marker::PhantomData;
use std::mem::MaybeUninit;
use std::ptr;
use std::sync::atomic::Ordering;
// size for block_node
pub const BLOCK_SIZE: usize = 1 << ... |
#[doc = "Register `MPCBB1_VCTR9` reader"]
pub type R = crate::R<MPCBB1_VCTR9_SPEC>;
#[doc = "Register `MPCBB1_VCTR9` writer"]
pub type W = crate::W<MPCBB1_VCTR9_SPEC>;
#[doc = "Field `B288` reader - B288"]
pub type B288_R = crate::BitReader;
#[doc = "Field `B288` writer - B288"]
pub type B288_W<'a, REG, const O: u8> = ... |
#[doc = "Register `ASCR` reader"]
pub type R = crate::R<ASCR_SPEC>;
#[doc = "Register `ASCR` writer"]
pub type W = crate::W<ASCR_SPEC>;
#[doc = "Field `ASC0` reader - These bits are written by software to configure the analog connection of the IOs."]
pub type ASC0_R = crate::BitReader<ASC0W_A>;
#[doc = "These bits are ... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - DTS_CFGR1 is the configuration register for temperature sensor 1."]
pub temp_cfgr1: TEMP_CFGR1,
_reserved1: [u8; 4usize],
#[doc = "0x08 - DTS_T0VALR1 contains the value of the factory calibration temperature (T0) for temper... |
//! Capture live traffic to analyze SSH fingerprinting
use std::time::Duration;
use pcap::{self, Active};
use crate::{
hassh::{Hassh, Hassher},
Error,
};
/// Capture live traffic
pub struct Capture {
cap: pcap::Capture<Active>,
hassher: Hassher,
}
impl Iterator for Capture {
type Item = Hassh;
... |
/*
Copyright 2019-2023 Didier Plaindoux
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... |
#[doc = "Register `SECCFGR` reader"]
pub type R = crate::R<SECCFGR_SPEC>;
#[doc = "Register `SECCFGR` writer"]
pub type W = crate::W<SECCFGR_SPEC>;
#[doc = "Field `WUP1SEC` reader - WKUP1 pin security"]
pub type WUP1SEC_R = crate::BitReader;
#[doc = "Field `WUP1SEC` writer - WKUP1 pin security"]
pub type WUP1SEC_W<'a, ... |
use std::env;
use std::fs;
use std::cmp::Ordering;
use std::collections::{BTreeSet, BinaryHeap};
use md5;
#[derive(Clone, Eq, PartialEq)]
struct State
{
cost : i32,
path : Vec<char>,
x : i32,
y : i32
}
impl State {
fn doors(&self, hash : &String) -> [bool; 4]
{
let mut res = [false; 4]... |
extern crate serde;
use serde::{Deserialize, Serialize};
pub const BUF_SIZE: usize = 64 * 1024; // max UDP packet size
#[derive(Debug, Serialize, Deserialize)]
pub struct Message {
pub msg_type: MsgType,
pub content: String,
}
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub enum MsgType {
Registe... |
extern crate actix_web;
use actix_web::{server, App, HttpRequest};
use std::time::SystemTime;
fn epoch() -> u64 {
match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
Ok(n) => n.as_secs(),
Err(_) => panic!("SystemTime before UNIX EPOCH!"),
}
}
fn index(_req: &HttpRequest) -> String... |
extern crate bindgen;
use std::env;
use std::path::PathBuf;
use std::process::Command;
const QUICKJS_VERSION: &'static str = "quickjs-2019-07-28";
fn main() {
// compile quickjs
if cfg!(target_os = "linux") || cfg!(target_os = "macos") {
Command::new("make")
.arg("libquickjs.bn.lto.a"... |
use librespot::{
core::{
authentication::Credentials, config::SessionConfig, session::Session, spotify_id::SpotifyId,
},
playback::{
audio_backend,
config::{AudioFormat, PlayerConfig},
mixer::NoOpVolume,
player::Player,
},
};
use librespot_connect::{
config::C... |
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
extern crate gl;
extern crate glutin;
use std::f32::consts::{FRAC_PI_2, PI};
use std::ffi::CStr;
use std::ffi::CString;
use std::io::Write;
use std::time::SystemTime;
use std::{fs, mem, ptr, str};
use serde::{Deserialize, Serialize};
use gl::types::... |
#![ feature( optin_builtin_traits ) ]
//
use
{
thespis :: { Actor, Message, Handler, Return, ReturnNoSend, Address } ,
thespis_impl :: { Addr } ,
async_executors :: { * } ,
futures :: { task... |
pub struct Solution {}
/**
https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/
**/
impl Solution {
pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 {
let mut i = 0;
for x in 0..nums.len() {
if i < 2 || nums[x] > nums[i - 2] {
nums[i] = nums[x];
... |
pub mod args;
pub mod compile;
|
enum Command {
Forward(i32),
Up(i32),
Down(i32),
}
fn parse_command(c: &str) -> Command {
let mut parts = c.split(' ');
let cmd = parts.next().unwrap();
let n = parts.next().unwrap().parse().unwrap();
if cmd == "forward" {
Command::Forward(n)
} else if cmd == "up" {
Comm... |
mod storage;
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct Index(Arc<InnerIndex>);
#[derive(Debug, Clone)]
pub(crate) struct InnerIndex {
storage: self::storage::Storage,
}
|
use mio::net::TcpListener;
use mio::{Events, Interest, Poll, Token};
use std::collections::HashMap;
use std::io;
use std::ops::BitOr;
const SERVER: Token = Token(0);
const DATA: &[u8] = b"Hello world!\n";
fn main() -> io::Result<()> {
let mut poll = Poll::new()?;
let mut events: Events = Events::with_capacit... |
mod author_repository;
mod category_repository;
mod collection_repository;
mod content_manager_repository;
mod interaction_repository;
mod publication_repository;
mod reader_repository;
pub use author_repository::*;
pub use category_repository::*;
pub use collection_repository::*;
pub use content_manager_repository::*;... |
use std::env;
use std::fmt;
use std::fs::File;
use std::io::prelude::*;
use failure::Error;
#[derive(Debug, Copy, Clone)]
enum TrackType {
Vertical,
Horizontal,
Clockwise,
CounterClockwise,
Junction,
}
impl TrackType {
fn from(c: char) -> Option<TrackType> {
match c {
'|' ... |
use std::sync::Arc;
use {
ast,
SyntaxNode, SyntaxRoot, TreeRoot, AstNode,
SyntaxKind::*,
};
// ArrayType
#[derive(Debug, Clone, Copy)]
pub struct ArrayType<R: TreeRoot = Arc<SyntaxRoot>> {
syntax: SyntaxNode<R>,
}
impl<R: TreeRoot> AstNode<R> for ArrayType<R> {
fn cast(syntax: SyntaxNode<R>) -> Op... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.