text
stringlengths
8
4.13M
use std::fmt::{self, Display}; use std::ops::Deref; use std::sync::Arc; use crate::erts::term::pid::InvalidPidError; use crate::erts::term::prelude::{TermDecodingError, TermEncodingError, TypeError}; #[derive(Clone)] pub struct ArcError(Arc<anyhow::Error>); impl ArcError { pub fn new(err: anyhow::Error) -> Self {...
use std::str::FromStr; use async_graphql::http::{WebSocketProtocols, WsMessage, ALL_WEBSOCKET_PROTOCOLS}; use async_graphql::{Data, ObjectType, Schema, SubscriptionType}; use futures_util::future::{self, Ready}; use futures_util::{Future, SinkExt, StreamExt}; use poem::web::websocket::{Message, WebSocket}; use poem::{...
use std::path::PathBuf; use std::io; mod data; mod index; mod test_utils; use self::data::*; use self::index::*; #[derive(Debug, Clone, Copy, Serialize, Deserialize)] pub struct Metadata { pub offset: u64, pub length: u32, pub hash: [u8; 32], } pub struct Storage { data: Data, index: Index, } i...
use side::{Side, BLACK}; use std::fmt; #[cfg(test)] use rand; pub type Internal = usize; /// Represents a square on the chessboard #[derive(PartialEq, PartialOrd, Copy, Clone)] pub struct Square(pub Internal); const NAMES: [&'static str; 64] = [ "a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1", "a2", "b2", "c2", ...
pub mod draw; pub mod profile; pub mod serdeflate;
pub use VkDebugReportErrorEXT::*; #[repr(u32)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum VkDebugReportErrorEXT { VK_DEBUG_REPORT_ERROR_NONE_EXT = 0, VK_DEBUG_REPORT_ERROR_CALLBACK_REF_EXT = 1, }
#![deny(warnings)] #![feature(abi_msp430_interrupt)] #![feature(proc_macro)] #![no_std] extern crate msp430; extern crate msp430g2553; #[macro_use(task)] extern crate msp430_rtfm as rtfm; use msp430::asm; use rtfm::app; app! { device: msp430g2553, tasks: { TIMER0_A1: { resources: [PORT_1...
#![deny(rustdoc::broken_intra_doc_links, rustdoc::bare_urls, rust_2018_idioms)] #![warn( missing_copy_implementations, missing_debug_implementations, clippy::explicit_iter_loop, // See https://github.com/influxdata/influxdb_iox/pull/1671 clippy::future_not_send, clippy::clone_on_ref_ptr, cli...
use test_deps::deps; use tokio::time::{self, Duration}; static mut COUNTER_RET_RESULT: usize = 0; #[deps(RET_RESULT_000)] #[tokio::test] async fn tokio_ret_result_000() -> Result<(), ()> { time::sleep(Duration::from_secs_f64(0.1)).await; unsafe { assert_eq!(0, COUNTER_RET_RESULT); COUNTER_RET_...
use std::env; use std::io; use std::io::BufRead; fn main() { let input: String = match env::args().nth(1) { None => { eprintln!("Usage: {} [input_string | -]", env::args().nth(0).unwrap()); eprintln!("If - is given as argument, read from stdin."); std::process::exit(0); ...
/* Copyright (c) 2015, 2016 Saurav Sachidanand 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, di...
// Copyright (c) 2020 zenoxygen // // 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, dis...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)]...
use intcode::*; fn main() { let program = parse_program(include_str!("../input/day_9.txt")); println!( "Part 1 => {}", IntcodeComputer::new(&program) .run(vec!(1)) .last() .unwrap() ); println!( "Part 2 => {}", IntcodeComputer::new(&p...
extern crate clap; extern crate hlife; use std::fs::File; use std::io::Read; use std::process::exit; use clap::{Arg, App}; use hlife::Hashlife; use hlife::global::Pattern; use hlife::format::write::format_rle; fn main() { let matches = App::new("Itai's Hashlife") .arg(Arg::with_name("INPUT-FILE") ...
#![feature(once_cell)] #![feature(option_result_unwrap_unchecked)] mod dyn_prefix; mod load_database; mod type_map_key; pub use dyn_prefix::*; pub use load_database::*; pub use type_map_key::*; use sqlx::{Pool, Postgres}; use std::lazy::SyncOnceCell as OnceCell; pub const DATABASE_ENABLED: bool = true; pub static P...
use std::{ future::Future, mem, pin::Pin, sync::{Arc, Condvar, Mutex}, task::{Context, Poll}, }; use cooked_waker::{IntoWaker, WakeRef}; use futures::pin_mut; // This is a naive implementation of a notifier which should already be available with any runtime // like Tokio #[derive(Debug, Default)] ...
pub struct Keypad{ pub keys: [bool; 16] } impl Keypad { pub fn new() -> Keypad { Keypad { keys: [false; 16] } } pub fn key_down(&mut self, index: u8){ self.keys[index as usize] = true; } pub fn key_up(&mut self, index: u8) { self.ke...
pub mod algorithms; pub mod data_structures; pub mod util;
use std::{ cell::RefCell, cmp, collections::{HashMap, HashSet}, }; use crate::core::{Part, Solution}; pub fn solve(part: Part, input: String) -> String { match part { Part::P1 => Day16::solve_part_one(input), Part::P2 => Day16::solve_part_two(input), } } #[derive(Debug)] struct Va...
// All data taken from www.brucelindbloom.com. use xyz::Xyz; use xyy::XyY; pub trait NamedWhitePoint<T> { fn get_xyz() -> Xyz<T>; fn get_xy_chromaticity() -> XyY<T>; } pub mod deg_2; pub mod deg_10; pub use self::deg_2::*;
use amethyst::{ core::{ math::Vector2, timing::Time, transform::Transform }, ecs::prelude::{Entities, Join, Read, Write, ReadStorage, System, WriteStorage}, }; use nalgebra as na; use crate::{ collision_world::CollisionWorld, components }; const SPEED: f32 = 120.0; pub stru...
use crate::runtime::data::launches::structures::{Launch, Article}; use crate::languages::LanguagePack; use crate::runtime::renderer::render_help_menu; use crate::settings::Config; use crate::runtime::state::State; use std::io::Stdout; use tui::Terminal; use tui::backend::CrosstermBackend; use tui::layout::{Layout, Di...
//! Persistent accounts are stored in below path location: //! <path>/<pid>/data/ //! //! The persistent store would allow for this mode of operation: //! - Concurrent single thread append with many concurrent readers. //! //! The underlying memory is memory mapped to a file. The accounts would be //! stored across m...
/* * @lc app=leetcode.cn id=102 lang=rust * * [102] 二叉树的层次遍历 * * https://leetcode-cn.com/problems/binary-tree-level-order-traversal/description/ * * algorithms * Medium (59.88%) * Likes: 356 * Dislikes: 0 * Total Accepted: 72.4K * Total Submissions: 119.7K * Testcase Example: '[3,9,20,null,null,15,7...
mod display_name; pub(crate) mod email; mod matrix; pub(crate) mod twitter; pub use display_name::{DisplayNameHandler, VIOLATIONS_CAP}; pub use email::{EmailHandler, EmailId, EmailTransport, SmtpImapClientBuilder}; pub use matrix::{EventExtract, MatrixClient, MatrixHandler, MatrixTransport}; pub use twitter::{Twitter,...
#[derive(Copy, Clone, Debug)] struct Edge { to: usize, cost: u64, } fn dijkstra(g: &Vec<Vec<Edge>>, start: usize) -> (Vec<u64>, Vec<Option<usize>>) { use std::cmp::Reverse; use std::collections::BinaryHeap; let n = g.len(); let mut d = vec![std::u64::MAX; n]; let mut q = BinaryHeap::new(); ...
#[allow(unused_imports)] use proconio::{marker::*, *}; #[fastout] fn main() { input! { n: i32, x: i32, a: [i32; n], } for a in a { if a == x { println!("Yes"); return; } } println!("No"); }
use super::*; #[derive(Clone, Eq, Ord, PartialEq, PartialOrd, Default)] pub struct Signature { pub kind: ElementType, pub pointers: usize, pub by_ref: bool, pub is_const: bool, pub is_array: bool, } impl Signature { pub fn is_blittable(&self) -> bool { self.pointers > 0 || self.kind.is...
test_stdout!(with_atom_returns_true, "true\n"); test_stdout!( without_atom_returns_false, "false\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\n" );
extern crate cc; extern crate cmake; fn main() { cc::Build::new() .file("./src/C/util.c") .file("./src/C/glad.c") .file("./src/C/qef_solver.cpp") .include("./src/H") .include("include") .compile("rsutil"); let dst = cmake::build("voxelized-3d-cuda"); printl...
//! Code generation for `#[graphql_union]` macro. use std::mem; use proc_macro2::{Span, TokenStream}; use quote::{quote, ToTokens as _}; use syn::{ext::IdentExt as _, parse_quote, spanned::Spanned as _}; use crate::common::{diagnostic, parse, path_eq_single, scalar, SpanContainer}; use super::{ all_variants_dif...
// 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::fmt; use std::io; use std::result; /// An enum that represents all types of errors that can occur when using PickleDB #[derive(Debug)] pub enum ErrorType { /// I/O error when reading or writing to file, for example: file not found, etc. Io, /// An error when trying to serialize or deserialize data...
extern crate meet; use meet::establish_connection; use meet::users::User; use std::io::{stdin}; fn main() { let connection = establish_connection(); println!("What would you like your username to be?"); let mut username = String::new(); stdin().read_line(&mut username).unwrap(); let username = &u...
use super::*; use std::ops::*; impl BitOr<Square88> for Square88 { type Output = Square88; fn bitor(self, rhs: Square88) -> Self::Output { Square88(self.0 | rhs.0) } } impl BitOrAssign<Square88> for Square88 { fn bitor_assign(&mut self, rhs: Square88) { self.0 |= rhs.0 } } impl BitA...
pub const FILE_ASSOCIATION: &'static [(&'static str, &'static str)] = &[ ("T32_bat1.256", "A2b_arch.pl8"), ("T32_bat1.256", "A2b_cros.pl8"), ("T32_bat1.256", "A2b_knig.pl8"), ("T32_bat1.256", "A2b_mace.pl8"), ("T32_bat1.256", "A2b_peas.pl8"), ("T32_bat1.256", "A2b_pike.pl8"), ("T32_bat1.256"...
//! The graphics platform that is used by the renderer. use std::num::NonZeroU32; use glutin::config::{ColorBufferType, Config, ConfigTemplateBuilder, GetGlConfig}; use glutin::context::{ ContextApi, ContextAttributesBuilder, GlProfile, NotCurrentContext, Version, }; use glutin::display::{Display, DisplayApiPrefe...
use models::{AppState, Canvas}; #[derive(Clone, Debug)] pub struct LoadingMessage {} impl LoadingMessage { pub fn new() -> Self { LoadingMessage {} } pub fn render_as_canvas(&self, _state: &AppState, width: u16) -> Canvas { use tui::style::*; let mut canvas = Canvas::new(width); ...
// Copyright 2019 CoreOS, 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 in...
use input_i_scanner::InputIScanner; use std::collections::HashMap; fn main() { let stdin = std::io::stdin(); let mut _i_i = InputIScanner::from(stdin.lock()); macro_rules! scan { (($($t: ty),+)) => { ($(scan!($t)),+) }; ($t: ty) => { _i_i.scan::<$t>() as $t ...
// 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 colored::*; use crc_any::CRCu16; use goblin::elf::program_header::*; use hidapi::{HidApi, HidDevice}; use maplit::hashmap; use std::{ fs::File, io::Read, path::PathBuf, process::{Command, Stdio}, time::Instant, }; use structopt::StructOpt; fn main() { // Initialize the logging backend. ...
// Copyright 2017 Mathias Svensson. See the COPYRIGHT file at the top-level // directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT> or the Unlicen...
//! RS-Poker is a library for poker. //! It's mostly meant for Holdem games, however the core functionality //! should work for all game types. //! //! # Implemented: //! Currently RS-Poker supports: //! //! * Hand Iteration. //! * Hand Ranking. //! * Hand Range parsing. //! * Hand Range generation. //! //! # Planned: ...
use crate::prelude::*; use std::os::raw::c_void; use std::ptr; #[repr(C)] #[derive(Debug)] pub struct VkPresentInfoKHR { pub sType: VkStructureType, pub pNext: *const c_void, pub waitSemaphoreCount: u32, pub pWaitSemaphores: *const VkSemaphore, pub swapchainCount: u32, pub pSwapchains: *const ...
// array static pada rust // gunakan vec! untuk dinamik elemen fn main() { let mut name = [""; 4]; name[0] = "Agus"; name[1] = "Susilo"; name[2] = "Rust"; name[3] = "Awesome"; for n in name.iter() { println!("{}", n); } let mut lang: [i32; 3] = [0; 3]; lang[0] = 1; lang[1] = 2; lang[2] = ...
// Shortest Distance to a Character // https://leetcode.com/explore/challenge/card/february-leetcoding-challenge-2021/584/week-1-february-1st-february-7th/3631/ pub struct Solution; impl Solution { pub fn shortest_to_char(s: String, c: char) -> Vec<i32> { let max_dist = s.len() as i32; let mut res...
//! Ergonomic bindings for the [Max/MSP](https://cycling74.com/) [SDK](https://github.com/Cycling74/max-sdk). //! //! # Example //! //! A very basic external the has `bang`, `int`, `list`, and `any` methods. //! *See the examples folder for more detailed examples.* //! //! ```no_run //! use median::{ //! atom::Atom...
use opc_strip::OpcStrip; use std::io; use color_strip::ColorStrip; use effects::effect::Effect; use effects::ripple::Ripple; use effects::flash::Flash; use effects::blink::Blink; use effects::stream::Stream; use effects::push::Push; use effects::river::River; use effects::fish::Fish; use effects::stream_center::Stream...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[cfg(feature = "ApplicationModel_Store_LicenseManagement")] pub mod LicenseManagement; #[cfg(feature = "ApplicationModel_Store_Preview")] pub mod Preview; #[link(name = "windows")] extern "system" {} #[re...
///! Kernel erlang is like Core Erlang with a few significant ///! differences: ///! ///! 1. It is flat! There are no nested calls or sub-blocks. ///! ///! 2. All variables are unique in a function. There is no scoping, or ///! rather the scope is the whole function. ///! ///! 3. Pattern matching (in cases and receiv...
use maat_graphics::math; use maat_graphics::DrawCall; use maat_graphics::ModelData; use maat_graphics::camera::PerspectiveCamera; use crate::modules::scenes::Scene; use crate::modules::scenes::SceneData; use crate::cgmath::{Vector2, Vector3 as cgVector3, Vector4}; //use crate::modules::objects::{Character, StaticObje...
// // // //! Language entrypoint #[lang="termination"] pub trait Termination { fn report(self) -> i32; } #[lang="start"] fn lang_start<T: Termination+'static>(main: fn()->T, argc: isize, argv: *const *const u8) -> isize { #[cfg(arch="native")] { ::syscalls::raw::native_init(32245); } kernel_log!("lang_start(ma...
use crate::{encode, resample, Image}; use std::{io, fs::File}; #[test] fn load() -> io::Result<()> { if let Err(err) = Image::load(File::open("tests/test.png")?) { panic!("FAILED AT PNG {:?}", err); } if let Err(err) = Image::load(File::open("tests/test.jpg")?) { panic!("FAILED A...
pub struct Solution; use self::Token::*; use std::iter::Peekable; use std::str::Bytes; #[derive(Debug, Eq, PartialEq)] enum Token { Open, Close, Plus, Minus, Number(i32), } struct Tokens<'a> { bytes: Peekable<Bytes<'a>>, } impl<'a> Tokens<'a> { fn new(s: &'a str) -> Self { Tokens...
#![allow(unused_attributes)] #![feature(no_coverage)] use std::marker::PhantomData; use fuzzcheck::mutators::testing_utilities::test_mutator; use fuzzcheck::mutators::unit::UnitMutator; use fuzzcheck::{make_mutator, DefaultMutator}; #[derive(Clone, Debug, PartialEq, Eq, Hash)] struct SampleStruct<T> { // #[field_...
type Link<T> = Option<Box<Node<T>>>; pub struct Stack<T>{ top: Link<T>, } struct Node<T> { data: T, next: Link<T>, } impl<T> Stack<T> { pub fn new() -> Self { Stack {top: None} } pub fn push(&mut self, data: T) { let node = Box::new(Node { data: data, next:...
//! `read` and `write`, optionally positioned, optionally vectored use crate::{backend, io}; use backend::fd::AsFd; // Declare `IoSlice` and `IoSliceMut`. #[cfg(not(windows))] pub use crate::maybe_polyfill::io::{IoSlice, IoSliceMut}; #[cfg(linux_kernel)] pub use backend::io::types::ReadWriteFlags; /// `read(fd, buf...
//! Parser mod lexer; use std::iter::Peekable; use syntax::ast::{Expr, Expr_}; use syntax::codemap::{Source, Span, Spanned}; use syntax::parse::lexer::{Delim, Lexer, Token_}; use syntax::{Error, Error_}; use util::interner::Interner; struct Parser<'a> { // NB `Option` needed for option dance interner: Optio...
#[cfg(feature = "Win32_Foundation")] ::windows_sys::core::link ! ( "wintrust.dll""system" #[doc = "*Required features: `\"Win32_Security_Cryptography_Catalog\"`, `\"Win32_Foundation\"`*"] fn CryptCATAdminAcquireContext ( phcatadmin : *mut isize , pgsubsystem : *const :: windows_sys::core::GUID , dwflags : u32 ) -> supe...
use crate::{ error::{ProximateShellError, ShellError}, parser::{ hir::NamedArguments, span::Span, token::{SpannedToken, Token}, }, signature::{NamedType, Signature}, }; use alloc::{string::String, vec::Vec}; pub mod classified; type OptionalHeadTail = (Option<Vec<S...
use failure::{bail, ensure, Error, Fail, ResultExt}; use libc::*; use std::ffi::{CStr, CString}; use std::result; use std::str::FromStr; use crate::engine::Engine; type Result<T> = result::Result<T, Error>; include!(concat!(env!("OUT_DIR"), "/cvar_array.rs")); pub const EMPTY_CVAR_T: cvar_t = cvar_t { name: 0 as *c...
// fn prim_serise(min: i32, max: i32) -> Vec<i32> { // let mut series: Vec<i32> = Vec::new(); //empty vector initialization // let mut count = 0; // for num in min..max { // count = 0; // for i in 2..num { // if num % i == 0 { // count += 1; // br...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[link(name = "windows")] extern "system" {} pub type BarcodeScannerDisableScannerRequest = *mut ::core::ffi::c_void; pub type BarcodeScannerDisableScannerRequestEventArgs = *mut ::core::ffi::c_void; pub t...
const NLOOPS: usize = 100000000; fn main(){ for i in 0..NLOOPS { let s = add(3,5); } } fn add(a: i32, b: i32) -> i32 { let s = a+b; s }
#[macro_use] extern crate clap; extern crate rodio; extern crate rustbox; extern crate yaml_rust; use rustbox::RustBox; use std::default::Default; use std::sync::{Arc, Mutex}; mod arguments; mod notes; mod play; mod output; fn main() { let matches = arguments::get_arguments(); // A workaround to stop cracki...
// Copyright 2016 `multipart` Crate Developers // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://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 exce...
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. pub fn serialize_structure_send_command_input( object: &mut smithy_json::serialize::JsonObjectWriter, input: &crate::input::SendCommandInput, ) { if let Some(var_1) = &input.session_token { object.key("SessionToken").st...
/* Copyright (c) 2017 The swc Project Developers 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, ...
use crate::weapon::Weapon; use fyrox::core::pool::Handle; pub enum Message { ShootWeapon { weapon: Handle<Weapon> }, }
use std::sync::mpsc::channel; use helixdb::iterator::Iterator; use helixdb::option::ScanOption; use helixdb::{HelixDB, NoOrderComparator}; use tokio::runtime::Builder; use crate::panel::Panel; pub fn scan(helixdb: HelixDB, num_thread: usize, repeat_time: usize, prefetch_buf_size: usize) { let (tx, rx) = channel(...
use crate::codec::{Decode, Encode}; use crate::remote_type; use crate::spacecenter::Vessel; mod servo; mod servogroup; pub use self::servo::*; pub use self::servogroup::*; remote_type!( /// This service provides functionality to interact with Infernal Robotics. service InfernalRobotics { properties: { { ...
#[macro_use] extern crate log; use actix_web::middleware::Logger; use actix_web::{web, App, HttpServer}; use std::env; mod db; mod graphql; mod handler; struct ActixConfig { host: String, port: u32, workers: u8, } fn get_server_env() -> ActixConfig { let host = env::var("SERVER_HOST").unwrap_or(String::from...
#![feature(proc_macro)] // allow defining non-derive proc macros extern crate proc_macro; use proc_macro::TokenStream; #[proc_macro] pub fn utf16(input: TokenStream) -> TokenStream { let mut it = input.into_iter(); let mut rv = Vec::new(); loop { match it.next() { Some(::proc_macro::TokenTree { kind: ::pr...
use rocket::Request; use rocket_contrib::Json; use serde_derive::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct JsonErrorResponse { pub error: String, } #[catch(404)] pub fn json_404(_req: &Request) -> Json<JsonErrorResponse> { Json(JsonErrorResponse { error: "Cou...
use rand::Rng; use secret_integers::*; /// classify vector of u8s into U8s fn classify_u8s(v: &[u8]) -> Vec<U8> { v.iter().map(|x| U8::classify(*x)).collect() } /// declassify vector of U8s into u8s fn declassify_u8s(v: &[U8]) -> Vec<u8> { v.iter().map(|x| U8::declassify(*x)).collect() } pub fn get_secret_ke...
use std::env; use std::fmt::Display; use std::fs::File; use std::path::{Path, PathBuf}; use std::str::FromStr; use color_eyre::eyre::Result; use structopt::StructOpt; use crate::day::Day; #[derive(StructOpt)] pub struct Run { /// Problem day to run day: Day, /// Path to input file #[structopt(long)] ...
// 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 agre...
use std::cmp::Ordering; fn main() { let secret_number = 0; let guess = 0; // -1, 1 match guess.cmp(&secret_number) { Ordering::Less => println!("小さすぎます。残念……"), Ordering::Greater => println!("大きすぎます。残念……"), Ordering::Equal => println!("ぴったり! やったね!"), } }
mod buffer; mod pool; mod status; mod string; pub use buffer::*; pub use pool::*; pub use status::*; pub use string::*; #[macro_export] macro_rules! ngx_string { ($x:expr) => { { // const asserts are not yet supported (see rust-lang/rust#51999) &[()][1 - (($x[$x.len() - 1] == b'\0'...
use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::eager_or_lazy::switch_to_lazy_eval; use clippy_utils::source::{snippet, snippet_with_applicability, snippet_with_macro_callsite}; use clippy_utils::ty::{implements_trait, match_type}; use clippy_utils::{contains_return, is_trait_item, last_path_segmen...
use std::fs::File; use std::io; use std::io::prelude::*; use std::sync::mpsc::{Receiver, Sender}; mod gui; mod i2c; mod protocol; mod shared; use shared::{Event, SerialEvent}; pub fn launch(tx: Sender<Event>, rx: Receiver<SerialEvent>) { let mut file = File::create("/tmp/altctrl.serial").unwrap(); file.write...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[cfg(feature = "Devices_I2c_Provider")] pub mod Provider; #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default...
extern crate jlib; use jlib::api::set_relation::data::{RelationType, RelationTxResponse, RelationSideKick}; use jlib::api::set_relation::api::Relation; use jlib::api::message::amount::Amount; use jlib::api::config::Config; pub static TEST_SERVER: &'static str = "ws://101.200.176.249:5040"; //dev12 国密服务器 fn main() {...
//! Tests auto-converted from "sass-spec/spec/parser/interpolate/04_space_list_quoted" #[allow(unused)] use super::rsass; #[allow(unused)] use rsass::precision; /// From "sass-spec/spec/parser/interpolate/04_space_list_quoted/01_inline" #[test] fn t01_inline() { assert_eq!( rsass( ".result {\n ...
extern crate limonite; extern crate clap; use clap::App; use limonite::site::Site; use limonite::VERSION; use std::path::Path; fn main() { let matches = App::new("limonite") .author("Douglas Campos <qmx@qmx.me>") .version(VERSION) .about("blazing fast static site and blog generator") ...
#[allow(non_upper_case_globals)] #[allow(non_camel_case_types)] #[allow(non_snake_case)] #[allow(unused)] #[allow(clippy::all)] #[cfg(feature = "callback")] pub mod callback { include!(concat!(env!("OUT_DIR"), "/callback.rs")); } #[allow(non_upper_case_globals)] #[allow(non_camel_case_types)] #[allow(non_snake_case)...
#![allow(non_camel_case_types)] #![allow(dead_code)] use std::cmp::Ordering; mod ffi { use std::cmp::Ordering; use std::hash::{Hash, Hasher}; #[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] #[repr(C)] pub enum Maybe<T> { Just(T), Nothing, } use self::Maybe::*;...
use std::env; use std::fs::canonicalize; use std::path::PathBuf; mod platform; fn main() { let args: Vec<String> = env::args().collect(); match args.len() { 1 => eprintln!( "No arguments is passed. Please pass the file path that you want to set to the wallpaper." ), 2 => {...
unsafe fn hello() { let x = 32; let y = 23; let pointx = &x; let pointy = &y; println!("{}",pointx); println!("{}",pointy); } fn main() { unsafe { hello(); } }
use model::*; use pancurses::*; type color_pair = u32; const DEFAULT_COLORS: color_pair = 0; const GOAL_COLORS: color_pair = 1; const BROKEN_TURRET_COLORS: color_pair = 2; const DAMAGED_TURRET_COLORS: color_pair = 3; const PLACEMENT_COLORS: color_pair = 4; const GAMEOVER_COLORS: color_pair = 5; const EMPTY_CELL: cht...
use std::{unimplemented, vec}; use utils::Grid; #[derive(Clone, Hash, PartialEq, Eq)] pub enum Seat { FLOOR, FILLED, EMPTY, } impl Default for Seat { fn default() -> Self { Seat::EMPTY } } // #[test] pub fn run() { let input = read_input(include_str!("input/day11.txt")); // print...
use std::collections::VecDeque; use hashbrown::HashMap; use pest::iterators::Pair; use pest::Parser; use serde::Serialize; use serde_json::value::{to_value, Map, Value as Json}; use crate::error::RenderError; use crate::grammar::{HandlebarsParser, Rule}; pub type Object = HashMap<String, Json>; /// The context wrap ...
// 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 std::fmt; use Command; #[deriving(PartialEq, Eq, PartialOrd, Ord)] pub struct Grid { width: u32, height: u32, chars: Vec<char>, } impl fmt::Show for Grid { fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { let s: String = String::from_chars(self.chars.as_slice()); write!(w, "G...
//! RPC interface for the transaction payment module. use jsonrpc_core::{Error as RpcError, ErrorCode, Result}; use jsonrpc_derive::rpc; use pallet_template_runtime_api::SumStorageApi as SumStorageRuntimeApi; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::{generic::BlockId, traits::Bl...
#[doc = "Reader of register SSDC1"] pub type R = crate::R<u32, super::SSDC1>; #[doc = "Writer for register SSDC1"] pub type W = crate::W<u32, super::SSDC1>; #[doc = "Register SSDC1 `reset()`'s with value 0"] impl crate::ResetValue for super::SSDC1 { type Type = u32; #[inline(always)] fn reset_value() -> Sel...
// Copyright 2017 Dasein Phaos aka. Luxko // // 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 // except a...
use text_grid::*; fn main() {} pub fn f_ok() -> Cell<impl CellSource> { let s = String::from("ABC"); cell(s) // OK } // fn f_error() -> Cell<impl CellSource> { // let s = String::from("ABC"); // cell(&s) // Error : returns a value referencing data owned by the current function // }