text
stringlengths
8
4.13M
use std::collections::HashMap; use std::path::PathBuf; use serde::{Deserialize, Serialize}; use crate::protocol::{LogStreamSource, ProcessSpec}; /// A request to start managing a new process. /// /// Eventually turned into a `ProcessSpec` internally, once managed. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Des...
use std::error; use std::ffi::CStr; use std::fmt; use std::os::raw::c_int; use std::result; use std::str; /// Error codes that the library might return. #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, PartialOrd, Ord)] pub enum Error { /// DNS server returned answer with no data. ENODATA = c_ares_sys::ARES_E...
#[doc = "Register `FDCAN_TEST` reader"] pub type R = crate::R<FDCAN_TEST_SPEC>; #[doc = "Field `LBCK` reader - Loop Back mode"] pub type LBCK_R = crate::BitReader; #[doc = "Field `TX` reader - Loop Back mode"] pub type TX_R = crate::FieldReader; #[doc = "Field `RX` reader - Control of Transmit Pin"] pub type RX_R = cra...
impl Solution { pub fn kth_largest_value(matrix: Vec<Vec<i32>>, k: i32) -> i32 { let mut matrix = matrix; let (n,m) = (matrix.len(),matrix[0].len()); let mut res= Vec::new(); for i in 0..n{ for j in 0..m{ if i >= 1{ matrix[i][j] ^= matr...
use crate::er::{self, Result}; pub struct JitsiEnvConfigLetsEncrypt { pub domain: String, pub email: String, } pub struct JitsiEnvConfig { pub config_dir: String, pub tz: String, pub public_url: String, pub letsencrypt: Option<JitsiEnvConfigLetsEncrypt>, pub http_port: i32, pub https_po...
#[doc = "Reader of register MDMA_C14TBR"] pub type R = crate::R<u32, super::MDMA_C14TBR>; #[doc = "Writer for register MDMA_C14TBR"] pub type W = crate::W<u32, super::MDMA_C14TBR>; #[doc = "Register MDMA_C14TBR `reset()`'s with value 0"] impl crate::ResetValue for super::MDMA_C14TBR { type Type = u32; #[inline(...
use std::io; use std::rand; fn get_random_number() -> uint { let secret_number = (rand::random::<uint>() % 100u) + 1u; secret_number } fn cmp(a: uint, b: uint) -> Ordering { if a < b { Less } else if a > b { Greater } else { Equal } } fn main() { let secret = get_random_number(); loop { ...
#[doc = "Register `MACFFR` reader"] pub type R = crate::R<MACFFR_SPEC>; #[doc = "Register `MACFFR` writer"] pub type W = crate::W<MACFFR_SPEC>; #[doc = "Field `PM` reader - Promiscuous mode"] pub type PM_R = crate::BitReader; #[doc = "Field `PM` writer - Promiscuous mode"] pub type PM_W<'a, REG, const O: u8> = crate::B...
extern crate lyon; //use lyon::tessellation as tess; use lyon::path::iterator::PathIterator; use lyon::path::FlattenedEvent; use lyon::algorithms::path::iterator::Flattened; #[derive(PartialEq)] pub struct Polygon { pub vertices: Vec<lyon::math::Point>, } impl Polygon { pub fn new() -> Self { Polygon...
pub fn encode(n: u64) -> String { let mut temp = n; let mut output: String = "".to_string(); let less_than_twenty = |num| { let value = match num { 0 => "zero", 1 => "one", 2 => "two", 3 => "three", 4 => "four", 5 => "five...
use anyhow::Result; use itertools::Itertools; use std::collections::{HashMap, HashSet}; use std::str::FromStr; #[derive(Debug)] struct Record(HashMap<String, String>); impl FromStr for Record { type Err = anyhow::Error; fn from_str(s: &str) -> Result<Self, Self::Err> { let data = s .split...
use crate::database::raw_index::InnerRawIndex; #[derive(Clone)] pub struct SynonymsIndex(pub(crate) InnerRawIndex); impl SynonymsIndex { pub fn alternatives_to(&self, word: &[u8]) -> Result<Option<fst::Set>, rocksdb::Error> { match self.0.get(word)? { Some(vector) => Ok(Some(fst::Set::from_byt...
#[macro_use] extern crate clap; mod cli; mod format; mod module; mod segments; mod theme; use crate::module::Module; use crate::segments::Segment; use crate::theme::Theme; #[derive(Clone, Copy, Eq, PartialEq)] pub enum Shell { Bare, Bash, Zsh } pub struct Powerline { segments: Vec<Segment>, them...
use std::io::{self, Write as IoWrite}; use std::fmt; use std::str::Chars; use std::iter::Peekable; use MathError::*; use Token::*; fn main() { println!("Shunting Yard algorithm calculator, enter an expression to be evaluated."); println!("Type `exit` to exit"); let mut input = String::new(); // let m...
use std::net::Ipv4Addr; use std::net::SocketAddrV4; use std::net::UdpSocket; use std::str::FromStr; use std::thread; use crate::config::Config; use crate::dns::answer::Answer; use crate::dns::header::Header; use crate::dns::message::Message; pub struct Server { pub thread: thread::JoinHandle<u8>, } impl Server {...
#[doc( brief = "Attribute parsing", desc = "The attribute parser provides methods for pulling documentation out of \ an AST's attributes." )]; import rustc::syntax::ast; import rustc::front::attr; import core::tuple; export crate_attrs, mod_attrs, fn_attrs, arg_attrs, const_attrs; export parse_crate,...
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// ScatterPlotWidgetDefinitionRequests : Widget definition. #[derive(Clone, Debug, PartialEq, Serial...
mod scheduler; pub use scheduler::WorkloadBuilder; use crate::atomic_refcell::AtomicRefCell; #[cfg(feature = "serde1")] use crate::atomic_refcell::RefMut; use crate::borrow::Borrow; use crate::entity_builder::EntityBuilder; use crate::error; #[cfg(feature = "serde1")] use crate::serde_setup::{ExistingEntities, Global...
//! # Operator Precedence Grammar Parser //! //! `opg` reads an context-free grammar input //! and outputs the precedence of the operators. mod dfs; mod table; use std::collections::HashMap; use std::collections::HashSet; use std::env; use std::fs; /// /// A struct to /// represent a production. /// struct Product...
use async_trait::async_trait; use messagebus::{ derive::{Error as MbError, Message}, error, receivers, AsyncHandler, Bus, Message, }; use thiserror::Error; #[derive(Debug, Error, MbError)] enum Error { #[error("Error({0})")] Error(anyhow::Error), } impl<M: Message> From<error::Error<M>> for Error { ...
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use crate::kty::{c_long}; pub use crate::syscall::raw::arch::asm::{ syscall0, syscall1, syscall2, syscall3, sysc...
use crypto::blake2s; use hash::{H256, H512}; #[inline] fn concat(a: &H256, b: &H256) -> H512 { let mut result = [0u8; 64]; result[0..32].copy_from_slice(a); result[32..64].copy_from_slice(b); result } pub fn merkle_root(hashes: &[H256]) -> H256 { if hashes.len() == 1 { return hashes[0].clone(); } let mut ro...
// Copyright (c) 2016, <daggerbot@gmail.com> // This software is available under the terms of the zlib license. // See COPYING.md for more information. use std::cell::RefCell; use std::rc::Rc; use std::sync::mpsc::{self, Sender, Receiver, TryRecvError}; use display::DisplayBridge; use error::{Error, Result};...
use json::JsonValue; use regex::Regex; use super::value_matchers::*; use super::{SelectionLens, SelectionLensParser}; struct Prop { name: String, value: Option<JsonValueMemberMatcher>, } impl Prop { pub fn prop_value_matches_exact<'a, 'b>( prop: &'a JsonValue, prop_value_matcher: &'b Json...
/* * Copyright 2017 Eldad Zack * * 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...
use std::collections::HashMap; use std::fs; use std::io::Error; use point::PointT; use point::PointPos; use polyomino::Polyomino; #[allow(dead_code)] pub enum Restrictions { None, SquareSymmetry, RectangularSymmetry, // SingleSided } #[allow(dead_code)] pub fn build_variations<T:PointT>(polys: &Vec<Polyo...
#[macro_use] extern crate serde_derive; mod client; mod protocol; pub use client::Client;
mod local; use clap::{ App, SubCommand, ArgMatches }; use context::Context; pub fn subcommand() -> App<'static, 'static> { SubCommand::with_name("addrs") .about("List known addresses") .subcommands(vec![ local::subcommand(), ]) } pub fn run(context: &mut Context, matches: &Ar...
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. // // @generated SignedSource<<76df3b41c55ac9a428ed15aad5841cbc>> // // To regenerate this file, run: // hphp/hack/src/oxidized/regen.s...
use serenity::framework::standard::{macros::command, Args, CommandResult}; use serenity::model::prelude::{Message, UserId}; use serenity::prelude::Context; use serenity::utils::parse_username; fn parse_id(s: String) -> Option<UserId> { let id = if s.starts_with('<') { parse_username(s)? } else { ...
#[macro_use(untyped)] extern crate untyped; use untyped::{eval, Term}; fn main() { let term = untyped! { ((λ x . 0) ((λ x . 0) (λ z . ((λ x . 0) 0)))) }; let evaluated_term = eval(&term); println!("Source term: {}", term); println!("Evaluated term: {}", evaluated_term); }
#![feature(test)] extern crate libc; extern crate test; use std::ffi::CString; use std::os::raw::c_char; #[no_mangle] pub extern fn about() -> *const c_char { let char_str = CString::new("rust_ffi").unwrap(); let ptr = char_str.as_ptr(); std::mem::forget(char_str); ptr } #[repr(C)] pub struct Foo { ...
fn main() { let numbers = [4, 65, 2, -31, 0, 99, 2, 83, 782, 1]; println!("{:?}\n", quick_sort(numbers.iter())); } fn quick_sort<T, E>(mut v: T) -> Vec<E> where T: Iterator<Item = E>, E: PartialOrd, { match v.next() { None => Vec::new(), Some(pivot) => { let (lower, h...
/*! ```rudra-poc [target] crate = "internment" version = "0.3.13" [report] issue_url = "https://github.com/droundy/internment/issues/20" issue_date = 2021-03-03 rustsec_url = "https://github.com/RustSec/advisory-db/pull/807" rustsec_id = "RUSTSEC-2021-0036" [[bugs]] analyzer = "SendSyncVariance" bug_class = "SendSync...
use std::{borrow::Cow, io, result, str::Utf8Error, string::FromUtf8Error}; use thiserror::Error; #[cfg(feature = "tokio_io")] use tokio::time::error::Elapsed; use url::ParseError; /// Clickhouse error codes pub mod codes; /// Result type alias for this library. pub type Result<T> = result::Result<T, Error>; /// Thi...
use lldb_sys as sys; use sys::{RunMode, SBErrorRef, SBThreadRef, DescriptionLevel}; use core::fmt; use std::{ffi::{CString, CStr}, os::raw::c_char, thread::{self, sleep}, time::Duration}; struct SBError { raw: SBErrorRef, } impl SBError { fn new() -> Self { SBError { raw: unsafe { sys::Cr...
use std::collections::VecDeque; pub fn brackets_are_balanced(text: &str) -> bool { if text.is_empty() { return true; } // maintain stack let mut stack = VecDeque::new(); for c in text.chars() { println!("stack : {:?} ", &stack); if c == '[' || c == '{' || c == '(' { ...
/* * Copyright Stalwart Labs Ltd. See the COPYING * 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>, at your * optio...
use std::fmt; #[derive(PartialEq, Debug)] pub enum Error { MissingLead, MissingPrefix, MissingHost, } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Error::MissingLead => write!(f, "missing lead colon"), Error::MissingP...
#![allow(dead_code)] use anyhow::{anyhow, Error}; type Num = i32; type Dim = usize; // Want to merely change the argument, think I did that right with a mutable reference? // Scalar addition of a value x to the matrix pub fn scalar_addition(v: &mut Vec<Num>, x: Num) { // For each element add x for i in v { ...
// (Full example with detailed comments in examples/17_yaml.rs) // // This example demonstrates clap's building from YAML style of creating arguments which is far // more clean, but takes a very small performance hit compared to the other two methods. use clap::{App, load_yaml}; fn main() { // The YAML file is fou...
use crate::days::day21::{FoodLine, parse_input, default_input}; use std::collections::{HashMap, HashSet}; use itertools::Itertools; pub fn run() { println!("{}", food_str(default_input()).unwrap()) } pub fn food_str(input : &str) -> Result<String, ()> { food(parse_input(input)) } pub fn food(input : Vec<Food...
use std::process; use std::io; use std::error::Error; use colored::*; use ini::Ini; mod draw_charts; use draw_charts::{save_final_chart, save_line_chart, save_cost_chart, normalize_elem}; use draw_charts::DataMM; fn read_from_csv() -> Result<(Vec<(f64, f64)>, (String, String)), Box<dyn Error>> { let mut records: Vec<...
pub mod controller; pub mod model; pub mod repository;
use super::{Coin,Inv,InvErr,InvWork,Intrinsics}; use std::collections::HashMap; use std::any::TypeId; use std::marker::Reflect; #[derive(Debug)] pub enum VendErr { Stock, Money, Inv(InvErr) } impl VendErr { fn from_inv (ie: InvErr) -> VendErr { VendErr::Inv(ie) } } #[derive(Debug)] pub struct Ve...
// Enumerate all boards which are reachable from the initial board. // // Input: none // // Output: // board depth // ... // // board: hex representation of bit-board // depth: the depth of the board // 1: winning board (the player can capture the opponent's lion) // 0: losing board (the opponent succ...
//! Logging utilities for the book data tools. //! //! This module contains support for initializing the logging infrastucture, and //! for dynamically routing log messages based on whether there is an active //! progress bar. use std::fmt::Debug; use std::marker::PhantomData; use friendly::scalar; use happylog::new_...
// This file is part of Substrate. // Copyright (C) 2017-2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // ht...
use std::ops::Add; fn read_vec() -> Vec<i32> { vec![3, 4, 6, -19] } fn vec_min<T: PartialOrd>(v: &Vec<T>) -> Option<&T> { if v.is_empty() { return None; } let mut min = Some(&v[0]); for e in v { min = min.map(|val| { if e < val { e } else { val } }); } min } fn vec...
use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CalcParam { pub machine: String, pub applicator: String, pub energy: f64, pub ssd: f64, pub depth_zref: f64, pub dose_zref: f64, pub planned_beam_mu: f64, pub fda_id: usize, } impl CalcParam...
extern crate jdbc; pub mod app; use app::zzzc::*; use jdbc::java::sql::*; use std::collections::HashMap; fn main() { let db = db::MDB::new("mysql", "127.0.0.1:3306", "root", "", "xxx").unwrap(); // exec let mut sql = "DELETE FROM log"; let bind_array = HashMap::new(); let (id_or_count, data) = d...
//! ABI decoder. use util::slice_data; use {Word, Token, ErrorKind, Error, ResultExt, ParamType}; struct DecodeResult { token: Token, new_offset: usize, } struct BytesTaken { bytes: Vec<u8>, new_offset: usize, } fn as_u32(slice: &Word) -> Result<u32, Error> { if !slice[..28].iter().all(|x| *x == 0) { return ...
#[doc = "Register `WRP1BR` reader"] pub type R = crate::R<WRP1BR_SPEC>; #[doc = "Register `WRP1BR` writer"] pub type W = crate::W<WRP1BR_SPEC>; #[doc = "Field `WRP1B_PSTRT` reader - WRP1B_PSTRT"] pub type WRP1B_PSTRT_R = crate::FieldReader; #[doc = "Field `WRP1B_PSTRT` writer - WRP1B_PSTRT"] pub type WRP1B_PSTRT_W<'a, ...
use super::*; pub struct RegisterID { rc: u32, virtual_register: VirtualRegister, is_tmp: bool, } impl RegisterID { pub fn ref_(&mut self) { self.rc += 1; } pub fn deref(&mut self) { self.rc -= 1; } pub fn rc(&self) -> u32 { self.rc } pub fn is_tmp(&se...
use nanorand::{ChaCha, RNG}; /// Create a ChaCha RNG, using the specified number of rounds #[no_mangle] pub extern "C" fn new_chacha(rounds: u8) -> ChaCha { ChaCha::new(rounds) } /// Create a ChaCha RNG, using the specified number of rounds, /// and the provided 256-bit key and 64-bit nonce #[no_mangle] pub extern "...
use crate::core::connection_string::*; pub struct ConnectionStringBuilder<'a>(ConnectionString<'a>); impl<'a> Default for ConnectionStringBuilder<'a> { fn default() -> Self { Self(ConnectionString::default()) } } impl<'a> ConnectionStringBuilder<'a> { pub fn new() -> Self { Self(Connectio...
fn main() { proconio::input! { a: i32, b: i32, } let mut plugs = 1; let mut ans = 0; while b > plugs { plugs += a - 1; ans += 1; } println!("{}", ans); }
#[doc = "Register `APB1ENR1` reader"] pub type R = crate::R<APB1ENR1_SPEC>; #[doc = "Register `APB1ENR1` writer"] pub type W = crate::W<APB1ENR1_SPEC>; #[doc = "Field `TIM2EN` reader - TIM2 timer clock enable"] pub type TIM2EN_R = crate::BitReader<TIM2EN_A>; #[doc = "TIM2 timer clock enable\n\nValue on reset: 0"] #[der...
pub fn find(haystack: &str, needle: char) -> Option<usize> { for (offset, c) in haystack.char_indices() { if c == needle { return Some(offset); } } None } pub fn find_extension_smpl(file_name: &str) -> Option<&str> { match find(file_name, '.') { None => None, ...
pub fn run() { let x = 4; let equal_to_x = |z| z == x; // Work fine as both values are equal //assert!(equal_to_x(4)); //Will be panic due to un equalilty assert!(equal_to_x(6), "My Code Error"); }
use super::context::Context; use super::error::Result; use super::types::ToDuktape; use duktape_sys::*; use std::ffi::{c_void, CString}; static KEY: &'static [u8] = b"\xFFptr"; /// A Callable is callable from js pub trait Callable { /// Specify how many arguments the function accepts fn argc(&self) -> i32 { ...
use std::collections::HashSet; use crate::solutions::Solution; use crate::util::int; pub struct Day1 {} impl Solution for Day1 { fn part1(&self, input: String) { let mut walker = Walker::new(); for (turn, magnitude) in movements(&input) { walker.turn(turn); walker.walk(ma...
// SPDX-License-Identifier: Apache-2.0 use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; use cipher_bench::{bench_block, BlockCipherAlgorithm}; use openssl::Aes128CbcCtxBuilder; use std::convert::TryInto; pub fn block_ciphers(c: &mut Criterion) { let mut group = c.benchmark_gr...
use crate::uses::*; use core::slice; use core::mem::transmute; use crate::util::misc::phys_to_virt_usize; pub mod madt; pub mod hpet; use madt::Madt; use hpet::Hpet; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum SdtType { // root system descriptor table Rsdt, // extended system descriptor table (64 bit ve...
use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize, Debug)] pub struct User { pub name: String, pub is_admin: u32, } #[derive(Serialize, Deserialize, Debug)] pub struct PostIdent { // Post ID pub id: u32, // Post Title pub title: String, // Timestamp when it was creat...
use serde::{Serialize}; use actix_web::{error, Error, HttpResponse}; use vt::types::*; pub type ActixResult = Result<HttpResponse, Error>; pub fn to_actix_result<A: Serialize>(result: MyResult<A>) -> ActixResult { match result { Ok(x) => Ok(HttpResponse::Ok().json(x)), Err(e) => Err(error::ErrorB...
#![cfg_attr(test, allow(dead_code))] extern crate lndir; use std::vec::Vec; use std::path::PathBuf; use std::env; use lndir::lndir; use lndir::options::Options; use lndir::argument_error::ArgumentError; fn parse_args() -> Result<(Options, Vec<PathBuf>, PathBuf), ArgumentError> { let mut options = Options::new(); ...
use na::{RealField, Rotation3, Unit, UnitComplex}; use crate::aliases::{TMat4, TVec2, TVec3, TVec4}; /// Build the rotation matrix needed to align `normal` and `up`. pub fn orientation<T: RealField>(normal: &TVec3<T>, up: &TVec3<T>) -> TMat4<T> { if let Some(r) = Rotation3::rotation_between(normal, up) { ...
use std::cmp::{max, min}; fn gcd(a: usize, b: usize) -> usize { match ((a, b), (a & 1, b & 1)) { ((x, y), _) if x == y => y, ((0, x), _) | ((x, 0), _) => x, ((x, y), (0, 1)) | ((y, x), (1, 0)) => gcd(x >> 1, y), ((x, y), (0, 0)) => gcd(x >> 1, y >> 1) << 1, ((x, y), (1, 1))...
use std::fmt::Debug; use std::panic::RefUnwindSafe; use serde::Deserialize; use gotham::router::builder::*; use gotham::router::Router; use receiver::{LoginHandler, Receiver, ReturnInfo}; /// Builds the subrouter for the Shibboleth-protected part of application, where new sessions will /// be received for processin...
use ast::{Ast, AstTrait}; use token::{Token, Type}; pub struct Parser { stack: Vec<Ast>, } pub trait ParserTrait { fn parse_token(&mut self, token: Token) -> bool; fn is_done(&self) -> bool; fn get_parsed_tree(&mut self) -> Option<Ast>; } impl ParserTrait for Parser { fn parse_token(&mut self, to...
//! The `par_direct` backend operates on `CompileNodes` directly in parallel use super::{JITBackend, JITResetData}; use crate::blocks::{Block, BlockEntity, BlockPos, ComparatorMode}; use crate::redpiler::{CompileNode, Link, LinkType}; use crate::world::{TickEntry, TickPriority}; use log::warn; use rayon::prelude::*; u...
use std::collections::HashMap; include!(concat!(env!("OUT_DIR"), "/english_frequencies.rs")); pub fn english(message: &str) -> bool { let expected_counts: HashMap<char, f32> = english_frequencies() .iter() .map(|(k, freq)| (k.clone() as char, (freq / 100.0) * (message.len() as f32))) .coll...
extern crate bspline; extern crate image; use std::iter; use std::ops::{Add, Mul}; #[derive(Copy, Clone, Debug)] struct Point { x: f32, y: f32, } impl Point { fn new(x: f32, y: f32) -> Point { Point { x: x, y: y } } } impl Mul<f32> for Point { type Output = Point; fn mul(self, rhs: f32...
extern crate chrono; #[macro_use] extern crate diesel; extern crate jsonrpc_core; #[macro_use] extern crate jsonrpc_macros; #[macro_use] extern crate nom; extern crate rumqtt; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate uuid; #[macro_use] extern crate failure; use ...
use crate::compiler::{Code, CompiledFunction}; use crate::ast; use std::collections::HashMap; #[derive(thiserror::Error, Debug)] #[error("running")] pub enum RunError { } #[derive(Default)] pub struct Environment { args: Vec<Evaluation>, values: HashMap<ast::Name, Evaluation>, } pub struct Tables<'compiler...
// This file is part of Substrate. // Copyright (C) 2017-2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the F...
pub fn test() -> String { "asdf".to_string() }
use tui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, text::Span, text::Spans, widgets::{Block, Borders, List, ListItem, ListState, Paragraph}, Frame, Terminal, }; use crate::{model::Post, model::PostView, state::State}; use anyhow::Res...
use std::ops; pub type Variable = u32; #[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Debug, Hash)] pub struct Literal { x: u32, } impl Literal { pub fn new(variable: Variable, signed: bool) -> Literal { Literal { x: variable << 1 | (signed as u32), } } /// Returns...
use DataHelper; #[derive(Default, System)] #[process(update)] pub struct AudioUpdate; fn update(_: &mut AudioUpdate, data: &mut DataHelper) { data.services .audio .studio .update() .expect("FMOD Studio updating shouldn't fail"); }
#[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { _reserved0: [u8; 64usize], #[doc = "0x40 - RTC Counters Lower"] pub ctrlow: CTRLOW, #[doc = "0x44 - RTC Counters Upper"] pub ctrup: CTRUP, #[doc = "0x48 - RTC Alarms Lower"] pub almlow: ALMLOW, #[doc = "0x4c - RTC Alarms U...
pub use std::collections::HashMap; pub use std::boxed::Box; pub use std::string::ToString; #[macro_export] macro_rules! json { (null) => { $crate::Json::Null }; ([ $( $element:tt ),* ]) => { $crate::Json::Array(vec![ $( json!($element) ),* ]) }; ({ $( $key:tt : $value:tt ),* }) => {...
//! Components for constructing HTTP applications. pub mod concurrency; pub mod config; pub mod path; mod recognizer; mod scope; mod service; #[cfg(test)] mod tests; pub(crate) use self::recognizer::Captures; pub use self::{ config::{Error, Result}, service::{AppBody, AppService}, }; use { self::{ ...
extern crate julia; use julia::Julia; // TODO: This is absolute garbage. #[test] fn init_works() { let jl = Julia::new("/Applications/Julia-0.5.app/Contents/Resources/julia/lib"); assert!(true) }
// Copyright © 2020, Oracle and/or its affiliates. // // Copyright (c) 2019 Intel Corporation. All rights reserved. // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // // Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license ...
use cocoa::base::{class, id}; use cocoa::foundation::NSUInteger; use objc::runtime::BOOL; use {MTLCPUCacheMode, MTLPixelFormat, MTLResourceOptions, MTLStorageMode, MTLTextureType, MTLTextureUsage}; /// A `MTLTextureDescriptor` object is used to configure new texture objects. /// /// A `MTLTexture` object is speci...
use sys_consts::options::*; use crate::uses::*; use crate::cap::CapFlags; use crate::sysret; use crate::syscall::{SysErr, SyscallVals}; use super::{VirtRange, PAGE_SIZE}; use super::phys_alloc::zm; use super::virt_alloc::{AllocType, PageMappingFlags, VirtLayout, VirtLayoutElement}; use super::shared_mem::*; use super:...
use aoc_utils::read_file; use day03::Claim; use day03::CLAIM_REGEX; use std::collections::HashMap; fn main() { if let Ok(contents) = read_file("./input") { let result: i32 = contents .lines() .filter_map(|line| { if let Some(caps) = CLAIM_REGEX.captures(line) { ...
use rand::prelude::*; use std::fmt; use std::slice::Iter; #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Suit { SPADE, DIAMOND, CLUB, HEART, } #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Rank { ACE = 1, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NIN...
pub mod consumer; pub mod consumer_to_game; pub mod consumer_structs;
use rusqlite::functions::{Aggregate, Context, FunctionFlags}; use rusqlite::types::ValueRef; use rusqlite::{Connection, Result}; use stats::OnlineStats; pub(crate) fn add_udfs(connection: &Connection) -> Result<()> { connection.create_scalar_function( "md5", 1, FunctionFlags::SQLITE_UTF8 | ...
#![no_std] #![cfg_attr(docsrs, feature(doc_cfg))] #![doc = include_str!("../README.md")] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg" )] #![warn(missing_docs, rust_2018_idioms, ...
use std::env; use std::path::Path; use anyhow::*; /// Read the input file for the current day's puzzle, i.e. `input/dayxx.txt`, and return its content as a String. pub fn input_string() -> Result<String> { let executable_name = env::args_os() .next() .ok_or(format_err!("no executable name?"))?; ...
use super::*; #[pymethods] impl EnsmallenGraph { #[text_signature = "(self, name)"] /// Set the name of the graph. /// /// Parameters /// ----------------------- /// name: str, /// Name of the graph. fn set_name(&mut self, name: String) { self.graph.set_name(name) } ...
#[doc = "Reader of register PWR_CR1"] pub type R = crate::R<u32, super::PWR_CR1>; #[doc = "Writer for register PWR_CR1"] pub type W = crate::W<u32, super::PWR_CR1>; #[doc = "Register PWR_CR1 `reset()`'s with value 0"] impl crate::ResetValue for super::PWR_CR1 { type Type = u32; #[inline(always)] fn reset_va...
use quote::quote_spanned; use super::{ FlowProperties, FlowPropertyVal, OperatorCategory, OperatorConstraints, OperatorInstance, OperatorWriteOutput, WriteContextArgs, RANGE_0, RANGE_1, }; /// > 1 input stream, 0 output streams /// /// > Arguments: a Rust closure /// /// Iterates through a stream passing each...
pub mod new_game; use self::new_game::*; use crate::{components::animal_kind::AnimalKind, utils::rgba_to_raui_color}; use oxygengine::user_interface::raui::core::prelude::*; #[pre_hooks(use_nav_container_active)] pub fn menu(mut context: WidgetContext) -> WidgetNode { let WidgetContext { key, .. } = context; ...
use gfx; use super::pipeline::*; use collision; pub struct ChunkObject<R: gfx::Resources> { pub data: pipe::Data<R>, pub slice: gfx::Slice<R>, pub position: [f32; 3], pub bounds: collision::Aabb3<f32>, pub cubes: usize, pub vertices: usize, pub triangles: usize, }
#[doc = "Register `ETH_MACLETR` reader"] pub type R = crate::R<ETH_MACLETR_SPEC>; #[doc = "Register `ETH_MACLETR` writer"] pub type W = crate::W<ETH_MACLETR_SPEC>; #[doc = "Field `LPIET` reader - LPIET"] pub type LPIET_R = crate::FieldReader<u32>; #[doc = "Field `LPIET` writer - LPIET"] pub type LPIET_W<'a, REG, const ...