text stringlengths 8 4.13M |
|---|
//! **!!Notice!!** This crate was migrated to [kdbplus](https://crates.io/crates/kdbplus) which has IPC module as well.
//!
//! Rust crate mirroring the C API header file (`k.h`) for kdb+. The expected usage is to build a
//! shared library for kdb+ in Rust.
//!
//! In order to avoid writing too large `unsafe` block... |
#![allow(clippy::float_cmp)]
use crate::{Constraint, RelationalOperator, Solver, SolverError, Variable, STRENGTH_REQUIRED};
#[test]
fn create_variable() {
let var = Variable::new("var_name");
assert_eq!(var.name(), "var_name");
}
#[test]
fn create_term() {
let var = Variable::new("var_name");
let _t... |
use super::{body::Body, id::Id};
use crate::{
builtin_functions::BuiltinFunction,
hir, impl_display_via_richir,
module::Module,
rich_ir::{ReferenceKey, RichIrBuilder, ToRichIr, TokenType},
};
use core::mem;
use derive_more::{From, TryInto};
use enumset::EnumSet;
use itertools::Itertools;
use num_bigint:... |
pub struct NumMatrix {
matrix: Vec<Vec<i32>>,
}
impl NumMatrix {
pub fn new(matrix: Vec<Vec<i32>>) -> Self {
let mut matrix = matrix;
for i in 0..matrix.len() {
for j in 0..matrix[i].len() {
if i > 0 {
matrix[i][j] += matrix[i - 1][j];
... |
use petgraph::graph::{EdgeIndex, Graph, IndexType, NodeIndex};
use petgraph::visit::{EdgeCount, IntoNeighbors, IntoNodeIdentifiers};
use petgraph::EdgeType;
use std::collections::{HashMap, HashSet};
use std::hash::Hash;
pub fn louvain_step<G>(graph: &G) -> Option<HashMap<G::NodeId, G::NodeId>>
where
G: EdgeCount +... |
// http://mathworld.wolfram.com/Runge-KuttaMethod.html
pub trait State: Add<Self, Self> + Mul<f64, Self> {
fn f(&self, t: f64) -> Self;
}
#[allow(dead_code)]
pub fn step_rk2<Y>(t: f64, dt: f64, y: &Y) -> Y
where Y: State {
let k_1 = y.f(t) * dt;
let k_2 = (*y + k_1 * 0.5).f(t + 0.5 * dt) * dt;
*y + k_... |
mod calc;
mod clear;
mod config;
mod error;
mod schedule;
mod track;
mod watcher;
use crate::config::Configuration;
pub use crate::config::get_config;
pub use error::TimeTrackerError;
pub struct TimeTracker<'a> {
config: &'a Configuration,
}
impl<'a> TimeTracker<'a> {
pub fn new(config: &'a Configuration) ... |
pub use health_check::*;
pub use subscriptions::*;
pub mod health_check;
pub mod subscriptions;
|
use std::iter::Peekable;
use crate::object::Object;
fn read_integer<T: Iterator<Item = char>>(lexer: &mut Peekable<T>) -> Result<Object, String> {
let c = lexer.next().unwrap();
let mut number = match c.to_string().parse::<i64>() {
Ok(number) => number,
Err(e) => {
return Err(form... |
extern crate itertools;
use std::fmt;
use std::collections::HashMap;
use itertools::Itertools;
pub struct Object {
pub map: HashMap<String, Value>,
}
impl Object {
pub fn to_basic_string(&self) -> String {
[
"{",
self.map.iter().map(|(key, value)| format!("\"{}\":{}", key, val... |
/*
* Given an array of integers and an integer k,
* you need to find the total number of continuous subarrays whose sum equals to k.
*
* Example 1:
* ----------
* Input: nums = [1, 1, 1], k = 2
* Output: 2
*/
use std::collections::HashMap;
pub fn subarray_sum(nums: Vec<i32>, k: i32) -> i32 {
let mut count... |
// The objects that help render and are to be rendered. Built on the data structures as defined in
// structures.rs.
use crate::structures::*;
use std::fs::File;
use std::io::prelude::*;
use std::ops::Mul;
#[derive(Debug, Clone)]
pub enum Colour {
Rgba(f64, f64, f64, f64), // (r, g, b, a)
Grey(f64), ... |
//! Prelude for this crate, this contains a lot of useful exports
pub use crate::Element as SVGElem;
pub use crate::Point2D;
pub use crate::attributes::Attribute as Attr;
pub use crate::tag_name::TagName as Tag;
pub use crate::path::PathDefinitionString as PathData;
#[cfg(feature = "parsing")]
pub use crate::parser... |
use std::io;
fn main() {
let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
let n: usize = buf.trim().parse().unwrap();
buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
let mut iter = buf.split_whitespace();
let mut num_vec: Vec<i64> = Vec::new();
... |
#[allow(unused_variables)]
pub fn hello_trait() {
trait Summarizable {
fn summary(&self) -> String;
fn default_summary(&self) -> String {
String::from("(read more...)")
}
}
struct NewsArticle {
headline: String,
location: String,
author: String,
... |
#[cfg(feature = "cli")]
mod cli {
#[cfg(not(feature = "std"))]
compile_error!("`std` feature is required for cli");
use std::io::BufRead;
use std::io::Write;
use clap::Clap;
#[derive(Clap, Copy, Clone)]
#[clap(version = "1.0")]
struct Opts {
#[clap(short, long)]
verify... |
// 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 ... |
//! Incremental solving.
use partial_ref::{partial, PartialRef};
use varisat_formula::Lit;
use varisat_internal_proof::{clause_hash, lit_hash, ClauseHash, ProofStep};
use crate::{
context::{parts::*, Context},
proof,
prop::{enqueue_assignment, full_restart, Reason},
state::SatState,
variables,
};... |
use rand::prelude::*;
use rand_chacha::ChaChaRng;
use snapcd::file::{put_data, read_data};
use snapcd::{ds::sqlite::SqliteDS, DataStore};
use std::collections::HashSet;
fn internal_test<T: DataStore, F: FnMut() -> T>(
ctor: &mut F,
size_upper_bound: usize,
seed_lower_bound: u64,
seed_upper_bound: u64,
... |
// ---------------------------------------
// Dreamspell server
// ---------------------------------------
use axum::{
extract::State,
http::{
header::{AUTHORIZATION, CONTENT_TYPE},
Method, StatusCode,
},
response::IntoResponse,
routing::{get, post},
Json, Router,
};
use axum_aut... |
use std::sync::atomic::{self, AtomicUsize};
use std::collections::HashMap;
use crate::types::*;
use crate::user::User;
use crate::pensioner::Pensioner;
use crate::calculations::*;
static USER_COUNTER: AtomicUsize = atomic::ATOMIC_USIZE_INIT;
pub struct Contributor {
id: usize,
wallet: Unit,
pub contributi... |
// 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 ... |
mod util;
extern crate rcgen;
use rcgen::{RcgenError, KeyPair, Certificate};
#[test]
fn test_key_params_mismatch() {
let available_key_params = [
&rcgen::PKCS_RSA_SHA256,
&rcgen::PKCS_ECDSA_P256_SHA256,
&rcgen::PKCS_ECDSA_P384_SHA384,
&rcgen::PKCS_ED25519,
];
for (i, kalg_1) in available_key_params.iter()... |
use crate::ast;
use crate::{Spanned, ToTokens};
use runestick::Span;
/// Helper to force an expression to have a specific semi-colon policy.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ForceSemi {
/// The span of the whole wrapping expression.
pub span: Span,
/// Whether or not the expressions needs ... |
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;
fn... |
fn main() {
let args: Vec<String> = env::args().collect();
match args.len() {
2 => search_by_title(args[1]),
3 => search_by_title_and_year(args[1], args[2]),
_ => invalid_input()
}
}
fn search_by_title(title: &str) {
}
fn search_by_title_and_year(title: &str, year: &str) {
... |
use crate::{FunctionData, Instruction, Value, ConstType, BinaryOp, Map, Type};
#[derive(Clone)]
struct Chain {
value: Value,
consts: Vec<u64>,
ty: ConstType,
op: BinaryOp,
}
pub struct SimplifyExpressionsPass;
impl super::Pass for SimplifyExpressionsPass {
fn name(&self) -> &str {
... |
use crate::gpu::GPU;
pub const SRAM_SIZE: usize = 0x2000;
pub const VRAM_SIZE: usize = 0x2000;
pub const BOOT_ROM: usize = 0x0100;
pub const BANK_ZERO: usize = 0x3FFF - 0x0000 + 1;
pub const BANK_N: usize = 0x7FFF - 0x4000 + 1;
pub const HIGH_RAM: usize = 0xFFFF - 0xFF80 + 1;
pub const IO_REG: usize = 0xFF7F - 0xFF00 ... |
use petgraph::graph::NodeIndex;
use super::super::{LayoutTree, TreeError};
use super::super::commands::CommandResult;
use super::super::core::container::{Container, ContainerType};
/// The mode the borders can be in. This affects the color primarily.
pub enum Mode {
/// Borders are active, this means they are foc... |
fn main() {
let mut sum: i64 = 0;
let n: i64 = 1000000000;
println!("n: {}", n);
for i in 0..n {
sum = sum + i;
}
println!("sum = {}", sum);
} |
// This file contains the raw stuff to libcmaes
use libc::{c_double, c_int, c_void};
#[link(name = "rcmaesglue", kind = "static")]
#[link(name = "cmaes")]
extern "C" {
pub fn cmaes_optimize(
noisy: c_int,
use_elitism: c_int,
use_surrogates: c_int,
algo: c_int,
initial: *mut ... |
#![deny(missing_docs)]
//! A non-empty vector with a cursor.
#[cfg(feature = "use_serde")]
extern crate serde;
#[cfg(feature = "use_serde")]
#[macro_use]
extern crate serde_derive;
#[cfg(feature = "use_serde")]
#[cfg(test)]
extern crate serde_json;
use std::error;
use std::fmt;
#[cfg(feature = "use_serde")]
use serd... |
use crate::planning::chronicles::{StateFun, Type};
use crate::planning::ref_store::{RefPool, RefStore};
use crate::planning::symbols::{Instances, SymId, SymbolTable};
use crate::planning::utils::enumerate;
use core::num::NonZeroU32;
use fixedbitset::FixedBitSet;
use std::collections::HashSet;
use std::fmt::{Display, Er... |
fn main() {
cxx_build::bridge("src/multi_cxx1.rs")
.flag_if_supported("-std=c++14")
.compile("multi_cxx1");
cxx_build::bridge("src/multi_cxx2.rs")
.flag_if_supported("-std=c++14")
.compile("multi_cxx2");
}
|
use std::ops::{Deref, DerefMut};
use rustwlc::{Geometry, Size, Point};
use super::super::borders::Borders;
use ::render::{BaseDraw, Drawable, DrawErr};
/// Draws the borders around windows.
/// They are all of the same size, including the top.
pub struct ViewDraw {
base: BaseDraw<Borders>
}
impl ViewDraw {
pu... |
use std;
use std::io::Write;
use errors::*;
use types::Client;
use utils::http;
use httpstream::{read_from_stream, HttpStream};
use openssl;
pub struct TlsStream {
pub tcp_stream: std::net::TcpStream,
pub stream: openssl::ssl::SslStream<std::net::TcpStream>,
}
impl HttpStream for TlsStream {
fn connect(... |
use crate::{DocBase, VarType};
const DESCRIPTION: &'static str = r#"
The round function returns the value of the argument rounded to the nearest integer, with ties rounding up.
"#;
const ARGUMENTS: &'static str = r#"
source (series(float)) Series of values to process.
length (int) Offset from the current bar to the p... |
use super::{Form, Content};
use database::{Database, Store, Serialize};
use std::marker::PhantomData;
pub struct Former<S: Store + Form + Default + Send + Sync, F: Fn(S) + Send + Sync> {
load: Option<S>,
function: F
}
impl<S: Store + Form + Default + Send + Sync, F: Fn(S) + Send + Sync> Former<S, F> {
pub... |
use collections::{EntityMap, EntitySet};
use ecs::{ComponentManager, ComponentManagerBase, Component, Entity};
use engine::*;
use math::*;
use std::{mem, ptr};
use std::fmt::{self, Debug, Formatter};
use std::cell::RefCell;
use stopwatch::Stopwatch;
/// HACK: Used to keep the data rows from reallocating and invalidati... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtCore/qeventtransition.h
// dst-file: /src/core/qeventtransition.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main bloc... |
use crate::{records::Bed3, ChromName};
use num::Num;
use std::io::{Result, Write};
pub trait Parsable<'a>: Sized {
fn parse(s: &'a str) -> Option<(Self, usize)>;
}
pub trait Serializable {
fn dump<W: Write>(&self, fp: W) -> Result<()>;
}
pub trait WithRegionCore<Chrom: ChromName> {
fn begin(&self) -> u32... |
mod front_of_house;
pub use crate::front_of_house::hosting;
pub fn eat_at_restaurant() {
hosting::add_to_waitlist();
hosting::add_to_waitlist();
hosting::add_to_waitlist();
}
fn main() {
println!("Hello, world!");
crate::eat_at_restaurant();
}
|
use midi_message::MidiMessage;
use color::Color;
use color_strip::ColorStrip;
use effects::effect::Effect;
use rainbow::get_rainbow_color;
pub struct StreamCenter {
color_strip: ColorStrip,
pressed_keys: Vec<u8>,
i: u64,
i2: u64
}
impl StreamCenter {
pub fn new(led_count: usize) -> StreamCenter {
... |
//! RTC
use e310x::RTC;
/// Rtc configuration
pub struct RtcConf {
enalways: bool,
scale: u8,
counter: u64,
cmp: u32,
}
impl RtcConf {
pub fn new() -> Self {
Self {
enalways: true,
scale: 0,
counter: 0,
cmp: 0,
}
}
pub fn set... |
// 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 ... |
extern crate spell_game;
extern crate time;
use std::sync::{Arc,Mutex};
use ted_net_code::{Client};
use std::thread;
use std;
pub fn game_thread(client_list: Arc<Mutex<Vec<Client>>>){
let mut game=spell_game::SpellGame::new();
let mut last_time=time::precise_time_ns();
loop{
{
let mut client_lock=client_list.... |
// 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 fidl_fuchsia_ui_input as uii;
/// Generates a default `TextInputState`, suitable for tests.
#[cfg(test)]
pub fn default_state() -> uii::TextInputState... |
extern crate circle_gh_tee;
use std::process;
use circle_gh_tee::run;
fn main() {
match run() {
Ok(s) => {
print!("{}", s.command_result.result);
if let Some(error_message) = s.error_message {
eprintln!("circle-gh-tee: error: {}", error_message);
pro... |
// 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.
//! This module defines a framework for using the crate::expectations module in
//! asynchronous situations, where you wish you detect the satisfiability o... |
use std::cell::UnsafeCell;
use std::env;
use std::ffi::OsString;
use std::fmt;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
use std::sync::Mutex;
pub use super::backtrace::Backtrace;
const GENERAL_BACKTRACE: &str = "RUST_BACKTRACE";
const FAILURE_BACKTRACE: &str = "RUST_FAILURE_BACKTRACE";
pub(... |
use coi::{container, Inject};
use std::sync::Arc;
#[derive(Inject)]
#[coi(provides Dep1 with Dep1)]
struct Dep1;
#[derive(Inject)]
#[coi(provides Impl1 with Impl1(dep1))]
struct Impl1(#[coi(inject = "dep1")] Arc<Dep1>);
#[test]
fn main() {
let container = container! {
dep1 => Dep1Provider,
impl1 ... |
//! To run this code in your own project, first install it:
//!
//! cargo install rusty_engine --example collider
//!
//! Then run it in your own project (with the asset pack present) with an image
//! placed somewhere in your `assets/` directory.
//!
//! collider assets/some_image.png
//!
//! Of course, you co... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[cfg(feature = "Win32_UI_Controls_Dialogs")]
pub mod Dialogs;
#[cfg(feature = "Win32_UI_Controls_RichEdit")]
pub mod RichEdit;
#[link(name = "windows")]
extern "system" {
#[cfg(all(feature = "Win32_Fo... |
use chrono::{Date, Datelike, NaiveDate, Utc};
use futures::stream::TryStreamExt;
use mongodb::bson::doc;
use serde::{Deserialize, Serialize};
use serenity::{
client::Context,
framework::standard::{macros::command, Args, CommandResult, Delimiter},
model::channel::Message,
prelude::{RwLock, TypeMapKey},
};
use std::{... |
#[doc = "Reader of register SWIER2"]
pub type R = crate::R<u32, super::SWIER2>;
#[doc = "Writer for register SWIER2"]
pub type W = crate::W<u32, super::SWIER2>;
#[doc = "Register SWIER2 `reset()`'s with value 0"]
impl crate::ResetValue for super::SWIER2 {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
use crate::voting::substrate::rpc::{
combine_decrypted_shares, combine_pk_shares, create_vote, get_tally, set_vote_phase,
store_question,
};
use crypto::helper::Helper;
use pallet_mixnet::types::{Topic, VotePhase};
use std::str::FromStr;
use substrate_subxt::Client;
use substrate_subxt::{ClientBuilder, Error, N... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn CeipIsOptedIn() -> super::super::super::Foundation::BOOL {
#[cfg(windows)]
{
#[link(name = "windows")]
ext... |
use futures::future::join;
use serde::{Deserialize, Serialize};
use crate::{format_string, Error};
#[cfg(feature = "cli")]
use clap::{CommandFactory, Parser};
#[cfg(feature = "cli")]
use tokio::io::{stdout, AsyncWriteExt};
use crate::{
config::Config, latitude::Latitude, longitude::Longitude, weather_api::Weath... |
#![recursion_limit = "1024"]
#[macro_use]
extern crate quick_error;
#[cfg(windows)]
pub mod windows;
#[cfg(windows)]
pub use windows::*;
#[cfg(target_os = "linux")]
pub mod linux;
#[cfg(target_os = "linux")]
pub use linux::*;
#[cfg(target_os = "emscripten")]
pub mod emscripten;
#[cfg(target_os = "emscripten")]
pub ... |
// Copyright 2021 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... |
use tdn::prelude::start;
use tdn_permission::PermissionlessGroup;
use tdn_types::message::{GroupReceiveMessage, ReceiveMessage};
fn main() {
smol::block_on(async {
let mut group = PermissionlessGroup::default();
let (_peer_addr, send, recv) = start().await.unwrap();
while let Ok(message) =... |
use chrono::NaiveDate;
use teloxide::utils::command::BotCommand;
use crate::database::period::Period;
#[derive(BotCommand)]
#[command(rename = "lowercase", description = "These commands are supported:")]
pub enum Command {
#[command(description = "Display help text.")]
Help,
#[command(description = "Creat... |
// https://leetcode.com/problems/decompress-run-length-encoded-list/submissions/
impl Solution {
pub fn decompress_rl_elist(nums: Vec<i32>) -> Vec<i32> {
let mut ans: Vec<i32> = Vec::new();
for i in 0..nums.len()/2 {
for j in 0..nums[i*2] {
ans.push(nums[i*2 + 1]... |
#[doc = "Reader of register MPCBB2_VCTR9"]
pub type R = crate::R<u32, super::MPCBB2_VCTR9>;
#[doc = "Writer for register MPCBB2_VCTR9"]
pub type W = crate::W<u32, super::MPCBB2_VCTR9>;
#[doc = "Register MPCBB2_VCTR9 `reset()`'s with value 0"]
impl crate::ResetValue for super::MPCBB2_VCTR9 {
type Type = u32;
#[i... |
//! Represents the `source` array table in the package manifest.
use std::collections::BTreeSet;
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
/// External fetchable source that can be cached in the store.
///
/// TODO: Change to `Uri` once https://github.com/hyperium/http/pull/274 gets merged.
#[deri... |
use liblumen_alloc::erts::exception;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::Term;
/// `band/2` infix operator.
#[native_implemented::function(erlang:band/2)]
pub fn result(
process: &Process,
left_integer: Term,
right_integer: Term,
) -> exception::Result<Term>... |
use super::derived_state::*;
use super::super::error::*;
use gluon::{RootedThread, Compiler};
use gluon::compiler_pipeline::{CompileValue, Executable};
use gluon::vm::api::{VmType, Getable};
use gluon::base::ast::{SpannedExpr};
use gluon::base::symbol::{Symbol};
use futures::*;
use std::mem;
use std::sync::*;
use std... |
// 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::{format_err, Error},
fuchsia_async as fasync,
helper::*,
net_types::ip::IpVersion,
std::net::UdpSocket,
};
const PACKET... |
//给定一个非负整数 num。对于 0 ≤ i ≤ num 范围中的每个数字 i ,计算其二进制数中的 1 的数目并将它们作为数组返回。
//
// 示例 1:
//
// 输入: 2
//输出: [0,1,1]
//
// 示例 2:
//
// 输入: 5
//输出: [0,1,1,2,1,2]
//
// 进阶:
//
//
// 给出时间复杂度为O(n*sizeof(integer))的解答非常容易。但你可以在线性时间O(n)内用一趟扫描做到吗?
// 要求算法的空间复杂度为O(n)。
// 你能进一步完善解法吗?要求在C++或任何其他语言中不使用任何内置函数(如 C++ 中的 __builtin_popcount)来执行此... |
use std::fmt;
use std::cmp::Ordering;
pub struct BinaryHeap<T> {
heap: Vec<T>,
}
#[derive(Clone, Copy, Default)]
pub struct PriorityTuple<T> {
priority: u32,
pub value: T,
}
impl<T> PartialOrd for PriorityTuple<T> {
fn partial_cmp(&self, other: &PriorityTuple<T>) -> Option<Ordering> {
Some(se... |
use crate::cpu::Cpu;
use crate::opcode::addressing_mode::AddressMode;
use crate::opcode::Operation;
use crate::opcode::*;
use std::string::ToString;
pub struct Branch {
branch_type: BranchType,
/// Offset to branch to on success.
offset: i8,
}
/// The type of branch operation.
enum BranchType {
/// (... |
use std::env;
fn main(){
let args: Vec<String> = env::args().collect();
let nom = &args[1];
let auteur = &args[2];
let version = &args[3];
println!("Lancement du module {} créé par {} en version {}", nom, auteur, version);
} |
/// Insert sort
pub fn sort<T: Ord + Clone>(list: &Vec<T>) -> Vec<T> {
let mut sorted = list.clone();
for cursor in 1..sorted.len() {
let value = sorted[cursor].clone();
let mut place = cursor;
while place > 0 && sorted[place - 1] > value {
sorted[place] = sorted[place - 1].c... |
// 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 fidl::endpoints::ServiceMarker;
use fidl_fuchsia_cobalt::LoggerFactoryMarker;
use fidl_fuchsia_fonts::ProviderMarker;
use fidl_fuchsia_ledger_cloud::Cl... |
use seed::{prelude::*, *};
use seed::web_sys::console;
use serde::{Serialize, Deserialize};
// ------ ------
// Init
// ------ ------
fn init(_: Url, orders: &mut impl Orders<Msg>) -> Model {
orders.send_msg(Msg::FetchData);
Model::default()
}
// ------ ------
// Model
// ------ ------
#[derive(Defa... |
pub use VkImageViewCreateFlags::*;
#[repr(u32)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum VkImageViewCreateFlags {
VK_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DYNAMIC_BIT_EXT = 0x0000_0001,
}
use crate::SetupVkFlags;
#[repr(C)]
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
pub struct VkImageViewCreateFla... |
pub(crate) mod async_buf_read;
pub(crate) mod async_read;
pub(crate) mod async_seek;
pub(crate) mod async_write;
pub(crate) mod sink;
pub(crate) mod stream;
|
use std::path::{PathBuf};
pub struct Pathfinder {
pub root: PathBuf,
}
impl Pathfinder {
/// Get the root directory.
pub fn root_dir(&self) -> PathBuf {
self.root.clone()
}
/// Get the backup directory.
pub fn backup_dir(&self) -> PathBuf {
self.root.join("_renom").join("Backu... |
use expansion_policy::ExpansionPolicy;
use node_pool::NodePool;
use pqueue::PriorityQueue;
use qcell::{TLCell, TLCellOwner};
pub mod domains;
pub mod pqueue;
pub mod util;
pub mod expansion_policy;
pub mod node_pool;
#[derive(Debug, Copy, Clone)]
pub struct SearchNode<VertexId> {
search_num: usize,
pqueue_loc... |
//! server of Blockchain
#![allow(warnings, unused)]
use super::*;
use crate::block::*;
use crate::transaction::*;
use crate::utxoset::*;
use bincode::{deserialize, serialize};
use failure::format_err;
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
use std::io::prelude::*;
use std::net::... |
extern crate argparse;
use std::process::exit;
use argparse::{ArgumentParser, StoreTrue, Store};
struct Options {
verbose: bool,
name: String,
}
fn main() {
let mut options = Options {
verbose: false,
name: "World".to_string(),
};
{
let mut ap = ArgumentParser::new();
... |
// Copyright 2019. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclai... |
use std::convert::TryInto;
use anyhow::*;
use liblumen_alloc::erts::exception;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::*;
use crate::runtime::context::*;
/// `delete_element/2`
#[native_implemented::function(erlang:delete_element/2)]
pub fn result(process: &Process, inde... |
use super::ema::ema_func;
use super::ema::rma_func;
use super::sma::{declare_ma_var, wma_func};
use super::tr::tr_func;
use super::VarResult;
use crate::ast::stat_expr_types::VarIndex;
use crate::ast::syntax_type::{FunctionType, FunctionTypes, SimpleSyntaxType, SyntaxType};
use crate::helper::err_msgs::*;
use crate::he... |
#[doc = "Reader of register APB1_FZR1"]
pub type R = crate::R<u32, super::APB1_FZR1>;
#[doc = "Writer for register APB1_FZR1"]
pub type W = crate::W<u32, super::APB1_FZR1>;
#[doc = "Register APB1_FZR1 `reset()`'s with value 0"]
impl crate::ResetValue for super::APB1_FZR1 {
type Type = u32;
#[inline(always)]
... |
use std::collections::HashMap;
use std::io;
use example_interface::{ClientState, Color, ConnectionId, MousePos};
use futures_util::SinkExt;
use nanoserde::{DeJson, SerJson};
use rand::{thread_rng, Rng};
use std::sync::atomic::{AtomicU32, Ordering};
use tokio::net::{TcpListener, TcpStream};
use tokio::select;
use tokio... |
use serde::{Deserialize, Serialize};
#[repr(C)]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub enum MismatchType {
None,
Access,
FileName,
FileSize,
}
#[repr(C)]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct RuleErrorMsg {
pub expected: String,
pub actua... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Hibernation RTC Counter"]
pub rtcc: RTCC,
#[doc = "0x04 - Hibernation RTC Match 0"]
pub rtcm0: RTCM0,
_reserved2: [u8; 4usize],
#[doc = "0x0c - Hibernation RTC Load"]
pub rtcld: RTCLD,
#[doc = "0x10 - Hibern... |
use crate::{CoordinateType, MultiPolygon, Polygon};
use crate::algorithm::winding_order::{Winding, WindingOrder};
pub trait Orient<T> {
/// Orients a Polygon's exterior and interior rings according to convention
///
/// By default, the exterior ring of a Polygon is oriented counter-clockwise, and any inte... |
use super::{
not::Not, or::Or, passthrough::Passthrough, ActiveFilter, DynamicFilter, FilterResult,
GroupMatcher, LayoutFilter,
};
use crate::internals::{query::view::Fetch, storage::component::ComponentTypeId, world::WorldId};
/// A filter which requires all filters within `T` match.
#[derive(Debug, Clone)]
p... |
use std::fs::File;
use std::io::Read;
use std::path::Path;
pub mod assembler;
pub mod instruction;
pub mod repl;
pub mod vm;
use clap::App;
fn main() {
let yaml = clap::load_yaml!("cli.yml");
let matches = App::from_yaml(yaml).get_matches();
let target_file = matches.value_of("INPUT_FILE");
match tar... |
use ::amethyst::core::timing::Time;
use ::amethyst::core::*;
use ::amethyst::ecs::*;
use serde::Serialize;
use nphysics_ecs::ncollide::query::*;
use nphysics_ecs::*;
use specs_physics::colliders::ColliderComponent;
#[derive(Debug, Clone, Default, Serialize, Deserialize, new)]
pub struct Grounded {
#[new(value = ... |
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
pub enum Command {
#[structopt(name = "addblock")]
/// Adds a block to the blockchain (use `addblock --help` for more info)
AddBlock {
#[structopt(short, long)]
/// adds a block to the blockchain
data: String,
},
#[struc... |
use juniper::graphql_object;
#[graphql_object]
enum Character {}
fn main() {}
|
use super::system_prelude::*;
#[derive(Default)]
pub struct KillEnemySystem;
impl<'a> System<'a> for KillEnemySystem {
type SystemData = (
Entities<'a>,
ReadStorage<'a, Player>,
ReadStorage<'a, Enemy>,
ReadStorage<'a, Collision>,
ReadStorage<'a, Loadable>,
ReadStora... |
use std::{
pin::Pin,
task::{Context, Poll},
};
use futures_core::ready;
use pin_project_lite::pin_project;
use crate::{actor::Actor, fut::ActorFuture};
pin_project! {
/// Future for the [`map`](super::ActorFutureExt::map) method.
#[project = MapProj]
#[project_replace = MapProjReplace]
#[deri... |
#[cfg(all(not(target_arch = "wasm32"), test))]
mod test;
use liblumen_alloc::erts::exception;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::Term;
use crate::runtime::integer_to_string::decimal_integer_to_string;
#[native_implemented::function(erlang:integer_to_binary/1)]
pub fn... |
use std::io::Seek;
use crate::{types, Error};
use crossbeam_channel as cc;
const RPC_VERSION: u32 = 1;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[repr(u32)]
pub(crate) enum OpCode {
Handshake = 0,
Frame = 1,
Close = 2,
Ping = 3,
Pong = 4,
}
/// Message immediately sent to Discord upon establ... |
use crate::window::{Window, WindowType, Geometry};
use std::fmt::Debug;
use crate::keys::KeyCombo;
use std::hash::Hash;
use crate::config::Config;
use futures::Stream;
pub mod xcb_server;
#[derive(Debug, Eq, PartialEq)]
pub enum Event<W, K> {
DisplayInited,
ScreenAdded(W, Geometry),
KeyPressed(K),
Win... |
extern crate piston_meta;
#[test]
fn test_syntax_opengex() {
use piston_meta::*;
let syntax_src = include_str!("assets/opengex-syntax.txt").to_string();
let rules = stderr_unwrap(&syntax_src, syntax(&syntax_src));
let ogex_src = include_str!("assets/cube.ogex").to_string();
let mut data = vec![];... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.