text stringlengths 8 4.13M |
|---|
#[derive(Debug, Copy, Clone)]
pub enum Direction {
Forward,
Backward
}
pub trait LegacyMovable {
fn ride(&mut self, d: Direction, velocity: u32);
fn print(&self);
}
#[derive(Debug, Copy, Clone)]
pub struct LegacyTrain {
pub d: Direction,
pub v: u32,
}
impl LegacyTrain {
pub fn new(d: Dir... |
use bson::{doc, Bson, Document};
use juniper::{
graphql_interface, graphql_object, http::GraphQLRequest, EmptySubscription, FieldError,
FieldResult, GraphQLInputObject, GraphQLObject, RootNode, ID,
};
use mongodb::{
options::ClientOptions, options::FindOneAndUpdateOptions, options::FindOptions,
options:... |
use egg::*;
use unscramble::*;
define_language! {
enum Prop {
Num(i32),
"*" = Times([Id; 2]),
"x" = X,
Symbol(Symbol),
}
}
type EGraph = egg::EGraph<Prop, ()>;
type Rewrite = egg::Rewrite<Prop, ()>;
macro_rules! rule {
($name:ident, $left:literal, $right:literal) => {
... |
#[macro_export]
macro_rules! c {
($x:tt = $y:tt) => {
Condition {
field_name: stringify!($x).to_string(),
operator: Operator::Eq,
value: stringify!($y).to_string(),
};
}
} |
pub fn hello2() {
println!("hello2");
} |
use heck::CamelCase;
use heck::SnakeCase;
use proc_macro2::{Span, TokenStream};
use quote::{format_ident, quote, ToTokens};
use std::collections::{BTreeMap, BTreeSet};
use syn::{
braced, bracketed,
parse::{Parse, ParseStream, Result},
punctuated::Punctuated,
Attribute, ExprBlock, Ident, ItemEnum, ItemFn... |
#![crate_name = "uu_users"]
/*
* This file is part of the uutils coreutils package.
*
* (c) KokaKiwi <kokakiwi@kokakiwi.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/* last synced with: whoami (GNU coreutils) 8.22 */
// ... |
pub mod control_knob;
pub use control_knob::*;
pub mod levels;
pub use levels::*;
pub mod value_knob;
pub use value_knob::*; |
use core::fmt;
use embedded_hal::blocking::{delay::DelayMs, i2c};
pub trait Display {
type Error;
fn clear(&mut self) -> Result<(), Self::Error>;
fn set_cursor_position(&mut self, row: u8, column: u8) -> Result<(), Self::Error>;
fn write(&mut self, characters: &[u8]) -> Result<(), Self::Error>;
}
pu... |
use std::io;
use byteorder::ByteOrder;
use code_wizards::model::Tree;
const PROTOCOL_VERSION: i32 = 1;
pub fn run<'r, B: ByteOrder>(host: &'r str, port: u16, token: String) -> io::Result<()> {
use std::io::{Error, ErrorKind, Write};
use std::net::TcpStream;
use code_wizards::model::Move;
use code_wiza... |
// One parameter of this macro has a default value
macro_rules! make_a_awesome_function {
($id: ident) => {
fn $id() {
println!("You called a awesome function named {}!", stringify!($id));
}
};
() => {
make_a_awesome_function!(foo);
};
}
make_a_awesome_function!(bar)... |
// 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::error::Error, fidl_fuchsia_pkg::ExperimentToggle as Experiment,
fidl_fuchsia_pkg_ext::BlobId, fuchsia_url_rewrite::RuleConfig, serde_j... |
//! This contains thin wrappers around `memfd_create` and the associated file sealing API.
//!
//! The [`MemFile`] struct represents a file created by the `memfd_create` syscall.
//! Such files are memory backed and fully anonymous, meaning no other process can see them (well... except by looking in `/proc` on Linux).
... |
fn main() {
const A: u32 = 1;
println!("A: {}", A);
let asas = 2;
println!("asas: {}", asas);
println!("{}", 4.0 / 3.0);
}
|
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from ../gir-files
// DO NOT EDIT
use crate::SessionFeature;
use std::fmt;
glib::wrapper! {
#[doc(alias = "SoupWebsocketExtensionManager")]
pub struct WebsocketExtensionManager(Object<ffi::SoupWebsocketExtensionManager, ffi::SoupWebsocketExte... |
pub mod data;
pub mod song;
use radio::song::Song;
/// A radio must be able to provide the currently played song
pub trait Radio {
/// Get the currently playing song.
fn get_current_song(&self) -> Option<Song>;
}
/// Representation of a radiostation
pub struct RadioStation {
/// Name
pub name: &'stat... |
mod primes_iter;
mod primality_checker;
pub fn iter() -> primes_iter::PrimesIter {
primes_iter::new()
}
pub fn is_prime(num: u64) -> bool {
primality_checker::new().is_prime(num)
}
#[test]
fn test_is_prime() {
assert_eq!(false, is_prime(10));
assert_eq!(true, is_prime(11));
} |
#![feature(box_syntax)]
extern crate actix_web;
extern crate rusqlite;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate askama;
#[macro_use]
extern crate log;
extern crate stderrlog;
extern crate structopt;
extern crate rusoto_core;
extern crate rusot... |
// Copyright 2018 Ulysse Beaugnon and Ecole Normale Superieure
//
// 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... |
pub mod descriptorsetlayoutbindingflagscreateinfoext;
pub mod descriptorsetvariabledescriptorcountallocationinfoext;
pub mod descriptorsetvariabledescriptorcountlayoutsupportext;
pub mod physicaldevicedescriptorindexingfeaturesext;
pub mod physicaldevicedescriptorindexingpropertiesext;
pub mod physicaldevicememorybudge... |
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::io::prelude::*;
use std::io::Read;
use std::process::Command;
#[derive(Serialize, Deserialize, Debug)]
struct Lock {
lock: bool, // commit to git
name: i64,
}
#[derive(Serialize, Deserialize, Debug)]
struct Data {
value: Vec<Insd>,
}
#[deriv... |
// 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 ... |
use std::io::BufWriter;
use protobuf::{parse_from_bytes, CodedInputStream, CodedOutputStream, Message};
use protobuf_exploration::message::gen::core::*;
use protobuf_exploration::message::gen::request::*;
use std::time::SystemTime;
fn main() {
let start = SystemTime::now();
let limit = 1_000_000;
for _ ... |
mod circular_buf;
mod raw_slab;
pub use self::circular_buf::CircularBuf;
pub use self::raw_slab::RawSlab;
|
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use tiberius::{numeric::Decimal, time::chrono::NaiveDate, Row};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ImageSource {
pub id: u8,
pub name: String,
}
impl TryFrom<&Row> for ImageSource {
type Error = cr... |
mod topography;
use nalgebra::Vector2;
use petgraph::algo::dijkstra;
use petgraph::graph::DiGraph;
use petgraph::prelude::NodeIndex;
use petgraph::Graph;
use topography::Topography;
struct Lift {
start: Vector2<u32>,
end: Vector2<u32>,
}
struct World {
topography: Topography,
lifts: Vec<Lift>,
}
struct ... |
// ignore-compare-mode-nll
// revisions: base nll
// [nll]compile-flags: -Zborrowck=mir
// Test that we give a note when the old LUB/GLB algorithm would have
// succeeded but the new code (which is stricter) gives an error.
trait Foo<T, U> {}
fn foo(x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>, y: &dyn for<'a> Foo<&'a u8... |
mod dependency;
pub use dependency::Dependency;
mod lemma;
pub use lemma::Lemma;
|
fn main() {
let mut s = String::from("Hello world!");
let index = first_world(&s);
println!("The index of first world of {} is {}", s, index);
s.clear(); //no problem。直接使用下标的方式在下标返回后就和原始字符串没有关联了,在字符串清空后,index并不受影响。这样就可能造成潜在的下标越界异常。
println!("The index of first world of {} is {}", s, index);
l... |
mod q {
/// Blurb.
fn foo() {
}
}
fn main() {
q::foo<caret>();
}
|
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2
use crate::FutureResult;
use jsonrpc_derive::rpc;
use starcoin_types::transaction::SignedUserTransaction;
pub use self::gen_client::Client as TxPoolClient;
#[rpc]
pub trait TxPoolApi {
#[rpc(name = "txpool.submit_transaction")]
... |
extern crate rustplot;
use rustplot::chart_builder;
use rustplot::chart_builder::Chart;
use rustplot::data_parser;
#[test]
fn bar_chart_tests() {
let data_1 = data_parser::get_str_col(0, 0, 5, "./resources/bar_chart_tests.csv");
let data_2 = data_parser::get_num_col(1, 0, 5, "./resources/bar_chart_tests.csv")... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhotoImportDeleteImportedItemsFromSourceResult(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhotoImportDelet... |
mod literals;
#[doc(hidden)]
pub use literals::*;
pub type HRESULT = i32;
pub type HSTRING = *mut ::core::ffi::c_void;
pub type IUnknown = *mut ::core::ffi::c_void;
pub type IInspectable = *mut ::core::ffi::c_void;
pub type PSTR = *mut u8;
pub type PWSTR = *mut u16;
pub type PCSTR = *const u8;
pub type PCWSTR = *cons... |
use serde::Serialize;
use crate::application::common::http_status;
use crate::application::dtos::response_dto::{ResponseBodyDto, ResponseDto};
pub fn body_to_vec<T: Serialize>(
status_code: u16,
message: String,
serialize_body: Option<T>,
) -> Vec<u8> {
let response = ResponseBodyDto::<T> {
co... |
use projecteuler::primes;
fn main() {
dbg!(solve_1(10));
//dbg!(solve_1(10_000));
dbg!(solve_2(10_000));
}
fn solve_1(n: usize) -> usize {
let mut sum = 0;
for a in 1..n {
let b = sum_divisors_1(a);
if a < b && a == sum_divisors_1(b) {
sum += a + b;
}
}
... |
// Copyright © 2016-2017 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
mod primary;
mod backup;
mod start_view_change;
mod do_view_change;
mod start_view;
mod state_transfer;
mod recovery;
mod reconfiguration;
mod leaving;
mod shutdown;
mod utils;
mod common;
pub use self::primary::Primary;... |
use crate::clients::localsoup::graph::RECIPE;
use crate::clients::{Parameters, ReadRequest, VoteClient, WriteRequest};
use clap;
use failure::ResultExt;
use noria::{self, ControllerHandle, TableOperation, ZookeeperAuthority};
use tokio::prelude::*;
use tower_service::Service;
#[derive(Clone)]
pub(crate) struct Conn {
... |
use clap::clap_app;
use crossbeam::{channel::unbounded, sync::WaitGroup};
use itertools::Itertools;
use num::{BigInt, BigRational, ToPrimitive};
use parking_lot::Mutex;
use std::{collections::HashMap, error::Error, sync::Arc, thread::spawn};
fn main() -> Result<(), Box<dyn Error>> {
let matches = clap_app!(first_s... |
//
// Mimic
//! A ComputerCraft emulator.
//
extern crate terminal;
extern crate jni;
extern crate serialize;
use emulator::Emulator;
use config::Config;
use error::ErrorWindow;
mod minion;
mod color;
mod emulator;
mod convert;
mod storage;
mod config;
mod error;
fn main() {
// Create the storage directory and... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtGui/qpainter.h
// dst-file: /src/gui/qpainter.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <= m... |
use crate::{config::Flavor, curse_api, tukui_api, utility::strip_non_digits};
use std::cmp::Ordering;
use std::path::PathBuf;
#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord)]
pub enum AddonState {
Ajour(Option<String>),
Downloading,
Fingerprint,
Unpacking,
Updatable,
}
#[derive(Debug, Clone... |
extern crate regex;
extern crate num_cpus;
extern crate memmap;
extern crate time;
extern crate ansi_term;
use std::fs::DirEntry;
use std::sync::{Arc, Mutex};
use std::thread;
use self::memmap::{Mmap, Protection};
use self::ansi_term::{Style, Colour};
use self::regex::bytes::Regex;
use std::path::PathBuf;
use std::str... |
// enumns can be defined with or without data contained in them
// data contained can be any type of primitive type, structs, an enum
// recursuive enum type need to be behind a pointer(Box,Rc)
#[derive(Debug)]
enum Direction {
N,
E,
W,
S,
}
enum PlayerAction {
Move { direction: Direction, speed: ... |
// Copyright (c) 2018-2022 Ministerio de Fomento
// Instituto de Ciencias de la Construcción Eduardo Torroja (IETcc-CSIC)
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the ... |
//! Background for an output
use rustwlc::WlcView;
use wayland_sys::server::wl_client;
/// A background is not complete until you call the "complete" method on it.
/// This will need to be executed via the view_created callback, because before that
/// we haven't properly set it.
#[derive(Debug, Clone, Copy, Eq, Part... |
mod minimax;
pub use minimax::*;
mod alphabeta;
pub use alphabeta::*;
use std::fmt::Debug;
use crate::game::Game;
pub const WIN: f64 = 10000.0;
pub const DRAW: f64 = 0.0;
pub const LOSS: f64 = -10000.0;
/// A heuristic that evaluates the game state at the leafs of a tree search.
pub trait Heuristic: Debug + Send + ... |
use super::{expm1, expo2};
// sinh(x) = (exp(x) - 1/exp(x))/2
// = (exp(x)-1 + (exp(x)-1)/exp(x))/2
// = x + x^3/6 + o(x^5)
//
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn sinh(x: f64) -> f64 {
// union {double f; uint64_t i;} u = {.f = x};
// uint32_t w;
// double t, ... |
use amethyst::core::shrev::{ReaderId};
use amethyst::ecs::{Write, ReadStorage, System, Read};
use amethyst::ecs::{Component, VecStorage};
use amethyst::core::transform::Transform;
use amethyst::prelude::*;
use amethyst::ecs::SystemData;
use specs_physics::events::{ProximityEvent, ProximityEvents};
use crate::room::De... |
mod advanced_functions_and_closures;
mod advanced_traits;
mod advanced_types;
mod unsafe_rust;
fn main() {
println!("===== 19. advanced features ======\n");
unsafe_rust::main();
advanced_traits::main();
advanced_types::main();
advanced_functions_and_closures::main();
}
|
extern crate midi_message;
extern crate rand;
pub mod color;
pub mod color_strip;
pub mod opc_strip;
pub mod midi_light_strip;
pub mod rainbow;
mod effects {
pub mod effect;
pub mod ripple;
pub mod flash;
pub mod blink;
pub mod stream;
pub mod stream_center;
pub mod push;
pub mod river... |
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
use cuda::ffi::driver_types::{cudaStream_t};
use cuda::ffi::library_types::{cudaDataType};
include!(concat!(env!("OUT_DIR"), "/cublas_bind.rs"));
|
use std::fmt::Debug;
fn add_things<T: Debug>(a: T, b: T) {
// a + b
println!("A : {:?} ", a);
}
fn where_display<T>(val: T)
where
T: Debug,
{
println!("Value is {:?}", val);
}
fn main() {
add_things(2, 2);
where_display(9);
}
|
use anymap::AnyMap;
use std::any::TypeId;
use std::collections::HashSet;
#[derive(Debug)]
pub struct Entity {
pub(crate) components: AnyMap,
pub(crate) shape: HashSet<TypeId>,
}
impl Default for Entity {
fn default() -> Self {
Self::new()
}
}
impl Entity {
pub fn new() -> Self {
S... |
pub use crate::traits::*;
pub use crate::{create_render_core, RenderCoreCreateInfo};
pub use crate::presentationcore::{ApplicationInfo, PresentationBackend, PresentationCore, VRMode};
pub use crate::renderbackend::{Eye, TargetMode, VRTransformations};
// input
pub use crate::input::{
controller::Controller, con... |
pub fn mean(li: &[i64]) -> f64 {
let sum: i64 = li.iter().sum();
sum as f64 / li.len() as f64
}
use std::cmp::Ord;
pub fn med<T: Ord + Copy>(list: &[T]) -> T {
let mut new_vec = list.to_vec();
new_vec.sort();
new_vec[new_vec.len() / 2]
}
use std::collections::HashMap;
use std::hash::Hash;
fn coun... |
pub const LIFESPAN: isize = 500;
pub const SCREEN_WIDTH: isize = 1200;
pub const SCREEN_HEIGHT: isize = 800;
pub const POPULATION_SIZE: usize = 300;
pub const POPULATION_ORIGIN_X: i32 = SCREEN_WIDTH as i32 / 2;
pub const POPULATION_ORIGIN_Y: i32 = SCREEN_HEIGHT as i32;
|
pub mod delete;
pub mod howto;
pub mod list;
pub mod new;
use colored::*;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Formatter, Result};
#[derive(Serialize, Deserialize)]
pub struct Command {
pub id: usize,
pub command: String,
pub keywords: Vec<String>,
}
impl fmt::Display for Command {
... |
struct Thing;
trait Method<T> {
fn method(&self) -> T;
fn mut_method(&mut self) -> T;
}
impl Method<i32> for Thing {
fn method(&self) -> i32 { 0 }
fn mut_method(&mut self) -> i32 { 0 }
}
impl Method<u32> for Thing {
fn method(&self) -> u32 { 0 }
fn mut_method(&mut self) -> u32 { 0 }
}
fn mai... |
use super::*;
use crate::engine::input::{InputEngine, InputState};
use cvar::IVisit;
use gvfs::filesystem::Filesystem;
use rhai::{
packages::{Package, StandardPackage},
plugin::*,
Dynamic, Engine, Scope, AST,
};
use std::{collections::HashMap, fmt, io::Read, path::PathBuf, str::FromStr};
pub struct ScriptE... |
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
use structopt::StructOpt;
// submodules
mod errors;
mod input;
mod local_search;
use input::{PlanningData, Player};
/// The command line options that can be given to this application.
#[derive(Debug, StructOpt)]
#[structopt(
name = "match-plan... |
//! This is a seperate file where the Errors for the filesystem have been defined
use thiserror::Error;
use cplfs_api::error_given::APIError;
use std::fmt;
use std::fmt::Formatter;
#[derive(Error, Debug)]
/// This structure defines the errors for the filestructure
/// All the potential errors are grouped here
pub en... |
#[doc = "Reader of register CONFRN4"]
pub type R = crate::R<u32, super::CONFRN4>;
#[doc = "Writer for register CONFRN4"]
pub type W = crate::W<u32, super::CONFRN4>;
#[doc = "Register CONFRN4 `reset()`'s with value 0"]
impl crate::ResetValue for super::CONFRN4 {
type Type = u32;
#[inline(always)]
fn reset_va... |
//! Creates the nlprule binaries from a *build directory*. Usage information in /build/README.md.
use fs_err as fs;
use fs::File;
use std::{
hash::{Hash, Hasher},
io::{self, BufReader, BufWriter},
num::ParseIntError,
path::{Path, PathBuf},
str::FromStr,
sync::Arc,
};
use crate::{
rules::R... |
// Copyright 2023 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... |
//! A module providing a CLI command to inspect the contents of a WAL file.
use std::{io::Write, ops::RangeInclusive, path::PathBuf};
use itertools::Itertools;
use wal::SequencedWalOp;
use super::Error;
#[derive(Debug, clap::Parser)]
pub struct Config {
/// The path to the input WAL file
#[clap(value_parser)... |
/*
@TODO:
+ move logic to separate module/lib
+ move URL building to separate struct
- accept command line arguments
*/
extern crate getopts;
extern crate rustc_serialize;
#[allow(unused_imports)]
use self::rustc_serialize::json;
#[allow(unused_imports)]
use self::rustc_serialize::json::Json;
#[allow(unused_import... |
use cortex_m::interrupt::free;
use heapless::{ArrayLength, Vec};
pub fn get_current_ticks() -> u32 {
free(|cs| {
let mut data = crate::SYSTEM_DATA.borrow(cs).borrow_mut();
data.get_mut().ticks_since_reset
})
}
pub fn uart_buffer_push(c: u8) {
free(|cs| {
let mut buffer = crate::UAR... |
// Copyright (c) 2016-2017 Nikita Pekin and the xkcd_rs contributors
// See the README.md file at the top-level directory of this distribution.
//
// 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.o... |
#[doc = "Reader of register STS"]
pub type R = crate::R<u32, super::STS>;
#[doc = "Writer for register STS"]
pub type W = crate::W<u32, super::STS>;
#[doc = "Register STS `reset()`'s with value 0"]
impl crate::ResetValue for super::STS {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
//! Macro for opaque `Debug` trait implementation.
#![no_std]
/// Macro for defining opaque `Debug` implementation. It will use the following
/// format: "HasherName { ... }". While it's convinient to have it
/// (e.g. for including in other structs), it could be undesirable to leak
/// internall state, which can happ... |
// Copyright 2021 Chiral Ltd.
// Licensed under the Apache-2.0 license (https://opensource.org/licenses/Apache-2.0)
// This file may not be copied, modified, or distributed
// except according to those terms.
//!
//! Workflow for Extenion Module: Molecule
//!
//! # Examples
//!
//! ```rust
//! use graph_canonicalizat... |
fn main() {
other();
}
fn other() {}
|
use crate::token::{Token, TokenType};
use std::convert::TryInto;
pub struct Scanner<'a> {
pub source: &'a str,
pub tokens: Vec<Token>,
start: usize,
current: usize,
line: u32,
had_error: bool,
}
impl<'a> Scanner<'a> {
pub fn new(source: &str) -> Scanner {
let tokens: Vec<Token> = V... |
mod assets;
mod handle;
pub use assets::*;
pub use handle::Handle;
|
use crate::prelude::*;
use utilities::prelude::*;
use super::block::Block;
use std::os::raw::c_void;
use std::sync::Arc;
pub struct Chunk {
device: Arc<Device>,
memory: VkDeviceMemory,
memory_type_index: u32,
size: VkDeviceSize,
blocks: Vec<Block>,
mapping: Option<*mut c_void>,
}
unsafe i... |
fn main() {
println!("My first Rust Program on GitHub");
}
|
#[derive(Clone)]
pub enum ArmaValue {
Number(f32),
Array(Vec<ArmaValue>),
Boolean(bool),
String(String),
}
impl std::fmt::Display for ArmaValue {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Number(n) => write!(f, "{}", n.to_string()),
... |
#![forbid(unsafe_code)]
#![no_std]
|
use crate::prelude::*;
use super::super::{c_char_to_vkstring, raw_to_slice};
use std::os::raw::{c_char, c_void};
use std::ptr;
#[repr(C)]
#[derive(Debug)]
pub struct VkDebugUtilsMessengerCallbackDataEXT {
pub sType: VkStructureType,
pub pNext: *const c_void,
pub flags: VkDebugUtilsMessengerCallbackDataFl... |
#[doc = "Reader of register OUT"]
pub type R = crate::R<u8, super::OUT>;
#[doc = "Reader of field `out`"]
pub type OUT_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:7"]
#[inline(always)]
pub fn out(&self) -> OUT_R {
OUT_R::new((self.bits & 0xff) as u8)
}
}
|
/// A Struct that stores some test data
#[derive(Debug)]
pub struct TestStruct {
pub name: String,
pub age: u8,
pub favorite_words: Vec<String>,
}
pub fn moved_param(param: TestStruct) {
println!("{:?}", param);
}
pub fn moved_and_returned_param(param: TestStruct) -> TestStruct {
println!("{:?}"... |
// 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 core::ops::FnMut;
use nom::bytes::complete::{escaped, is_not};
use nom::character::complete::{char, line_ending, one_of};
use nom::combinator::{flat_map, map_res};
use nom::error::context;
use nom::multi::many0;
use nom::sequence::terminated;
use nom::IResult;
use nom::Parser;
use crate::error::{FullError, StompP... |
// Copyright 2020 - 2021 Alex Dukhno
//
// 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... |
use crate::tiles::*;
use crate::groups::Set::{Chow, Pung, Pair};
pub use std::str::FromStr;
use std::fmt::{Display, Formatter, Error, Debug};
use crate::score::Fu;
/// 複数枚の牌に関する情報
pub trait Tiles {
/// 么九牌を含むかどうか
fn contains_yaotyu(&self) -> bool;
/// 么九牌のみかどうか
fn all_yaotyu(&self) -> bool;
/// 一九... |
// TODO: compare these to the ones in the ropey examples
use ropey::{iter::Chunks, str_utils::byte_to_char_idx, RopeSlice};
use unicode_segmentation::{GraphemeCursor, GraphemeIncomplete};
use unicode_width::UnicodeWidthStr;
// hard code for base 10 digits,
// because I don't think we'll have any other kind
pub fn dig... |
//! Datastructures and functions for building and simulating a redcode core
mod mars;
pub use self::mars::{
Mars,
LoadResult,
LoadError,
SimulationResult,
SimulationEvent,
SimulationError
};
mod builder;
pub use self::builder::{
MarsBuilder,
BuilderError
};
|
//! Backoff functionality.
#![deny(rustdoc::broken_intra_doc_links, rustdoc::bare_urls, rust_2018_idioms)]
#![warn(
missing_copy_implementations,
missing_debug_implementations,
missing_docs,
clippy::explicit_iter_loop,
// See https://github.com/influxdata/influxdb_iox/pull/1671
clippy::future_no... |
//! Methods for dealing with segments of a segmented sieve represented in a memory-efficient way.
//!
//! # Overview
//!
//! A segment represents the numbers in a given range which are prime. The range must begin and
//! end on a multiple of 240, due to the way that the segment is represented internally, and is
//! ind... |
pub mod binary;
pub mod localization;
pub mod pack;
pub mod prefab;
pub mod set;
pub mod text;
pub mod yaml;
pub mod prelude {
pub use super::{binary::*, localization::*, pack::*, prefab::*, set::*, text::*, yaml::*};
}
|
use diesel;
use diesel::result::Error;
use diesel::ExpressionMethods;
use diesel::QueryDsl;
use diesel::RunQueryDsl;
use uuid::Uuid;
use crate::db;
use crate::models::maps::{Map, NewMap};
use crate::schema::maps;
use crate::schema::maps::dsl::*;
pub struct Filters<'a> {
pub hash: Option<&'a String>,
}
pub fn get... |
//! Loggers and logging events for declarative dataflow.
/// Logger for differential dataflow events.
pub type Logger = ::timely::logging::Logger<DeclarativeEvent>;
/// Possible different declarative events.
#[derive(Debug, Clone, Serialize, Ord, PartialOrd, Eq, PartialEq)]
pub enum DeclarativeEvent {
/// Tuples ... |
// 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... |
// 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... |
#[doc = "Reader of register CFGR3"]
pub type R = crate::R<u32, super::CFGR3>;
#[doc = "Writer for register CFGR3"]
pub type W = crate::W<u32, super::CFGR3>;
#[doc = "Register CFGR3 `reset()`'s with value 0"]
impl crate::ResetValue for super::CFGR3 {
type Type = u32;
#[inline(always)]
fn reset_value() -> Sel... |
#[cfg(test)]
extern crate env_logger;
#[macro_use]
extern crate statechart;
use statechart::ast::*;
use statechart::interpreter::*;
#[test]
fn assign_string() {
let _ = env_logger::init();
let sc = states!{ S {
substates: [
state!{ S1 {
transitions: [goto!(target: S2)],
... |
//! # What's this?
//!
//! A **resizeable array** based on a **segmented array structure**.
//!
//! ## When should I use it?
//!
//! You may want to use a `SegVec` instead of a `Vec` if:
//! - **...you have a `Vec` that grows a lot** over the lifetime of your program
//! - ...**you want to shrink a `Vec`**, but don't w... |
use once_cell::sync::Lazy;
use regex::Regex;
/// The Card is the main unit of analysis. We use it to represent a
/// zettel file.
use std::path::{Path, PathBuf};
type Tag = String;
static TAG_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"#[[:alnum:]:-]+").unwrap());
#[derive(Debug, Clone)]
pub struct Card {
///... |
use std::{hint::unreachable_unchecked, io::{BufRead, Read, stdin}, ops::{Index, IndexMut}};
#[derive(Copy, Clone)]
struct SVecC {
inner: [u8; 80],
len: usize
}
impl SVecC {
pub fn new() -> Self {
Self {
inner: [0; 80],
len: 0
}
}
#[inline]
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.