text stringlengths 8 4.13M |
|---|
use crate::util;
pub fn whoami() -> anyhow::Result<()> {
let username = util::get_username()?.unwrap_or("(not logged in)".to_string());
println!("{}", username);
Ok(())
}
|
use hex;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
fn main() {
let input = File::open("file.txt").unwrap();
find_the_xor(BufReader::new(input))
}
fn score_ascii_byte(c: u8) -> i64 {
let c = if b'A' <= c && c <= b'Z' {
c - b'A' + b'a'
} else {
c
};
retu... |
mod collection;
mod contract;
mod publication;
mod user;
pub use collection::*;
pub use contract::*;
pub use publication::*;
pub use user::*;
|
/* Copyright 2020 Yuchen Wong */
use opencv::core::{Mat, Scalar_, Size_, Vec3f};
use opencv::prelude::{MatTrait, Vector};
use opencv::types::{VectorOfMat};
use std::error::Error;
#[path = "../base/math_utils.rs"] mod math_utils;
pub fn map(src: &Mat,
alpha: f32,
phi: f32,
epsilon: f3... |
#[doc = "Register `MAXWLR` reader"]
pub type R = crate::R<MAXWLR_SPEC>;
#[doc = "Register `MAXWLR` writer"]
pub type W = crate::W<MAXWLR_SPEC>;
#[doc = "Field `MWL` reader - maximum data write length (when I3C is acting as target) This field is initially written by software when I3C_CFGR.EN=0 and updated by hardware on... |
mod http;
pub use self::http::index; |
//! A library for manipulating SMPTE timecodes.
use std::fmt;
use std::marker;
use std::ops;
use std::str;
mod frame_rate;
pub use frame_rate::{FrameRate, FrameRate2398, FrameRate24, FrameRate25,
FrameRate2997, FrameRate30, FrameRate50, FrameRate5994,
FrameRate60};
use fram... |
use async_std::os::unix::net::UnixStream;
use async_std::task;
use hyperspace_common::*;
mod freemap;
mod session;
mod stream;
pub use hyperspace_common::codegen;
pub use session::*;
pub use stream::*;
/// Open a remote corestore
///
/// Example:
/// ```no_run
/// # #[async_std::main]
/// # async fn main () -> anyho... |
#[doc = "Reader of register USBPHY_DIRECT_OVERRIDE"]
pub type R = crate::R<u32, super::USBPHY_DIRECT_OVERRIDE>;
#[doc = "Writer for register USBPHY_DIRECT_OVERRIDE"]
pub type W = crate::W<u32, super::USBPHY_DIRECT_OVERRIDE>;
#[doc = "Register USBPHY_DIRECT_OVERRIDE `reset()`'s with value 0"]
impl crate::ResetValue for ... |
/// AddTimeOption options for adding time to an issue
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct AddTimeOption {
pub created: Option<String>,
/// time in seconds
pub time: i64,
/// User who spent the time (optional)
pub user_name: Option<String>,
}
impl AddTimeOption {
... |
use std::io;
use bincode::{serialize, deserialize, Infinite};
use bytes::{BytesMut, BufMut};
trait SequentialStreamCodec {
type In;
type Out;
type Error;
fn decode(&mut self, buf: &mut BytesMut) -> Result<Self::In, Self::Error>;
fn encode(&mut self, msg: Self::Out, buf: &mut BytesMut);
}
struct S... |
#[doc = "Register `BGPFCCR` reader"]
pub type R = crate::R<BGPFCCR_SPEC>;
#[doc = "Register `BGPFCCR` writer"]
pub type W = crate::W<BGPFCCR_SPEC>;
#[doc = "Field `CM` reader - Color mode"]
pub type CM_R = crate::FieldReader;
#[doc = "Field `CM` writer - Color mode"]
pub type CM_W<'a, REG, const O: u8> = crate::FieldWr... |
use common::catalog::Catalog;
use common::logical_plan::*;
use common::table::*;
use common::{get_name, CrustyError, DataType, Field, PredicateOp};
use sqlparser::ast::{
BinaryOperator, Expr, Function, JoinConstraint, JoinOperator, SelectItem, SetExpr, TableFactor,
Value,
};
use std::collections::HashSet;
/// ... |
// vim: tw=80
//! Attributes are applied to the mock object, too.
use mockall::*;
pub struct A{}
#[automock]
impl A {
// Neither A::foo nor MockA::foo should be defined
#[cfg(target_os = "multics")] pub fn foo(&self, x: DoesNotExist) {}
// Both A::bar and MockA::bar should be defined
#[cfg(not(target_... |
use youchoose;
fn main() {
let mut menu = youchoose::Menu::new(0..100)
.preview(multiples) // Sets the preview function
.preview_pos(youchoose::ScreenSide::Bottom, 0.3) // Sets the position of the preview pane
.preview_label(" multiples ".to_string()) // Sets the text at the top of the prev... |
use crate::demo::data::DemoTick;
use crate::demo::message::packetentities::EntityId;
use crate::demo::message::packetentities::PacketEntity;
use crate::demo::message::{Message, MessageType};
use crate::demo::packet::datatable::ClassId;
use crate::demo::packet::stringtable::StringTableEntry;
use crate::demo::parser::ana... |
use crate::models::{ComicId, ComicIdInvalidity, Token};
use crate::util::{ensure_is_authorized, ensure_is_valid, AddMonths};
use actix_web::{error, web, HttpResponse, Result};
use actix_web_grants::permissions::AuthDetails;
use chrono::{DateTime, TimeZone, Utc};
use database::models::{Comic as DatabaseComic, LogEntry};... |
use nu_engine::{eval_block, CallExt};
use nu_protocol::ast::{Call, CellPath, PathMember};
use nu_protocol::engine::{CaptureBlock, Command, EngineState, Stack};
use nu_protocol::{
Category, Example, FromValue, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData,
ShellError, Signature, Span, SyntaxShape... |
use std::io;
fn main() {
let numbers = (1, 2, 3, 4.5);
println!("{:?}", numbers);
println!("{:?}", numbers.0);
println!("{:?}", numbers.3);
let l0 = 'V';
println!("{l0}");
let s: String = "Vilmar, o gatinho".to_string();
println!("{}", s);
let mut vazia : String = String::new();
vazia.push_str("Vilmar");
... |
//! Tests auto-converted from "sass-spec/spec/libsass-closed-issues/issue_713"
#[allow(unused)]
use super::rsass;
// From "sass-spec/spec/libsass-closed-issues/issue_713/and.hrx"
// Ignoring "and", error tests are not supported yet.
// From "sass-spec/spec/libsass-closed-issues/issue_713/not.hrx"
// Ignoring "not",... |
#![feature(test)]
extern crate extended_collections;
extern crate rand;
extern crate test;
use extended_collections::avl_tree::AvlMap;
use extended_collections::skiplist::SkipMap;
use extended_collections::treap::TreapMap;
use self::rand::Rng;
use std::collections::BTreeMap;
use test::Bencher;
const NUM_OF_OPERATIONS... |
pub(crate) unsafe fn raw_syscall(num: i64, arg0: u64, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) -> i64 {
let mut num = num;
asm!("syscall",
inout("rax") num,
in("rdi") arg0,
in("rsi") arg1,
in("rdx") arg2,
in("r8") arg3,
in("r9") arg4,
in("r10") arg... |
use std::{str::FromStr, num::ParseIntError};
use problem::{Problem, solve};
struct Input {
min_letter: u32,
max_letter: u32,
letter: char,
password: String,
}
impl Input {
fn is_valid(&self) -> bool {
let mut count = 0;
for c in self.password.chars() {
if c == self.lett... |
use image::{ImageBuffer, Rgb};
extern crate nom;
use nom::{
alt, character::complete::digit0, combinator::eof, do_parse, eof, many_till, map_res,
multi::many_till, named, opt, peek, tag, take_until,
};
use std::{fs::File, io::Read, path::PathBuf, str::FromStr, u32};
#[derive(Debug)]
struct Cluster {
pub c... |
//! Module defining the `Filters` struct, which represents the possible filters applicable on network traffic.
use crate::{AppProtocol, IpVersion, TransProtocol};
/// Possible filters applicable to network traffic
#[derive(Clone, Copy)]
pub struct Filters {
/// Internet Protocol version
pub ip: IpVersion,
... |
#[doc = "Register `CIFR` reader"]
pub type R = crate::R<CIFR_SPEC>;
#[doc = "Field `LSI1RDYF` reader - LSI1 ready interrupt flag"]
pub type LSI1RDYF_R = crate::BitReader;
#[doc = "Field `LSERDYF` reader - LSE ready interrupt flag"]
pub type LSERDYF_R = crate::BitReader;
#[doc = "Field `MSIRDYF` reader - MSI ready inter... |
use chrono::{NaiveDateTime, Utc};
use discorsd::BotState;
use discorsd::errors::{BotError, HangmanError};
use discorsd::http::channel::GetMessages;
use discorsd::model::ids::{ChannelId, GuildId, Id, MessageId};
use itertools::Itertools;
use once_cell::sync::Lazy;
use rand::{Rng, thread_rng};
use rand::prelude::SliceRan... |
#[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 - WUPx secure protection"]
pub type WUP1SEC_R = crate::BitReader;
#[doc = "Field `WUP1SEC` writer - WUPx secure protection"]
pub type WUP1SE... |
use pyo3_ffi::*;
use std::os::raw::c_char;
#[allow(non_snake_case)]
#[no_mangle]
pub unsafe extern "C" fn PyInit_pyo3_ffi_pure() -> *mut PyObject {
let module_name = "pyo3_ffi_pure\0".as_ptr() as *const c_char;
let init = PyModuleDef {
m_base: PyModuleDef_HEAD_INIT,
m_name: module_name,
... |
use proc_macro::TokenStream;
use quote::quote;
use syn;
#[proc_macro_derive(AttributesContainer, attributes(attributes))]
pub fn attributes_container_macro_derive(input: TokenStream) -> TokenStream {
let ast = syn::parse(input).expect("Error parsing input");
impl_attributes_container_macro(&ast)
}
fn impl_at... |
use std::io;
use std::io::prelude::*;
use std::process;
mod operation;
mod mixed_number;
mod fraction;
mod math;
/// Single evaluation mode evaluates the given expression and terminates
pub fn run_single_evaluation(expression: &str) {
let result = evaluate_expression(&expression);
if result.is_err() {
... |
pub mod stream_mapper;
use num_enum::IntoPrimitive;
use num_enum::TryFromPrimitive;
use super::enums::*;
#[repr(u8)]
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, IntoPrimitive, TryFromPrimitive)]
pub enum OpCode {
AdvertisementPacket = 0,
CreateConnectionChannelResponse = 1,
ConnectionStatusChanged ... |
//! Types used by [`crate::Transport`].
use crate::data::channel;
use crate::data::history;
use crate::data::message::Message;
use crate::data::object::Object;
use crate::data::presence;
use crate::data::timetoken::Timetoken;
use std::collections::HashMap;
/// A response to a publish request.
pub type Publish = Timet... |
#![deny(missing_docs, warnings)]
#![allow(unstable)]
//! `Router` provides a fast router handler for the Iron web framework.
extern crate iron;
extern crate "route-recognizer" as recognizer;
#[cfg(test)] extern crate test;
pub use router::Router;
pub use recognizer::Params;
mod router;
|
/*******************************************************
* Copyright (C) 2019,2020 Jonathan Gerber <jlgerber@gmail.com>
*
* This file is part of packybara.
*
* packybara can not be copied and/or distributed without the express
* permission of Jonathan Gerber
******************************************************... |
//! Interacting with debugging agent
//!
//! # Example
//!
//! This example will show how to terminate the QEMU session. The program
//! should be running under QEMU with semihosting enabled
//! (use `-semihosting` flag).
//!
//! Target program:
//!
//! ```no_run
//! use cortex_m_semihosting::debug::{self, EXIT_SUCCESS... |
/// Acceptor class handles the acceptance of inbound socket connections. It's
/// used to start listening on a local socket address, to accept incoming
/// connections and to handle network errors.
pub mod acceptor;
/// Async channel that handles the sending of messages across the network.
/// Public interface is used... |
#[macro_use] extern crate modelone;
#[macro_use] extern crate uione;
use modelone::object::*;
use modelone::history::*;
use modelone::change_string::*;
use modelone::change_vec::*;
use modelone::change_value::*;
use uione::vec2::*;
use uione::*;
use std::sync::Arc;
#[derive(Debug, Clone, PartialEq)]
struct NameReco... |
pub trait DigitalOutput: Send {
fn set_value(&mut self, val: bool);
}
|
use crate::{server::UdpTuple, transport::TransportMsg, Error};
use common::rsip::{self, prelude::*, Transport};
use std::convert::{TryFrom, TryInto};
use std::net::SocketAddr;
//TODO: we probably need better naming here
#[derive(Debug, Clone)]
pub struct RequestMsg {
pub sip_request: rsip::Request,
pub peer: S... |
extern crate byteorder;
extern crate encoding_rs;
#[macro_use]
extern crate failure;
extern crate goblin;
extern crate image;
extern crate regex;
extern crate rustc_demangle;
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate standalone_syn as syn;
extern crate toml;
extern crate zip;
mod assembl... |
use super::{operate, BytesArgument};
use nu_engine::CallExt;
use nu_protocol::ast::Call;
use nu_protocol::ast::CellPath;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value,
};
use std::cmp::Ordering;
#[derive(C... |
use std::hash::Hash;
use std::marker::PhantomData;
use bit_vec::BitVec;
use hash::NthHash;
#[derive(Debug)]
pub struct BloomFilter<T: ?Sized> {
bits: BitVec,
slice_bitwidth: usize,
number_of_slices: usize,
_value: PhantomData<T>,
}
impl<T: Hash + ?Sized> BloomFilter<T> {
pub fn new(slice_bitwidth:... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - RAMECC interrupt enable register"]
pub ier: IER,
_reserved1: [u8; 0x1c],
#[doc = "0x20 - RAMECC monitor x configuration register"]
pub m1cr: M1CR,
#[doc = "0x24 - RAMECC monitor x status register"]
pub m1sr: M1S... |
use crate_with_external_symbols::test_not_using_extern;
fn main() {
test_not_using_extern();
println!("Hello, world!");
}
|
extern crate itertools;
extern crate rand;
use itertools::Itertools;
use rand::thread_rng;
mod genetic_architecture;
mod population;
mod samplers;
// Simulation of Hardy model
//
// Assumes a single diploid autosome with a single locus.
// There are two alleles, resulting in three possible genotypes.
// There is no ... |
use crate::ast;
use crate::{Parse, ParseError, Peek, Resolve, Spanned, Storage, ToTokens};
use runestick::Source;
use std::borrow::Cow;
/// A path, where each element is separated by a `::`.
#[derive(Debug, Clone, ToTokens, Spanned, Parse)]
pub struct Path {
/// The first component in the path.
pub first: ast:... |
mod convex_hull;
mod hanoi;
mod kmeans;
mod xorshift;
pub use self::convex_hull::convex_hull_graham;
pub use self::hanoi::hanoi;
pub use self::kmeans::f32::kmeans as kmeans_f32;
pub use self::kmeans::f64::kmeans as kmeans_f64;
pub use self::xorshift::Rand;
|
use std::cmp::{ Eq, PartialEq };
#[derive(Eq, PartialEq, Debug)]
pub struct ObjectKey {
object_type: String,
named: String,
}
impl ObjectKey {
pub fn new(object_type: &str) -> ObjectKey {
ObjectKey {
object_type: object_type.to_string(),
named: "".to_string(),
}
... |
//! Classification of structurally significant JSON bytes.
//!
//! Provides the [`Structural`] struct and [`StructuralIterator`] trait
//! that allow effectively iterating over structural characters in a JSON document.
//!
//! Classifying [`Commas`](`Structural::Comma`) and [`Colons`](`Structural::Colon`) is disabled b... |
use std::env;
use std::str::FromStr;
fn gcd(mut x: u64, mut y: u64) -> u64 {
assert!(x != 0 && y != 0);
while x != 0 {
if x < y {
let t = x;
x = y;
y = t;
}
x = x % y
}
y
}
fn main() {
let mut numbers: Vec<u64> = Vec::new();
for numb... |
// Copyright (C) 2021 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use nom::bytes::complete::take_while;
use nom::character::complete::space0;
use nom::character::is_alphanumeric;
use nom::{Err, IResult, Needed};
use std:... |
use crate::{
Load,
MemmyGenerator
};
use notices::{
DiagnosticSourceBuilder,
DiagnosticLevel
};
use ty::Ty;
use ir::{
Chunk,
hir::HIRInstruction
};
use ir_traits::ReadInstruction;
impl Load for Ty{
type Output = Ty;
fn load(chunk: &Chunk, memmy: &MemmyGenerator) -> Result<Self::Out... |
use sdl::video::{SurfaceFlag, VideoFlag};
pub fn init() -> (sdl::video::Surface, sdl::video::VideoInfo) {
sdl::init(&[sdl::InitFlag::Video]);
let best = sdl::video::get_video_info();
let screen = match sdl::video::set_video_mode(
best.width,
best.height,
best.format.bpp as isize,
... |
use std::cell::RefCell;
use std::mem;
use std::rc::{Rc, Weak};
use iter_exact::{ChainExactExt, CollectExactExt};
use geometry::primitive::{Facet, Plane, Point, SimplexSubset};
use linalg::{Scalar, Vect, VectorNorm};
use num::traits::Float;
use typehack::prelude::*;
// TODO: This quickhull implementation is not well... |
use std::{error::Error, fmt, io};
#[derive(Debug)]
pub enum LoraWanError {
InvalidPacketType(u8),
InvalidFPortForFopts,
Io(io::Error),
}
impl fmt::Display for LoraWanError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
LoraWanError::InvalidPacketType(v) =... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - the control interface must clear the STGEN_CNTCR.EN bit before writing to this register."]
pub stgenr_cntcvl: STGENR_CNTCVL,
#[doc = "0x04 - the control interface must clear the STGEN_CNTCR.EN bit before writing to this registe... |
use std::ops::{Add, Sub};
#[derive(Copy, Clone, Debug)]
pub struct Point {
pub x: f32,
pub y: f32,
}
impl Point {
pub fn new(x: f32, y: f32) -> Point {
Point { x: x, y: y }
}
pub fn from_tuple(t: (f32, f32)) -> Point {
Point::new(t.0, t.1)
}
pub fn zero() -> Point {
... |
#[doc = "Register `ISR` reader"]
pub type R = crate::R<ISR_SPEC>;
#[doc = "Register `ISR` writer"]
pub type W = crate::W<ISR_SPEC>;
#[doc = "Field `ADRDY` reader - ADC ready flag"]
pub type ADRDY_R = crate::BitReader;
#[doc = "Field `ADRDY` writer - ADC ready flag"]
pub type ADRDY_W<'a, REG, const O: u8> = crate::BitWr... |
use crate::{
gui::{BuildContext, Ui, UiMessage, UiNode},
scene::commands::{
light::{
SetSpotLightDistanceCommand, SetSpotLightFalloffAngleDeltaCommand,
SetSpotLightHotspotCommand,
},
SceneCommand,
},
send_sync_message,
sidebar::{make_f32_input_field, m... |
mod q2v1q;
mod q2v2q;
mod q2v3q;
mod q2v4q;
mod q2v5q;
mod q2v6q;
mod q2v7q;
mod q2v8q;
mod q2v9q;
use q2v1q::vec_macro;
use q2v2q::new_pixel_buffer;
use q2v3q::new_vec;
use q2v4q::it_vec;
use q2v5q::palindrome;
use q2v6q::capacity;
use q2v7q::in_rm_vec;
use q2v8q::pop_vec;
use q2v9q::imp_or_fun;
fn main() {
vec_... |
use super::*;
use crate::resources::ResourceType;
use crate::{requests, ReadonlyString};
use azure_core::HttpClient;
/// A client for Cosmos trigger resources.
#[derive(Debug, Clone)]
pub struct TriggerClient {
collection_client: CollectionClient,
trigger_name: ReadonlyString,
}
impl TriggerClient {
/// C... |
//! Helper types for working with GCS
use crate::error::Error;
use std::borrow::Cow;
/// A wrapper around strings meant to be used as bucket names,
/// to validate they conform to [Bucket Name Requirements](https://cloud.google.com/storage/docs/naming#requirements)
#[derive(Debug)]
pub struct BucketName<'a> {
nam... |
#[derive(Debug, PartialEq, Clone)]
pub struct Program {
pub declarations: Option<Declarations>,
pub commands: Commands,
}
pub type Declarations = Vec<Declaration>;
#[derive(Debug, PartialEq, Clone)]
pub enum Declaration {
Var { name: String },
Array { name: String, start: i64, end: i64 },
}
impl Decl... |
// Copyright 2016 FullContact, Inc
// Copyright 2017 Jason Lingle
//
// 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... |
#[derive(Clone)]
struct Person {
name: String,
age: i32,
height: i32,
weight: i32,
}
fn person_create(name: String, age: i32, height: i32, weight: i32) -> Box<Person> {
let who = Box::new(Person{name, age, height, weight});
return who;
}
fn person_print(who: Box<Person>) -> () {
println!("... |
struct ShutdownRequest;
impl Request for ShutdownRequest {
fn make_message() -> RequestMessage<ShutdownRequest> {
IncompleteRequestMessage {
method: "shutdown",
params: ShutdownRequest
}
}
}
struct ShutDownResponse;
|
#![feature(proc_macro)]
// import macbuild!() and #[register]
extern crate macbuild_macros;
use macbuild_macros::*;
// this generates code to import bootstrap()
macbuild!();
fn main() {
bootstrap(); // this calls all functions annotated with #[register]
}
/// first registered function
#[register]
pub fn a() {
... |
/*
* 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.
*/
use juno::ast::{Node, NodeKind, NodePtr, SourceLoc, SourceRange, Visitor};
mod validate;
pub fn node(kind: NodeKind) -> Box<Node>... |
fn main() {
let func: fn(i32) -> i32 = plus_one; // This is a function pointer
/*
Having a function pointer enables us to point
to a specific function (as long as the return types match)
and thereby instantiate variables based on the function pointer
*/
let seven = func(6);
prin... |
#![allow(dead_code)]
#![allow(unused_variables)]
fn main() {
/*
Let's define a 'method'.
Quite like 'function', but it
=> definied within the context of 'struct' (or enum, trait)
=> first param is `self` (like Python, I think), not all.
*/
let rc1 = Rect {width: 25... |
use std::{
collections::HashMap,
fmt,
future::Future,
io::{self, Read, Seek, SeekFrom},
mem,
pin::Pin,
process::exit,
sync::{
atomic::{AtomicUsize, Ordering},
Arc,
},
task::{Context, Poll},
thread,
time::{Duration, Instant},
};
use futures_util::{
fut... |
use std::collections::HashMap;
use actix_web::{
web::{Data, Path, Query},
Responder,
};
use tracing::info;
use tracing::instrument;
use htsget_http::{get, Endpoint};
use htsget_search::htsget::HtsGet;
use crate::AppState;
use super::handle_response;
/// GET request reads endpoint
#[instrument(skip(app_state))]... |
use super::request;
use std::fmt;
#[derive(Debug, PartialEq, Clone, Eq, Hash)]
pub struct KeyType(String);
impl fmt::Display for KeyType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}
impl From<Key> for KeyType {
fn from(k: Key) -> Self {
use self::Mo... |
extern crate url_serde;
extern crate serde_json;
use std::mem;
use std::collections::hash_map::DefaultHasher;
use std::collections::HashSet;
use std::hash::{Hash, Hasher};
use chrono::prelude::*;
use sha2::{Sha256, Digest};
use byteorder::{BigEndian, WriteBytesExt};
use url::Url;
use futures::{Future, Stream};
use hyp... |
/*
* 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... |
#![feature(in_band_lifetimes, cell_update)]
mod camera;
mod inspect;
mod render;
mod transform;
mod world;
use futures::executor::block_on;
use imgui::{im_str, ComboBox, Condition, FontSource, ImString};
use imgui_inspect::{InspectArgsStruct, InspectRenderStruct};
use inspect::IntoInspect;
use log::info;
use nalgebr... |
mod q02asf1q;
use q02asf1q::gcd;
fn main () {
let n = gcd(12, 16);
println!("greatest common divisor of 12 and 16 is {}", n);
}
|
use super::Provider;
use crate::{BoxFuture, Result};
pub trait ProviderFactory: Send + Sync + 'static {
type Provider: Provider;
fn create_provider(&self) -> BoxFuture<'_, Result<Self::Provider>>;
}
|
//! # Storage initialization
//!
//! This modules initializes the storage, by inserting values into the node using the ICS26
//! interface.
//!
//! The initial values are taken from the configuration (see `config` module).
use std::str::FromStr;
use ibc::{
ics02_client::client_state::AnyClientState, ics02_client::... |
// Fichero que usamos para reimportar modulos
// Asi tenemos todos los algoritmos disponibles con crate::algorithms::<nombre>
pub mod local_search;
pub mod copkmeans;
pub mod generational_genetic;
pub mod steady_genetic;
pub mod memetic;
pub mod multistart_local_search;
pub mod iterative_local_search;
pub mod simulate... |
#![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 rand::rngs::StdRng;
use rand::{RngCore, SeedableRng};
use hybridpir::server::HybridPirServer;
fn main() {
env_logger::init();
let id = std::env::args().nth(1).unwrap().parse().unwrap();
let mut prng = StdRng::seed_from_u64(1234);
let size = 1 << 22;
let raidpir_servers = 2;
let raidpir_... |
// Copyright 2017 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... |
//this will be the global state; including what the current data, index, registers, etc are at any time
//this will get trick I think as in C++ we use ptrs to manipulate data dn indices, which we wont be doing here
pub struct GlobalState {
pub current_index: usize,
pub data: [char; 8],
pub x_register: char... |
extern crate rand;
use std::fs::File;
use std::io::{Write};
use std::time::Instant;
use std::process::exit;
extern crate serde;
use serde::Deserialize;
extern crate serde_json;
extern crate rmp_serde;
use rmp_serde::Deserializer;
extern crate rayon;
use rayon::prelude::*;
#[macro_use(value_t)]
extern crate clap;
use... |
use sqlx::{query_file, query_file_as, Error, PgPool};
use uuid::Uuid;
use super::image::{Image, NewImage};
pub struct AppUser {
pub id: Uuid,
pub created: time::OffsetDateTime,
pub email: String,
pub password_hash: String,
pub is_admin: bool,
}
impl AppUser {
pub async fn new(
pool: &... |
// 2019-01-17 Déplacé le module dans son fichier à lui
// un struct est rendu public par pub, mais pas ses champs
// pas besoin d'annoncer la couleur avec mod plante { }
// En effet, on est l'a déjà fait avec mod plante; dans main.rs
#[derive(Debug)] // pour afficher les structs
pub struct Legume { ... |
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
//! An example that tracks thread pedigree using local state.
use std::io;
use std::mem;
use bitv... |
use crate::schema::shopify_connections;
use crate::utils::now;
use chrono::naive::NaiveDateTime;
use diesel::prelude::*;
#[derive(Debug, Identifiable, Queryable)]
#[table_name = "shopify_connections"]
pub struct ShopifyConnection {
pub id: i32,
pub shop: String,
pub nonce: String,
pub access_token: Opt... |
pub(in crate) mod empty_iterator;
pub(in crate) mod generator_iterator;
|
use std::fs;
use aoc20::days::day3::{Geology};
fn geology() -> Geology {
let contents = fs::read_to_string("data/day3example.txt")
.expect("Something went wrong reading the file");
Geology::new(&contents)
}
#[test]
fn day3_parse() {
let geo = geology();
assert_eq!(geo.width(), 11);
ass... |
use http::request::Parts;
pub fn get_root_path(parts: &Parts) -> String {
match parts.uri.path() {
"/" => "default".to_owned(),
_ => {
let stage_one: Vec<&str> = parts.uri.path().split("/").collect(); // Convert to array
let stage_two = &stage_one[1..stage_one.len() - 1]; // R... |
//! This module contains general interrupt handlers.
//!
//! None of the contained interrupt handlers should be architecture specific.
//! They should instead
//! be called by the architecture specific interrupt handlers.
use arch::{self, schedule, Architecture};
use memory::VirtualAddress;
use multitasking::CURRENT_T... |
use once_cell::sync::Lazy;
#[link(wasm_import_module = "host")]
extern "C" {
#[link_name = "draw_str"]
fn draw_str_low_level(ptr: i32, len: i32, x: f32, y: f32);
fn draw_rect(x: f32, y: f32, width: f32, height: f32);
fn save();
fn clip_rect(x: f32, y: f32, width: f32, height: f32);
fn draw_rrec... |
use yew::prelude::*;
use yew_router::component;
use yew_router::route;
use yew_router::{Route, Router};
use crate::page_not_found::PageNotFound;
pub struct AComp {}
pub enum Msg {}
impl Component for AComp {
type Message = Msg;
type Properties = ();
fn create(_props: Self::Properties, _link: ComponentL... |
use nix::unistd::Pid;
use std::fs::File;
use std::io::{Read, Write};
use std::path::PathBuf;
use std::process::{Child, Command, Stdio};
use crate::configs::FunctionConfig;
use crate::request::Request;
use crate::request;
use cgroups::{cgroup_builder::CgroupBuilder, Cgroup};
use log::{info, warn, error};
pub enum VmSt... |
use crate::dither::{Ditherer, DithererBuilder};
use zerocopy::AsBytes;
#[derive(AsBytes, Copy, Clone, Debug)]
#[allow(non_camel_case_types)]
#[repr(transparent)]
pub struct i24([u8; 3]);
impl i24 {
fn from_s24(sample: i32) -> Self {
// trim the padding in the most significant byte
#[allow(unused_va... |
// Biquadratic (BiQuad) Infinite Impulse Response (IIR) Filter.
/// Generic vector for integer IIR filter.
/// This struct is used to hold the x/y input/output data vector or the b/a coefficient
/// vector.
pub type Vec5 = [i32; 5];
/// Main IIR struct holds coefficient vector and a shift value which defines the ... |
use super::responses::GetTipsResponse;
use crate::Result;
use reqwest::Client;
/// Returns the list of tups
pub async fn get_tips(client: Client, uri: String) -> Result<GetTipsResponse> {
let body = json!({
"command": "getTips",
});
Ok(client
.post(&uri)
.header("ContentType", "appl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.