text
stringlengths
8
4.13M
mod graph_app; pub mod gui_renderer; mod perf_app; mod stat_app; pub use graph_app::GridApp; pub use gui_renderer::GUIRenderer; pub use perf_app::PerfApp; pub use stat_app::StatApp;
fn func1(){ let sum = 0; for i in 1..5 { let sum = sum + i; println!("{}",sum) } println!("{}",sum); println!("ここまでがfunc1です") } fn func2(){ let mut sum = 0; for i in 0..15 { sum = sum + i } println!("{}!!!!",sum) } fn main(){ func1(); func2() }
// 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. //! The Archivist collects and stores diagnostic data from components. #![allow(dead_code)] #![warn(missing_docs)] use { archivist_lib::{archive, con...
//! Search query parser //! //! This module parses a query and converts it into a SQL statement. This statement can be used in //! the database to search for tracks. /// Enum providing allowed tags in the search query, like 'title:Crazy' #[derive(Debug)] pub enum Tag { Any(String), Title(String), Album(Str...
// 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 std::time::{SystemTime, UNIX_EPOCH}; use num::BigUint; /// The modulus constant from the GCC implementation of rand (2^31). We can make this more efficient /// with binary trickery if we so choose, since it's just a power of two. const GCC_MOD: u64 = 2147483648; /// The multiplication constant from GCC const GCC_M...
use std::io; use std::result; use log; use std::num; pub type Result<T> = result::Result<T, TransferError>; quick_error! { #[derive(Debug)] pub enum TransferError { Io(err: io::Error) { cause(err) description(err.description()) from() } Lo...
// This file was generated by gir (https://github.com/gtk-rs/gir) // from ../gir-files // DO NOT EDIT use crate::Message; use crate::MessageHeaders; use glib::object::IsA; use glib::translate::*; use glib::StaticType; use std::fmt; use std::ptr; glib::wrapper! { #[doc(alias = "SoupMultipartInputStream")] pub ...
//! A wrapper to implement hash for k8s resource objects. use k8s_openapi::{apimachinery::pkg::apis::meta::v1::ObjectMeta, Metadata}; use std::hash::{Hash, Hasher}; use std::ops::Deref; /// A wrapper that provdies a [`Hash`] implementation for any k8s resource /// object. /// Delegates to object uid for hashing and e...
//! An instrumenting state wrapper. use crate::internal_events::kubernetes::instrumenting_state as internal_events; use async_trait::async_trait; use futures::future::BoxFuture; /// A [`super::Write`] implementatiom that wraps another [`super::Write`] and /// adds instrumentation. pub struct Writer<T> { inner: T,...
use image; use crate::shaders::OurShader; use crate::AbstractContext; use crate::Context; use crate::NativeTexture; #[derive(Copy, Clone)] pub enum TextureFormat { RGBA, LUMINANCE, } pub struct Texture { texture: NativeTexture, _format: TextureFormat, _type: u32, } impl Texture { pub fn from...
use std::{ collections::{hash_map::Entry as HashMapEntry, HashMap, VecDeque}, convert::AsRef, error::Error, fmt, io::{Error as IoError, ErrorKind as IoErrorKind}, net::{SocketAddr, UdpSocket}, ops::Deref, sync::Arc, time::{Duration, Instant}, }; use async_io::Async; use futures_chan...
// Copyright 2015 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 ...
// 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 jlib; use jlib::wallet::wallet::{ WalletType }; use jlib::wallet::builder::generate_wallet; fn main() { let wallet = generate_wallet(WalletType::SECP256K1); println!("new wallet : {:#?}", wallet); }
use std::io::Read; fn read<T: std::str::FromStr>() -> T { let token: String = std::io::stdin() .bytes() .map(|c| c.ok().unwrap() as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().unwrap() } fn main() { let...
#[derive(Default)] pub struct Viewport { width: u32, height: u32, } impl Viewport { pub fn new(width: u32, height: u32) -> Self { Viewport{width, height} } pub fn size(&self) -> (u32, u32) { (self.width, self.height) } pub fn resize(&mut self, width: u32, height: u32) { ...
use pyo3::prelude::*; use pyo3::types::{IntoPyDict, PyList}; use n3_program::CodeData; use super::base::{BuildArgs, BuildCode}; use super::out::Outs; impl<'a> BuildCode<'a> for n3_program::NodeCode { type Args = &'a BuildArgs<'a>; type Output = &'a PyAny; fn build(&'a self, py: Python<'a>, args: Self::A...
//! This module mainly contains functionality replicating the miniz higher level API. use std::{cmp, mem, ptr, slice, usize}; use std::io::Cursor; use libc::{self, c_char, c_int, c_uint, c_ulong, c_void, size_t}; use miniz_oxide::deflate::core::{CompressionStrategy, TDEFLFlush, TDEFLStatus, compress, c...
// 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 ...
pub fn advance_lifetime() { let context = Context("aaa"); let result = parse_context(context); } struct Context<'s>(&'s str); /// lifetime sub-typing /// `'b: 'a` 声明一个不短于`'a`的生命周期`'b` struct Parser<'c, 's: 'c> { context: &'c Context<'s>, } impl<'c, 's> Parser<'c, 's> { fn parse(&self) -> Result<(), &...
// 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 { cm_fidl_validator, cm_json::{self, cm, Error}, fidl_fuchsia_data as fdata, fidl_fuchsia_sys2 as fsys, serde_json::{Map, Value}, }; /...
/* * Firecracker API * * RESTful public-facing API. The API is accessible through HTTP calls on specific URLs carrying JSON modeled data. The transport medium is a Unix Domain Socket. * * The version of the OpenAPI document: 0.25.0 * Contact: compute-capsule@amazon.com * Generated by: https://openapi-generator.t...
#![allow(dead_code)] use std::fmt::{Result, Display, Formatter}; use square88::*; use piece::*; use mask::Mask; use bit_board::BitBoard; pub struct Board88([Piece; 0x78]); impl Board88 { pub fn new() -> Self { Board88([VOID; 0x78]) } pub fn from(source: &BitBoard) -> Self { let mut result...
#![allow(non_snake_case)] use core::convert::TryInto; use test_winrt_signatures::*; use windows::core::*; use Component::Signatures::*; #[implement(Component::Signatures::ITestUInt8)] struct RustTest(); impl RustTest { fn SignatureUInt8(&self, a: u8, b: &mut u8) -> Result<u8> { *b = a; Ok(a) ...
/// Structs for manipulating a Tuple Variation Header /// /// Tuple Variation Headers are used within a Tuple Variation Store to locate /// the deltas in the design space. These are low-level data structures, /// generally used only in serialization/deserialization. use bitflags::bitflags; use otspec::types::*; use ots...
#[doc = "Reader of register C6ESR"] pub type R = crate::R<u32, super::C6ESR>; #[doc = "Reader of field `TEA`"] pub type TEA_R = crate::R<u8, u8>; #[doc = "Reader of field `TED`"] pub type TED_R = crate::R<bool, bool>; #[doc = "Reader of field `TELD`"] pub type TELD_R = crate::R<bool, bool>; #[doc = "Reader of field `TE...
#![feature(custom_derive)] extern crate rustc_serialize; extern crate toml; use std::env; use std::fs::File; use std::io::Read; use std::str; use rustc_serialize::Decodable; #[derive(Debug,RustcDecodable)] struct Config { core: CoreConfig, } #[derive(Debug,RustcDecodable)] struct CoreConfig { port: u16, ...
struct BinaryExpr { left: Expr, right: Expr }; enum Expr { } Binary (&'static str, binary!(^ pow ops::Pow), binary!(* mul ops::Mul), binary!(+ add ops::Add), binary!(- sub ops::Sub), fn parse(input: &str, level: usize) { let mut stack = Vec::new(); let mut iter = input.chars(); fo...
// Copyright 2019 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT // http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD // https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied, // modified, or di...
//! Projection expression plan. use timely::dataflow::scopes::child::Iterative; use timely::dataflow::Scope; use timely::progress::Timestamp; use differential_dataflow::lattice::Lattice; use crate::binding::Binding; use crate::domain::Domain; use crate::plan::{Dependencies, Implementable}; use crate::timestamp::Rewi...
// Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org> // SPDX-License-Identifier: MIT use std::process; use crate::{Choice, Error, Input, Message, Password, Question, Result}; /// The `zenity` backend. /// /// This backend uses the external `zenity` program to display GTK+ dialog boxes. #[derive(Debug)] pub stru...
/// A file serialization format. /// /// Is implemented by `GraphSyntax` for graph files and `DatasetSyntax` for dataset files. pub trait FileSyntax: Sized { /// Its canonical IRI. fn iri(self) -> &'static str; /// Its [IANA media type](https://tools.ietf.org/html/rfc2046). fn media_type(self) -> &'sta...
// // traits.rs // Copyright (C) 2019 Malcolm Ramsay <malramsay64@gmail.com> // Distributed under terms of the MIT license. // use std::{fmt, ops, slice}; use anyhow::Error; use nalgebra::SVector; use serde::Serialize; use svg::node::element::Group; use svg::Document; use crate::{Basis, Transform2}; pub trait Trans...
use projecteuler::primes; fn main() { println!("{:?}", primes::factorize(600_851_475_143)); }
use std::collections::HashSet; use normalize::normalize; fn shingles(s: &str) -> HashSet<String> { let chars: Vec<_> = s.chars().collect(); chars.windows(2).map(|w| w.iter().cloned().collect()).collect() } // Intersection of the sets divided by the size of the union of the // sets. fn jaccard_distance(s1: &s...
use super::Constant; pub fn ne(args: Vec<Constant>) -> Constant { super::not::not(vec![super::eq::eq(args)]) }
use crate::context::*; use crate::text_edit::apply_text_edits_to_buffer; use crate::types::*; use lsp_types::request::*; use lsp_types::*; use serde::Deserialize; use url::Url; pub fn text_document_range_formatting( meta: EditorMeta, params: EditorParams, ranges: Vec<Range>, ctx: &mut Context, ) { ...
//! Compiles the network to bytecode. use crate::bytecode::*; use crate::network::{Network, Node, NodeKind}; use crate::value::{Value, ValueKind}; use std::collections::HashMap; trait ToByteCode { fn to_bytecode(&self, bytecode: &mut Vec<u8>); } // impl ToByteCode for Value { // fn to_bytecode(&self, bytecod...
use rustc_serialize::json; use std::collections::HashMap; use std::env; use std::fs::File; use std::io::{Read, Write}; use std::path::PathBuf; pub fn load() -> HashMap<String, String> { let mut data = String::new(); match File::open(&data_file_path()) { Ok(mut file) => { file.read_to_strin...
/// Generates an `apply` function that is called when the smart contract is invoked. #[macro_export] macro_rules! abi { ($($t:ty),*) => { #[no_mangle] pub extern "C" fn apply(receiver: u64, code: u64, action: u64) { std::panic::set_hook(Box::new(|panic_info| { let payload...
#[cfg(feature = "flame-it")] use std::ffi::OsString; /// Struct containing all kind of settings for the python vm. #[non_exhaustive] pub struct Settings { /// -d command line switch pub debug: bool, /// -i pub inspect: bool, /// -i, with no script pub interactive: bool, /// -O optimizati...
#[macro_use] extern crate glium; mod teapot; fn main() { use glium::{glutin, Surface}; let mut events_loop = glutin::EventsLoop::new(); let dimensions = glutin::dpi::LogicalSize::new(800.0, 800.0); let window = glutin::WindowBuilder::new().with_dimensions(dimensions); let context = glutin::Contex...
extern crate x11_clipboard; use x11_clipboard::Clipboard; fn main() { let clipboard = Clipboard::new().unwrap(); let val = clipboard.load( clipboard.setter.atoms.clipboard, clipboard.setter.atoms.utf8_string, clipboard.setter.atoms.property, None ...
use wasm_bindgen::prelude::*; #[wasm_bindgen] extern { #[wasm_bindgen(js_namespace = console)] fn log(s: &str); } #[wasm_bindgen] extern { pub type Data; #[wasm_bindgen(method)] fn show(this: &Data); #[wasm_bindgen(method, getter)] fn name(this: &Data) -> String; #[wasm_bindgen(met...
use super::{PyType, PyTypeRef}; use crate::{ builtins::PyTupleRef, class::PyClassImpl, function::PosArgs, protocol::{PyIter, PyIterReturn}, types::{Constructor, IterNext, Iterable, SelfIter}, Context, Py, PyObjectRef, PyPayload, PyResult, VirtualMachine, }; #[pyclass(module = false, name = "map...
#![feature(ptr_as_ref)] #![feature(custom_derive)] pub mod stack; pub mod concurrent_stack;
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[cfg(feature = "Media_AppBroadcasting")] pub mod AppBroadcasting; #[cfg(feature = "Media_AppRecording")] pub mod AppRecording; #[cfg(feature = "Media_Audio")] pub mod Audio; #[cfg(feature = ...
use std; use std::ops::Mul; use cgmath::{BaseFloat, Basis2, Matrix, Matrix3, Quaternion, SquareMatrix, Zero}; use super::{Material, Volume}; /// Mass /// /// Mass properties for a body. Inertia is the moment of inertia in the base pose. For retrieving /// the inertia tensor for the body in its current orientation, s...
//! Fields which are common to all segment-section and gate descriptors use shared::PrivilegeLevel; use shared::segmentation; /// System-Segment and Gate-Descriptor Types for IA32e mode. When the `S` /// (descriptor type) flag in a segment descriptor is clear, the descriptor type /// is a system descriptor. /// /// ...
use std::io; use std::mem; use std::thread; use anyhow::anyhow; use anyhow::Context; use anyhow::Result; use crate::db; use crate::nexus::Doc; use crate::nexus::Event; #[cfg(feature = "crossbeam-channel")] mod channel { pub type Sender = crossbeam_channel::Sender<super::Doc>; pub type Receiver = crossbeam_ch...
use proconio::input; use fenwick_tree::FenwickTree; fn main() { input! { n: usize, m: usize, a: [[u32; m]; n], }; let mut values = Vec::new(); for a in &a { for &x in a { values.push(x); } } values.sort(); let ord = |x: u32| -> usize { ...
//! ffi-safe types that aren't wrappers for other types. pub mod bitarray; mod constructor; mod ignored_wrapper; mod late_static_ref; mod maybe_cmp; mod move_ptr; mod nul_str; mod rmut; mod rref; pub mod rsmallbox; mod static_ref; pub mod version; pub use self::{ bitarray::BitArray64, constructor::{Constructo...
use std::io::{stdin,BufRead}; use clap::{App, Arg, ArgMatches}; struct Cola2 { debug: bool, serialize: bool, ret: u128, p: u128, } impl Cola2 { fn is_on_octet_boundary(&self) -> bool { self.ret % 8 == 0 && self.ret != 0 } //opb is operation A for collats' map fn opa(&mut self...
extern crate rush; use rush::{get_line, run_command}; pub fn main() { while let Some(line) = get_line("$ ") { run_command(line); } }
extern crate chrono; extern crate hex; use self::hex::ToHex; use chrono::Utc; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; use sha3::{Digest, Sha3_256}; const COST: usize = 4; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct DataPoint { pub from: String, pub to: String, pub amo...
#[doc = "Reader of register ITLINE2"] pub type R = crate::R<u32, super::ITLINE2>; #[doc = "Reader of field `TAMP`"] pub type TAMP_R = crate::R<bool, bool>; #[doc = "Reader of field `RTC`"] pub type RTC_R = crate::R<bool, bool>; impl R { #[doc = "Bit 0 - TAMP"] #[inline(always)] pub fn tamp(&self) -> TAMP_R ...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct IOpcCertificateEnumerator(pub ::windows::core:...
//! Modify the list of `ComponentEntry` objects in a `DataBase`. // This module is a bit of a mess. use error::{GrafenCliError, UIResult, UIErrorKind}; use ui::utils::{MenuResult, get_value_from_user, print_description, print_list_description_short, remove_items, reorder_list, select_command, select_d...
use std::error::Error; use std::fmt::{self, Debug, Formatter, Display}; use std::str::{self, Utf8Error}; use std::sync::Arc; use mioco::sync::{Mutex, RwLock}; use mioco::sync::mpsc::Sender; use utils::*; use rand; pub type Id = u32; pub struct Player { pub id : Id, pub tx : Mutex<Sender<Arc<Message>>>, ...
use std::fmt::Debug; use std::ops::{Add, Mul, Sub}; use cgmath::{ BaseFloat, Basis2, EuclideanSpace, InnerSpace, Matrix3, Point2, Point3, Quaternion, Rotation, Transform, Vector3, Zero, }; use collision::dbvt::TreeValue; use collision::{Bound, ComputeBound, Contains, Discrete, HasBound, SurfaceArea, Union}; us...
/// Compose two functions. /// /// Takes functions `f` and `g` and returns `f ∘ g` (in other words something /// _like_ `|a: A| f(g(a))`. /// /// # Examples: /// /// ``` /// use fntools::unstable::compose; /// /// let add_two = |a: i32| a + 2; /// let add_three = |a: i32| a + 3; /// let add_five = compose(add_two, add_...
use std::cell::RefCell; use std::collections::BTreeMap; use std::fmt; use std::rc::Rc; use cranelift_entity::{entity_impl, PrimaryMap}; use firefly_diagnostics::{SourceSpan, Spanned}; use firefly_syntax_base::{FunctionName, Signature}; use super::*; /// Represents the structure of a function #[derive(Clone, Spanned...
#[doc = "Reader of register MPCBB1_VCTR24"] pub type R = crate::R<u32, super::MPCBB1_VCTR24>; #[doc = "Writer for register MPCBB1_VCTR24"] pub type W = crate::W<u32, super::MPCBB1_VCTR24>; #[doc = "Register MPCBB1_VCTR24 `reset()`'s with value 0xffff_ffff"] impl crate::ResetValue for super::MPCBB1_VCTR24 { type Typ...
// "Tifflin" Kernel // - By John Hodge (thePowersGang) // // arch/amd64/macros.rs // - Architecture-provided macros /// Emits a distinctive instruction (with no effect) // SAFE: No-op macro_rules! CHECKMARK{ () => (unsafe { asm!("xchg cx, cx", options(nostack));}); } // vim: ft=rust
use std::{ borrow::Cow, ops::{Deref, DerefMut}, }; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use crate::{ from_value, parser::types::Field, registry::{MetaType, MetaTypeId, Registry}, to_value, ContextSelectionSet, InputType, InputValueResult, OutputType, Positioned, Serve...
// Copyright 2020 IOTA Stiftung // // 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 in w...
use std::{borrow::Cow, convert::TryInto, path::PathBuf, sync::Arc, time::Instant}; use arrow::{ array::{ArrayRef, Int64Array, StringArray}, record_batch::RecordBatch, }; use futures::TryStreamExt; use observability_deps::tracing::{debug, info}; use rustyline::{error::ReadlineError, hint::Hinter, history::FileH...
use anyhow::Result; use clap::Parser; use maple_core::helptags::generate_tag_lines; use maple_core::paths::AbsPathBuf; use std::io::Write; use utils::read_lines; /// Parse and display Vim helptags. #[derive(Parser, Debug, Clone)] pub struct Helptags { /// Tempfile containing the info of vim helptags. #[clap(in...
// Copyright (c) 2019 Jason White // // 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, merge, publish, d...
use crate::v0::support::{with_ipfs, MaybeTimeoutExt, StringError, StringSerialized}; use ipfs::{Ipfs, IpfsTypes, MultiaddrWithPeerId}; use serde::{Deserialize, Serialize}; use warp::{query, Filter, Rejection, Reply}; #[derive(Debug, Serialize)] #[serde(rename_all = "PascalCase")] struct Response<S: AsRef<str>> { p...
use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; fn lines_from_file(filename: impl AsRef<Path>) -> Vec<String> { let file = File::open(filename).expect("no such file"); let buf = BufReader::new(file); buf.lines() .map(|l| l.expect("Could not parse line")) .collect(...
use mng::engine::GameLoop; struct MyGameLoop { running: bool, } impl MyGameLoop { pub fn new() -> MyGameLoop { MyGameLoop { running: true } } } impl GameLoop for MyGameLoop { fn is_running(&self) -> bool { self.running } fn process_events(&mut self) { println!("MyGameL...
/// NTP v3: https://tools.ietf.org/html/rfc1305 /// NTP v4: https://tools.ietf.org/html/rfc5905 /// NTP v4 extend: https://tools.ietf.org/html/rfc7822 #[derive(Debug, Default)] #[derive(PackedStruct)] #[packed_struct(bit_numbering="msb0")] #[packed_struct(endian="msb")] pub struct NTPPacket { #[packed_field(bits="0...
use ansi_term::{ Color::Red, Colour::{Blue, Cyan, Green, Purple}, }; use can_dbc::{self, Message}; use pretty_hex::*; use rand::Rng; use socketcan; use std::{ fs::File, io::{self, prelude::*}, path::PathBuf, time::Instant, }; use structopt::StructOpt; use tokio::time; use tokio_socketcan::CANFra...
//! Implement syscalls using the vDSO. //! //! <https://man7.org/linux/man-pages/man7/vdso.7.html> //! //! # Safety //! //! Similar to syscalls.rs, this file performs raw system calls, and sometimes //! passes them uninitialized memory buffers. This file also calls vDSO //! functions. #![allow(unsafe_code)] #[cfg(targ...
#![allow(non_snake_case)] // Setup types and consts type brute_num = f32; const RAND_UPPER_LIMIT: usize = 5; const RAND_LOWER_LIMIT: usize = 0; const DEBUG: bool = false; extern crate rand; use rand::{thread_rng, Rng}; extern crate clap; use clap::{Arg, App}; fn main() { let matches = App::new("brutecorr") ...
// Copyright 2018 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 std::default::Default; /// Seek position inside a directory. This traversal expect the directory to store entries in /// alphabetical order, a traver...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] pub const ACTRL_DS_CONTROL_ACCESS: u32 = 256u32; pub const ACTRL_DS_CREATE_CHILD: u32 = 1u32; pub const ACTRL_DS_DELETE_CHILD: u32 = 2u32; pub const ACTRL_DS_DELETE_TREE: u32 = 64u32; pub con...
//! # Serial //! //! Asynchronous serial communication using the interal USART peripherals //! //! The serial modules implement the [`Read`] and [`Write`] traits. //! //! [`Read`]: embedded_hal::serial::Read //! [`Write`]: embedded_hal::serial::Write use core::{convert::Infallible, ops::Deref}; use crate::{ gpio:...
use crate::event::{Event, LogEvent, Metric}; use rlua::prelude::*; impl<'a> ToLua<'a> for Event { fn to_lua(self, ctx: LuaContext<'a>) -> LuaResult<LuaValue> { let table = ctx.create_table()?; match self { Event::Log(log) => table.set("log", log.to_lua(ctx)?)?, Event::Metric...
mod database; use crate::database::{Database, DatabaseConfig}; use serde_json::json; fn main() { let mut db = Database::new(DatabaseConfig { path: "db.json".to_string(), }); let success = db.insert_one(json!({ "name": "Billy", "age": 27, })); match success { Err(e...
use std::io::{Write, BufRead, BufReader}; use std::fs::{self, File}; use std::collections::HashMap; use std::process::Command; use hex_database::{Track, Reader, Writer, Playlist}; pub fn modify_tracks(write: &Writer, tracks: Vec<Track>) { { let mut file = File::create("/tmp/cli_modify").unwrap(); ...
use failure::{format_err, Fallible, ResultExt}; use std::path::Path; use std::process::ExitStatus; use super::{cmd, util}; pub fn run(files: Vec<&str>, stdin: &str) -> Fallible<ExitStatus> { let work_dir = util::dirname(files[0])?; let bin_file = "main_oc"; let compile_cmd = format!( "clang `gnus...
use std::cell::RefCell; use std::collections::HashMap; use std::rc::{Rc, Weak}; use crate::common::FilePosition; use crate::idl; use super::errors::ValidationError; use super::fieldset::Fieldset; use super::fqtn::FQTN; use super::namespace::Namespace; use super::options::Range; use super::r#enum::Enum; use super::r#s...
use super::charset::Charset; pub trait DrawBox { fn new(content: Vec<String>, charset: Charset) -> Self; // Print the box fn print(&self); // Individual box parts fn print_top(&self); fn print_middle(&self); fn print_bottom(&self); } // Find the count of visible chars in a String fn coun...
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. pub fn parse_http_generic_error( response: &http::Response<bytes::Bytes>, ) -> Result<smithy_types::Error, smithy_json::deserialize::Error> { crate::json_errors::parse_generic_error(response.body(), response.headers()) } pub fn de...
extern crate web3; use common::*; use futures::{future, stream, FutureExt, StreamExt}; use web3::{transports, Web3}; const NODE_URL: &str = "http://localhost:8545"; // const NODE_URL: &str = "https://mainnet.infura.io/v3/c15ab95c12d441d19702cb4a0d1313e7"; const DB_PATH: &str = "_rpc_db"; #[tokio::main] async fn mai...
//! A common library for constructing dataflow analyses on frawk programs. use crate::builtins::Variable; use crate::bytecode::{Accum, Instr, Reg}; use crate::common::{Graph, NodeIx, NumTy, WorkList}; use crate::compile::{HighLevel, Ty}; use hashbrown::{HashMap, HashSet}; use petgraph::{ visit::{Dfs, EdgeRef}, ...
#![feature(proc_macro_hygiene, decl_macro)] #![allow(unused)] extern crate openssl; #[macro_use] extern crate rocket; #[macro_use] extern crate rocket_contrib; use std::path::PathBuf; use clap::{App, Arg}; use rocket::config::Environment; use rocket::http::ContentType; use rocket::logger::LoggingLevel; use rocket::Co...
// Day 9 use std::error::Error; use std::fs; use std::process; fn main() { let input_filename = "input.txt"; if let Err(e) = run(input_filename) { println!("Application error: {}", e); process::exit(1); } } fn run(filename: &str) -> Result<(), Box<dyn Error>> { // Read the input file ...
extern crate startuppong; use startuppong::Account; fn main() { let account = Account::from_env().unwrap(); let player_res = startuppong::get_players(&account).unwrap(); let players = player_res.players(); println!("{:?}", players); }
//! This benchmark defines some test benchmarks that exercise various parts of cargo-criterion. use criterion::{ criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion, PlotConfiguration, SamplingMode, Throughput, }; use std::thread::sleep; use std::time::Duration; fn special_characters(c: &mut Cr...
use std::cell::RefCell; use crate::virtual_filesystem_core::graph::{Node, NodePointer, Edge, Graph}; pub type Name = String; pub type Data = String; pub type FileNode = Node<FileType>; pub type FileNodePointer = NodePointer<FileType>; #[derive(Debug, PartialEq)] pub enum FileType { Directory { name: Na...
// Copyright 2013-2014 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-MI...
//- // Copyright 2017, 2018 The proptest 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. This file may not be copied, modified, or distributed /...
fn partitions(mut cards: [usize; 10], subtotal: usize) -> i32 { let mut m=0; let mut total; // Hit for i in 0..10 { if cards[i]>0 { total = subtotal+i+1; if total < 21 { // Stand m += 1; // Hit again cards[i] -= 1; m += partitions(ca...
#[doc = "Reader of register RESBEHAVCTL"] pub type R = crate::R<u32, super::RESBEHAVCTL>; #[doc = "Writer for register RESBEHAVCTL"] pub type W = crate::W<u32, super::RESBEHAVCTL>; #[doc = "Register RESBEHAVCTL `reset()`'s with value 0"] impl crate::ResetValue for super::RESBEHAVCTL { type Type = u32; #[inline(...
// 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 std::fmt::Debug; use std::ops::{Deref, DerefMut}; use std::path::Path; use mpq::Archive; use crate::binary_reader::BinaryReader; use crate::binary_writer::BinaryWriter; use crate::MpqError::IoError; #[derive(Debug, PartialOrd, PartialEq, Clone, Copy)] pub enum GameVersion { RoC, TFT, Reforged, } imp...