text
stringlengths
8
4.13M
use std::rc::Rc; use crate::class_file::unvalidated::Attribute; use crate::class_file::unvalidated::AttributeInfo; use crate::class_file::unvalidated::ConstantIdx; // TODO: helper to consistency check flags #[derive(Debug, Clone, Copy)] pub struct MethodAccessFlags { pub flags: u16, } #[allow(dead_code)] impl Me...
// Num of CSRs const NUM_CSR: usize = 0x1000; // CSR Index definitions const CSR_INDEX_MSTATUS : usize = 0x300; const CSR_INDEX_MTVEC : usize = 0x305; const CSR_INDEX_MEPC : usize = 0x341; const CSR_INDEX_MCAUSE : usize = 0x342; const CSR_INDEX_MTVAL : usize = 0x343; // register definitions bitfield! { pu...
#[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::_3_CTL { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &...
//#![feature(remarkable)] extern crate libremarkable; use self::libremarkable::framebuffer as remarkable_fb; use self::libremarkable::framebuffer::{FramebufferIO, FramebufferRefresh, FramebufferBase}; use geom::Rectangle; use framebuffer::{UpdateMode, Framebuffer}; use errors::*; use self::libremarkable::framebuffer:...
use crate::keys::{Key, KeyCombo, ModKey}; #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub struct XcbKeyCombo { pub mod_mask: u32, pub key: u32, } impl From<ModKey> for u32 { fn from(mod_key: ModKey) -> Self { match mod_key { ModKey::Shift => xcb::MOD_MASK_SHIFT, ModKey::Lo...
// 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 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 ...
//! Methods to cleanup the object store. use std::{ collections::HashSet, sync::{Arc, Mutex}, }; use crate::{ catalog::{CatalogParquetInfo, CatalogState, PreservedCatalog}, storage::data_location, }; use futures::TryStreamExt; use object_store::{ path::{parsed::DirsAndFileName, ObjectStorePath}, ...
use anyhow::{Context, Result, bail, ensure}; // enum MyError{ // Io(std::io::Error), // Num(std::num::ParseIntError), // } fn get_int_from_file() -> Result<i32>{ let path = "number.txt"; let num_str = std::fs::read_to_string(path).with_context(|| format!("failed to read string from {}", path))?; ...
mod address; pub use self::address::write_address; pub use self::address::read_address;
//! Demo runner. use std::fmt; pub mod debug; /// Possible runner errors. #[derive(Debug)] pub enum Error { CannotCreateWindow(String), CannotCreateStore(String), DemoInitializationFailure(String) } impl Error { pub(crate) fn cannot_create_window<R>(reason: R) -> Self where R: Into<String> { Error::Cann...
use std::fmt; use super::*; use crate::support::StringRef; extern "C" { type LlvmType; } /// Represents the kind of a type /// /// This is primarily used in FFI #[repr(C)] #[derive(Copy, Clone, PartialEq, Eq)] #[allow(non_camel_case_types)] pub enum TypeKind { Void = 0, FP16, FP32, FP64, FP80...
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use std::box...
//! A collection of general utilities use crate::error::QuicksilverError; use futures::{Future, future}; use std::path::Path; #[cfg(not(target_arch="wasm32"))] use { crate::Result, std::{ fs::File, io::Read, } }; #[cfg(target_arch="wasm32")] use { futures::Async, std::io::{Error as ...
use super::*; #[derive(Clone,Copy,Eq)] pub struct Vertex { pub id:i32, pub x: i32, pub y: i32, } impl AsIndexForGraph for Vertex { fn index(&self) -> &i32 {&(self.id)} } impl Ord for Vertex { fn cmp(&self, other:&Vertex) -> Ordering { self.id.cmp(&other.id) } } impl PartialOrd for Ve...
/* Copyright (C) 2016 Yutaka Kamei */ #![allow(non_snake_case)] use std::error::Error; use std::fmt::{self, Debug}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_serialize::base64::{self, FromBase64, ToBase64}; use time::{Tm, now_utc, strftime, strptime}; pub mod resource; const USER : &'s...
// 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 ...
// 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 ...
//! Reinterprets the bits of a value of one type as another type. //! A more secure version than raw_transmute because it additionally checks the data sizes. use crate::raw_transmute::unchecked_transmute; /// Reinterprets the bits of a value of one type as another type. /// The function is completely constant, in ...
use std::collections::HashMap; use crate::{ config::Config, fs::{self, FileInfo}, sync::file_events_buffer::FileEventsBuffer, }; use tokio::{ io::AsyncRead, io::AsyncReadExt, io::AsyncWrite, io::AsyncWriteExt, io::{ReadHalf, WriteHalf}, }; const BUFFER_SIZE: usize = 8 * 1024; pub stru...
use crate::types::*; use itertools::Itertools; use serde::{Deserialize, Serialize}; use super::engine::composition::PosMatcher; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct POSFilter { pub matcher: PosMatcher, } impl POSFilter { fn is_word_data_match(&self, data: &WordData) -> bool { se...
pub use utils::RcStr; pub use telamon_gen::ast::*; pub use telamon_gen::lexer::{Lexer, LexerPosition, Position, Spanned}; pub use telamon_gen::parser; #[cfg(test)] mod undefined { pub use super::*; /// Missing the set MySet from a Integer. #[test] fn parameter() { assert_eq!( pars...
//! Prints "Hello, world!" on the host console using semihosting #![no_main] #![no_std] extern crate panic_halt; extern crate stm32f1; #[macro_export] extern crate lcd1602; use stm32f1::stm32f103::{Interrupt, Peripherals, CorePeripherals, gpioa}; use lcd1602::replace; use lcd1602::driver; use cortex_m_rt::entry; use...
extern crate winrt_notification; use winrt_notification::{ Duration, Sound, Toast, }; fn main() { let duration = Duration::Short; let sound = Some(Sound::SMS); Toast::new(Toast::POWERSHELL_APP_ID) .title("first toast") .text1("line1") .duration(duration) .sound(...
// Copyright 2012 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 ...
use crate::errors::*; use crate::version::Version; use bytes::*; use std::cell::RefCell; use std::mem; use std::ops::{Add, Sub}; use std::rc::Rc; pub const INT_8: u8 = 0xC8; pub const INT_16: u8 = 0xC9; pub const INT_32: u8 = 0xCA; pub const INT_64: u8 = 0xCB; #[derive(Debug, PartialEq, Eq, Clone)] pub struct BoltInt...
pub struct Solution; impl Solution { pub fn longest_substring(s: String, k: i32) -> i32 { fn rec(bytes: &[u8], k: usize) -> usize { if bytes.len() < k { return 0; } let mut count = [0; 26]; for &b in bytes { count[(b - b'a') as...
use std::cell::RefCell; use std::collections::HashMap; use std::collections::{btree_map::Entry as BTreeMapEntry, BTreeMap}; use std::rc::Rc; use crate::common::FilePosition; use crate::idl; use super::errors::ValidationError; use super::fieldset::Fieldset; use super::r#enum::Enum; use super::r#struct::Struct; use sup...
#![allow(dead_code)] #![allow(unused_imports)] #![allow(unused_parens)] extern crate num; extern crate eventual; pub mod mandelbrot; pub struct Generator { center_x: f64, center_y: f64, zoom: f64, res: u32, threads: u32, iterations: u32 } impl Generator { pub fn new(res: u32, threads: u32...
// 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::registry::base::Command; use crate::registry::service_context::ServiceContext; use crate::switchboard::base::{ IntlInfo, SettingRequest, Set...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtCore/qjsonarray.h // dst-file: /src/core/qjsonarray.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin => /...
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::StaticType; use ...
#![cfg_attr(not(feature = "std"), no_std)] use frame_support::{ decl_module, decl_event,dispatch,transactional, traits::{Currency, ExistenceRequirement::{KeepAlive},tokens::WithdrawReasons}, }; use frame_system::{ensure_root}; type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::Acc...
//! Independent traits //! //! This implements `Rng` for any `CryptoRng` implicitly. //! Each `Rng` automatically and safely implements its base `CryptoRng`. //! //! Note: this *only* considers the next_u32 member function //! //! Thoughts: works nicely. Implementing each trait requires only one impl block. //! It s...
use tendermint_light_client::{ components::{ io::{AtHeight, Io}, scheduler, verifier::ProdVerifier, }, fork_detector::ProdForkDetector, light_client::{self, LightClient}, peer_list::PeerList, state::State, store::LightStore, supervisor::{Handle, Instance, Supervis...
use challenges::{ chal43::{dsa_leaky_k_attack, hash_msg_to_hexstr, is_dsa_key_pair}, chal43::{DsaKeyPair, DsaPubKey, DsaPublicParam, DsaSignature}, random_bytes, }; use num::{BigUint, FromPrimitive}; use std::process; fn main() { println!("🔓 Challenge 43"); println!("Leaky k DSA signing attack .....
#![feature(core_intrinsics)] mod lehmer64; pub use lehmer64::*; mod xorshift; pub use xorshift::*; mod xorshift_nocell; pub use xorshift_nocell::*; mod xorshift32_2; pub use xorshift32_2::*; mod xoshiro128plus; pub use xoshiro128plus::*; mod xoshiro256starstar; pub use xoshiro256starstar::*; mod xorshift32; pub ...
extern crate ansi_escapes; extern crate atomic_counter; extern crate clap; extern crate collect_slice; extern crate crossbeam_channel; extern crate disque; extern crate indicatif; extern crate itertools; extern crate rand; extern crate shellexpand; mod job; mod signals; //use std::str::from_utf8; //use std::time::Dur...
fn main() { let input = include_str!("day8.txt"); let mut v: Vec<Vec<&str>> = input.split("\n").map(|x: &str| x.split(" ").collect()).collect(); let mut accumulator = 0; let mut ranthru: Vec<i32> = vec![1000]; let mut i= 0; while !ranthru.contains(&i) { if v[i as usize][0] == "acc"...
//! # Resource //! //! A `Resource` is an immutable representation of the entity producing telemetry. For example, a //! process producing telemetry that is running in a container on Kubernetes has a Pod name, it is //! in a namespace, and possibly is part of a Deployment which also has a name. All three of these //! a...
use thiserror::Error; #[derive(Debug, Error)] pub enum Error { #[error("Null error")] NullError, #[error("Data parse error")] DataParseError, #[error("Network error")] NetworkError, #[error("Invalid packet")] InvalidPacketError, #[error("Pipe error")] PipeError, #[error("Ope...
use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet}; use ic_cdk::export::candid::{CandidType, Deserialize, Principal}; use ic_cron::types::TaskId; use currency_token_client::types::{ControllerList, Controllers, TokenInfo}; use crate::common::types::Error; #[derive(CandidType, Deserialize...
mod token; mod parser; use std::env; use std::path::PathBuf; use std::io::BufReader; use std::fs::File; use token::tokenize; use token::token::Token; use parser::types::Value; use parser::parse; fn main() -> Result<(), Box<std::error::Error>> { const USAGE: &str = "usage: json_parser path/to/json/file"; let a...
use super::*; #[test] fn with_number_atom_reference_function_port_or_local_pid_returns_first() { run!( |arc_process| { ( strategy::term::pid::external(arc_process.clone()), strategy::term::number_atom_reference_function_port_or_local_pid( arc_...
use log::{info, warn, LevelFilter, Log}; fn main() { log::set_logger(&LOGGER) .map(|()| log::set_max_level(LevelFilter::Info)) .unwrap(); let mut yak = Yak("yak".to_string()); shave_the_yak(&mut yak); } struct SimpleLogger; impl Log for SimpleLogger { fn enabled(&self, metadata: &log:...
use proconio::{input, marker::Usize1}; fn main() { input! { n: usize, _k: usize, a: [[u8; n]; n], q: usize, queries: [(Usize1, Usize1); q], }; const INF: u64 = std::u64::MAX / 2; let mut d = vec![vec![INF; n]; n]; for v in 0..n { d[v][v] = 0; } ...
use prec::{Assoc, Climber, Expression, Rule, Token as PrecToken}; use std::fmt; /* This example uses the `prec` crate to perform integer operations. It supports parentheses, addition, subtraction, division, multiplication, exponents, and an additional operator for rounded-up division. */ #[derive(Hash, ...
use crate::structs::raw::common::AddProp; use serde::Deserialize; #[derive(Deserialize)] #[serde(rename_all = "PascalCase")] pub struct CostItem { pub id: Option<usize>, pub count: Option<usize>, } #[derive(Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Data { pub weapon_promote_id: usize, ...
use vec3::*; use ray::*; use util::*; pub use num_traits::Zero; // ffmin/ffmax are faster because they do not worry about NaN and other issues. #[inline(always)] fn ffmin(a: f64, b: f64) -> f64 { if a < b { a } else { b } } #[inline(always)] fn ffmax(a: f64, b: f64) -> f64 { if a > b { a } else { b } } #[de...
extern crate toml; #[macro_use] extern crate serde_derive; extern crate yansi; extern crate hyper; extern crate base64_url; mod config; fn main() { config::config(); }
#[cfg(any(test, feature = "use_serde", feature = "default"))] use serde; use rand::os::OsRng; use rand::Rng; use std::fmt; use std::io; use std::cmp::{ PartialEq, Eq }; /// The length of a hash salt in bytes. /// /// Should be at least 16 bytes for really good salts. /// Doesn't need to be a huge number. pub const...
#![allow(unused_unsafe)] #![allow(dead_code)] use super::dx_pub_use::*; use super::unsafe_util::*; use std::ffi::CStr; use winapi::_core::mem; #[derive(Copy, Clone, Debug)] pub struct Vertex { pos: [f32; 3], uv: [f32; 2], } impl Vertex { pub fn new(pos: [f32; 3], uv: [f32; 2]) -> Vertex { Vertex {...
// File: The analyzer of the tool // Purpose: Functions defined in this file are mainly used for analyze // the symbol table, generate proper advice and print out // the advice // Author : Ziling Zhou (802414) use SymbolTable; use builtin::Ty; use VarInfo; use std::collections::{H...
// `fold` mirip map reduce fn main() { let nums = vec![1, 2, 3]; println!("{}", nums.into_iter().fold(0, |acc, x| acc + x)); }
pub mod bench; pub use self::bench::Bench; use futures::prelude::*; use indexmap::IndexMap; use k8s_openapi::api::core::v1::{Pod, Service}; use std::sync::Arc; use structopt::StructOpt; use tokio::sync::Mutex; use tokio_compat_02::FutureExt; use tracing::{info, warn}; #[derive(StructOpt)] #[structopt(about = "Kuberne...
use cs_bindgen::prelude::*; use derive_more::*; use lazy_static::lazy_static; use num_traits::{ops::wrapping::WrappingAdd, One, PrimInt}; use serde::*; use strum::*; #[cs_bindgen] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, From, Serialize, Deserialize)] pub enum Tile { Simple(SimpleTile), ...
use crate::ast::{TmRef, TyRef}; use crate::check::infer; use crate::exhibit::{TmExhibit, TyExhibit}; pub type TCM<T> = Result<T, TCE>; pub type TCE = &'static str; pub struct TCS { pub tm_exh: TmExhibit, pub ty_exh: TyExhibit, pub gamma: Vec<TyRef>, } impl TCS { pub fn new(tm_exh: TmExhibit, ty_exh: ...
use rand::Rng; #[derive(Copy, Clone)] pub enum DestRoom { Relative(isize, isize, i32, i32,), Absolute(isize, isize, i32, i32,), } impl DestRoom { pub fn to_absolute_coordinates(&self, (x, y): (i32, i32)) -> (i32, i32) { match self { DestRoom::Relative(rel_x, rel_y, _, _) => (x + *rel_x...
// 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...
use std::io; use actix; use actix::{WrapFuture, Actor, fut, ActorFuture, ContextFutureSpawner, AsyncContext}; use actix_web; use futures::{Future, IntoFuture, Stream}; use tokio_postgres; use database::models; pub struct PgConnection { client: Option<tokio_postgres::Client>, create_st: Option<tokio_postgres:...
use libraries::Library; use vm::Value; #[derive(Debug)] pub struct IO; impl IO { pub fn new() -> IO { IO } fn println(&self, val: Value) -> Value { println!("{:?}", val); Value::null() } } impl Library for IO { fn call(&self, method: String) -> Value { let method : &str = method.trim(); match method...
use ethcontract::prelude::*; use crate::cli::{Currency, Eth, Scm}; use chrono::{Local, NaiveDateTime, TimeZone, Utc}; use ethcontract::batch::CallBatch; use futures::StreamExt as _; #[derive(structopt::StructOpt)] #[structopt(about = "Participate in SCM ICO")] pub enum IcoCommand { #[structopt(about = "Get status...
use crate::{config, err, util}; use anyhow::Result; use std::path::Path; use std::process::Command; /// Returns the timestamp of the most recent commit modifying `path` in seconds. pub fn timestamp<P: AsRef<Path>>(path: P) -> Result<u64> { use chrono::prelude::*; let output = Command::new("git") .arg("-C") ...
use num::FromPrimitive; use super::opcodes::Opcode; pub struct Instruction{ pub opcode: u8, } impl Instruction { pub fn opcode(&self) -> Opcode { println!("{}",self.opcode); Opcode::from_u8((self.opcode) & 0xff).unwrap_or_else( || panic!("Unrecognized instruction: {:#x}", self.opcode)...
use lazy_static::lazy_static; use regex::Regex; use std::collections::HashSet; use std::rc::Rc; fn main() { let all_foods = read_foods(include_str!("../input.txt").lines()); println!("appearances: {}", part_1(&all_foods)); println!("{}", part_2(&all_foods)); } fn part_1(all_foods: &[Food]) -> usize { ...
mod client; mod message; mod read_message; mod write_message; pub use self::client::run; pub use self::message::Message; pub use self::read_message::ReadMessage; pub use self::write_message::WriteMessage;
mod client; mod server; mod smtp; pub use self::client::*; pub use self::server::*; pub use self::smtp::*;
use std::io::Read; fn main() { let mut buf = String::new(); // 標準入力から全部bufに読み込む std::io::stdin().read_to_string(&mut buf).unwrap(); // 行ごとのiterが取れる let mut iter = buf.split_whitespace(); let n: usize = iter.next().unwrap().parse().unwrap(); let buttons: Vec<usize> = (0..n) .map(|_...
fn main() { for arg in std::env::args().skip(1) { respond(&arg) } } fn respond(arg: &str) { match arg { "hi" => println!("Hello there!"), "bye" => println!("Ok, goodbye!"), _ => println!("Sorry, I don't know what {} means", arg), } }
//! Implementation of channels that supports iterator-like operation such as `map`, `filter` //! ... /// Near drop-in replacement for std::sync::mpsc; pub mod mpsc;
use arbitrary::Unstructured; use rand::{prelude::random, rngs::SmallRng, Rng, SeedableRng}; use super::*; use crate::state; #[test] fn test_journal() { let seeds: Vec<u128> = vec![193003787382804392805109954488729196323, random()]; let seed = seeds[random::<usize>() % seeds.len()]; // let seed: u128 = 148...
use core::cell::UnsafeCell; use alloc::boxed::Box; use crate::process::Tid; use crate::process::structs::*; use crate::process::thread_pool::ThreadPool; use crate::interrupt::*; // 调度单元 Processor 的内容 pub struct ProcessorInner { // 线程池 pool: Box<ThreadPool>, // idle 线程 idle: Box<Thread>, // 当前正在运行的线...
#[doc = "Reader of register WAKESTAT"] pub type R = crate::R<u32, super::WAKESTAT>; #[doc = "Reader of field `STAT4`"] pub type STAT4_R = crate::R<bool, bool>; impl R { #[doc = "Bit 4 - P\\[4\\] Wake Status"] #[inline(always)] pub fn stat4(&self) -> STAT4_R { STAT4_R::new(((self.bits >> 4) & 0x01) !...
use crate::isolate::{IsolatedBoxOptions, IsolatedBoxOptionsBuilder}; use merge::Merge; use serde::Deserialize; use std::collections::HashMap; use validator::Validate; #[derive(Deserialize, Debug, Clone, Default, Merge, Validate)] pub struct PhaseSandboxSettings { pub run_time_limit: Option<u64>, pub extra_time...
use std::collections::HashMap; use serde::{Serialize, Serializer, Deserialize, Deserializer}; use super::var::VarInt; use super::slot::Slot; use super::uuid::Uuid; use super::chat::Chat; use serde::de::{Visitor, SeqAccess, DeserializeOwned, DeserializeSeed}; use std::convert::TryInto; use core::borrow::Borrow; #[deri...
mod bfs; mod dfs; mod dijkstra; mod graph; pub struct Graph { node_size: usize, edge_size: usize, edge: Vec<Vec<(usize, i64)>>, }
#![crate_name = "uu_echo"] /* * This file is part of the uutils coreutils package. * * (c) Derek Chiang <derekchiang93@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; extern crate libc; #[macro_u...
use super::{utils::FiberIdExtension, variable::VariablesKey, PausedState}; use dap::{ requests::ScopesArguments, responses::ScopesResponse, types::{Scope, ScopePresentationhint}, }; impl PausedState { pub fn scopes(&mut self, args: ScopesArguments) -> ScopesResponse { let stack_frame_key = self...
pub fn example13() { let vect1 = vec![1, 2, 3]; let vect2 = vect1; // this is invalid // xprintln!("vect1[0] = {}", vect1[0]); xprintln!("vect2[0] = {}", vect2[0]); let prim_val = 1; let prim_val2 = prim_val; xprintln!("prim_val: {}", prim_val); xprintln!("prim_val2: {}", prim_val2); xprintln!("sum of vect:...
//! Top level error module. use crate::project_config::ProjectParseError; use crate::tmux::TmuxError; use std::fmt::{Debug, Display}; use std::io; use std::path::PathBuf; use thiserror::Error; /// Top level error. #[derive(Error, Debug)] pub enum AppError { /// Problem getting the configuration directory. #[e...
#![feature(lang_items)] #![feature(start)] #![feature(asm)] #![no_main] #![no_std] pub mod arch; pub use arch::*; pub mod devices; #[no_mangle] #[start] pub extern fn rusternel_main() { devices::crt::puts("Hello,rusternel!\r\n"); unsafe { x86_32::gdt::init_gdtidt(); loop { x86_32:...
use crossterm::style::Color; use printer::printer::{PrintQueue, PrinterItem}; use std::sync::OnceLock; static NO_COLOR: OnceLock<bool> = OnceLock::new(); /// Have the top precedence fn no_color() -> bool { *NO_COLOR.get_or_init(|| std::env::var("NO_COLOR").is_ok()) } pub fn format_err<'a>(original_output: &'a str...
//! All the traits exposed to be used in other custom pallets use crate::*; use codec::{Decode, Encode}; use frame_support::dispatch; use scale_info::TypeInfo; /// Anchor trait definition to be used in other pallets pub trait AnchorInterface<T: Config<I>, I: 'static = ()> { // Creates a new anchor fn create(creator:...
use core::future; use std::sync::Arc; use futures::{future::{AbortHandle, Abortable, join, select}, pin_mut}; use tokio::{io::copy, net::{TcpListener, TcpStream, ToSocketAddrs}, sync::watch}; use watch::{Receiver, Sender}; use crate::error::Error; async fn proxy_to_remote(incoming: TcpStream, outgoing: TcpStream) { ...
extern crate messycanvas; fn main() { messycanvas::client::main(); }
// 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 ...
//! # Piccolo //! //! Piccolo is a small, light, high-pitched scripting language (eventually) intended //! for embedding in Rust projects. pub extern crate downcast_rs; pub extern crate fnv; #[macro_use] pub extern crate log; pub mod compiler; pub mod error; pub mod runtime; /// Commonly used items that you might wa...
// Copyright 2018 The Servo Project Developers. See the COPYRIGHT // 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.org/licenses/MIT>, at ...
use serde::{Deserialize, Serialize}; use serde_json::Result; type StockId = String; #[derive(Debug, Serialize, Deserialize)] struct Stock { id: StockId, qty: i32, } #[derive(Debug, Serialize, Deserialize)] #[serde(tag = "type")] enum Event { Created { id: StockId }, Updated { id: StockId, qty: i32 },...
// revisions: base nll // ignore-compare-mode-nll //[nll] compile-flags: -Z borrowck=mir fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'static u32 { let (ref y, _z): (&'a u32, u32) = (&22, 44); *y //~ ERROR } fn main() {}
//! namespace introduces a namespace Datastore Shim, which basically //! mounts the entire child datastore under a prefix. //! Use the Wrap function to wrap a datastore with any Key prefix. //! # For example: //! //! ```norun //! let db = /*...*/; //! let mut ns = wrap(db.clone(), Key("/foo/bar")); //! ns.put(Key("/bee...
// 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 crate::engine::game::Game; #[derive(Clone, Copy, Debug, PartialEq)] pub struct Replicated { pub id: ReplicationId, pub entity_type: ReplicatedEntityType, } impl Replicated { pub fn new_for_game(game: &mut Game, entity_type: ReplicatedEntityType) -> Self { Self { id: game.get_new_re...
extern crate hyper; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate time; mod radio; mod util; use radio::data::RADIOSTATIONS; use radio::Radio; use radio::song::Song; use std::collections::LinkedList; use std::thread; use std::time::Duration; use util::html_generato...
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use libc; use std::bo...
// 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 ...
use winapi::um::winnt::HANDLE; use winapi::um::handleapi::CloseHandle; use winapi::shared::winerror::WAIT_TIMEOUT; use winapi::um::winbase::{WAIT_OBJECT_0, WAIT_FAILED}; use winapi::um::winnt::{SYNCHRONIZE, EVENT_MODIFY_STATE}; use winapi::um::synchapi::{CreateEventW, OpenEventW, SetEvent, WaitForSingleObject}; use std...
//! An API for declaring rust-code callbacks to be executed when a given pattern is matched. //! //! A flexer rule is a [`crate::automata::pattern`] associated with rust code to be executed as a //! callback. use crate::automata::pattern::Pattern; // ========== // == Rule == // ========== /// A flexer rule. #[deri...
//! Tests for the raw (unprepared) query API for Postgres. use sqlx::{Cursor, Executor, Postgres, Row}; use sqlx_test::new; /// Tests the edge case of executing a completely empty query string. /// /// This gets flagged as an `EmptyQueryResponse` in Postgres. We currently /// catch this and just return no rows. #[cfg...
#![cfg_attr(windows, allow(dead_code, unused_imports))] use std::cmp; use std::env; use std::fs::{self, File}; use std::io; use std::path::{Path, PathBuf}; use std::collections::HashMap; use quickcheck::{Arbitrary, Gen, QuickCheck, StdGen}; use rand::{self, Rng, RngCore}; use super::{DirEntry, WalkDir, IntoIter, Err...