text stringlengths 8 4.13M |
|---|
fn main() {
let s1 = String::from("Hello");
let s2 = s1.clone();
//takes_ownership(s1);
//let x = 5;
//makes_copy(x);
//println!("{}", x);
//let len = calculate_length(&s1);
//println!("{}", len)
let mut s = String::from("hello");
let r1 = &s;
let r2 = &s;
println!(... |
#![feature(test)]
extern crate test;
extern crate raytracer;
use test::Bencher;
use raytracer::*;
#[bench]
fn bench_perlin(b: &mut Bencher) {
let v = Vec3::new(0.5, 0.6, 0.7);
b.iter(|| perlin_noise(&v))
}
|
use crate::Literal;
use std::mem::swap;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct CRef {
idx: u32,
len: u16,
}
impl CRef {
pub fn iter<'a>(&'a self, db: &'a Database) -> impl Iterator<Item = &Literal> + 'a {
self.as_slice(db).iter()
}
#[inline]
pub fn as_slice<'a>(&'a self, db: &'a... |
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
use std::iter::Iterator;
use std::ops::{Add, AddAssign, Mul};
use std::str::FromStr;
use std::fmt::Debug;
/// The output is wrapped in a Result to allow matching on errors
/// Returns an Iterator to the Reader of the lines of the file.
pub fn read_... |
use crate::error::Error;
pub enum CloseReason {
Normal,
Abnormal(Error),
}
|
use libc;
/*
* raidautorun implementation for busybox
*
* Copyright (C) 2006 Bernhard Reutner-Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
//config:config RAIDAUTORUN
//config: bool "raidautorun (1.3 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
//... |
//! Handles all the FASTA/FASTQ parsing
use std::fs::File;
use std::io::{stdin, Cursor, Read};
use std::path::Path;
#[cfg(feature = "compression")]
use bzip2::read::BzDecoder;
#[cfg(feature = "compression")]
use flate2::read::MultiGzDecoder;
#[cfg(feature = "compression")]
use xz2::read::XzDecoder;
use crate::errors:... |
/**
* Copyright © 2019
* Sami Shalayel <sami.shalayel@tutamail.com>,
* Carl Schwan <carl@carlschwan.eu>,
* Daniel Freiermuth <d_freiermu14@cs.uni-kl.de>
*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published... |
#![feature(test)]
extern crate test;
use test::Bencher;
extern crate graph_layout;
use graph_layout::layout::*;
use graph_layout::compression::*;
#[bench]
fn encode_decode_h(bencher: &mut Bencher) {
let tangler = Hilbert::new();
let mut index = 0;
bencher.iter(|| { index += 1; assert!(index == tangler.ent... |
use std::sync::Arc;
use sourcerenderer_core::graphics::{
Backend,
CommandBuffer,
Device,
Queue,
Swapchain,
SwapchainError, FenceRef,
};
use sourcerenderer_core::Platform;
use crate::input::Input;
use crate::renderer::render_path::{
FrameInfo,
RenderPath,
SceneInfo,
ZeroTextures... |
use proconio::input;
use std::collections::HashSet;
fn main() {
input! {
n: usize,
x: i32,
y: i32,
a: [i32; n],
};
let mut dp_x = HashSet::new();
dp_x.insert(a[0]);
let mut dp_y = HashSet::new();
dp_y.insert(0);
for i in 1..n {
if i % 2 == 1 {
... |
// This file is part of linux-epoll. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-epoll/master/COPYRIGHT. No part of linux-epoll, including this file, may be copied, modified, propagated, or distri... |
mod models;
use models::{Stock, CreateStock, ShipStock, ArriveStock, StockEvent};
fn print_restore(events: Vec<&StockEvent>) {
println!(
"*** restore {}: {:?}",
events.len(),
Stock::restore(Stock::Nothing, events)
);
}
fn main() {
let id1 = "s1";
let r1 = Stock::handle(Stock... |
use crate::auth::AuthParam;
use crate::list_form::ListForm;
use serde::{Deserialize, Serialize};
use structopt::StructOpt;
#[derive(Debug, Serialize, Deserialize, StructOpt)]
#[structopt(about = "Occurrence related operations")]
#[serde(untagged)]
pub enum OccurrenceCmd {
#[serde(rename_all = "camelCase")]
#... |
use std::io::{self, prelude::*};
use std::net::TcpStream;
use tui::Terminal;
use tui::backend::CrosstermBackend;
use tui::widgets::{Widget, Block, Borders, Paragraph, Wrap};
use tui::layout::{Layout, Constraint, Direction};
use tui::text::{Spans, Span};
fn main() -> std::io::Result<()> {
let stdout = io::stdout();... |
pub mod use_case_diagram;
|
// Copyright (c) 2021 ESRLabs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agre... |
// 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 ... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Clock control register"]
pub cr: CR,
#[doc = "0x04 - Internal clock sources calibration register"]
pub icscr: ICSCR,
#[doc = "0x08 - Clock configuration register"]
pub cfgr: CFGR,
#[doc = "0x0c - Clock interrupt... |
use openexr_sys as sys;
use std::ffi::CString;
use std::path::Path;
use crate::core::{error::Error, header::HeaderRef, version::Version};
type Result<T, E = Error> = std::result::Result<T, E>;
/// Manages writing multi-part images.
///
/// Multi-part images are essentially just containers around multiple
/// [`Inpu... |
use std::path::Path;
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
use std::env;
use echain::{ErrorKind, Result};
use gtk;
use gtk::prelude::*;
use gtk::{Builder, Window, WidgetExt, TreeView, TreeViewExt, TreeViewColumn, CellRendererText, TreeStore, TreeModel, TextTag};
use sourceview::{Buffer, Bu... |
/// Defines a bloc in LaTex
/// for example \begin{center}...\end{center}
///
use core::*;
use latex_file::LatexFile;
use std::io::BufWriter;
use std::io::Write;
use writable::*;
#[derive(Clone)]
pub struct Bloc {
/// The type of the Bloc
bloc_type: String,
/// The content in the Bloc
content: Vec<Core... |
fn main() {
println!("Don't forget --release before you benchmark!");
}
|
//! Traits for generic code over low and high bit depth video.
//!
//! Borrowed from rav1e.
use num_traits::{AsPrimitive, PrimInt};
use std::fmt::{Debug, Display};
/// Defines a type which supports being cast to from a generic integer type.
///
/// Intended for casting to and from a [`Pixel`](trait.Pixel.html).
pub t... |
use anyhow::Result;
use app::{
models::{cache, entry, entry_tag, tag},
templates::get_env,
};
use camino::Utf8Path;
use glob::glob;
use lol_html::{element, html_content::ContentType, text, HtmlRewriter, Settings};
use minijinja::context;
use pathdiff::diff_utf8_paths;
use sea_orm::{
prelude::*, sea_query::Index, Act... |
use crate::{config::ServerConfig, connect};
use futures_util::ready;
use futures_util::stream::{Stream, StreamExt};
use hyper::server::{accept::from_stream, conn::Http, Builder};
use hyper::service::{make_service_fn, service_fn};
use std::convert::Infallible;
use std::net::IpAddr;
use std::pin::Pin;
use std::sync::Arc;... |
//! Contains constructs for describing the nodes in a Binary Merkle Patricia Tree
//! used by Starknet.
//!
//! For more information about how these Starknet trees are structured, see
//! [`MerkleTree`](crate::tree::MerkleTree).
use std::{cell::RefCell, rc::Rc};
use bitvec::{order::Msb0, prelude::BitVec, slice::BitSl... |
use procon_reader::ProconReader;
use std::collections::HashMap;
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let n: usize = rd.get();
let a: Vec<u32> = rd.get_vec(n);
let mut freq = HashMap::new();
let mut ans = n * (n - 1) / 2;
for x in a {
... |
// 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::*;
use crate::{TableIndex, TypeReader};
#[derive(Copy, Clone)]
pub struct InterfaceImpl {
pub reader: &'static TypeReader,
pub row: Row,
}
impl InterfaceImpl {
pub fn interface(&self) -> TypeDefOrRef {
self.reader.decode(self.row, 1)
}
pub fn attributes(&self) -> impl Iterator<... |
#![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 AllJoynAboutData(pub ::windows::core::IInspect... |
#![allow(non_snake_case)]
use core::convert::TryInto;
use test_winrt_signatures::*;
use windows::core::*;
use Component::Signatures::*;
#[implement(Component::Signatures::ITestInt16)]
struct RustTest();
impl RustTest {
fn SignatureInt16(&self, a: i16, b: &mut i16) -> Result<i16> {
*b = a;
Ok(a)
... |
use super::super::client::SendClientRPC;
use super::super::common_rpc_types::{GraphCommonArgs, NodeName, ShellStartCodeChainRequest, UpdateCodeChainRequest};
use super::super::router::Router;
use super::super::rpc::{response, RPCError, RPCResponse};
use super::types::{
Context, DashboardGetNetworkResponse, Dashboar... |
#[doc = r" Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Configuration for shared functions."]
pub cfg: CFG,
#[doc = "0x04 - Status register for Master, Slave, and Monitor functions."]
pub stat: STAT,
#[doc = "0x08 - Interrupt Enable Set and read register."]
pub intenset... |
//! Grammar-based mutators and related utilties.
//!
//! This module provides a grammar-based `impl Mutator<AST>` which generates an abstract syntax
//! tree satisfying a grammar, created through [`grammar_based_ast_mutator`]. The resulting mutator can be
//! transformed into a `Mutator<(AST, String)>`, where the secon... |
use hex::encode;
use rand::Rng;
pub mod iso {
//! ISO compatible UUID generators
use super::encode;
use super::Rng;
/// Generate UUID following ISO standards
pub fn uuid_v4() -> String {
let bytes = (
encode(rand::thread_rng().gen::<[u8; 4]>()),
encode(rand::thread_... |
use hyper::{Response, Body, StatusCode};
/// # Forbidden
/// Returns a response payload that indicates a 403 forbidden.
pub(crate) fn forbidden() -> Response<Body> {
match Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("403 Forbidden"))
{
Ok(response) => response,
... |
#[path = "../repository/employee_repo.rs"] mod employee_repo;
use employee_repo::*;
use models::*;
use warp::{Filter, Rejection, Reply};
pub fn create_employee_endpoints() -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
let employees = warp::path("employees");
let get_all = employees... |
//! statusplaybefore1stcard.rs - code flow from this status
//region: use
use crate::gamedata::CardStatusCardFace;
use crate::rootrenderingcomponent::RootRenderingComponent;
use crate::websocketcommunication;
use crate::logmod;
use mem4_common::{GameStatus, WsMessage};
use dodrio::builder::text;
use dodrio::bumpalo::... |
/*
Primitive Types--
Integers: u8, i8, u16, i16, u32, i32, u64, i64, u128, i128 (number of bits they take in memory)
Floats: f32, f64
Boolean (bool)
Characters (char)
Tuples
Arrays
*/
// Rust is a statically typed language, which means that it
// must know the types of all variables at compile time.
pub fn run() {
... |
#![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 AppRecordingManager(pub ::windows::core::IInsp... |
// 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 {
crate::{capability::*, model::*},
cm_rust::{
self, CapabilityPath, ExposeDecl, ExposeSource, ExposeTarget, OfferDecl,
OfferDi... |
//! Contains an ffi-safe wrapper for `parking_lot::Once`.
use std::{
any::Any,
fmt::{self, Debug},
mem,
panic::{self, AssertUnwindSafe},
};
use parking_lot::{Once as PLOnce, OnceState};
use super::{UnsafeOveralignedField, RAW_LOCK_SIZE};
use crate::{
prefix_type::WithMetadata,
sabi_types::RMu... |
use crypto::ripemd160::Ripemd160 ;
use crypto::digest::Digest;
pub struct JRipemd160 {
pub jripemd160x: Ripemd160,
}
impl JRipemd160 {
pub fn new() -> Self {
JRipemd160 {
jripemd160x: Ripemd160::new(),
}
}
pub fn input(&mut self, input: &[u8]) {
self.jripemd160x.in... |
#[cfg(feature = "mongo-backend")]
use bson;
#[cfg(feature = "redis-backend")]
use redis::{ErrorKind, FromRedisValue, RedisResult, ToRedisArgs, Value as RedisValue};
#[cfg(feature = "dynamo-backend")]
use rusoto_dynamodb::AttributeValue;
#[cfg(feature = "redis-backend")]
use serde_json;
#[cfg(feature = "dynamo-backend"... |
#[doc = "Reader of register ACR"]
pub type R = crate::R<u32, super::ACR>;
#[doc = "Writer for register ACR"]
pub type W = crate::W<u32, super::ACR>;
#[doc = "Register ACR `reset()`'s with value 0x30"]
impl crate::ResetValue for super::ACR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {... |
mod command;
mod device;
mod instance;
pub use crate::raw::command::RawVkCommandPool;
pub use crate::raw::device::{
RawVkDevice,
VkFeatures,
};
pub use crate::raw::instance::{
RawVkDebugUtils,
RawVkInstance,
};
|
pub trait IntoBoxed {
type Boxed: ?Sized;
fn into_boxed(self) -> Box<Self::Boxed>;
}
/*
impl<T: ?Sized> IntoBoxed for Box<T> {
type Boxed = T;
fn into_boxed(self) -> Box<Self::Boxed> {
self
}
}
impl<T: ?Sized> IntoBoxed for T {
type Boxed = T;
fn into_boxed(self) -> Box<Self::Boxed> {
Box::new(self)
... |
// Copyright 2022 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 ... |
extern crate cmake;
use std::env;
fn find_and_link_tgl(cmake_cfg: &mut cmake::Config) {
let dst = cmake_cfg.build();
let path = dst.join("build")
.join("tgl");
if cfg!(windows) {
println!("cargo:rustc-link-search=native={}", path.join("Release").display());
} else {
println!("... |
//! This module deals with setting up file associations.
//! Since this only makes sense on Windows, this entire module is Windows-only.
use std::io;
use itertools::Itertools;
use winreg::{enums as wre, RegKey};
use crate::error::{Blame, Result};
#[derive(Debug)]
pub enum Args {
Install { amend_pathext: bool },... |
#[macro_use]
mod internal;
#[macro_use]
mod nul_str_macros;
/// Can be used to construct [`CompGenericParams`],
/// when manually implementing [`StableAbi`].
///
/// This stores indices and ranges for the type and/or const parameters taken
/// from the [`SharedVars`] stored in the same [`TypeLayout`] where this is st... |
use std::{
fmt::{Debug, Display},
sync::Arc,
};
use async_trait::async_trait;
use data_types::{CompactionLevel, ParquetFileParams};
use datafusion::{error::DataFusionError, physical_plan::SendableRecordBatchStream};
use iox_time::Time;
use crate::partition_info::PartitionInfo;
pub mod dedicated;
pub mod logg... |
#![cfg(test)]
mod process;
mod utils;
|
fn main() {
}
#[test]
fn test_shadowing() {
let mut x: i32 = 1;
x = 7;
let x = x;
let y = 4;
let y = "I can also be bound to text!";
print_number(5);
print_number(add_one(6));
let f: fn(i32) -> i32;
}
fn print_number(x: i32) {
println!("x is: {}", x);
}
fn add_one(x: i32) -> i3... |
struct Detector { }
trait Detect<T> {
fn detect(input: T);
}
impl Detect<i32> for Detector {
fn detect(input: i32) {
println!("{} is i32", input);
}
}
impl Detect<&'static str> for Detector {
fn detect(input: &'static str) {
println!("{} is &str", input);
}
}
fn main() {
Dete... |
pub mod communication;
pub mod foreman;
pub mod map;
pub mod miner;
pub mod system;
|
//! Channel flavors.
//!
//! There are six flavors:
//!
//! 1. `after` - Channel that delivers a message after a certain amount of time.
//! 2. `array` - Bounded channel based on a preallocated array.
//! 3. `list` - Unbounded channel implemented as a linked list.
//! 4. `never` - Channel that never delivers messages.
... |
// 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 std::fmt::Display;
use async_trait::async_trait;
use data_types::{Partition, PartitionId};
use super::PartitionSource;
#[derive(Debug)]
pub struct MockPartitionSource {
partitions: Vec<Partition>,
}
impl MockPartitionSource {
#[allow(dead_code)] // not used anywhere
pub fn new(partitions: Vec<Partit... |
use anyhow::{Context, Error, Result};
use pathfinder_common::event::Event;
use pathfinder_common::{
BlockHash, BlockNumber, BlockTimestamp, Chain, ChainId, EventCommitment, SequencerAddress,
StarknetVersion, StateCommitment, TransactionCommitment, TransactionSignatureElem,
};
use pathfinder_merkle_tree::Transac... |
fn main() {
let name = "agus";
}
|
fn main() {
proconio::input! {k:u64,n:usize,a:[u64;n]};
let mut c = a[0] + k - a[n - 1];
for i in 0..n - 1 {
c = c.max(a[i + 1] - a[i]);
}
println!("{}", k-c)
} |
use abi_stable::{
declare_root_module_statics,
external_types::{RawValueBox, RawValueRef},
library::RootModule,
nonexhaustive_enum::{DeserializeEnum, NonExhaustiveFor, SerializeEnum},
package_version_strings, rvec, sabi_trait,
sabi_types::VersionStrings,
std_types::{RBox, RBoxError, RResult,... |
use common::aoc::{load_input, run_many, print_result, print_time};
fn main() {
let input = load_input("day02");
let (program, dur_parse) = run_many(10000, || parse_input(&input));
let (res_part1, dur_part1) = run_many(10000, || part1(&program));
let (res_part2, dur_part2) = run_many(10000, || part2(&p... |
/*
* Firecracker API
*
* RESTful public-facing API. The API is accessible through HTTP calls on specific URLs carrying JSON modeled data. The transport medium is a Unix Domain Socket.
*
* The version of the OpenAPI document: 0.25.0
* Contact: compute-capsule@amazon.com
* Generated by: https://openapi-generator.t... |
/*
struct PortBBits
{
_BIT_ flippers_motor_backward:1;
_BIT_ spin_motor_forward:1;
_BIT_ spin_motor_backward:1;
_BIT_ mouth_open_switch:1;
_BIT_ mouth_closed_switch:1;
_BIT_ head_push_switch:1;
_BIT_ charger_inhibit_signal:1;
_BIT_ external_io:1;
}
union
{
Byte: u8;
_PORTB_BITS... |
mod js_object_utils;
mod options;
mod resources;
mod settings;
use crate::{
js_object_utils::is_null_or_undefined, options::js_options_object_to_rust_options_struct,
resources::ResourceReader, settings::js_settings_object_to_rust_settings_struct,
};
use eyeliner::{inline, servo_config::opts, servo_embedder_tra... |
#[cfg(all(not(target_arch = "wasm32"), test))]
mod test;
use anyhow::*;
use liblumen_alloc::erts::exception;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::*;
#[native_implemented::function(erlang:list_to_tuple/1)]
pub fn result(process: &Process, list: Term) -> exception::Resul... |
use klt;
use std::{ptr, slice};
use std::os::raw;
pub unsafe fn unsafe_main() {
let ft = klt::KLTReadFeatureTable(ptr::null_mut(), s!("features.txt"));
let ftr = &mut *ft;
let fl = klt::KLTCreateFeatureList(ftr.n_features);
klt::KLTExtractFeatureList(fl, ft, 1);
klt::KLTWriteFeatureList(fl, s!("fea... |
use super::*;
use crate::fn_pointer_extractor::FnParamRet;
abi_stable_shared::declare_type_layout_index! {
attrs=[]
}
impl TypeLayoutIndex {
/// Used to recover from syn errors,
/// this value shouldn't be used in the layout constant since it's reserved
/// for errors.
pub const DUMMY: Self = Sel... |
// 1. CLI
// 2. File associations
// 3. Context menu option
mod sys;
pub(super) fn stdin() -> bool {
use tauri::api::clap::{App, Arg};
let app = App::new("gmpublisher");
let matches = app
.version(env!("CARGO_PKG_VERSION"))
.author("William Venner <william@venner.io>")
.about("Publish, extract and work with G... |
use fall_tree::{AstNode, File};
mod syntax;
mod ast_ext;
pub use self::syntax::*;
pub use self::ast_ext::{SelectorKind, RefKind};
pub fn parse(text: String) -> File {
LANG.parse(text)
}
pub fn ast(file: &File) -> FallFile {
FallFile::new(file.root())
}
|
//!
//! The Tileset struct contains all of the information necessary for tile
//! definitions.
//!
//! Tilesets contain references to the image, have all of the
//! relevant information to turn these images into graphical tiles, and include
//! animation and collision data on a tile-by-tile basis (if any was defi... |
use core::{convert::TryFrom, fmt, mem, ops::Range};
use alloc::{boxed::Box, format, string::String, sync::Arc, vec, vec::Vec};
use crate::util::{
alphabet::{self, ByteClassSet},
decode_last_utf8, decode_utf8,
id::{IteratorIDExt, PatternID, PatternIDIter, StateID},
is_word_byte, is_word_char_fwd, is_wo... |
polygraph::schema!{
type Tree;
pub struct Surname(String);
pub struct Person {
surname: Key<Surname<'a>>,
name: String,
}
}
fn main() {
}
|
//! Displays debug lines using an orthographic camera.
use amethyst::{
core::{
transform::{Transform, TransformBundle},
Time,
},
ecs::{Read, ReadExpect, Resources, System, SystemData, Write},
prelude::*,
renderer::{
camera::Camera,
debug_drawing::{DebugLines, DebugLi... |
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://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 those terms.
use crate::lexer::lexer::... |
//! This crate provides C ABI interface for [battery](https://crates.io/crate/battery) crate.
//!
//! # Bindings generation
//!
//! Among library creation this crate generates `battery_ffi.h` file, enabled by default by `cbindgen` feature,
//! which might be useful for automatic bindings generation or just with plain `... |
use async_graphql::*;
#[tokio::test]
async fn test_flatten() {
#[derive(SimpleObject)]
struct A {
a: i32,
b: i32,
}
#[derive(SimpleObject)]
struct B {
#[graphql(flatten)]
a: A,
c: i32,
}
struct Query;
#[Object]
impl Query {
async fn... |
use self::ConfigError::*;
use super::*;
use std::error::Error;
#[derive(Debug)]
pub enum ConfigError {
/// The configuration file was not found.
NotFound,
/// There was an I/O error while reading the configuration file.
IoError,
/// The path at which the configuration file was found was invalid.
... |
// 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 ... |
use super::widget::WidgetKind;
use crate::{
cpu::CPU,
debug::{util::FromHexString, widget::Widget},
disassembly::{Disassembler, InstructionWindow},
memory_map::{Mem, Mem16},
opcode::{Decoder, Opcode},
register::Reg16,
Src,
};
use crossterm::event::{KeyCode, KeyEvent};
use std::{borrow::Cow, ... |
use super::{BUTTON, LED};
use crate::app::App;
use drogue_device::{
actors::{button::Button, led::Led},
ActorContext, DeviceContext,
};
use embassy::executor::Spawner;
pub struct MyDevice {
app: ActorContext<'static, App>,
led1: ActorContext<'static, Led<LED>>,
led2: ActorContext<'static, Led<LED>>... |
use super::join::Join;
use bit_set::BitSet;
use std::cell::RefCell;
use std::sync::{Arc, LockResult, Mutex, MutexGuard};
use super::resource::Fetch;
pub type Entity = usize;
#[derive(Derivative)]
#[derivative(Default(new = "true"))]
pub struct EntityStorage {
next_id: Arc<Mutex<RefCell<usize>>>,
alive: Arc<M... |
// 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 (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 ... |
use advent::helpers;
use anyhow::{Context, Result};
use derive_more::Display;
use itertools::Itertools;
type LiteralType = u64;
#[derive(Debug, Display)]
enum BinaryOpKind {
#[display(fmt = "+")]
Add,
#[display(fmt = "*")]
Mul,
}
#[derive(Debug)]
enum MathExpr {
Literal(LiteralType),
BinaryOp... |
use super::cso::{CSO, Cell, MAX_PURITY, SEWAGE_PURITY};
use super::random::Random;
use super::point::Point;
struct CellFactory {
pub point: Point,
pub cell: Cell,
pub interval: u8,
pub count: u8
}
struct CellDrain {
pub point: Point,
pub interval: u8,
}
pub struct Level {
factories: Vec<C... |
// 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 crate::audio::{GenericMusicStream, MusicStream};
use std::iter::Peekable;
// TODO maybe use higher quality resampling algorithm?
/// Resample a MusicStream using linear interpolation
pub struct Resample<I: Iterator<Item = f32> + Send> {
/// The iterator that yields interleaved audio samples
/// (e.g. an i... |
use std::sync::Arc;
use proptest::prop_oneof;
use proptest::strategy::{BoxedStrategy, Just, Strategy};
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::*;
use crate::test::strategy::term::{is_binary, is_byte};
use crate::test::strategy::{DEPTH, MAX_LEN};
pub fn non_recursive_elem... |
pub type IItemEnumerator = *mut ::core::ffi::c_void;
pub type ISettingsContext = *mut ::core::ffi::c_void;
pub type ISettingsEngine = *mut ::core::ffi::c_void;
pub type ISettingsIdentity = *mut ::core::ffi::c_void;
pub type ISettingsItem = *mut ::core::ffi::c_void;
pub type ISettingsNamespace = *mut ::core::ffi::c_void... |
use num::complex::Complex;
pub struct MandelbrotPoint {
pub x: u32,
pub y: u32,
pub color: image::Rgb<u8>
}
fn mandelbrot(z: Complex<f32>, c: Complex<f32>) -> Complex<f32> {
num::pow(z, 2) + c
}
pub fn in_mandelbrot_set(c: Complex<f32>, iterations: u32) -> (bool, u32) {
let mut z = c;
for i ... |
use proptest::prop_assert_eq;
use proptest::strategy::Just;
use liblumen_alloc::erts::term::prelude::*;
use crate::erlang::put_2::result;
use crate::test::strategy;
#[test]
fn without_key_returns_undefined_for_previous_value() {
run!(
|arc_process| {
(
Just(arc_process.clone()... |
mod with_integer_integer;
use proptest::{prop_assert, prop_assert_eq};
use liblumen_alloc::erts::term::prelude::*;
use crate::erlang::integer_to_list_2::result;
use crate::test::strategy;
#[test]
fn without_integer_integer_errors_badarg() {
crate::test::without_integer_integer_with_base_errors_badarg(file!(), r... |
use chrono::{Date, NaiveDate, Utc};
use serenity::{
async_trait,
client::{Context, EventHandler},
framework::{
standard::{
macros::{command, group},
CommandResult,
},
StandardFramework,
},
model::{channel::Message, id::UserId, prelude::Ready},
prelude::{RwLock, TypeMapKey},
Client,
};
use std::{
co... |
use audio_core::{Buf, Channel, ChannelMut, Channels, ChannelsMut, ExactSizeBuf, WriteBuf};
/// Make a mutable buffer into a write adapter that implements [WriteBuf].
///
/// # Examples
///
/// ```rust
/// use audio::{Buf as _, ReadBuf as _, WriteBuf as _};
/// use audio::io;
///
/// let from = audio::interleaved![[1.0... |
use actix_identity::Identity;
use actix_web::web::{Data, Json, Path};
use auth::identity_matches_game_id;
use db::{get_conn, PgPool};
use errors;
use crate::handlers::{get_game_status, StatusResponse};
pub async fn status(
id: Identity,
game_id: Path<i32>,
pool: Data<PgPool>,
) -> Result<Json<StatusRespo... |
use smartcore::dataset::*;
// DenseMatrix wrapper around Vec
use smartcore::linalg::naive::dense_matrix::DenseMatrix;
// KNN
use smartcore::neighbors::knn_classifier::KNNClassifier;
use smartcore::neighbors::knn_regressor::KNNRegressor;
// Logistic/Linear Regression
use smartcore::linear::elastic_net::{ElasticNet, Elas... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.