text stringlengths 8 4.13M |
|---|
#![deny(warnings, unused_must_use)]
extern crate log;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use structopt::StructOpt;
use zircon_loader::*;
use zircon_object::object::*;
#[derive(Debug, StructOpt)]
#[structopt()]
struct Opt {
#[structopt(parse(from_os_str))]
prebuilt_path: PathBuf,
#[struc... |
use std::borrow::Cow;
use std::convert::TryFrom;
#[cfg(feature = "sender")]
use crate::sender;
pub struct Uri<'a> {
pub(crate) address: bitcoin::Address,
pub(crate) amount: bitcoin::Amount,
pub(crate) endpoint: Cow<'a, str>,
pub(crate) disable_output_substitution: bool,
}
impl<'a> Uri<'a> {
pub fn... |
pub fn inverse(self) -> Self {{
let high_bits = (self.bits & ({low_bits})) << 1;
let low_bits = (self.bits & ({high_bits})) >> 1;
let same_bits = self.bits & ({same_bits});
{type_name} {{ bits: low_bits | high_bits | same_bits}}
}}
|
use std::io::Write;
use std::io;
use std::io::prelude::*;
use std::rc::Rc;
use std::env;
use std::fs::File;
mod tokenizer;
mod parser;
mod builtins;
mod interpreter;
macro_rules! perror(
($($arg:tt)*) => { {
writeln!(&mut ::std::io::stderr(), $($arg)*).expect("failed printing to stderr");
} }
);
fn process_line... |
use super::bbox::BBox;
use crate::{
geo::{collection::Mesh, HitTemp},
linalg::{Ray, Vct},
Flt,
};
#[derive(Clone, Debug)]
pub struct Node {
pub bbox: BBox,
pub data: Data,
}
#[derive(Clone, Debug)]
pub enum Data {
A(usize, usize, usize, Flt), // l, r, dim, key
B(Vec<usize>),
}
#[derive(Cl... |
//! Syntax
pub mod ast;
pub mod codemap;
pub mod parse;
pub mod pp;
use syntax::codemap::Spanned;
/// A spanned error
pub type Error = Spanned<Error_>;
/// Syntax error
#[derive(Clone, Copy, Debug)]
pub enum Error_ {
/// Only a single expression is expected per line. `(+ 1 2) 3` is an error
ExpectedEndOfLin... |
use crate::database::{Database, HasArguments, HasStatement, HasStatementCache, HasValueRef};
use crate::postgres::arguments::PgArgumentBuffer;
use crate::postgres::value::{PgValue, PgValueRef};
use crate::postgres::{
PgArguments, PgColumn, PgConnection, PgQueryResult, PgRow, PgStatement, PgTransactionManager,
P... |
use crossbeam::queue::SegQueue;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use crate::global::*;
use crate::object::Point;
use std::sync::atomic::Ordering::{Relaxed, SeqCst};
use crate::calculation::common_step::step;
type Work = (usize, usize);
type DataPtr = Arc<SharedData>;
struct SharedData {
queu... |
#[cfg(test)]
mod test {
use crate::data_structures::directed_graph::DirectedGraph;
#[test]
fn straight_line() {
let mut foo = DirectedGraph::with_nodes(4);
foo.add_edge(0, 1, 1);
foo.add_edge(1, 2, 1);
foo.add_edge(2, 3, 1);
assert_eq!(foo.distance(0, 1), 1);
... |
use super::*;
pub enum ConstantValue {
Bool(bool),
U8(u8),
I8(i8),
U16(u16),
I16(i16),
U32(u32),
I32(i32),
U64(u64),
I64(i64),
F32(f32),
F64(f64),
String(String),
TypeDef(TypeDef),
}
impl ConstantValue {
pub fn unwrap_u32(&self) -> u32 {
match self {
... |
extern crate random_access_disk as rad;
extern crate random_access_storage;
extern crate tempfile;
use random_access_storage::RandomAccess;
use tempfile::Builder;
#[test]
fn can_call_new() {
let dir = Builder::new()
.prefix("random-access-disk")
.tempdir()
.unwrap();
let _file = rad::RandomAccessDisk:... |
#[doc = "Reader of register MDIOS_DINR2"]
pub type R = crate::R<u32, super::MDIOS_DINR2>;
#[doc = "Reader of field `DIN2`"]
pub type DIN2_R = crate::R<u16, u16>;
impl R {
#[doc = "Bits 0:15 - Input data received from MDIO Master during write frames"]
#[inline(always)]
pub fn din2(&self) -> DIN2_R {
... |
use crate::{
marker_type::{ErasedObject, NonOwningPhantom},
sabi_types::{RMut, RRef},
std_types::{RNone, ROption, RSome, RVec, Tuple2},
traits::IntoReprC,
utils::Transmuter,
};
///////////////////////////////////////////////////////////////////////////////////
#[repr(C)]
#[derive(StableAbi)]
pub s... |
//! Binary clauses.
use partial_ref::{partial, PartialRef};
use varisat_formula::Lit;
use varisat_internal_proof::{DeleteClauseProof, ProofStep};
use crate::{
context::{parts::*, Context},
proof,
};
/// Binary clauses.
#[derive(Default)]
pub struct BinaryClauses {
by_lit: Vec<Vec<Lit>>,
count: usize... |
use super::icon;
use std::fs::File;
use std::path::Path;
use std::path::PathBuf;
#[test]
fn load_dmi() {
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/load_test.dmi");
let path = Path::new(&path);
let file = File::open(&path).unwrap_or_else(|_| panic!("No lights dmi: {:?}", path));
le... |
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
time::Duration,
};
use futures_core::ready;
use pin_project_lite::pin_project;
use tokio::sync::oneshot;
use crate::{
actor::Actor,
clock::{sleep, Sleep},
fut::{ActorFuture, ActorStream},
};
#[deprecated(
since = "0.11.0",
... |
use proconio::input;
fn main() {
input! {
n: usize,
x: [usize; n],
c: [u64; n],
};
let mut seen = vec![false; n];
let mut ans = 0;
for v in 0..n {
if seen[v] {
continue;
}
let mut route = Vec::new();
let mut v = v;
while !... |
//mod system_stat;
// mod regex_trials;
mod mover;
fn main() {
// system_stat::system_stat();
// regex_trials::regex_em();
mover::mover();
}
|
// Should display error about no main.
mod no_main_mod;
// Not sure why no-trans doesn't handle this properly.
// end-msg: ERR(check) main function not found
// end-msg: NOTE(check) the main function must be defined
// end-msg: MSG(check) Note: no_main_mod.rs:1
|
//! Linux auxv support.
//!
//! # Safety
//!
//! This uses raw pointers to locate and read the kernel-provided auxv array.
#![allow(unsafe_code)]
use crate::backend::c;
use crate::backend::elf::*;
use crate::fd::OwnedFd;
#[cfg(feature = "param")]
use crate::ffi::CStr;
use crate::fs::{Mode, OFlags};
use crate::utils::{... |
#[doc = "Reader of register MPCBB1_VCTR49"]
pub type R = crate::R<u32, super::MPCBB1_VCTR49>;
#[doc = "Writer for register MPCBB1_VCTR49"]
pub type W = crate::W<u32, super::MPCBB1_VCTR49>;
#[doc = "Register MPCBB1_VCTR49 `reset()`'s with value 0"]
impl crate::ResetValue for super::MPCBB1_VCTR49 {
type Type = u32;
... |
//! Simple consensus runtime.
use std::collections::BTreeMap;
use oasis_runtime_sdk::{self as sdk, modules, types::token::Denomination, Version};
pub mod runtime;
/// Simple consensus runtime.
pub struct Runtime;
impl sdk::Runtime for Runtime {
const VERSION: Version = sdk::version_from_cargo!();
type Modu... |
use super::cubic_path::CubicPath;
use super::design_space::{DPoint, DVec2, ViewPort};
use super::hyper_path::{HyperPath, HyperSegment, HYPERBEZ_LIB_VERSION_KEY};
use super::point::{EntityId, PathPoint};
use super::point_list::{PathPoints, RawSegment};
use druid::kurbo::{
Affine, BezPath, Line, LineIntersection, Par... |
extern crate cassandra;
use cassandra::*;
struct Pair<'a> {
key: &'a str,
value: i32,
}
const CONTACT_POINTS:&'static str = "127.0.0.1";
static CREATE_KEYSPACE:&'static str = "CREATE KEYSPACE IF NOT EXISTS examples WITH replication = { \
\'class\': \'SimpleStrategy\', \... |
//! A DEFLATE-based stream compression/decompression library
//!
//! This library is meant to supplement/replace the
//! `flate` library that was previously part of the standard rust distribution
//! providing a streaming encoder/decoder rather than purely
//! an in-memory encoder/decoder.
//!
//! Like with [`flate`], ... |
//! Fork of the Arrow Rust FlightSQL client
//! <https://github.com/apache/arrow-rs/tree/master/arrow-flight/src/sql/client.rs>
//!
//! Plan is to upstream much/all of this to arrow-rs
//! see <https://github.com/apache/arrow-rs/issues/3301>
// Licensed to the Apache Software Foundation (ASF) under one
// or more cont... |
macro_rules! check_roundtrip {
(
$funcs:ident,
$initial_int:expr,
($($ret_val:ident=$composite:expr),* $(,)*),
$ret_fn:ident,
$take_fn:ident
$(,)*
) => {
#[allow(unused_parens)]
{
let res=($funcs.$ret_fn)($initial_int);
let composi... |
/// Packed points within a Tuple Variation Store
use otspec::types::*;
use otspec::{deserialize_visitor, read_field, read_field_counted};
use serde::de::SeqAccess;
use serde::de::Visitor;
use serde::ser::SerializeSeq;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
/// An array of packed points
///
/// ... |
// 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 ... |
pub mod vim_help;
use paths::truncate_absolute_path;
use std::fs::File;
use std::io::Read;
use std::path::Path;
use utils::bytelines::ByteLines;
use utils::read_first_lines;
/// Preview of a file.
#[derive(Clone, Debug)]
pub struct FilePreview {
/// Line number of source file at which the preview starts (exclusiv... |
use std::path::PathBuf;
pub fn download(steamcmd_path: &PathBuf) {
std::fs::create_dir_all(steamcmd_path.parent().unwrap()).unwrap();
let response = reqwest::blocking::Client::new().get({
#[cfg(windows)] {
"https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip"
}
#[cfg(unix)] {
"https://steamcdn... |
extern crate reqwest;
fn fetch_text(url: &str) -> Result<(String), reqwest::Error> {
let body = reqwest::get(url)?
.text()?;
Ok(body)
}
fn main() {
let result = fetch_text("https://www.rust-lang.org");
let count = result.unwrap();
println!("{}", count);
}
|
use buffer;
use error;
use image;
use memory;
use MemoryRequirements;
/// Trait for resource creation, memory allocation and mapping.
pub trait Device: memory::Device + Sized {
/// Image sampler.
type Sampler: 'static;
/// Buffer type that can be used with this device.
/// `UnboundedBuffer` can be con... |
// 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 ... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless ... |
use crate::{HdbError, HdbResult, HdbValue};
use bigdecimal::{BigDecimal, Zero};
use byteorder::{ByteOrder, LittleEndian};
use num_bigint::{BigInt, Sign};
use serde_db::ser::SerializationError;
// MANTISSA 113-bit Integer mantissa
// (byte 0; byte 14, lowest bit)
// EXPONENT 14-bit... |
#[doc = "Reader of register PP"]
pub type R = crate::R<u32, super::PP>;
#[doc = "Maximum Conversion Rate\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum MCR_A {
#[doc = "7: Full conversion rate (FCONV) as defined by TADC and NSH"]
FULL = 7,
}
impl From<MCR_A> for u8 {
#[... |
// An "interner" is a data structure that associates values with uint tags and
// allows bidirectional lookup; i.e. given a value, one can easily find the
// type, and vice versa.
import std::ivec;
import std::map;
import std::map::hashmap;
import std::map::hashfn;
import std::map::eqfn;
import std::option;
import std:... |
mod url_array_validator;
pub use self::url_array_validator::validate_urls;
use validator::*;
pub fn append_validation_error(
validation_errors: Result<(), ValidationErrors>,
field: &'static str,
validation_error: Result<(), ValidationError>,
) -> Result<(), ValidationErrors> {
if let Err(validation_er... |
// Definition for a binary tree node.
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
#[inline]
pub fn new(val: i32) -> Self {
TreeNode {
val,
lef... |
#![allow(dead_code, collapsible_if)]
#![allow(trivial_casts, trivial_numeric_casts)]
use super::root::*;
use mask::*;
use mask::masks::*;
use side::*;
use piece::*;
use castle;
use color::*;
bitflags! {
pub struct Assessment: u32 {
const VALID = 0 ;
const HAS_NO_WHITE_KING = 1;
const HAS_... |
mod with_big_integer_dividend;
mod with_small_integer_dividend;
use proptest::prop_assert_eq;
use proptest::strategy::{BoxedStrategy, Just};
use liblumen_alloc::erts::exception;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::*;
use crate::erlang::rem_2::result;
use crate::runtim... |
use std::io;
fn main() {
println!("Welcome to Dhrumil's epic Armstrong number verifier.");
println!("My regards go to Brigadier General Armstrong and Edward Elric.");
loop {
println!("Please input the Armstrong number you'd like to verify.");
let mut str_number = String::ne... |
use aoc_runner_derive::{aoc, aoc_generator};
#[aoc_generator(day1)]
pub fn gen(input: &str) -> Vec<i32> {
input.lines().map(|l| l.parse::<i32>().unwrap()).collect()
}
#[aoc(day1, part1)]
pub fn solve_part1(input: &Vec<i32>) -> i32 {
let mut i = 0;
while i < input.len() - 1 {
let mut j = i + 1;
... |
pub mod prelude {
pub use climer::Timer;
pub use deathframe::handles::SpriteSheetHandles;
pub use super::best_time::BestTime;
pub use super::checkpoint::{CheckpointData, CheckpointRes};
pub use super::insert_resources;
pub use super::player_deaths::PlayerDeaths;
pub use super::reset_level::... |
extern crate rucaja;
extern crate tinkerpop_rs;
use rucaja::{Jvm, JvmAttachment, JvmString};
use tinkerpop_rs::graph::Graph;
fn main() {
// The class path must contain the fat JAR.
let class_path = "-Djava.class.path=../java/build/libs/tinkerpop.jar";
let jvm_options = [class_path];
// Instantiate... |
pub mod mutations;
pub mod queries;
pub mod service;
use super::datastore::prelude::*;
use chrono::prelude::*;
use juniper::ID;
#[derive(juniper::GraphQLObject)]
#[graphql(description = "Independent project")]
pub struct Project {
id: ID,
/// project name
name: String,
/// project description
desc... |
//! # Note
//! This is a 'cat' program based on Rust.
//! @auhtor: Mrbanana
//! @date: 2021-7-25
//! @license: The MIT License
//!
//! Usage:
//!
//! ```bash
//! rust-cat [files ...]
//! ```
//!
//! # Knowledge you will learn
//! - How to read a file in Rust
//! - How to get argv[] from enviroment variable
... |
use hal::register::Register;
pub enum Mode {
Input,
Output,
Alternate,
Analog
}
pub enum PullUpPullDown {
None,
PullUp,
PullDown,
}
pub struct Port {
moder: Register<u32>,
otyper: Register<u32>,
ospeedr: Register<u32>,
pupdr: Register<u32>,
idr: Register<u32>,
odr:... |
use crate::{
resource::Resource,
scheme::{Gemini, Http, Https, Log, Null, Random, Zero},
*,
};
use log::debug;
use std::cell::RefCell;
use std::io::{Read, Write};
use url::Url;
use wasmer_runtime::{Array, Ctx, WasmPtr};
pub fn open(ctx: &mut Ctx, ptr: WasmPtr<u8, Array>, len: u32) -> Result<i32, error::Err... |
//! Read information about the operating system from `/proc`.
use std::collections::HashMap;
use std::fs;
use std::io::{Error, ErrorKind, Result};
use std::str::FromStr;
use std::{thread, time};
use PID;
#[derive(Debug)]
pub struct VirtualMemory {
/// Amount of total memory
pub total: u64,
/// Amount of... |
use std::ops::Range;
use candy_frontend::position::Offset;
use enumset::{EnumSet, EnumSetType};
use lazy_static::lazy_static;
use lsp_types::{Position, SemanticToken, SemanticTokensLegend};
use rustc_hash::FxHashMap;
use strum::IntoEnumIterator;
use strum_macros::EnumIter;
use crate::utils::range_to_lsp_range_raw;
#... |
use core::fmt;
use pins;
use spin;
use svd;
const BAUDRATE_9600_BAUD: u32 = 0x00275000;
const UART_ENABLE: u32 = 0x00000004;
lazy_static! {
pub static ref SERIAL: spin::Mutex<Serial> = spin::Mutex::new(Serial::new());
}
pub struct Serial();
impl Serial {
fn new() -> Serial {
unsafe {
pin... |
// 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... |
extern crate day04;
use std::io;
use std::io::BufRead;
use day04::is_valid_passphrase;
fn main() {
let stdin = io::stdin();
let handle = stdin.lock();
let mut count = 0;
for line in handle.lines() {
match line {
Ok(line) => {
if is_valid_passphrase(line) {
... |
use super::circular_unit::CircularUnit;
use super::faction::Faction;
use super::unit::Unit;
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)]
pub enum Type {
Unknown = -1,
MagicMissile = 0,
FrostBolt = 1,
Fireball = 2,
Dart = 3,
Count = 4,
}
#[derive(Clone, Debug, PartialEq)]
pub s... |
// 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 ... |
// ar_enb: LTE eNodeB implementation in Rust
#[allow(dead_code)]
#[allow(non_snake_case)]
#[allow(unused_variables)]
#[allow(non_upper_case_globals)]
#[allow(unused_imports)]
extern crate ngr;
// use ngr::rrc;
// use ngr::pdcp;
// use ngr::phy;
use ngr::security::*;
fn main() {
// let mut l1 = phy::PhysicalLaye... |
use crate::clist::*;
use crate::mailimf_types::*;
use crate::x::*;
pub const STATE_WORD: libc::c_uint = 1;
pub const STATE_SPACE: libc::c_uint = 2;
pub const STATE_BEGIN: libc::c_uint = 0;
/*
mailimf_string_write writes a string to a given stream
@param f is the stream
@param col (* col) is the column number w... |
use std::fs::File;
use xmltree::Element;
fn main() -> Result<(), anyhow::Error> {
let data: &'static str = r##"
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<names>
<name first="bob" last="jones" />
<name first="elizabeth" last="smith" />
</names>
"##;
let mut names_element = Element::parse... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtWidgets/qstatusbar.h
// dst-file: /src/widgets/qstatusbar.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begi... |
use serde::{Serialize, Deserialize, Deserializer};
use serde::de::Visitor;
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct NBT(nbt::Blob);
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct GZIPNBT(nbt::Blob);
|
use near_sdk::{json_types::U128, AccountId};
use near_sdk::{serde_json::json, PendingContractTx};
use near_sdk_sim::*;
use oysterpack_near_stake_token::domain::{Gas, YoctoNear};
use oysterpack_near_stake_token::interface::StakeAccount;
use oysterpack_near_stake_token::near::NO_DEPOSIT;
pub fn owner_id(contract_account... |
use std::ops;
use channel::ChannelFormatCast;
pub trait ColorChannel {
type Format: Clone + PartialEq + PartialOrd + Default + ops::Add<Self::Format, Output = Self::Format> + ops::Sub<Self::Format, Output = Self::Format>;
type Scalar;
type Tag;
fn min_bound() -> Self::Format;
fn max_bound() -> Sel... |
extern crate image;
extern crate num;
extern crate graphics;
use image::ImageDecoder;
use std::fmt;
use std::env;
use std::error;
use std::fs::File;
fn main() {
println!("editing an image");
match run_app() {
Ok(()) => println!("ran successfully"),
Err(err) => println!("error: {} (reason: {}... |
///! "Interface" tests for pin store, maybe more later
use crate::repo::DataStore;
use std::path::PathBuf;
use std::sync::Arc;
use tempfile::TempDir;
pub struct DSTestContext<T> {
#[allow(dead_code)]
tempdir: TempDir,
datastore: Arc<T>,
}
impl<T: DataStore> DSTestContext<T> {
/// Create the test conte... |
use crate::utils::StatefulList;
use crate::todo::{ Todo, TodoData };
pub struct TodoList {
pub items: StatefulList<Todo>
}
impl<'a> TodoList {
pub fn new(data: TodoData) -> TodoList {
TodoList {
items: StatefulList::with_items(data.todos)
}
}
}
|
#[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::RCGCTIMER {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R... |
pub mod file;
pub mod array;
pub mod class; |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Flash Memory Address"]
pub fma: FMA,
#[doc = "0x04 - Flash Memory Data"]
pub fmd: FMD,
#[doc = "0x08 - Flash Memory Control"]
pub fmc: FMC,
#[doc = "0x0c - Flash Controller Raw Interrupt Status"]
pub fcris: ... |
// 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 (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
pub mod helper;
pub mod storage;
pub mod transactions;
|
fn inplace_swap(x: &mut i32, y: &mut i32) {
*y = *x ^ *y; // 第一步
*x = *x ^ *y; // 第二步
*y = *x ^ *y; // 第三步
}
|
extern crate monkey;
use std::vec;
use monkey::evaluator::*;
use monkey::lexer::*;
use monkey::object::*;
use monkey::parser::*;
#[test]
fn test_eval_integer_expression() {
let tests = vec -> Result<()> {
codegen::run()?;
Ok(())
}
|
use super::{utils::FiberIdExtension, PausedState};
use crate::{
database::Database,
debug_adapter::{
session::StartAt1Config,
tracer::{DebugTracer, StackFrame},
utils::FiberIdThreadIdConversion,
},
utils::{module_to_url, LspPositionConversion},
};
use candy_frontend::{ast_to_hir:... |
use rustc_semver::RustcVersion;
macro_rules! msrv_aliases {
($($major:literal,$minor:literal,$patch:literal {
$($name:ident),* $(,)?
})*) => {
$($(
pub const $name: RustcVersion = RustcVersion::new($major, $minor, $patch);
)*)*
};
}
// names may refer to stabilized feature ... |
mod climsg;
mod filetarget;
mod kmp;
mod maketarget;
mod target;
mod tmaster;
use crate::climsg::CliMsg;
fn print_todo() {
let msg = CliMsg::new(
"TO-DO",
vec![
">consider creating a menu that allows you",
"to pick in what order makefiles get compiled",
">maybe ... |
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
mod account;
mod agent;
mod asset;
#[macro_use]
mod macros;
mod mission_control;
mod rate;
|
use super::base::Base;
use super::traits::get::Get;
use super::traits::delete::Delete;
use super::traits::edit::Edit;
pub struct Done {
pub super_struct: Base
}
impl Done {
pub fn new(input_title: String) -> Done {
let input_status: String = String::from("done");
let base: Base = Base::new(input_title, in... |
// Standard library
use std::sync::{Arc, Mutex};
use crate::collections::BaseRegistry;
use crate::config::Config;
use crate::exts::LockIt;
use crate::signals::poll::PollQuery;
use crate::signals::{Signal, SignalEvent, SignalEventShared, SignalOrderCurrent, UserSignal};
use anyhow::Result;
use delegate::delegate;
use ... |
fn main() {
println!("{}", lpf(600851475143));
}
fn lpf(mut x: u64) -> u64 {
let mut largest_prime = 2;
while x > largest_prime {
if x % largest_prime == 0 {
x = x / largest_prime;
largest_prime = 2;
} else {
largest_prime += 1;
}
}
lar... |
use error::{Error, ErrorKind, Result};
use serde::ser::{self, Serialize};
struct PrimitiveSerializer {
result: String,
}
pub fn serialize_primitive<T: Serialize>(v: T) -> Result<String> {
let mut serializer = PrimitiveSerializer::new();
v.serialize(&mut serializer)?;
Ok(serializer.result)
}
impl Prim... |
use futures_03::prelude::*;
use log::{error, info};
use nix::unistd::close;
use std::io::Error;
use std::net::SocketAddr;
use std::os::unix::io::FromRawFd;
use std::os::unix::io::RawFd;
use std::result::Result;
use stream_cancel::{Trigger, Tripwire};
use tokio::sync::mpsc::UnboundedSender;
// use nix::sys::socket::{shu... |
pub use crate::error::Error;
pub mod clickhouse;
pub mod error;
pub mod export;
pub mod geom;
pub trait Named {
fn name(&self) -> &'static str;
}
|
// 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 ... |
use itertools::*;
use utils::Vector2;
// #[test]
pub fn run() {
let input = read_input1(include_str!("input/day13.txt"));
println!("{}", exercise_1(&input));
println!("{}", exercise_2(&input.1));
}
pub fn read_input1(input: &str) -> (usize, Vec<Option<usize>>) {
let mut lines = input.lines();
let... |
//! This is documentation for the `ftp` module.
//! `ftp` module includes all necessary functionnalities to manage ftp connections.
extern crate regex;
use super::utils::Configuration;
use std::net::{SocketAddr,TcpStream, Shutdown};
use std::io::{Read,Write};
use std::str;
use self::regex::Regex;
/// Struct represe... |
// Defines the action requested from the database server.
// Is documented as Message Type.
// Irrelevant RequestTypes (abap related, "reserved" stuff) are omitted.
#[derive(Copy, Clone, Debug)]
pub enum RequestType {
ExecuteDirect = 2, // Directly execute SQL statement
Prepare = 3, // Prepare an SQ... |
use std::collections::VecDeque;
use input_i_scanner::InputIScanner;
use join::Join;
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.s... |
use crate::{AST, FALSE, TRUE};
fn numeric_op(lhs: AST, rhs: AST, f: fn(i64, i64) -> i64) -> Result<AST, String> {
match (lhs, rhs) {
(AST::Const(l), AST::Const(r)) => Ok(AST::Const(f(l, r))),
(_, _) => Err("type error".to_string()),
}
}
fn unpack2(mut args: Vec<AST>) -> Result<(AST, AST), Stri... |
pub mod utilities;
use crate::utilities::Verify;
use proffer::*;
#[test]
fn basic_gen() {
let tr8t = Trait::new("Foo").set_is_pub(true).to_owned();
let expected = r#"
pub trait Foo
{
}
"#;
let src_code = tr8t.generate_and_verify();
println!("{}", &src_code);
assert_eq... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type IWebAccountProviderBaseReportOperation = *mut ::core::ffi::c_void;
pub type IWebAccountProviderOperation = *mut ::core::ffi::c_void;
pub type IWebAccou... |
pub mod squaring
{
pub mod sub_squaring
{
pub fn square(input_1:u32)
{
println!("Square of the {} is: {}",input_1,input_1*input_1 );
}
}
} |
use std::collections::HashMap;
use std::hash::{Hasher, Hash};
use std::rc::Rc;
use std::fmt;
use crate::class_file::unvalidated;
use crate::class_file::unvalidated::ConstantIdx;
use crate::class_file::unvalidated::{ClassFile as UnvalidatedClassFile};
use crate::virtual_machine::VMError;
use crate::virtual_machine::VM... |
#![cfg_attr(not(feature = "std"), no_std)]
use ink_lang as ink;
pub use self::meeting::Meeting;
#[ink::contract]
mod meeting {
use template::TemplateTrait;
use nfticket::NfticketTrait;
use ink_env::call::FromAccountId;
use ink_prelude::vec::Vec;
use primitives::{Meeting as MeetingStruct, MeetingEr... |
use std::process::Command;
pub fn run_cmd() {
let output = Command::new("bash")
.arg("-c")
.arg("ls /home/susilo")
.output()
.expect("gagal menjalankan proses");
println!("{}", String::from_utf8_lossy(&output.stdout));
} |
use std::cmp::Ordering;
use std::fmt::{Display, Formatter, Result};
pub enum Value {
NONE,
ANY,
TRUE,
FALSE,
}
pub struct Hypothesis {
pub len: usize,
pub values: Vec<Value>,
}
pub struct Data {
pub len: usize,
pub values: Vec<bool>,
pub result: bool,
}
impl Data {
pub fn new() -> Self {
Dat... |
extern crate oxygengine_core as core;
pub mod animation;
pub mod curve;
pub mod phase;
pub mod spline;
pub mod transition;
pub mod prelude {
pub use crate::animation::*;
pub use crate::curve::*;
pub use crate::phase::*;
pub use crate::spline::*;
pub use crate::transition::*;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.