text
stringlengths
8
4.13M
fn main() { let s1 = String::from("hello"); // We're defining this string as before let len = calculate_length(&s1); // Here we pass the pointer of s1, rather than the value itself println!("The length of '{}' is {}.", s1, len); } fn calculate_length(s: &String) -> usize { s.len() // s here is a poin...
use jsonwebtoken::{Algorithm, DecodingKey, EncodingKey, Header, Validation}; use serde::{Deserialize, Serialize}; use time::{Duration, OffsetDateTime}; const SECRET: &str = "some-secret"; #[derive(Debug, PartialEq, Serialize, Deserialize)] struct Claims { sub: String, #[serde(with = "jwt_numeric_date")] i...
#![ allow (unused_parens) ] use std::error::Error; use std::hash::Hash; use std::io::Read; use std::io::Write; use std::fs; use std::fs::File; use std::ops::DerefMut; use std::path::Path; use std::path::PathBuf; use std::sync::Arc; use std::sync::Mutex; use futures; use futures::BoxFuture; use futures::Future; use f...
use derivative::Derivative; use serde::{Deserialize, Serialize}; use crate::bson::{Document, Timestamp}; /// Struct modeling a cluster time reported by the server. /// /// See [the MongoDB documentation](https://www.mongodb.com/docs/manual/core/read-isolation-consistency-recency/) /// for more information. #[derive(D...
fn main() { let vec: Vec<i32> = Vec::new(); let v = vec![1, 2, 3]; let mut v = Vec::new(); v.push(5); v.push(6); v.push(7); v.push(8); let v = vec![1, 2, 3, 4, 5]; let third: &i32 = &v[2]; println!("The third element is {}", third); match v.get(2) { Some(third) =...
// Copyright 2021 The Matrix.org Foundation C.I.C. // // 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...
use std::cmp::Ordering; #[derive(Debug)] enum Node { Leaf { value: i32, left: Box<Node>, right: Box<Node>, }, End } impl Node { fn new(arr: &mut [i32]) -> Node { arr.sort(); Node::build_tree(arr) } fn build_tree(arr: &[i32]) -> Node { match arr.l...
extern crate panic_at_the_disco; fn main() { panic_at_the_disco::init(); panic!("at the disco"); }
impl Solution { pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 { fn back(xs: &mut Vec<i32>, I: usize, step: usize) { for i in I..xs.len() { xs[i-step] = xs[i]; } } if nums.len() == 0 { return 0; } let mut cnt = 1; ...
use std::io; use rand::{self, Rng}; use std::fmt::Write as FWrite; use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian}; use std::net::{SocketAddr, Ipv4Addr, SocketAddrV4}; use ring::digest; pub fn io_err<T>(reason: &'static str) -> io::Result<T> { Err(io::Error::new(io::ErrorKind::Other, reason)) } pub fn io_...
#[doc = "Reader of register INTR_SIE_MASKED"] pub type R = crate::R<u32, super::INTR_SIE_MASKED>; #[doc = "Reader of field `SOF_INTR_MASKED`"] pub type SOF_INTR_MASKED_R = crate::R<bool, bool>; #[doc = "Reader of field `BUS_RESET_INTR_MASKED`"] pub type BUS_RESET_INTR_MASKED_R = crate::R<bool, bool>; #[doc = "Reader of...
use std::error::Error; use std::ffi::*; use std::io::prelude::*; use std::net::TcpStream; const ADDR_PORT: &str = "127.0.0.1:9841"; fn main() -> Result<(), Box<dyn Error>> { let mut stream = TcpStream::connect(ADDR_PORT)?; let c_string = CString::new("hello")?; //stream.write(&[0x41, 0x42, 0x43, 0x00])?;...
//! ITP1_4_Aの回答 //! [https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_A](https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_A) use std::io; use std::str::FromStr; /// ITP1_4_Aの回答(エントリポイント)。 #[allow(dead_code)] pub fn main() { loop { let mut line = String::new(); if le...
extern crate gtk; use gtk::*; mod components; use components::App; mod db; use self::db::DataConect; fn main() { let conn = DataConect::new("TODO.db"); // conn.add("Milk"); let app = App::new(conn); app.window.show_all(); gtk::main(); }
use core::future::Future; use core::pin::Pin; use embassy_traits::delay::Delay; use embedded_hal::digital::v2::OutputPin; use crate::{ error::{Error, Result}, non_blocking::bus::DataBus, }; pub struct EightBitBus< RS: OutputPin, EN: OutputPin, D0: OutputPin, D1: OutputPin, D2: OutputPin, D3: OutputPin, D4: O...
use std::net::{UdpSocket, ToSocketAddrs}; fn main() { let total = 10 * 1000 * 1000; println!("{}", total); let buf = [b'Q'; 64]; let socket = UdpSocket::bind("127.0.0.1:0").unwrap(); let dst_addr = ToSocketAddrs::to_socket_addrs("127.0.0.1:9999").unwrap().next().unwrap(); for _ in 0 .. total...
use super::*; use crate::{debug, input::InputBlockIterator, FallibleIterator}; use std::marker::PhantomData; pub(crate) struct SequentialQuoteClassifier<'i, I, const N: usize> where I: InputBlockIterator<'i, N>, { iter: I, escaped: bool, in_quotes: bool, phantom: PhantomData<&'i ()>, } impl<'i, I,...
pub(crate) mod trader; pub(crate) mod history; pub(crate) mod private; pub mod public;
use std::collections::hash_map::Entry; use std::collections::VecDeque; use std::slice; use super::HalfJoinState; use crate::util::clear::Clear; type HashMap<K, V> = rustc_hash::FxHashMap<K, V>; use smallvec::{smallvec, SmallVec}; #[derive(Debug)] pub struct HalfMultisetJoinState<Key, ValBuild, ValProbe> { // Her...
use std::mem; #[derive(Debug)] struct Node<T> { elem: T, next: Link<T> } type Link<T> = Option<Box<Node<T>>>; #[derive(Debug)] pub struct List<T> { head: Link<T>, } impl<T> List<T> { pub fn new() -> Self { List{head: None} } } impl<T> List<T> { pub fn push(&mut self, elem: T) { ...
// Copyright 2021 Red Hat, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
mod test_utils; use relational_types::*; use test_utils::*; #[derive(GetCorresponding)] pub struct Model { #[get_corresponding(weight = "abc")] animals_to_felines: OneToMany<Animal, Feline>, } fn main() {}
use std::collections::HashSet; use std::string::ToString; pub struct UniqueNamer { taken_names: HashSet<String>, } /// Returns unique names. impl UniqueNamer { pub fn new() -> UniqueNamer { UniqueNamer { taken_names: HashSet::new() } } /// Returns a name, either `desired_name` or something "c...
extern crate rand; pub mod parser; pub mod rpn; use parser::read_eval_print_loop; fn main() { if let Err(err) = read_eval_print_loop() { println!("Error: {:?}", err); } }
#[test] fn test_present() { // i32 assert_eq!(Some(0), bin_search(&0_i32, &[0, 1, 2, 4, 8, 16])); assert_eq!(Some(1), bin_search(&1_i32, &[0, 1, 2, 4, 8, 16])); assert_eq!(Some(2), bin_search(&2_i32, &[0, 1, 2, 4, 8, 16])); assert_eq!(Some(3), bin_search(&4_i32, &[0, 1, 2, 4, 8, 16])); assert_eq...
use actix_session::Session; use actix_web::{web, HttpRequest, HttpResponse}; use rustimate_core::session::EstimateSession; use rustimate_service::AppConfig; #[derive(serde::Deserialize)] pub(crate) struct QueryStringKey { key: String } /// Available at `/s/create` pub(crate) fn create(session: Session, cfg: web::D...
use crate::vector::Vec2f; use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize)] #[derive(Debug, Clone)] pub struct Polygon { centroid: Vec2f, points: Vec<Vec2f>, } impl Polygon { pub fn new(points: Vec<Vec2f>) -> Self { Self::new2(centroid(&points), points) } pub fn new2(...
#[cfg(test)] pub mod opcode_tests; pub mod cpu;
pub(crate) mod compact_block;
pub struct Adler32 { a: u32, b: u32, } impl Adler32 { pub fn new() -> Self { Self { a: 1, b: 0 } } #[inline] pub fn eat(&mut self, c: u8) { self.a = (self.a + c as u32) % 65521; self.b = (self.b + self.a) % 65521; } #[inline] pub fn eat_slice(&mut s...
// This file is part of Substrate. // Copyright (C) 2018-2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // 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 // // ht...
use crate::eval::prelude::*; impl Eval<&ast::ExprLit> for ConstCompiler<'_> { fn eval( &mut self, expr_lit: &ast::ExprLit, used: Used, ) -> Result<Option<ConstValue>, crate::CompileError> { self.budget.take(expr_lit)?; match &expr_lit.lit { ast::Lit::Bool(b)...
#[doc = "Register `DTXFSTS1` reader"] pub type R = crate::R<DTXFSTS1_SPEC>; #[doc = "Field `INEPTFSAV` reader - IN endpoint TxFIFO space available"] pub type INEPTFSAV_R = crate::FieldReader<u16>; impl R { #[doc = "Bits 0:15 - IN endpoint TxFIFO space available"] #[inline(always)] pub fn ineptfsav(&self) ->...
extern crate docopt; #[macro_use] extern crate log; extern crate reduced_c as compiler; use docopt::Docopt; use std::fs::File; use std::io::{self, BufReader, Read, Write}; use std::process; mod logger { use ::log::{Level, LevelFilter, Metadata, Record, SetLoggerError}; struct StdoutLogger(Level); impl :...
//! Various network abstractions //! //! Based on [`PollEvented`](../reactor/struct.PollEvented.html). mod tcp_connect; mod tcp_listen; mod tcp_stream; mod udp_socket; pub use self::tcp_connect::TcpConnectFuture; pub use self::tcp_listen::{TcpListener, TcpIncoming}; pub use self::tcp_stream::TcpStream; pub use self::...
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #![allow(unused_imports)] use anyhow::Result; use diem_sdk::{ client::BlockingClient, transaction_builder::TransactionFactory, types::{account_config::xus_tag, LocalAccount}, }; use diem_types::{ account_address::Account...
#![doc = "generated by AutoRust 0.1.0"] #![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct AvailabilityGroupListenerProperties { #[serde(rename = "provisioningState", default, skip_serializing_if = "Opt...
// Jacob Schneck // CS 120 // Module Three: Open Ended Project use std::fs::File; use std::io::{BufRead, BufReader, Error, ErrorKind, Read}; //========================= Driver =============================== fn main() { let filename: String = String::from("numbers.txt"); let num_lines: u32 = 10; let vec...
#[derive(Clone)] struct Board { numbers: Vec<Vec<(u32, bool)>>, } impl std::str::FromStr for Board { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { let numbers = s .lines() .map(|l| { l.split(' ') .filter(|s| !s.is_empty...
use crate::{ config::{CONFIGURATION, PROGRESS_PRINTER}, filters::WildcardFilter, scanner::should_filter_response, statistics::StatCommand, utils::{ferox_print, format_url, get_url_path_length, make_request, status_colorizer}, FeroxResponse, }; use console::style; use indicatif::ProgressBar; use ...
mod queue_account_client; mod queue_client; pub use queue_account_client::QueueAccountClient; pub use queue_client::QueueClient;
use serde::{Deserialize, Serialize}; use super::native_image_asset_type; #[derive(Serialize, Deserialize, Debug, PartialEq)] pub struct ImageAssetFormat { #[serde(rename = "type")] asset_type: Option<native_image_asset_type::NativeImageAssetType>, mime: String, w: Option<i32>, h: Option<i32>, ...
use sequence_trie::SequenceTrie; use itertools::Itertools; use std::collections::HashSet; use std::iter::FromIterator; use utils; pub fn problem_043() -> u64 { let mut tries = vec![]; let primes = vec![2,3,5,7,11,13,17]; for &p in primes.iter(){ let mut trie: SequenceTrie<u32, u32> = SequenceTrie...
//! Implements `Lexicon` in the most basic way, using a `Vec` to store strings. //! This provides O(n) performance for all of the operations in the `Lexicon` //! trait, where n is the size of the lexicon and the size of words is //! negligible compared to the size of the lexicon. //! //! This lexicon is case-insensitiv...
use bevy::core::FixedTimestep; use bevy::diagnostic::{Diagnostics, FrameTimeDiagnosticsPlugin}; use bevy::prelude::*; use bevy::DefaultPlugins; use rand::Rng; use wasm_bindgen::prelude::*; use crate::materials::Materials; use crate::position::Position; use crate::size::Size; pub mod materials; pub mod position; pub m...
/// An enum to represent all characters in the Arabic block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum Arabic { /// \u{600}: '؀' NumberSign, /// \u{601}: '؁' SignSanah, /// \u{602}: '؂' FootnoteMarker, /// \u{603}: '؃' SignSafha, /// \u{604}: '؄' SignSamvat, ...
use std::cell::RefCell; use std::rc::Rc; use hydroflow::scheduled::graph::Hydroflow; use hydroflow::util::multiset::HashMultiSet; use hydroflow::{assert_graphvis_snapshots, hydroflow_syntax}; use multiplatform_test::multiplatform_test; use tokio::sync::mpsc::error::SendError; // /// Testing an interesting topology: a...
fn compute_moving_average(window: &[(u32, u32)]) -> (u32, f32) { let window_size = window.len(); println!("window.len(): {}", window.len()); println!("window_size: {}", window_size); let current_year = window[window_size / 2].0; println!("current_year: {}", current_year); // Summiert alle Werte...
use bulletproofs::{BulletproofGens, PedersenGens}; #[macro_use] extern crate criterion; use criterion::Criterion; fn pc_gens(c: &mut Criterion) { c.bench_function("PedersenGens::new", |b| b.iter(|| PedersenGens::default())); } fn bp_gens(c: &mut Criterion) { c.bench_function_over_inputs( "Bulletproof...
use std::convert::TryFrom; use libpulse_binding::volume::{ChannelVolumes, Volume, VOLUME_NORM}; use pulsectl::controllers::DeviceControl; use pulsectl::controllers::SinkController; const NOMMO_VENDOR_ID: u16 = 0x1532; const NOMMO_PRODUCT_ID: u16 = 0x0517; const VOL_DELTA: f64 = 0.05; #[derive(Debug, PartialEq)] enum...
#[derive(Debug, Clone, PartialEq)] pub enum MouseButton { Left = 1 << 0, Right = 1 << 1, Middle = 1 << 2, Move = 1 << 3, WheelUp = 1 << 4, WheelDown = 1 << 5, Wheel = 1 << 6, None = 1 << 7, Unknown = 1 << 8, } #[derive(Debug, Clone, PartialEq)] pub enum Event { Resize(u32, u32), MouseMove(MouseButton, u32, ...
extern crate regex; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; fn main() -> Result<(), std::io::Error> { let input_path = Path::new("input.txt"); let reader = BufReader::new(File::open(&input_path)?); let input = reader.lines().flatten().collect(); let p1 = part_01(&inp...
mod scanner; mod token; pub use scanner::Scanner;
use std::fmt; use uuid::Uuid; #[derive(Serialize, Deserialize, Debug)] pub struct Rush { uuid: String, } impl fmt::Display for Rush { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!(formatter, "Rush[uuid: {}]", self.uuid) } } impl Rush { pub fn with(uuid: String) -> Rush...
#[macro_use] extern crate text_io; use std::ops::Fn; use std::time::{Instant}; static mut STATE0: u64 = 1; static mut STATE1: u64 = 2; unsafe fn random(max_value: i32) -> i32 { let mut s1: u64 = STATE0; let s0: u64 = STATE1; STATE0 = s0; s1 ^= s1 << 23; s1 ^= s1 >> 17; s1 ^= s0; s1 ^= s0 ...
use std::{time::Duration}; fn main() { let ports = serialport::available_ports().expect("No ports found!"); for p in ports { println!("{}", p.port_name); } let port_name = "/dev/tty.usbserial-14240"; let baud_rate = 115_200; let port = serialport::new(port_name, baud_rate) .ti...
#[doc = "Register `ETH_MACVTR` reader"] pub type R = crate::R<ETH_MACVTR_SPEC>; #[doc = "Register `ETH_MACVTR` writer"] pub type W = crate::W<ETH_MACVTR_SPEC>; #[doc = "Field `VL` reader - VL"] pub type VL_R = crate::FieldReader<u16>; #[doc = "Field `VL` writer - VL"] pub type VL_W<'a, REG, const O: u8> = crate::FieldW...
#![allow(unused)] pub mod code; pub mod cpu; pub mod instruction; pub mod memory; pub mod registers;
use crate::{OpArgBuf, WORD_SIZE}; struct OpInfo { args: u8, suffix: u8, } #[repr(u8)] #[derive(Debug, Copy, Clone)] pub enum OpCode { // 0 arg ops TosDown = OpInfo { args: 0, suffix: 0 }.pack(), // stack- WrapAddStack = OpInfo { args: 0, suffix: 1 }.pack(), // stack--+ DecStack = OpInfo { args...
#![allow(dead_code)] use glob::glob; pub use std::path::Path; pub use std::path::PathBuf; use app_dirs::{get_app_root, AppDataType}; use getset::Getters; use std::io::Read; use tempfile::{tempdir, TempDir}; pub trait DisplayPath { fn display_path(&self) -> String; } impl DisplayPath for PathBuf { fn display...
fn main() { // This is just a simple example of two differnt ways // you can initilize some basic variables. Just different // sytax. Both valid. let some_u32_v: u32 = 4; let some_u32_v2 = 5u32; println!("some_u32_v: {}", some_u32_v); println!("some_u32_v2: {}", some_u32_v2); let s: S...
use core::alloc::Layout; use core::sync::atomic::{AtomicBool, Ordering}; use buddy_system_allocator::{Heap, LockedHeapWithRescue}; use kerla_utils::alignment::align_up; use crate::arch::PAGE_SIZE; use crate::page_allocator::{alloc_pages, AllocPageFlags}; const ORDER: usize = 32; const KERNEL_HEAP_CHUNK_SIZE: usize =...
use super::Token; use std::str::Chars; use std::iter::Peekable; pub struct Lexer<'a>{ cached_str: &'a str, input: Peekable<Chars<'a>>, cache: Vec<Token> } impl<'a> Lexer<'a>{ pub fn new(input: &str) -> Lexer{ Lexer {input: input.chars().peekable(), cache: Vec::new(), cached_str: input} } ...
//! # The XML `<nduiml>` format //! //! This is use in: //! - The `res/ui/templates/item.xml` file
#[doc = "Reader of register SETUP_1"] pub type R = crate::R<u32, super::SETUP_1>; #[doc = "Writer for register SETUP_1"] pub type W = crate::W<u32, super::SETUP_1>; #[doc = "Register SETUP_1 `reset()`'s with value 0"] impl crate::ResetValue for super::SETUP_1 { type Type = u32; #[inline(always)] fn reset_va...
mod matrix; mod vector; pub use matrix::{ Matrix }; pub use vector::{ Vector };
use crate::{Error, LoadFunction, TemplateMap}; use std::path::PathBuf; use std::time::SystemTime; /// A backing store for a set of templates pub trait TemplateStore { /// Tries to parse the template map /// /// # Errors /// - Any I/O error associated with fetching this data /// - Any deserializati...
use priv_prelude::*; use spawn_complete; /// A set of clients that can be attached to a router node. pub trait RouterClientsV4 { /// The output of the nodes attached to the router. type Output: Send + 'static; /// Build the set of nodes. fn build(self, handle: &Handle, subnet: SubnetV4) -> (SpawnCompl...
use std::collections::{BTreeMap, HashMap}; use crate::error::Error; use crate::error::Result; use rbatis::crud::CRUD; use rbatis::plugin::page::Page; use crate::domain::domain::{SysRes, SysRoleRes}; use crate::domain::dto::{ RoleAddDTO, RoleEditDTO, RolePageDTO, SysRoleResAddDTO, SysRoleResPageDTO, SysRoleResUpda...
mod commands; mod logging; mod parameters; mod webhook; use teloxide::prelude::*; #[tokio::main] async fn main() { run().await; } async fn run() { logging::init_logger(); log::info!("Starting Supapro bot"); let parameters = std::sync::Arc::new(parameters::Parameters::new()); let bot = Bot::from...
#[doc = "Reader of register CID1"] pub type R = crate::R<u32, super::CID1>; #[doc = "Reader of field `COMP_ID_1`"] pub type COMP_ID_1_R = crate::R<u8, u8>; impl R { #[doc = "Bits 0:7 - Component ID 1"] #[inline(always)] pub fn comp_id_1(&self) -> COMP_ID_1_R { COMP_ID_1_R::new((self.bits & 0xff) as ...
use anyhow::Result; use super::super::builtin; use super::prelude::*; use super::Object; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Builtin { pub func: builtin::Function, } impl Display for Builtin { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "builtin function.") } } ...
use distinst_chroot::Command; use std::io; use std::path::Path; // pub fn update_initramfs() -> io::Result<()> { // Command::new("update-initramfs").args(&["-ck", "all"]).run() // } pub fn rsync(src: &[&Path], target: &str, args: &[&str]) -> io::Result<()> { Command::new("rsync").args(args).args(src).arg(targ...
#![cfg_attr(feature = "unstable", feature(test))] // Launch program : cargo run --release < input/input.txt // Launch benchmark : cargo +nightly bench --features "unstable" /* Benchmark results: running 4 tests test tests::test_part_1 ... ignored test tests::test_part_2 ... ignored test bench::bench_...
// 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::model::*, cm_rust::ComponentDecl, fidl_fuchsia_data as fdata, std::collections::HashSet, std::sync::Arc, }; /// Returns true if the g...
/********************************************** > File Name : twitter.rs > Author : lunar > Email : lunar_ubuntu@qq.com > Created Time : Mon 13 Dec 2021 07:12:00 PM CST > Location : Shanghai > Copyright@ https://github.com/xiaoqixian **********************************************/ use std::...
use std::fs::File; use std::io::{BufRead, BufReader}; mod job; use job::Job; fn main() { let mut jobs = get_jobs_from_file("jobs.small.txt"); jobs.sort(); jobs.reverse(); let mut prev_task_length = 0; let mut total_completion_time:i64 = 0; for job in jobs { let curr_task_length = job....
use rand::RngCore; use std::{fs::File, io::Write}; fn main() { build_file("data/zobrist.txt", 12 * 64 * 2).unwrap(); build_file("data/en_passant.txt", 64).unwrap(); build_file("data/castling.txt", 4).unwrap(); } pub fn build_file(path: &str, size: usize) -> Result<(), std::io::Error> { let mut rng = r...
use hyper::Uri; use serde_json as json; use chrono::UTC; #[derive(Clone, Deserialize, Serialize, Debug)] pub struct PapersUri(#[serde(with = "uri_deserializer")] pub Uri); /// See https://serde.rs/custom-date-format.html for the custom deserialization. /// An alternative design would be making a ...
#[doc = "Register `PUPDR` reader"] pub type R = crate::R<PUPDR_SPEC>; #[doc = "Register `PUPDR` writer"] pub type W = crate::W<PUPDR_SPEC>; #[doc = "Field `PUPD0` reader - Port x configuration bits (y = 0..15)"] pub type PUPD0_R = crate::FieldReader<PUPD0_A>; #[doc = "Port x configuration bits (y = 0..15)\n\nValue on r...
use serde::ser; use crate::ser::{Error, Result, Serializer}; pub struct SerializeMap<'a, 'b> { ser: &'a mut Serializer<'b>, first: bool, } impl<'a, 'b: 'a> SerializeMap<'a, 'b> { pub(crate) fn new(ser: &'a mut Serializer<'b>) -> Self { SerializeMap { ser, first: true } } } impl<'a, 'b: 'a> s...
use std::{io, thread}; use std::sync::atomic; use std::fmt::Debug; use {amy, slog}; use {TC, LOG}; pub struct Handle<I, O> { pub tx: amy::Sender<O>, pub rx: amy::Receiver<I>, } impl<I: Debug + Send + 'static, O: Debug + Send + 'static> Handle<I, O> { pub fn new( creg: &mut amy::Registrar, ...
pub mod command; pub mod editing; pub mod filesystem; pub mod movement;
use std::env; fn main() { let args: Vec<_> = env::args().collect(); if args.len() == 2 { // execute the file println!("{:?}", args) } else { // open REPL println!("Hello, world!") } }
// Copyright 2019, 2020 Wingchain // // 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 crate::client::Client; use std::collections::HashMap; use tokio::sync::mpsc::{self, Receiver, Sender}; #[derive(Debug)] pub enum BrokerMessage { AddPublisher(Client); AddSubscriber(Client); RemovePublisher(Client); RemoveSubscriber(Client); } pub struct Broker { publisher: Vec<Client>, su...
use core::ptr; use core::mem::MaybeUninit; use std::sync::atomic::{AtomicUsize, Ordering}; use std::ffi::CString; use esp_idf_bindgen::{ esp_err_t, ESP_ERR_NVS_NO_FREE_PAGES, ESP_ERR_NVS_NEW_VERSION_FOUND, nvs_open_mode_t, nvs_handle_t, nvs_flash_init_partition, nvs_flash_erase_partition, nvs_flash_de...
use async_std::{io, prelude::*, fs::{self, File}, task}; const LEN: usize = 16 * 1024; // 16 Kb pub async fn ls(path: &str) -> io::Result<()> { task::block_on(async { let mut dir = fs::read_dir(&path).await?; while let Some(res) = dir.next().await { let entry = res?; printl...
use math::SpacialNumericConversion; use crate::*; /// Construct a set of [`Sprite`]s from a set of [`riddle_image::Image`]s which share a texture atlas. /// /// # Example /// /// ```no_run /// # use riddle::{common::Color, image::*, platform::*, renderer::*, math::*, *}; /// # fn main() -> Result<(), RiddleError> { /...
use toml::{Table, Value}; use std::thread::{self, JoinHandle}; use std::sync::{Arc, Once, ONCE_INIT }; use std::sync::mpsc::{sync_channel, SyncSender, Receiver}; use serde_json::Value as JValue; use rs_es::Client; use rs_es::operations::bulk::Action; use rs_es::error::EsError; use std::time::{Duration, Instant}; use ...
//! Helper methods for modifying shapes. pub use vecmath::vec2_len; /// Rotate position some rounds. #[allow(non_snake_case)] pub fn rotate2d__pos_rounds(pos: [f64; 2], rounds: f64) -> [f64; 2] { use vecmath::row_mat2x3_transform_pos2 as tr; let angle = rounds * std::f64::consts::PI * 2.0; let cos = angl...
#![feature(nll)] extern crate termion; extern crate extra; mod grid; use termion::{async_stdin, clear, color, cursor, style}; use termion::raw::{IntoRawMode, RawTerminal}; use std::io::{self, Write, Read, Result}; use std::thread; use std::time; fn main() { let stdout = io::stdout(); let mut game = Game::n...
#[macro_use] extern crate gfx; extern crate gfx_core; extern crate gfx_device_gl; extern crate gfx_window_glutin; extern crate glutin; extern crate image; extern crate rand; extern crate fnv; pub mod types; pub mod render_system; pub mod camera; pub mod pipeline; //pub mod material; //pub mod sphere; //pub mod texture...
/* * 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 */ /// FormulaAndFunctionEventQueryGroupBySort : Options for sorting group by results. #[derive(Clone, D...
#[derive(Debug, PartialEq)] pub enum CpuErrorKind { SegFault, InvalidOpCode, } #[derive(Debug, PartialEq)] pub struct CpuError { message: String, addr: u16, kind: CpuErrorKind, } impl CpuError { pub fn code_segment_out_of_range(addr: u16) -> CpuError { CpuError { message: f...
use crate::part::Part; use std::fs::File; use std::{ collections::HashMap, io::{BufRead, BufReader}, }; fn play(xs: &[i64], target: i64) -> i64 { let mut seen = HashMap::new(); seen.extend( xs.iter() .enumerate() .map(|(turn, &x)| (x, (-1, turn as i64 + 1))), ); ...
use crate::RrtVec3::Vec3; use crate::RrtVec3::unit_vector; use crate::RrtSphere::hit_sphere; use crate::RrtHittableList::HittableList; use crate::RrtHittable::hit_record; use crate::RrtWeekend::infinity; pub fn ray_color(ray: Ray, world : HittableList) -> Vec3 { let mut rec : hit_record = hit_record::new(); ...
extern crate metl; extern crate cocoa; use cocoa::base::{BOOL, nil}; use cocoa::foundation::NSString; use metl::{CompileOptions, DepthStencilDescriptor, Device, FeatureSet, LanguageVersion, PixelFormat, SpecificLanguageVersion, SamplerDescriptor, TextureDescriptor}; use metl::LibraryError; use metl::{FromR...
#![allow(unused)] /// This struct loads in vulkan from NVidia's special wrapper library, since the normal driver is not actually installed on Comet. /// use libc::c_char; use shared_library::{self}; use std::ffi::c_void; use std::mem; use std::path::Path; use vulkano::instance::loader::{Loader, LoadingError}; /// Imp...
extern crate regex; use regex::Regex; use std::fmt; use std::path::Path; use visuals; use decoder_class; use decoder_usecase; use decoding_to_visual; pub struct Model { pub class_amount: i32, pub class_file_name: String, pub use_case_amount: i32, pub use_case_file_name: String, pub errors: Strin...