text
stringlengths
8
4.13M
use actix_web::HttpResponse; pub async fn get_version() -> HttpResponse { HttpResponse::Ok().json(json!({"version": "1.0.0"})) } pub async fn get_health() -> HttpResponse { HttpResponse::Ok().json(json!({})) }
// 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 fidl_fuchsia_bluetooth_avdtp::PeerManagerControlHandle; /// State for storing the control handle for PeerManager /// We need this to reply back to bt-...
use regex_automata::util::prefilter::{self, Candidate, Prefilter}; #[derive(Clone, Debug)] pub struct SubstringPrefilter(bstr::Finder<'static>); impl SubstringPrefilter { pub fn new<B: AsRef<[u8]>>(needle: B) -> SubstringPrefilter { SubstringPrefilter(bstr::Finder::new(needle.as_ref()).into_owned()) }...
extern crate arrow; extern crate parquet; use std::error::Error; use std::fs::File; use std::sync::Arc; use arrow::array::{ArrayRef, Int32Array, Int8Array}; use arrow::compute::{add, cast}; use arrow::datatypes::{DataType, Field, Schema}; use arrow::record_batch::RecordBatch; // Scenario - add two columns of differe...
use super::context::{Ctx, PineRuntimeError, RVRunner, Runner, RunnerForFunc, RunnerForObj}; pub use crate::ast::stat_expr_types::{ Condition, DataType, Exp, FunctionCall, PrefixExp, RVVarName, RefCall, Statement, TypeCast, VarIndex, }; use crate::ast::syntax_type::{FunctionType, SimpleSyntaxType, SyntaxType}; u...
use crate::{ bls::{SecretKey, SIG_SIZE}, cli::Opts, rpc::Rpc, }; use crossbeam_channel::{bounded, RecvTimeoutError, Sender}; use hashbrown::HashMap; use log::{debug, info, trace, warn}; use meroxidizer::utils::difficulty_to_max_hash; use parking_lot::RwLock; use randomx::{Cache, HASH_SIZE}; use std::{ c...
use midi_message::MidiMessage; use color_strip::ColorStrip; use effects::effect::Effect; use rainbow::get_rainbow_color; pub struct Push { color_strip: ColorStrip, } impl Push { pub fn new(led_count: usize) -> Push { Push { color_strip: ColorStrip::new(led_count), } } } impl ...
// 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 ...
use crate::pac::ccu::{ Ahb1Apb1Config, Ahb2Config, Apb2Config, BusClockGating0, BusClockGating1, BusClockGating2, BusClockGating3, BusSoftReset0, BusSoftReset1, BusSoftReset4, PllCpuXControl, PllDeControl, PllPeriph0Control, PllVideo0Control, CCU, }; use cortex_a::asm; use embedded_time::rate::Hertz; pub t...
use super::lane_type::LaneType; use super::skill_type::SkillType; #[derive(Clone, Debug, Eq, PartialEq)] pub struct Message { pub lane: LaneType, pub skill_to_learn: SkillType, pub raw_message: Vec<i8>, }
pub type SymbolId = String;
use std::{sync::{Arc, Mutex, mpsc::{self, Receiver, Sender}}, thread::{self, JoinHandle}}; use std::{time::{Duration, SystemTime}}; use chrono::{Local, Timelike}; use rand::Rng; use crate::{Config, DEFAULT_CONFIG_PATH, DEFAULT_DOWNLOAD_PATH, Hour, download_photo, get_weather, make_unsplash_client, search_photos, set_...
// Copyright 2018 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 ...
#![feature(test)] extern crate futures; extern crate test; use futures::{Async, Poll}; use futures::executor; use futures::executor::{Notify, NotifyHandle}; use futures::sync::BiLock; use futures::sync::BiLockAcquire; use futures::sync::BiLockAcquired; use futures::future::Future; use futures::stream::Stream; use t...
extern crate bit_vec; use std::mem::size_of; use std::option::Option; use bit_vec::BitVec; const PAGE_SIZE: usize = 4096; struct BranchNode<T> { branches: Vec<Node<T>>, valid: BitVec } struct LeafNode<T> { data: Vec<T>, valid: BitVec, marked: BitVec, } enum Node<T> { Branch(BranchNod...
use crate::Part; use regex::Regex; use std::collections::HashMap; struct Entry(HashMap<String, String>); pub fn run(part: Part, input_str: &str) { let re = Regex::new(r"(?P<field>[a-z]+):(?P<value>\S+)").unwrap(); let mut entries = Vec::new(); for passport in input_str.split("\n\n") { let mut hash...
use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; pub type PythonScripts = BTreeMap<String, PythonScript>; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct PythonScript { pub name: String, pub source: String, } impl PartialEq for PythonScript { fn eq(&self, other: &Self) -> ...
#[macro_use] extern crate log; extern crate term; extern crate getopts; extern crate openssl; extern crate mqtt3; extern crate netopt; extern crate mqttc; pub mod client;
use failure::{bail, Fallible}; use std::process::Command; pub(crate) trait CommandRunExt { fn run(&mut self) -> Fallible<()>; } impl CommandRunExt for Command { fn run(&mut self) -> Fallible<()> { let r = self.status()?; if !r.success() { bail!("Child [{:?}] exited: {}", self, r); ...
#[doc = "Reader of register ASCR2"] pub type R = crate::R<u32, super::ASCR2>; #[doc = "Writer for register ASCR2"] pub type W = crate::W<u32, super::ASCR2>; #[doc = "Register ASCR2 `reset()`'s with value 0"] impl crate::ResetValue for super::ASCR2 { type Type = u32; #[inline(always)] fn reset_value() -> Sel...
// Copyright 2018 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 ...
#[cfg(test)] mod test { use crate::data_structures::linked_list::{LinkedList}; #[test] fn basic() { let mut foo: LinkedList<i32> = LinkedList::new(); foo.push(1); foo.push(2); foo.push(3); foo.push(4); assert_eq!(foo.pop(), Some(4)); assert_eq!(*f...
// Implementation derived from `weak` in Rust's // library/std/src/sys/unix/weak.rs at revision // fd0cb0cdc21dd9c06025277d772108f8d42cb25f. // // Ideally we should update to a newer version which doesn't need `dlsym`, // however that depends on the `extern_weak` feature which is currently // unstable. #![cfg_attr(lin...
use bevy::{diagnostic::FrameTimeDiagnosticsPlugin, diagnostic::PrintDiagnosticsPlugin, prelude::*}; // use collision_rays::CollisionRay; use components::DarkSkyComponentRegistry; // use main_2d_camera::Main2dCamera; use main_3d_camera::Main3dCamera; // use meshie_ship_test::MeshieShipTest; // use motion_test::MotionTes...
use std::io; use std::convert; #[derive(Fail, Debug)] pub enum Error { #[fail(display = "parser cmd fail : {}", _0)] ParseCmdFailError(String), #[fail(display = "I/O error")] Io(#[cause] ::std::io::Error), } impl convert::From<io::Error> for Error { fn from(error: io::Error) -> Self { Error::Io(err...
use juniper::graphql_interface; #[graphql_interface] trait Character { fn id(&self) -> &str; #[graphql(name = "id")] fn id2(&self) -> &str; } fn main() {}
use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use beerxml::hop; #[test] fn hops_file_read() { let file = File::open("tests/beerxml/data/hops.xml").unwrap(); let mut buf_reader = BufReader::new(file); let mut contents = String::new(); buf_reader.read_to_string(&mut contents).unwra...
// 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 ...
import foo::bar; mod foo { import zed::bar; export bar; mod zed { fn bar() { log "foo"; } } } fn main(args: vec[str]) { bar(); }
//! Core for ATmega88PA. use crate::{modules, RegisterBits, Register}; #[allow(non_camel_case_types)] pub struct EXTENDED; impl EXTENDED { pub const BOOTSZ: RegisterBits<Self> = RegisterBits::new(0x6); pub const BOOTSZ0: RegisterBits<Self> = RegisterBits::new(1<<1); pub const BOOTSZ1: RegisterBits<Self> ...
enum Sentence { Hello(u32), Nice, Goodbye { Person: String }, } fn manage(person: &Sentence) { match *person { Sentence::Hello(n) => { for _ in 0..n { println!("Hello"); } } Sentence::Nice => { println!("Nice to meet you"); ...
use crate::prelude::*; pub struct Edges<'a, N, E> { edges: &'a generational_arena::Arena<Edge<N, E>>, direction: Direction, next: Next<N, E>, } impl<'a, N, E> Edges<'a, N, E> { pub(crate) fn new( direction: Direction, next: Next<N, E>, edges: &'a generational_arena::Arena<Edge<...
#[cfg(test)] mod tests { use pygmaea::ast::*; use pygmaea::lexer::Lexer; use pygmaea::parser::Parser; fn setup_let_statement_input() -> Vec<String> { vec![ " let x = 5;", "let y = 10;", "let foobar = 838383; ", ] .into_iter() ...
//! Interior mutability stuff. #[cfg(feature = "v2")] use crate::v2::models::Resolvable; #[cfg(feature = "v2")] use serde::{Serialize, Serializer}; #[cfg(feature = "v2")] impl<T> Serialize for Resolvable<T> where T: Serialize, { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where ...
#![warn(unsafe_code)] #![warn(rust_2018_idioms)] #![allow(dead_code)] use auto_enums::enum_derive; #[cfg(feature = "external_libraries")] #[test] fn stable_external() { #[enum_derive( rayon::ParallelIterator, rayon::IndexedParallelIterator, rayon::ParallelExtend, serde::Serialize ...
use std::cmp; use std::convert::TryFrom; use std::str::FromStr; enum Mode { Position, Immediate, } #[derive(Debug)] struct ModeParseError; impl TryFrom<char> for Mode { type Error = ModeParseError; fn try_from(c: char) -> Result<Self, Self::Error> { match c { '0' => Ok(Mode::Posi...
pub struct Solution; #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Tree, pub right: Tree, } use std::cell::RefCell; use std::rc::Rc; type Tree = Option<Rc<RefCell<TreeNode>>>; impl Solution { pub fn binary_tree_paths(root: Tree) -> Vec<String> { fn rec(node: R...
mod reqmgr; pub use reqmgr::*; mod server; pub use server::*;
pub mod database; pub mod daemon; pub mod settings; use self::daemon::Daemon; use self::database::Database; use self::settings::Settings; pub struct Root { daemon: Option<Daemon>, database: Option<Database>, settings: Option<Settings> } impl Root { pub fn new() -> Root { let mut root = Root { daemo...
fn main() { println!("Area of a 50x30 rect params is {}", area(30, 50)); println!("Area of a 50x30 rect tuples is {}", area_tup((30, 50))); let rect = Rectangle { width: 30, height: 50, }; println!("Area of a 50x30 rect struct is {}", area_rect(&rect)); println!("Area of a 50x30 rect struct with imp...
//! An efficient representation of a 2D matrix. use crate::prelude::*; use std::ops::Index; use std::ops::IndexMut; // ============ // == Matrix == // ============ /// An efficient 2D matrix implemented on top of [`std::vec::Vec`]. #[derive(Clone,Debug,Default,PartialEq,Eq)] #[allow(missing_docs)] pub struct Matr...
// LCOV_EXCL_START use yaml_rust::{Yaml, YamlLoader}; lazy_static! { /// Translations for the application service pub static ref TRANSLATIONS: Vec<Yaml> = { let translations = include_str!("../../assets/translations.yaml"); YamlLoader::load_from_str(translations).expect("Could not load translat...
use core::fmt; use alloc::Vec; use alloc::String; use alloc::slice::SliceConcatExt; use kernel::random; #[derive(Debug)] pub struct UUID(Vec<u8>); impl UUID { pub fn new() -> Self { UUID(random::read(16)) } } impl fmt::Display for UUID { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ...
use wasm_bindgen::prelude::*; #[wasm_bindgen] pub fn say(s: &str) -> String { return String::from("NASA's Content of the day: ") + s; }
#![allow(clippy::all)] fn parse_line(line: &str) -> ((usize, usize), (usize, usize)) { let mut parts = line.trim().split(" -> "); let mut begin_part = parts.next().unwrap().split(","); let mut end_part = parts.next().unwrap().split(","); let x1 = begin_part.next().unwrap().parse::<usize>().unwrap(); ...
use std::collections::HashSet; use std::sync::mpsc; use std::thread; fn generate_multiples_until(x: u32, limit: u32) -> Vec<u32> { let mut multiples: Vec<u32> = Vec::new(); if x == 0 { return multiples; } let mut multiple: u32 = x; while multiple < limit { multiples.push(multipl...
#[cfg(feature = "async")] use crate::protocol::util_async; #[cfg(feature = "sync")] use crate::protocol::util_sync; use crate::HdbResult; #[cfg(feature = "sync")] use byteorder::{LittleEndian, ReadBytesExt}; #[derive(Debug)] pub struct ReadLobReply { locator_id: u64, is_last_data: bool, data: Vec<u8>, } im...
extern crate reverse_endian; #[cfg(test)] mod tests { use reverse_endian::ReverseEndian; #[derive(Debug, PartialEq, ReverseEndian)] struct TestStruct { four_bytes: u32, two_bytes: u16, } #[test] fn test_struct_named() { let original = TestStruct { four_byte...
// 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...
// These functions are only used if the API uses Nullable properties, so allow them to be // dead code. #![allow(dead_code)] #[cfg(feature = "serdejson")] use serde::de::Error as SerdeError; #[cfg(feature = "serdejson")] use serde::de::{Deserialize, DeserializeOwned, Deserializer}; #[cfg(feature = "serdejson")] use ser...
pub use ts_33_401::*; pub mod ts_33_401;
// An experiment to better understand nom's implementation and ideas #[derive(Debug)] pub enum ErrorKind { ParseError, EncodingError, Take, TakeUntil, Integer, Verify, Byte, Tag, Eof, } #[derive(Debug, Clone, Copy, PartialEq)] pub enum Endianness { Big, Little, } #[derive(...
use std::{i8, i16, i32, i64, u8, u16, u32, u64, isize, usize, f32, f64}; use std::io::stdin; fn main() { println!("Max i8={}", i8::MAX); println!("Min i8={}\n", i8::MIN); println!("Max i16={}", i16::MAX); println!("Min i16={}\n", i16::MIN); println!("Max i32={}", i32::MAX...
use std::cmp; use std::intrinsics::unlikely; use std::ptr::{self, NonNull}; use intrusive_collections::{LinkedListLink, UnsafeRef}; use liblumen_alloc_macros::*; use liblumen_core::alloc::mmap; use liblumen_core::alloc::prelude::*; use liblumen_core::alloc::size_classes::{SizeClass, SizeClassIndex}; use liblumen_core...
use super::component_prelude::*; #[derive(Default)] pub struct CanHover; impl Component for CanHover { type Storage = NullStorage<Self>; }
extern crate env_logger; extern crate tokio_core; extern crate futures; extern crate tokio_solicit; use std::str; use std::io::{self}; use futures::{Future, Stream}; use futures::future::{self}; use tokio_core::reactor::{Core}; use tokio_solicit::client::H2Client; // Shows the usage of `H2Client` when establishing...
#[derive(Debug)] pub struct HighScores<'a> { scores: &'a [u32], } impl<'a> HighScores<'a> { pub fn new(scores: &'a [u32]) -> Self { HighScores { scores } } pub fn scores(&self) -> &[u32] { self.scores } pub fn latest(&self) -> Option<u32> { match self.scores.len() { ...
use alloc::alloc::{AllocError, Allocator, Global, Layout}; use alloc::borrow::{self, Cow}; use core::any::{Any, TypeId}; use core::fmt::{self, Debug, Display}; use core::hash::{Hash, Hasher}; use core::marker::{PhantomData, Unsize}; use core::mem::{self, MaybeUninit}; use core::ops::{Deref, DerefMut}; use core::ptr::{s...
#![allow(unused)] use super::configs::WindowConfig; use super::osspecific::osspecific::OsSpecific; use super::vulkancore::VulkanCore; #[cfg(feature = "audio")] use super::soundhandler::SoundHandler; use crate::prelude::*; use presentation::{input::eventsystem::PresentationEventType, prelude::*}; use std::collectio...
extern crate rand; extern crate minifb; extern crate ears; extern crate config; mod chip8; mod tests; mod modules; use chip8::cpu::Cpu; use std::{env, thread}; use std::io::Read; use std::io::Result; use std::fs::File; use std::path::Path; use std::time::Duration; use crate::modules::config::Config; fn main() { ...
pub use crate::board::Board; pub use crate::ai::AI; use text_io::read; pub struct HumanPlayer { board: Board, } impl AI for HumanPlayer { fn get_move(&mut self, last_move : i64) -> i64 { if last_move != -1 { self.board.make_move(last_move as usize); } self.board.pretty_prin...
use std::io; use std::convert::TryInto; use std::collections::HashSet; use std::collections::HashMap; use std::collections::LinkedList; use std::cmp::Reverse; use std::cmp; use std::str::FromStr; use std::iter::FromIterator; use std::time::Instant; use rand::Rng; use rand::seq::SliceRandom; use rand::thread_rng; cons...
use crate::parser::stream::Stream; use crate::parser::*; use crate::token::Keyword; use anyhow::Result; use trace; pub fn parse_statements(stream: &mut Stream) -> Result<Statements> { trace!(stream, "parse_statements", { let mut statements = Vec::new(); loop { if let Some(vardec) = pa...
//! named accounts for synthesized data accounts for bank state, etc. //! use crate::pubkey::Pubkey; pub mod slot_hashes; /// "Sysca11111111111111111111111111111111111111" /// owner pubkey for syscall accounts const ID: [u8; 32] = [ 6, 167, 211, 138, 69, 216, 137, 185, 198, 189, 33, 204, 111, 12, 217, 220, 229,...
#[doc = "Reader of register CR"] pub type R = crate::R<u32, super::CR>; #[doc = "Writer for register CR"] pub type W = crate::W<u32, super::CR>; #[doc = "Register CR `reset()`'s with value 0x2000_2000"] impl crate::ResetValue for super::CR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type ...
use proptest::collection::SizeRange; use proptest::prop_assert_eq; use proptest::strategy::{Just, Strategy}; use proptest::test_runner::{Config, TestRunner}; use liblumen_alloc::erts::term::prelude::*; use crate::erlang::list_to_tuple_1::result; use crate::test::strategy; use crate::test::{with_process, with_process_...
// Copyright 2012-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...
#[doc = r"Value read from the register"] pub struct R { bits: u8, } #[doc = r"Value to write to the register"] pub struct W { bits: u8, } impl super::LPMIM { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w ...
fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let n: usize = rd.get(); let m: usize = rd.get(); let mut h: Vec<u64> = (0..n).map(|_| rd.get()).collect(); let w: Vec<u64> = (0..m).map(|_| rd.get()).collect(); h.sort(); let mut a = vec![0; n]; ...
// 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::{ models::{AddModInfo, DisplayInfo, Suggestion}, story_context_store::ContextEntity, suggestions_manager::SearchSu...
use super::{ ConstGmEvent, ConstGmObject, ConstGmObjectOverrideProperty, ConstGmObjectProperty, EventType, }; use crate::{FilesystemPath, ResourceVersion, Tags, ViewPath}; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use smart_default::SmartDefault; #[derive(Debug, Seria...
use crate::extensions::{self as ext}; use crate::keypackage::Timespec; use crate::keypackage::{self as kp, KeyPackage, OwnedKeyPackage}; use crate::message::*; use crate::tree::*; use crate::utils::{encode_vec_u8_u8, read_vec_u8_u8}; use ra_client::EnclaveCertVerifier; use rustls::internal::msgs::codec::{self, Codec, R...
//! File Appender use {Append, Filter, Named}; use config::appender::Appender; use config::filter::FilterType; use log::LogRecord; use std::error::Error; use std::fmt; use std::fs::OpenOptions; use std::io::Write; use std::path::PathBuf; use std::sync::{Arc, Mutex}; /// FileAppender Struct pub struct FileAppender { ...
// 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 libc; us...
// 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 { bitflags::bitflags, failure::{format_err, Error, ResultExt}, fidl_fuchsia_bluetooth as bt, fidl_fuchsia_bluetooth_bredr::*, fuchs...
use AsLua; use AsMutLua; use Push; use PushGuard; use LuaRead; /// Represents any value that can be stored by Lua #[derive(Clone, Debug, PartialEq)] pub enum AnyLuaValue { LuaString(String), LuaNumber(f64), LuaBoolean(bool), LuaArray(Vec<(AnyLuaValue, AnyLuaValue)>), /// The "Other" element is (h...
//! A set implemented on a trie. Unlike `std::collections::HashSet` the elements in this set are not //! hashed but are instead serialized. use crate::collections::next_trie_id; use crate::env; use borsh::{BorshDeserialize, BorshSerialize}; use near_vm_logic::types::IteratorIndex; use std::marker::PhantomData; #[deriv...
/* * 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...
use super::*; mod with_different_process; #[test] fn with_same_process_adds_process_message_to_mailbox_and_returns_ok() { run!( |arc_process| { ( Just(arc_process.clone()), strategy::term(arc_process.clone()), valid_options(arc_process), ...
use super::{PyType, PyTypeRef}; use crate::{ builtins::PyTupleRef, class::PyClassImpl, function::{ArgIntoBool, OptionalArg, PosArgs}, protocol::{PyIter, PyIterReturn}, types::{Constructor, IterNext, Iterable, SelfIter}, AsObject, Context, Py, PyObjectRef, PyPayload, PyRef, PyResult, TryFromObjec...
use std::num::NonZeroU64; use bytemuck::{Pod, Zeroable}; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Zeroable, Pod)] #[repr(transparent)] pub struct EntityId(pub u64); /// Returned by `query_begin`. Contains pointers /// to the data yielded by the query. #[derive(Copy, Clone, Debug, Zeroable, Pod)] #[repr(C)] ...
use regex::Regex; use std::collections::HashMap; mod utils; fn main() { let data = utils::load_input("./data/day_7.txt").unwrap(); let re = Regex::new(r"\b(?P<container>[a-z]+ [a-z]+) bags \b(?:contain no|contain(?P<list>(?: \d+ [a-z]+ [a-z]+ bags?.)+))").unwrap(); let re_list = Regex::new(r"(\d) ([a-z]+ ...
// 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 fuchsia_inspect::Inspector; use fuchsia_inspect_contrib::nodes::BoundedListNode; use parking_lot::Mutex; use std::sync::Arc; use wlan_inspect::iface_mg...
#![feature(asm)] #![feature(globs)] use self::bitboard::base::BB; use self::stringable::*; use self::iterable::*; use self::square::*; use self::piece::*; use self::mv::*; use self::fen::*; mod bitboard; mod board; mod piece; mod square; mod mv; mod piecelist; mod fen; mod castling; mod side; mod stringable; mod iter...
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...
extern crate cgmath; extern crate gl; extern crate glfw; use std::ffi::CStr; use std::mem; use std::os::raw::c_void; use std::ptr; use cgmath::*; use rand::Rng; use crate::shader::Shader; use self::gl::types::*; pub struct BulletInstance { pub position: Vector3<f32>, pub direction: Vector3<f32>, pub cl...
fn main() { let s1 = "abc"; let s2 = b"abc"; println!("{}", s1); println!("{:?}", s2); let s3 = "テスト"; println!("{}", s3); println!("{:?}", "テスト".as_bytes()); }
// 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...
use std::time; #[derive(Debug)] pub struct FrameClock { clock: time::Instant, previous: u64, elapsed: u64, } impl FrameClock { pub fn new() -> FrameClock { FrameClock { clock: time::Instant::now(), previous: 0, elapsed: u64::max_value(), } } ...
use crate::{DocBase, VarType}; pub fn gen_doc() -> Vec<DocBase> { vec![ DocBase { var_type: VarType::Variable, name: "year", signatures: vec![], description: "Current bar year in exchange timezone.", example: "", returns: "", ...
use parser::ast::*; use evaluator::object::*; pub struct BuiltinsFunctions; impl Default for BuiltinsFunctions { fn default() -> Self { Self::new() } } impl BuiltinsFunctions { pub fn new() -> Self { BuiltinsFunctions {} } pub fn get_builtins(&self) -> Vec<(Ident, Object)> { ...
pub trait Predicate<V> { fn apply(&self, value: &V) -> bool; }
#[cfg(target_os = "macos")] mod macos; #[cfg(target_os = "macos")] pub use macos::get_page_cache_info; #[cfg(target_os = "macos")] pub use macos::read_advise; #[cfg(target_os = "macos")] pub use macos::read_ahead; // pub const PAGE_SIZE: usize = ???; include!(concat!(env!("OUT_DIR"), "/os_consts.rs")); #[allow(dead_...
use crate::{sealed::Sealed, tuple::push::TuplePush}; /// Popes element from the **end** of the tuple, producing new tuple. /// /// Return tuple of remaining tuple and poped element. /// /// ## Examples /// ``` /// use fntools::tuple::pop::TuplePop; /// /// assert_eq!((999,).pop(), ((), 999)); /// assert_eq!((47, "str"...
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 y: usize = iter.next().unwrap().parse().unwrap(); let x: usize = iter.next().unwrap().parse().unwr...
use serde_json::Value; use rbatis_core::convert::StmtConvert; use rbatis_core::db::DriverType; use crate::sql::Date; impl Date for DriverType { fn date_convert(&self, value: &Value, index: usize) -> rbatis_core::Result<(String, Value)> { let mut sql = String::new(); match self { Drive...
//! # General traits pub mod trait_impl; /// Data type of the start and end coordinates pub type Coordinate = i64; /// Data type of the chromosomes pub type Chrom = String; /// Returns a tuple of the form /// (chromosome, start_inclusive, end_exclusive, value) pub trait ToChromStartEndVal<V> { fn to_chrom_start...
// RGB standard library // Written in 2020 by // Dr. Maxim Orlovsky <orlovsky@pandoracore.com> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warr...
use hello_macro::HelloMacro; use hello_macro_derive::HelloMacro; fn main() { macro_rules(); derive_macro(); attribute_like_macros(); function_like_macros(); } fn macro_rules() { #[macro_export] macro_rules! my_vec { ( $( $x:expr ),* ) => { { let mut temp_ve...
//! Implements the traits that are required to hook up low level Tokio IO to the Tokio //! protocol API. //! //! The main struct that it exposes is the `H2ClientTokioTransport`, which is the bridge between //! the semantic representation of an HTTP/2 request/response and the lower-level IO. //! //! Also exposes the `H2...