text stringlengths 8 4.13M |
|---|
#[doc = "Register `CSR` reader"]
pub type R = crate::R<CSR_SPEC>;
#[doc = "Register `CSR` writer"]
pub type W = crate::W<CSR_SPEC>;
#[doc = "Field `LSION` reader - LSI oscillator enable Set and reset by software."]
pub type LSION_R = crate::BitReader<LSION_A>;
#[doc = "LSI oscillator enable Set and reset by software.\n... |
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::BLECFG {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mu... |
// TODO: Add scrollbar stuff to theme
use std::{cell::Cell};
use chiropterm::{Brush, FSem, Font, MouseButton, MouseEvent, Signal};
use euclid::{rect, vec2};
use crate::{InternalWidgetDimensions, UI, Widget, WidgetMenu, Widgetlike, widget::{AnyWidget, LayoutHacks}};
// Smallvec size -- set this to "higher than most ... |
#[derive(Debug)]
struct Obj {
no:u128,
id:u128,
}
impl Obj{
fn new(no:u128,id:u128)->Obj{
Obj {
no:no,
id:id,
}
}
}
fn main (){
let mut v:Vec<Obj> = Vec::new();
v.push(Obj::new(44, 68));
println!("{:?}",v.get(0));
println!("{:?}",v.get(20));
}
|
#![allow(dead_code)]
macro_rules! die {
($msg:expr, $code:expr) => {
println!("ERROR: {}", $msg);
std::process::exit($code);
}
}
pub fn lo_bits(arg: u16) -> u8 {
(arg & 0xFF) as u8
}
pub fn hi_bits(arg: u16) -> u8 {
(arg >> 8) as u8
}
pub fn hi_bits_no_shift(arg: u16) -> u16 {
a... |
use crate::services::metrics::models::MetricsValue;
use crate::services::metrics::MetricsService;
use indy_api_types::errors::prelude::*;
use indy_wallet::WalletService;
use serde_json::{Map, Value};
use std::collections::HashMap;
use std::rc::Rc;
const THREADPOOL_ACTIVE_COUNT: &str = "active";
const THREADPOOL_QUEUED... |
static SHADER_DIR: &'static str = "src/_shaders";
static GLSL_VALIDATOR: &'static str = "/usr/local/bin/glslangValidator";
use std::fs;
use std::process::Command;
fn main() {
check_glsl();
}
fn check_glsl() {
let shader_directory = fs::read_dir(SHADER_DIR)
.expect(&format!("Could not read shader dire... |
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use crate::raw::{
error::{Error, Fallible},
security,
};
use alloc::sync::Arc;
use core::{convert::TryInto, ptr::NonNull};
use s2n_tls_sys::*;
use std::ffi::CString;
struct Owned(NonNull<s2n_config>);
... |
#[doc = "Reader of register MMMS_MASTER_CREATE_BT_CAPT"]
pub type R = crate::R<u32, super::MMMS_MASTER_CREATE_BT_CAPT>;
#[doc = "Reader of field `BT_SLOT`"]
pub type BT_SLOT_R = crate::R<u16, u16>;
impl R {
#[doc = "Bits 0:15 - This register captures the BT_SLOT when master connection is created, granularity is 625... |
use crate::{arg, component::Component};
use clap::{App, ArgMatches};
use digitalocean::prelude::*;
use failure::Error;
pub struct List;
impl Component for List {
const DEFAULT_OUTPUT: Option<&'static str> = Some("table");
fn app() -> App<'static, 'static> {
App::new("list")
.a... |
/*
* Sliding window min/max (Rust)
*
* Copyright (c) 2022 Project Nayuki. (MIT License)
* https://www.nayuki.io/page/sliding-window-minimum-maximum-algorithm
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"),... |
mod impls;
pub use impls::*;
|
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{BaseConfig, ChainNetwork, ConfigModule, StarcoinOpt};
use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
static LOGGER_FILE_NAME: &str = "starcoin.log";
#[derive(Clone, Debug, Deserialize,... |
#[doc = "Reader of register IC_INTR_MASK"]
pub type R = crate::R<u32, super::IC_INTR_MASK>;
#[doc = "Writer for register IC_INTR_MASK"]
pub type W = crate::W<u32, super::IC_INTR_MASK>;
#[doc = "Register IC_INTR_MASK `reset()`'s with value 0x08ff"]
impl crate::ResetValue for super::IC_INTR_MASK {
type Type = u32;
... |
//! Build a Sightglass engine using Wasmtime. Usage:
//!
//! ```
//! rustc build.rs
//! [REPOSITORY=<repo url>] [REVISION=<hash|branch|tag>] ./build [<destination dir>]
//! ```
//!
//! Note that a `hash` must be the full commit hash.
#![deny(missing_docs)]
#![deny(clippy::all)]
#![warn(clippy::pedantic)]
#![allow(clip... |
use std::{
cell::RefCell,
rc::Rc,
sync::{Arc, Mutex},
};
use rand;
use smithay::{
reexports::wayland_server::{
protocol::{wl_buffer, wl_shell_surface, wl_surface},
Display,
},
wayland::{
compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceEvent},
... |
use std::f64;
use rand::seq::{SliceRandom};
use rand::{Rng, thread_rng};
#[derive(Copy, Clone)]
enum Funcs {
SinFunc,
CosFunc,
TimesFunc,
X,
Y
}
pub trait EvalFunc {
fn eval(&self, x: f64, y: f64) -> f64;
}
impl From<(Funcs, f64)> for Box<dyn EvalFunc> {
fn from(t: (Funcs, f64)) -> Self {... |
#[cfg(test)]
mod message_test;
pub mod builder;
pub mod header;
pub mod name;
mod packer;
pub mod parser;
pub mod question;
pub mod resource;
use header::*;
use packer::*;
use parser::*;
use question::*;
use resource::*;
use crate::errors::*;
use std::fmt;
use std::collections::HashMap;
use util::Error;
// Messag... |
#[doc = "Reader of register INTR_HOST_EP_MASK"]
pub type R = crate::R<u32, super::INTR_HOST_EP_MASK>;
#[doc = "Writer for register INTR_HOST_EP_MASK"]
pub type W = crate::W<u32, super::INTR_HOST_EP_MASK>;
#[doc = "Register INTR_HOST_EP_MASK `reset()`'s with value 0"]
impl crate::ResetValue for super::INTR_HOST_EP_MASK ... |
use crate::grammar::ast::eq::AstEq;
use crate::grammar::ast::Underscore;
use crate::grammar::model::{HasSourceReference, WrightInput};
use crate::grammar::tracing::parsers::tag;
use crate::grammar::tracing::{parsers::map, trace_result};
use nom::IResult;
impl<T: Clone + std::fmt::Debug> Underscore<T> {
/// The nam... |
mod dvec2_impl;
mod dvec3_impl;
mod dvec4_impl;
mod ivec2_impl;
mod ivec3_impl;
mod ivec4_impl;
mod i64vec2_impl;
mod i64vec3_impl;
mod i64vec4_impl;
mod u64vec2_impl;
mod u64vec3_impl;
mod u64vec4_impl;
mod uvec2_impl;
mod uvec3_impl;
mod uvec4_impl;
mod vec2_impl;
mod vec3_impl;
#[cfg(any(
not(any(
... |
use bit_vec::BitVec;
use std::cmp::Ordering;
type ChildNode = Option<Box<Node>>;
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Node {
pub value: Option<u8>,
pub weight: usize,
pub left: ChildNode,
pub right: ChildNode,
}
impl PartialOrd for Node {
fn partial_cmp(&self, other: &Self) -> Option<... |
use std::fs;
use std::fs::File;
use std::io::Write;
use std::io::prelude::*;
extern crate serde_json;
use serde_json::{Value, Error};
static DATA_DIR: &'static str = "../data/";
static OUT_FILE: &'static str = "ret.md";
fn list_json(dir:&str) -> Vec<String> {
let mut json_list: Vec<String> = Vec::new();
let ... |
// Refs:
// - https://doc.rust-lang.org/nightly/cargo/commands/cargo-clean.html
// - https://github.com/rust-lang/cargo/blob/0.62.0/src/cargo/ops/cargo_clean.rs
use std::path::Path;
use anyhow::Result;
use camino::Utf8Path;
use cargo_metadata::PackageId;
use walkdir::WalkDir;
use crate::{
cargo::{self, Workspace... |
use super::*;
use std::boxed::Box;
use std::rc::Rc;
type ParseResult = Result<Expr,GreyError>;
pub struct Parser {
current: usize,
tokens: Vec<Token>
}
impl Parser {
pub fn new(tokens: Vec<Token>) -> Parser {
Parser {
current: 0,
tokens: tokens
}
}
pub fn... |
#[doc = "Reader of register OA1_SLOPE_OFFSET_TRIM"]
pub type R = crate::R<u32, super::OA1_SLOPE_OFFSET_TRIM>;
#[doc = "Writer for register OA1_SLOPE_OFFSET_TRIM"]
pub type W = crate::W<u32, super::OA1_SLOPE_OFFSET_TRIM>;
#[doc = "Register OA1_SLOPE_OFFSET_TRIM `reset()`'s with value 0"]
impl crate::ResetValue for super... |
use hacspec_lib::*;
fn bool_true() -> bool {
true
}
fn bool_false() -> bool {
false
}
fn num_u8() -> u8 {
100u8
}
fn num_u16() -> u16 {
100u16
}
fn num_u32() -> u32 {
100u32
}
fn num_u64() -> u64 {
100u64
}
fn num_u128() -> u128 {
100u128
}
fn num_usize() -> usize {
100usize
}
f... |
use lexer::{Input, State, Reader};
use super::super::token::{Token, TokenKind};
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct IdentifiersReader;
impl Reader<TokenKind> for IdentifiersReader {
#[inline(always)]
fn priority(&self) -> usize { 2usize }
fn read(&self, input: &Input, state: &mut S... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: support@datadoghq.com
* Generated by: https://openapi-generator.tech
*/
/// UsageSyntheticsHour : The number of synthetics tests run for each hour for a given organization.
... |
// This is the first Rust code I've ever written, cut me some slack
use std::collections::HashMap;
#[derive(Hash, Eq, PartialEq, Debug)]
struct Pos {
n: u64,
m: u64
}
// o(2^n) or something silly
fn grid_traveler_naive(n: u64, m: u64) -> u64 {
if n <= 1 || m <= 1 {
return 1;
}
return grid_... |
use drm::buffer::Buffer;
use drm::control::{connector, crtc, encoder, framebuffer, Device as ControlDevice, Mode, ResourceInfo};
use drm::Device as BasicDevice;
use std::collections::HashSet;
use std::os::unix::io::{AsRawFd, RawFd};
use std::rc::Rc;
use std::sync::RwLock;
use crate::backend::drm::{DevPath, RawSurface... |
use bootloader::boot_info::{FrameBufferInfo, PixelFormat};
use conquer_once::spin::OnceCell;
use core::{
fmt::{self, Write},
ptr,
};
use font8x8::UnicodeFonts;
use spinning_top::{RawSpinlock, Spinlock};
pub static LOGGER: OnceCell<LockedLogger> = OnceCell::uninit();
pub struct LockedLogger(Spinlock<Logger>);
... |
// The Quasar runtime
// bare-metal reimplementation of some basic Rust libstd and libcore
// functions.
pub mod lang;
pub mod io;
pub mod ops;
pub mod num;
|
use crate::{
DataSet,
ItemSet,
Support,
closed::{
InitialSets,
is_dup
}
};
/// Parallel implementation of the DCI-Closed algorithm. This implementation is a simple
/// adaptation of the original algorithm from the paper, using Rayon. It should use all the
/// CPU cores.
///
/// The returned collection will *... |
use std::time::Instant;
use skulpin::skia_safe::*;
use winit::dpi::PhysicalPosition;
pub use winit::event::{ElementState, MouseButton, VirtualKeyCode};
use winit::event::{KeyboardInput, WindowEvent};
const MOUSE_BUTTON_COUNT: usize = 8;
const KEY_CODE_COUNT: usize = 256;
pub struct Input {
// mouse input
mou... |
mod hook;
pub use hook::*;
#[cfg(feature = "discord")]
pub mod discord;
|
//! Traits for abstracting away frame allocation and deallocation.
use crate::addr::Frame;
/// A trait for types that can allocate a frame of memory.
pub trait FrameAllocator {
/// Allocate a frame of the appropriate size and return it if possible.
fn alloc(&mut self) -> Option<Frame>;
}
/// A trait for type... |
use futures_locks::Mutex;
use std::{
collections::HashMap,
convert::TryFrom,
sync::Arc,
time::{Duration, Instant},
};
use yggy_core::{
dev::*,
interfaces::{router::session, switch},
types::{
Address, AllowedEncryptionPublicKeys, BoxNonce, BoxPublicKey, Coords, Handle, NodeID,
... |
use std::collections::HashMap;
use nom::IResult;
const INPUT: &str = include_str!("../inputs/day_7_input");
#[derive(Debug)]
struct Step {
name: char,
allows: char,
}
impl Step {
fn parse(i: &str) -> IResult<&str, Self> {
use nom::bytes::complete::tag;
use nom::character::complete::anych... |
// Copyright (c) 2017 The Noise-rs Developers.
//
// 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. All files in the
// project carrying such notice may not be cop... |
//! Fixed-point to `f64` conversions.
use util::bits::BitField;
/// Reads a fixed-point number from a `u32`.
///
/// A fixed-point number represents a fractional value (eg. 5.3) as an integer
/// in smaller units (eg. 53 tenths). Ie. in contrast to floating-point numbers,
/// there are a fixed number of bits after th... |
// MIT License
// Copyright (c) 2017 Jerome Froelich
// 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 Software without restriction, including without limitation the rights
// to use, copy, modify,... |
use super::*;
/// A block of source code.
///
/// # Semantics
///
/// Same as [`ExampleBlock`] but usually contains source code. The content will be highlighted
/// according to the language specified.
///
/// # Syntax
///
/// ```text
/// #+BEGIN_SRC LANGUAGE FLAGS ARGUMENTS
/// CONTENTS
/// #+END_SRC
/// ```
///
/// ... |
/// The functions and files pertaining to the TUI debugger for the VM.
///
/// This provides a way to step through instructions and inspect memory through the execution of a
/// program, allowing the user to either debug the VM or the program.
use crate::lc3::{consts::Register, DispatchTables, LC3};
use num_traits::Fro... |
//! Crate for getting the user's username, realname and environment.
//!
//! ## Getting Started
//! Using the whoami crate is super easy! All of the public items are simple
//! functions with no parameters that return `String`s (with the exception of
//! [`env()`](fn.env.html), and [`platform()`](fn.platform.html) whi... |
#[doc = "Reader of register ADV_SCN_RSP_TX_FIFO"]
pub type R = crate::R<u32, super::ADV_SCN_RSP_TX_FIFO>;
#[doc = "Writer for register ADV_SCN_RSP_TX_FIFO"]
pub type W = crate::W<u32, super::ADV_SCN_RSP_TX_FIFO>;
#[doc = "Register ADV_SCN_RSP_TX_FIFO `reset()`'s with value 0"]
impl crate::ResetValue for super::ADV_SCN_... |
use std::collections::HashMap;
use super::type_table::{TypeTableEntry, TypeTableType};
pub struct EventTable {
table: TypeTableType
}
impl TypeTableEntry for EventTable {
fn get(&self, key: u16) -> String {
let result = self.table.get(&key);
match result {
Some(r) => r.clone(),
... |
/*
* 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.
*/
//! Tests for parallelism and concurrency
use reverie::syscalls::Syscall;
use reverie::Error;
use ... |
#![cfg_attr(feature = "unstable", feature(test))]
// Launch program : cargo run --release < input/input.txt
// Launch benchmark : cargo +nightly bench --features "unstable"
/*
Benchmark results:
running 5 tests
test tests::test_part_1 ... ignored
test tests::test_part_2 ... ignored
test bench::bench_... |
#[derive(Clone, PartialEq, Eq)]
pub struct UserFilter {
/// the search term
pub phrase: String,
/// levenshtein edit distance https://en.wikipedia.org/wiki/Levenshtein_distance
pub levenshtein: Option<u8>,
}
impl std::fmt::Debug for UserFilter {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>... |
use std::fs::File;
use std::io::prelude::*;
fn decode_seat(seat: &str) -> (u32, u32) {
let mut row_upper = 127;
let mut row_lower = 0;
let mut col_upper = 7;
let mut col_lower = 0;
for byte in seat.bytes() {
match byte {
b'F' => {
row_upper = (row_lower + row_up... |
#[cfg(test)]
extern crate rand;
pub mod counter;
pub mod buffer;
pub mod role;
pub mod sequence;
pub mod queue;
|
#![feature(pattern_parentheses)]
#![feature(const_fn)]
#![feature(associated_type_defaults)]
#![feature(step_trait)]
#![feature(generators, generator_trait)]
#![feature(const_cell_new)]
#![feature(decl_macro)]
extern crate rand;
extern crate redo;
extern crate image;
extern crate nfd;
extern crate cgmath;
#[macro_use]... |
use std::collections::HashMap;
use std::fs;
fn part1(instructions: &Vec<(String, i32)>) -> i32 {
let mut m: HashMap<i32, ()> = HashMap::new();
let mut instr: i32 = 0;
let mut acc: i32 = 0;
while !m.contains_key(&instr) {
m.insert(instr, ());
match instructions.get(instr as usize).unwr... |
#![no_main]
#![no_std]
use bootloader::{entry_point, BootInfo};
use core::panic::PanicInfo;
mod vgabuffer;
//extern crate goodnight;
entry_point!(kernel);
#[no_mangle]
fn kernel(bootinfo: &'static BootInfo) -> !
{
// vgabuffer::print_whatever();
loop {}
}
#[panic_handler]
fn panic(_info: &PanicInfo) -> !
{
loop ... |
fn main() {
let mut n = 0;
for i in 1..101 {
n += i * i;
}
println!("{}", 5050 * 5050 - n);
}
|
extern crate rustc_serialize;
extern crate crypto;
extern crate rand;
extern crate getopts;
mod data_base;
mod user;
mod connection;
use std::sync::{Arc, Mutex};
use std::io::{BufRead, BufReader, Read, Write};
use std::net::TcpListener;
use std::thread;
use std::path::Path;
use std::env;
use std::str::from_utf8;
use ... |
use std::{fs, io};
use std::collections::{BTreeMap, HashMap};
use std::process::exit;
use std::rc::{self, Rc};
use log::{debug, error, info, trace, warn};
use pddl_problem_parser::{Predicate, PddlProblem};
use crate::operators::{SatelliteEnum, SatelliteGoals, SatelliteState};
use crate::operators::SatelliteEnum::{Dir... |
//! Peripheral access API for STM32WL microcontrollers
//! (generated using [svd2rust](https://github.com/rust-embedded/svd2rust)
//! 0.30.0)
//!
//! You can find an overview of the API here:
//! [svd2rust/#peripheral-api](https://docs.rs/svd2rust/0.30.0/svd2rust/#peripheral-api)
//!
//! For more details see the README... |
//! ocaml-rs is a library for directly interacting with the C OCaml runtime, in Rust.
//!
//! **Note:** `ocaml-rs` is still experimental, please report any issues on [github](https://github.com/zshipko/ocaml-rs/issues)
//!
//! This crate will allow you to write OCaml C stubs directly in Rust. It is suggested to build
/... |
use std::cmp::Ordering;
use super::{BoundType, Bound};
use super::Bound::*;
#[test]
fn test_equality() {
assert_eq!(Unbounded::<i32>, Unbounded);
assert_eq!(Inclusive(1), Inclusive(1));
assert_eq!(Exclusive(1), Exclusive(1));
assert!(Inclusive(1) != Unbounded);
assert!(Inclusive(1) != Exclusive(1... |
// Example code that deserializes and serializes the model.
// extern crate serde;
// #[macro_use]
// extern crate serde_derive;
// extern crate serde_json;
//
// use generated_module::[object Object];
//
// fn main() {
// let json = r#"{"answer": 42}"#;
// let model: [object Object] = serde_json::from_str(&jso... |
use crate::netlink_packet_core::NetlinkMessage;
use failure::{Fail, ResultExt};
use futures::Stream;
use netlink_packet_route::RtnlMessage;
use netlink_proto::{sys::SocketAddr, ConnectionHandle};
use crate::{AddressHandle, Error, ErrorKind, LinkHandle};
lazy_static! {
static ref KERNEL_UNICAST: SocketAddr = Socke... |
mod win;
use failure::Error;
use img_dedup::Config;
use log::{debug, info};
use relm::Widget;
use simplelog::{LevelFilter, TermLogger};
use structopt::StructOpt;
use win::Win;
fn main() -> Result<(), Error> {
let config = Config::from_args();
let level = match config.verbosity {
0 => LevelFilter::Err... |
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_dynamodb::model::AttributeValue;
use aws_sdk_dynamodb::{Client, Error, Region, PKG_VERSION};
use std::process;
use structopt::StructOpt;
#... |
use regex::{Regex, Captures};
use std::fs;
type Result<T> = ::std::result::Result<T, Box<dyn ::std::error::Error>>;
struct Row {
start: usize,
end: usize,
password: String,
letter: char
}
fn main() -> Result<()> {
let contents = fs::read_to_string("src/input.txt").expect("Failed to read input.txt... |
///This is meant to be a tool for rendering setup
extern crate specs;
extern crate cgmath;
use cgmath::{Euler, Matrix4, Vector3, Deg};
///MACROS!
//gfx's macros must be in scope to use these macros in other crates
#[macro_use] extern crate gfx;
//generates the gfx vertex primitive with the specified type
#[macro_e... |
use libc::c_uint;
/// provides required enums for advanced currency operations.
///
/// These enums as arguments are used in [`tcmb_evds_c_get_advanced_data`](crate::tcmb_evds_c_get_advanced_data).
///
/// # Example
///
/// ```C
/// // frequency formulas declarations.
/// TcmbEvdsAggregationType aggregation_ty... |
use super::*;
// Header is a representation of a DNS message header.
#[derive(Default, Debug, Copy, Clone, PartialEq)]
pub struct Header {
pub id: u16,
pub response: bool,
pub op_code: OpCode,
pub authoritative: bool,
pub truncated: bool,
pub recursion_desired: bool,
pub recursion_available... |
// TODO:
// Walk the call graph
// - first preprocess the AST into a Map from name to definition
// fns = Map<String, syn::FunDef>
// - another mutable Map stores the result - whether a function needs the input param or not
// is_using_input = mut Map<String, ?bool>
// - then start from pixel_color, find ... |
use crate::math::{Color, Rect, Vec2};
use core::{
assets::{asset::AssetId, database::AssetsDatabase},
error::*,
Ignite, Scalar,
};
use serde::{Deserialize, Serialize};
use std::{borrow::Cow, ops::Range};
#[derive(Ignite, Debug, Default, Clone, Serialize, Deserialize)]
pub struct Rectangle {
pub color: ... |
extern crate tch;
use tch::{kind, Tensor};
fn main() {
let t = Tensor::randn(&[5, 4], kind::FLOAT_CPU);
t.print();
} |
#[derive(Debug)]
struct MyStruct {
name: &'static str
}
impl MyStruct {
fn new(name: &'static str) -> Self {
MyStruct {
name: name
}
}
}
fn main() {
println!("{:?}", MyStruct::new("Doggie"));
}
|
use clap::App;
use clap::ArgMatches;
use colored::Colorize;
use diar::command::CommandResult;
use diar::commands::add::WhereToAdd;
use diar::commands::jump::JumpTo;
use diar::commands::{add, clear, delete, jump, list, ls, rename};
use diar::interface::presenter;
use diar::{
command::command,
infrastructure::{db... |
#[doc = "Register `BSEC_OTP_ERROR0` reader"]
pub type R = crate::R<BSEC_OTP_ERROR0_SPEC>;
#[doc = "Field `ERR` reader - ERR"]
pub type ERR_R = crate::FieldReader<u32>;
impl R {
#[doc = "Bits 0:31 - ERR"]
#[inline(always)]
pub fn err(&self) -> ERR_R {
ERR_R::new(self.bits)
}
}
#[doc = "BSEC_OTP_E... |
fn main() {
type Name = String;
let x: Name = "Hello".to_string();
println!("{}", x);
type Num = i32;
let x: i32 = 5;
let y: Num = 5;
if x == y {
println!("x == y");
}
use std::result;
#[allow(dead_code)]
enum ConcreteError {
Foo,
Bar,
}
... |
use lexer::Lexer;
use parser::Parser;
fn main() {
let tokens = Lexer::new(
"Name,Email,Phone Number,Address
Bob Smith,bob@example.com,123-456-7890,123 Fake Street
Mike Jones,mike@example.com,098-765-4321,321 Fake Avenue"
.to_string(),
)
.lex();
// println!("{:?}", to... |
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![feature(core_intrinsics)]
#![test_runner(ros::test_runner)]
#![reexport_test_harness_main = "test_main"]
use ros::{init, println, utils};
#[no_mangle]
pub extern "C" fn _start() -> ! {
init();
println!("Hello, world!");
// x86_64::instructions... |
use amethyst::{
core::{alga::linear::EuclideanSpace, math::Point2, Transform},
ecs::{Entities, Entity, Join, ReadStorage, System, WriteStorage},
};
use crate::components::{Ai, Ship, StateQuery};
// Only handle transitions
pub struct AiSystem;
impl<'s> System<'s> for AiSystem {
type SystemData = (
... |
// Rust’s standard library provides a lot of useful functionality,
// but WebAssembly does not support all of it.
// eng_wasm exposes a subset of std.
#![no_std]
// The eng_wasm crate allows to use the Enigma runtime, which provides:
// manipulating state, creation of random, printing and more
extern crate eng_wasm;
... |
use std::fs::File;
use std::io::prelude::*;
#[derive(PartialEq, Clone, Debug)]
enum CellState {
Floor,
Empty,
Occupied,
}
struct FloorState {
content: Vec<Vec<CellState>>,
}
impl FloorState {
fn width(&self) -> usize {
self.content[0].len()
}
fn height(&self) -> usize {
s... |
pub(crate) mod rover_service; |
#![feature(libc)]
#![feature(core)]
#![allow(dead_code)]
extern crate libc;
extern crate core;
mod linkedlist;
|
#[cfg(test)]
mod tests {
use bbqueue::BBBuffer;
#[test]
fn sanity_check() {
let bb: BBBuffer<6> = BBBuffer::new();
let (mut prod, mut cons) = bb.try_split().unwrap();
const ITERS: usize = 100000;
for i in 0..ITERS {
let j = (i & 255) as u8;
#[cfg(f... |
/* mod.rs contains the handlers for the podcasts api */
use rocket::http::Status;
use rocket_contrib::json::{Json, JsonValue};
use serde::Deserialize;
mod db;
/* podcasts main, receives get request and returns json data for podcasts main page*/
#[get("/podcasts")]
pub fn podcasts_main() -> &'static str {
"podcast... |
#[allow(unused_imports)]
use super::prelude::*;
use super::intcode::IntcodeDevice;
type Input = IntcodeDevice;
pub fn input_generator(input: &str) -> Input {
input.parse().expect("Error parsing the IntcodeDevice")
}
pub fn part1(input: &Input) -> usize {
let mut device = input.clone();
let mut blocks_cou... |
use std::net;
use std::sync::Arc;
use std::time::Duration;
use std::{u32, u64};
use http;
use indexmap::IndexMap;
use conduit_proxy_controller_grpc::common::{
TcpAddress,
Protocol,
};
use conduit_proxy_controller_grpc::telemetry::{
ClientTransport,
eos_ctx,
EosCtx,
EosScope,
ReportRequest,... |
use std::ops::{Rem, Div, Neg, Sub, Mul, Add};
use std::fmt::Debug;
pub fn floor_divmod<D>(mut a: D, mut b: D) -> (D, D)
where
D: Div<Output=D>,
D: Mul<Output=D>,
D: Rem<Output=D>,
D: Neg<Output=D>,
D: Sub<Output=D>,
D: Add<Output=D>,
D: Copy + PartialEq<D> + ... |
mod custom_value;
use nu_protocol::{PipelineData, ShellError, Span, Value};
use polars::frame::groupby::{GroupBy, GroupsProxy};
use polars::prelude::{DataFrame, GroupsIdx};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum NuGroupsProxy {
Idx {
sorted: bool,
... |
use lambda::handler_fn;
use hearts::deliver;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Sync + Send + 'static>> {
env_logger::init();
lambda::run(handler_fn(deliver)).await?;
Ok(())
}
|
extern crate console_error_panic_hook;
extern crate js_sys;
extern crate midir;
extern crate wasm_bindgen;
extern crate web_sys;
use js_sys::Array;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use web_sys::console;
use std::error::Error;
use std::sync::{Arc, Mutex};
use midir::{Ignore, MidiInput};
pub fn... |
use crate::ticket::Ticket;
#[derive(Debug)]
pub enum PacketError
{
Cancel,
}
pub struct Packet
{
ticket_result: Result<Ticket, PacketError>,
}
impl Packet
{
pub fn from_ticket(ticket: Ticket) -> Packet
{
Packet
{
ticket_result: Ok(ticket),
}
}
pub fn cance... |
extern crate lz4;
use std::env;
use std::fs::File;
use std::io;
use std::io::Result;
use std::io::Read;
use std::io::Write;
use std::path::Path;
use lz4::Encoder;
fn main() {
let args: &Vec<String> = &mut env::args().collect();
let mut width: u64 = 0;
let mut height: u64 = 0;
let mut frame: u64 = 0;
... |
//! HTTP endpoints exposed in /api context
use crate::Context;
use hyper::{
header::{qitem, Accept, Authorization, Basic, UserAgent},
mime::Mime,
net::HttpsConnector,
status::StatusCode,
Client,
};
use rocket::request::{self, FromRequest, Request};
use rocket::response::{content, status, Redirect};... |
use crate::server::{
controlchan::{error::ControlChanError, Reply},
Event,
};
use async_trait::async_trait;
use std::{future::Future, pin::Pin};
// Defines the requirements for code that wants to intercept and do something with control channel events.
#[async_trait]
pub trait ControlChanMiddleware: Send + Sync... |
/*!
Armstrong Kernel WIP
*/
#![feature(core, core_intrinsics, no_std, lang_items, const_fn)]
#![warn(missing_docs)]
#![deny(unused_extern_crates)]
#![warn(unused_qualifications)]
#![deny(box_pointers)]
#![deny(unused_results)]
#![deny(overflowing_literals)]
#![no_std]
#[allow(unused_extern_crates)]
#[cfg(not(f... |
#[doc = "Reader of register RCC_USBCKSELR"]
pub type R = crate::R<u32, super::RCC_USBCKSELR>;
#[doc = "Writer for register RCC_USBCKSELR"]
pub type W = crate::W<u32, super::RCC_USBCKSELR>;
#[doc = "Register RCC_USBCKSELR `reset()`'s with value 0"]
impl crate::ResetValue for super::RCC_USBCKSELR {
type Type = u32;
... |
pub mod font;
pub mod window;
|
// Licensed: Apache 2.0
// allow some unused utility functions
#![allow(dead_code)]
const MULTIPLIER: u64 = 0x5DEECE66D_u64;
const MASK: u64 = 0x0000FFFFFFFFFFFF_u64;
// #define MASK_BYTES 2
const ADDEND: u64 = 0xB;
const LOWSEED: u64 = 0x330E;
pub struct Rng {
pub x: u64,
}
impl Rng {
#[inline]
fn ... |
#![allow(dead_code)]
#![allow(clippy::collapsible_if)]
#![allow(clippy::let_and_return)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::single_char_pattern)]
use crate::pb;
use std::collections::VecDeque;
use std::sync::Arc;
use tokio::sync::{mpsc, oneshot, Mutex};
#[derive(Clone, PartialEq)]
pub enum ServerR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.