blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
98780179b2160eb518b27d98720eec9a10e7e0da | Rust | blt/bitintr | /src/alg/x86/bmi/tzcnt.rs | UTF-8 | 1,096 | 3.53125 | 4 | [
"MIT"
] | permissive | use int::Int;
/// Counts the number of trailing least significant zero bits.
///
/// When the source operand is 0, it returns its size in bits.
///
/// This is equivalent to searching for the least significant set bit and
/// returning its index.
///
/// **Keywords**: Count trailing zeros, Bit scan forward, find first... | true |
88c06c6a83d74b874e86621827abbf28a84a88bd | Rust | katoozi/rust-practices | /loops/src/main.rs | UTF-8 | 977 | 3.8125 | 4 | [
"Unlicense"
] | permissive | fn main() {
let mut x = 1024;
loop {
if x < 0 {
break;
}
println!("{} more runs to go", x);
x -= 1;
}
let a: u32 = 10;
let b: u32 = 4;
let result = silly_sub(a, b);
println!("{} - {} = {}", a, b, result);
// while loop
let mut x2 = 1... | true |
cf814ae0c537d30b71ce6d0774169be0eca28c46 | Rust | apllodb/apllodb | /apllodb-storage-engine-interface/src/rows/row_schema.rs | UTF-8 | 1,495 | 2.671875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::collections::HashSet;
use apllodb_shared_components::{RPos, Schema};
use crate::table_column_name::TableColumnName;
use sorted_vec::SortedSet;
/// Schema of [Row](crate::Row)s holding pairs of (RowPos, TableColumnName).
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub struct RowSchema(Sort... | true |
16b238977bc50d2e12728d597775a0c2878ecc35 | Rust | dylanblokhuis/wp-pkg | /src/db.rs | UTF-8 | 4,895 | 2.65625 | 3 | [
"MIT"
] | permissive | use mysql::{prelude::Queryable, Pool, PooledConn, Row};
use regex::{Captures, Regex};
use std::fs;
struct Table {
sql: String,
name: String,
insert: String,
}
pub fn dump(
dump_destination: &str,
db_url: &str,
current_domain: Option<&String>,
new_domain: Option<&String>,
) -> Result<(), mys... | true |
63dae2ab9327286251dbf80db77cc42cfdd86d45 | Rust | inv2004/coinbase-pro-rs | /src/utils.rs | UTF-8 | 3,142 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use serde::de::{self, Visitor};
use serde::{Deserialize, Deserializer};
use std::fmt;
use std::str::FromStr;
use uuid::Uuid;
use chrono::{Utc};
struct F64InQuotes;
impl<'de> Visitor<'de> for F64InQuotes {
type Value = f64;
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("f64 ... | true |
a68b7a3d82823e7c410a3fb8b44ecf4939330878 | Rust | BarcodeResource/rust_barcode | /src/barcode/mod.rs | UTF-8 | 1,028 | 2.65625 | 3 | [] | no_license | pub struct BarcodeProperties {
pub input: String,
pub check_digit: i32,
pub human_text: String,
}
pub trait Barcode {
//fn encode(&mut self, input: &String, check_digit: i32) -> String;
fn encode(&mut self) -> String;
fn get_human_text(&self) -> Stri... | true |
a9bf52446af80654702d4f7019f1ffba7875cb87 | Rust | Moxinilian/kira | /kira/src/parameter/mapping.rs | UTF-8 | 1,273 | 3.4375 | 3 | [
"MIT"
] | permissive | /// A transformation from one range of values to another.
#[derive(Debug, Copy, Clone)]
#[cfg_attr(
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize),
serde(default)
)]
pub struct Mapping {
/// The input range of the mapping.
pub input_range: (f64, f64),
/// The corresponding output range of... | true |
c405481a84a530b2b3d6e6136dfbc11624a706c5 | Rust | SymmetricChaos/classic_crypto | /src/codes/binary/unicode.rs | UTF-8 | 5,002 | 3.28125 | 3 | [] | no_license | use std::{char, convert::TryInto};
use itertools::Itertools;
fn bits_to_u32(text: &str) -> u32 {
let mut out = 0u32;
for (e, s) in text.chars().rev().enumerate() {
match s {
'0' => (),
'1' => out += (2usize.pow(e.try_into().unwrap())) as u32,
_ => panic!("bits can ... | true |
64309663429dae794bdd2e3d6f1ac35696550284 | Rust | jo12bar/rust-exe-packer | /elk/delf/src/parse.rs | UTF-8 | 6,697 | 3.421875 | 3 | [] | no_license | //! Utilities for parsing little-endian, 64-bit ELF files via [`nom`].
use nom::{ErrorConvert, Slice};
use std::{fmt, ops::RangeFrom};
/// Implements a parse method for an enum, allowing you to parse some number
/// value into an enum type.
///
/// The first argument, `$type`, should be the enum to implement `::parse... | true |
5165f551be96a848d8235bc6aec0b849250bef95 | Rust | dimforge/nalgebra | /nalgebra-glm/src/gtc/integer.rs | UTF-8 | 329 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | //use na::Scalar;
//
//
//use crate::aliases::TVec;
//pub fn iround<T: Scalar, const D: usize>(x: &TVec<T, D>) -> TVec<i32, D> {
// x.map(|x| x.round())
//}
//
//pub fn log2<I>(x: I) -> I {
// unimplemented!()
//}
//
//pub fn uround<T: Scalar, const D: usize>(x: &TVec<T, D>) -> TVec<u32, D> {
// unimplemente... | true |
f6c2a463248da106d4466e60d22356537d3ed29e | Rust | zRedShift/aoc-2018 | /aoc11/src/main.rs | UTF-8 | 1,414 | 3.109375 | 3 | [] | no_license | const SIZE: usize = 300;
const INPUT: usize = 9005;
fn calculate(x: usize, y: usize) -> i8 {
let rack_id = x + 11;
(((rack_id * y + rack_id + INPUT) * rack_id) % 1000 / 100) as i8 - 5
}
fn populate(grid: &mut [[i8; SIZE]; SIZE]) {
for (y, row) in grid.iter_mut().enumerate() {
for (x, cell) in row.... | true |
63a45f2d080bdd144e6dca82ce39416c6ac2fa52 | Rust | SierraSoftworks/bender | /src/api/quote/models.rs | UTF-8 | 4,841 | 3.09375 | 3 | [
"MIT"
] | permissive | use crate::models::Quote;
use actix_web::{HttpRequest, HttpResponse, Responder, http::header, http::header::Header, body::BoxBody};
use tracing::Span;
#[derive(Serialize, Deserialize)]
pub struct QuoteV1 {
pub quote: String,
pub who: String,
}
impl From<QuoteV1> for Quote {
fn from(val: QuoteV1) -> Self ... | true |
0cedf27295a334f1c7510e8921d512d379719022 | Rust | rodrimati1992/structural_crates | /structural_derive/src/utils.rs | UTF-8 | 1,570 | 2.90625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use proc_macro2::Span;
pub(crate) trait SpanExt {
fn combine_span(self, other: Span) -> Span;
}
impl SpanExt for Span {
fn combine_span(self, other: Span) -> Span {
self.join(other).unwrap_or(self)
}
}
////////////////////////////////////////////////////////////////////////////////
pub(crate) fn... | true |
a3bc6efcf08b8e66998c1e7f629a73e2454ac0ab | Rust | hegza/serpent-rs | /src/transpile/ast_to_ast/from_py.rs | UTF-8 | 27,796 | 2.703125 | 3 | [
"MIT"
] | permissive | //! Defines conversions from Python AST nodes into Rust AST nodes.
//!
//! TODO: Review all HACKs, FIXMEs
use super::{dummy, util};
use crate::transpile::context::AstContext;
use itertools::Itertools;
use log::{error, warn};
use rustc_ap_rustc_ast as rustc_ast;
use rustc_ap_rustc_span::source_map::Spanned;
use rustc_a... | true |
eeaea6254acfebaf8b7e8ff48be7c312d03f7a38 | Rust | wisdark/BadDNS | /src/write_handler.rs | UTF-8 | 1,487 | 2.53125 | 3 | [
"MIT"
] | permissive | use std::thread;
use std::io::Write;
use std::process::exit;
use std::fs::OpenOptions;
use std::sync::mpsc::{Receiver, Sender};
use serde_json;
use serde_derive::{Serialize, Deserialize};
use crate::mem_util::Statue;
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct ResultsSubDomain {
pub subdomain: St... | true |
0225c2dc6731bdb200992554ee8d69b38126b68d | Rust | fiji-flo/lazytable | /src/lib.rs | UTF-8 | 9,087 | 3.9375 | 4 | [
"MIT"
] | permissive | //! # `lazytable`: lazy tables with stuipd wrapping
//!
//! ## Why?
//!
//! [prettytable](https://github.com/phsym/prettytable-rs) is awesome.
//! But wrapping in a teminal is no fun.
//!
//! ## Example
//!
//! ```rust
//! #[macro_use]
//! extern crate lazytable;
//! use lazytable::Table;
//!
//! fn main() {
//! ... | true |
b17c4890d0538b1394d25d3dc75c8c35ccd17ad2 | Rust | coriolinus/trait-bound-pretty | /src/lib.rs | UTF-8 | 4,323 | 3.125 | 3 | [
"MIT"
] | permissive | use std::io::Write;
use lalrpop_util::lalrpop_mod;
lalrpop_mod!(pub parser);
#[cfg(test)]
mod parser_tests;
pub trait Pretty {
/// Pretty-print `Self` to the supplied writer.
///
/// This function must only ever write valid utf8 strings.
fn pretty_to<Writer: Write>(&self, writer: &mut Writer) -> Resu... | true |
ab4ca4925511b1aa6e1cd5a516ec71cfd1122c32 | Rust | LoyVanBeek/learning_rust | /robot_skills/src/amigo_base.rs | UTF-8 | 1,687 | 3 | 3 | [] | no_license | extern crate geometry_msgs;
#[derive(Debug)]
enum BaseError {
HardwareFail,
EnvironmentCollision,
GoalUnreachable,
}
pub type BaseResult = Result<geometry_msgs::PoseStamped, BaseError>;
pub trait Base {
fn new() -> Self;
fn base_move(& mut self, goal: geometry_msgs::PoseStamped) -> BaseResult;
... | true |
7e5a3600f83dc7d928fe82b78a6c33836fb6a77a | Rust | kilatev/rusty_solana | /rusty_actix/src/main.rs | UTF-8 | 3,017 | 2.75 | 3 | [
"MIT"
] | permissive | use actix_cors::Cors;
use actix_web::{get, http, post, web, App, HttpResponse, HttpServer, Responder};
use serde::Deserialize;
use std::collections::HashMap;
#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().body("Hello world!")
}
#[get("/getSlot")]
async fn getSlot() -> impl Responder {
let ... | true |
9908404e57a722ac8964aa0fde24d3926a245a2e | Rust | join3r/kurz5 | /src/firestorm.rs | UTF-8 | 1,029 | 3 | 3 | [] | no_license | use std::io;
pub fn main() {
// Vyžiadaj deň, mesiac a rok od usera (ako čísla)
// Vypíš meno mesiaca, ktoré zadal user:
// Napríklad. User zadal
// 10
// 5
// 1982
// Výstup: 10 Máj 1982
// struct Month
let months = ["Januar", "Februar", "Marec","april","Maj","Jun","Jul","August","September", "Oktober", "November"... | true |
a107c4975c211577fab5951dd650dbcb214e2049 | Rust | talldan/gluon | /examples/http.rs | UTF-8 | 13,870 | 2.53125 | 3 | [
"MIT"
] | permissive | //! This example uses [hyper][] to create a http server which handles requests asynchronously in
//! gluon. To do this we define a few types and functions in Rust with which we register in gluon
//! so that we can communicate with `hyper`. The rest of the implementation is done in gluon,
//! routing the requests and co... | true |
1cd8fe21d829a62b49316944183e235b7a4ff499 | Rust | Dirbaio/rp2040-pac | /src/adc.rs | UTF-8 | 1,701 | 2.609375 | 3 | [] | no_license | use crate::generic::*;
#[doc = "Control and data interface to SAR ADC"]
#[derive(Copy, Clone)]
pub struct Adc(pub *mut u8);
unsafe impl Send for Adc {}
unsafe impl Sync for Adc {}
impl Adc {
#[doc = "ADC Control and Status"]
pub fn cs(self) -> Reg<regs::Cs, RW> {
unsafe { Reg::from_ptr(self.0.add(0usize... | true |
9597fd0069c167c1b2c25b24029e7d3f96b7f1d1 | Rust | Byron/ripgrep | /tests/hay.rs | UTF-8 | 739 | 2.59375 | 3 | [
"MIT",
"Unlicense"
] | permissive | pub const SHERLOCK: &'static str = "\
For the Doctor Watsons of this world, as opposed to the Sherlock
Holmeses, success in the province of detective work must always
be, to a very large extent, the result of luck. Sherlock Holmes
can extract a clew from a wisp of straw or a flake of cigar ash;
but Doctor Watson has to... | true |
9a34c12215a2fcf1e3a698b488a515b00bf6ddeb | Rust | bqoul/dabt | /src/main.rs | UTF-8 | 3,127 | 3.375 | 3 | [] | no_license | use std::io::prelude::*;
enum NodeOrigin {
Main,
Right,
Left,
}
#[derive(serde::Deserialize, Clone)]
struct Node {
value: i128,
left: Option<Box::<Node>>,
right: Option<Box::<Node>>,
}
impl std::fmt::Display for Node {
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
fn sort_display(... | true |
c4b726c7cdde1270f6dd0f952d1062d8fa910baf | Rust | tensorbase/tensorbase | /crates/parquet/src/file/properties.rs | UTF-8 | 24,706 | 2.703125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-free-unknown"
] | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | true |
ecc6cbc6337d4eb6525238254969f3e3490e739c | Rust | Spaceface16518/polycons-rust-wasm | /src/polycons/mod.rs | UTF-8 | 2,457 | 2.65625 | 3 | [
"MIT"
] | permissive | use std::iter::repeat;
use std::ops::{Add, AddAssign, Div, Mul, Sub};
use alga::general::ClosedNeg;
use nalgebra::{RealField, Scalar};
use num_traits::{CheckedSub, ToPrimitive, Zero, NumCast};
use rand::distributions::uniform::SampleUniform;
use rand::Rng;
use config::WorldConfig;
pub use line::Line;
pub use node::No... | true |
8fb7dfca3652fdaa12c96a595a0a13411d4c700b | Rust | munckymagik/async-workshop | /src/bin/06_channels.rs | UTF-8 | 1,310 | 3.203125 | 3 | [] | no_license | #[tokio::main]
async fn main() {
println!("hello from main");
let mut receiver = generator();
let mut result: i32 = 0;
for _ in 0i32..5 {
if let Some(val) = receiver.recv().await {
println!("received {}", val);
result += val
} else {
println!("None r... | true |
0724f467d3b9bf2f6638a8e7fb62bef2bfe5e979 | Rust | mostobriv/CodingZipAlgos | /AriCoding/src/ari_coder/mod.rs | UTF-8 | 6,574 | 3.078125 | 3 | [] | no_license | pub struct Ari {
pub stats: Vec<usize>,
cum_freq: Vec<usize>,
high: usize,
low: usize,
bits_to_follow: isize,
value: usize,
counter: usize,
}
//i dont want to think about this code, so i just copy-paste most of it
const MAX_VAL: usize = 65535;
const BITS_N: usize = 16;
const FIRST_Q: usize... | true |
206df9c9dd84c592a296c75a495ee25ec07fcc80 | Rust | GuildOfWeavers/winterfell | /air/src/errors.rs | UTF-8 | 2,055 | 3.109375 | 3 | [
"MIT"
] | permissive | // Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use core::fmt;
// ASSERTION ERROR
// ================================================================================================
///... | true |
82b00de59bef2ae45098fcffafcec39ce10b3941 | Rust | caglardursun/intro_rust | /basics/src/threads_channels.rs | UTF-8 | 2,018 | 3.671875 | 4 | [
"MIT"
] | permissive | use std::thread;
use std::sync::mpsc; //multiple producer single consumer
use std::time::Duration;
fn basic_usage(){
let mut c = vec![];
for i in 0..10{
c.push(
//move closure Capture a closure's environment by value.
//rust thread doesn't guarantee that jop order
... | true |
71e951334252e22e997c0514bf006f1233a73529 | Rust | thepowersgang/rust_os | /Kernel/Modules/usb_ohci/int_buffers.rs | UTF-8 | 3,964 | 2.53125 | 3 | [
"BSD-2-Clause"
] | permissive | // "Tifflin" Kernel - OHCI USB driver
// - By John Hodge (Mutabah / thePowersGang)
//
// Modules/usb_ohci/int_buffers.rs
//! Buffer pool for interrupt endpoints
use ::core::sync::atomic::{Ordering, AtomicU32};
/// A single page used as a pool of interrupt transfer buffers
pub struct InterruptBuffers
{
// TODO: Re-wri... | true |
002309346ea59441504d028c4f46fc524029b269 | Rust | Stovoy/StovBot | /src/admin.rs | UTF-8 | 417 | 2.578125 | 3 | [] | no_license | use crate::{Event, EventBusSender};
use std::io;
#[derive(Debug, Clone)]
pub enum AdminEvent {
Message(String),
}
pub fn cli_run(sender: EventBusSender) {
loop {
let mut buffer = String::new();
io::stdin().read_line(&mut buffer).unwrap();
let buffer = buffer.trim();
let event =... | true |
2767e77d53847fb8896cd2a94cbd5375eeba3e99 | Rust | anziem/rust_web_scraper | /src/main.rs | UTF-8 | 1,554 | 2.890625 | 3 | [
"MIT"
] | permissive | extern crate hyper;
extern crate select;
use hyper::Client;
use std::env;
use std::io::Read;
use select::document::Document;
use select::predicate::{Class, Attr, Name};
fn main() {
let client = Client::new();
let url = &env::args().nth(1).expect("No url supplied"); // in rust 1.1 env::args() returns an Iter... | true |
b22a42cde256ddc3624d7348d05811460c14bc89 | Rust | d3r1n/Rust-BruteForce | /src/main.rs | UTF-8 | 1,083 | 3.375 | 3 | [] | no_license | use std::env;
use rand::Rng;
use std::time::Instant;
const CHARSET: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
fn crack(password: String) {
let now = Instant::now();
let pass_list: Vec<char> = password.chars().collect();
let chrst: Vec<char> = CHARSET.chars().collect();
l... | true |
265f64c870d11bd20eb0a6e3bedf676fd80cf06b | Rust | aleosd/wefo | /src/configure.rs | UTF-8 | 790 | 2.578125 | 3 | [] | no_license | #[derive(Serialize, Deserialize, Debug)]
pub struct WeFoConfig {
pub system_config: SystemConfig,
pub city_id: u32,
pub openweathermap_api_key: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct SystemConfig {
pub log_level: String,
}
impl ::std::default::Default for WeFoConfig {
fn def... | true |
42e3ea1048b14c4bca6a007308077e963d0a63ad | Rust | AcrylicShrimp/mk-test | /src/ecs/src/component_iter_tuple.rs | UTF-8 | 691 | 2.65625 | 3 | [] | no_license | use super::component::Component;
use std::slice::IterMut;
pub trait ComponentIterTuple<'a>: 'a + Sized {}
macro_rules! component_iter_tuple_impls {
(@next) => {};
(@next $first:ident, $($rest:ident,)*) => {
component_iter_tuple_impls!($($rest,)*);
};
($($components:ident,)*) => {
impl<... | true |
1f74fcaf1c87949113401fb4df93969c7414d75e | Rust | toasty-toast/advent-of-code-2020 | /src/day-15.rs | UTF-8 | 1,240 | 3.421875 | 3 | [] | no_license | use std::collections::HashMap;
mod utils;
fn main() {
let values: Vec<i32> = utils::read_puzzle_input()[0]
.split(",")
.map(|value| value.parse::<i32>().unwrap())
.collect();
println!("Part 1: {}", get_nth_number(&values, 2020));
println!("Part 2: {}", get_nth_number(&values, 3000... | true |
6c66fae49eaafe979cac8fb984251027bcda0367 | Rust | jblondin/rhubarb | /src/event.rs | UTF-8 | 1,073 | 2.75 | 3 | [
"MIT"
] | permissive | use std::panic::RefUnwindSafe;
use control;
use error;
use layout::ComponentIndex;
#[derive(Debug, Serialize, Deserialize)]
pub struct EventMessage {
// pub src_name: String,
pub idx: ComponentIndex,
pub event: Event
}
#[derive(Debug, Serialize, Deserialize)]
pub enum Event {
ButtonClick(control::but... | true |
9e672a9882962cdc79dc8d8551143ddb15e628d7 | Rust | bertiespell/redistribution | /redistribution/src/hasher.rs | UTF-8 | 571 | 2.546875 | 3 | [] | no_license | use openssl::sha;
use std::time::Duration;
pub fn calculate_hash(
index: &u32,
previous_hash: &str,
timestamp: &Duration,
data: &str,
difficulty: &u32,
nonce: &u128,
) -> String {
let mut hasher = sha::Sha256::new();
hasher.update(&index.to_be_bytes());
hasher.update(&previous_hash.... | true |
063ba974ed3aa7df6a0798480f718c4bfdde4342 | Rust | ckkashyap/LearningPrograms | /rust/struct.rs | UTF-8 | 316 | 3.40625 | 3 | [] | no_license | struct S {
x: u32,
y: &'static str,
}
static mut x : S = S { x:10 , y:"ABCD" };
fn f1( s :&mut S, xx : &'static str) {
println!("{}", s.x);
println!("{}", s.y);
s.x = 30;
s.y = xx;
}
fn main(){
println!("hello");
unsafe {
x.x = 20;
f1(& mut x, "AAA");
f1(& mut x, "BBB");
f1(& mut x, "BBB");
}
}
| true |
3ce87785eb9a1761b56e2cae52ebbfed01e0714b | Rust | boy20100619/ccc109a | /00/rust/alg/00-complexity/backup/dataStructure/hashmap.rs | UTF-8 | 230 | 3.078125 | 3 | [] | no_license | use std::collections::HashMap;
fn main() {
let mut map = HashMap::new();
map.insert("a", 1);
map.insert("b", 2);
map.insert("c", 3);
for (key, val) in map.iter() {
println!("key: {} val: {}", key, val);
}
}
| true |
8454c80ea977e5f02d1504f29cbdf60b5d6a9ceb | Rust | SchrodingerZhu/blog-system | /src/api.rs | UTF-8 | 9,639 | 2.703125 | 3 | [
"MIT"
] | permissive | use async_diesel::*;
use chrono::Utc;
use diesel::{ExpressionMethods, QueryDsl};
use crate::api::JsonResponse::*;
use crate::ConnPool;
use crate::model::{Comment, NewPageRaw, Post, Page, POST_COLUMNS, NewPostRaw};
#[derive(serde::Serialize, serde::Deserialize, Debug)]
#[serde(tag = "request_type", content = "request_... | true |
3b1b790d5f9fead59b68c801c07cbe012a2f2822 | Rust | vitoraalmeida/learning-rust | /commom-programming/for_iter_if_match.rs | UTF-8 | 694 | 3.78125 | 4 | [] | no_license | fn main() {
let haystack = [1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862]; // array literal
for reference in haystack.iter() {//iter transforma um iterável em iterador
let item = *reference; //retorna referencias para os itens, o
//simbolo * dereferencia o ender... | true |
b6130ac6f8eefbce7770578f657d96757e0d99d2 | Rust | Keirua/exercism | /isogram/src/lib.rs | UTF-8 | 650 | 3.1875 | 3 | [] | no_license | fn get_letter_index(c: char) -> Option<u8> {
if c >= 'a' && c <= 'z' {
Some(c as u8 - 'a' as u8)
} else if c >= 'A' && c <= 'Z' {
Some(c as u8 - 'A' as u8)
} else {
None
}
}
pub fn check(candidate: &str) -> bool {
let mut char_counts : [i32; 26] = [0;26];
for c in cand... | true |
cf157ef1981b6e10f8707c1607401d9228c9f81d | Rust | rh01/Quarter-1_3.30-6.30 | /Class_Codes/week_10_29th-September,2019/part6/src/main.rs | UTF-8 | 305 | 3.15625 | 3 | [
"MIT"
] | permissive | fn main() {
let x = 19;
match x {
90 ..= 100 => println!("{}", "A+"),
80 ..= 90 => println!("{}", "A"),
70 ..= 80 => println!("{}", "B"),
_ => println!("{}", "Failed")
};
//To recall range
for i in 1..= 10 {
println!("{}", i);
}
}
| true |
3f1bded93f340bf673fe88cc8ef8b8863e7be3e1 | Rust | claytonspinner/rust-petstore | /src/domain/mod.rs | UTF-8 | 868 | 2.78125 | 3 | [] | no_license | extern crate rustc_serialize;
use std::str::FromStr;
#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Pet {
pub id: u32,
category: Category,
name: String,
photo_urls: Vec<String>,
tags: Vec<Tag>,
pub status: Status
}
#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Categ... | true |
805b1e432192c37e7833ea519f4ece197b44ad6f | Rust | chesedo/cos-700 | /Code/Rust/macro-lib/src/token_stream_utils.rs | UTF-8 | 4,639 | 3.359375 | 3 | [] | no_license | use proc_macro2::{Group, TokenStream, TokenTree};
use quote::{ToTokens, TokenStreamExt};
use std::collections::HashMap;
use syn::punctuated::Punctuated;
/// Trait for tokens that can replace interpolation markers
pub trait Interpolate {
/// Take a token stream and replace interpolation markers with their actual va... | true |
d5979310bfceb7c02d8fa473c0a45d8af922cca7 | Rust | ootsby-forks/learning_game_design_patterns | /ggez_infinite_runner/src/score.rs | UTF-8 | 498 | 2.84375 | 3 | [] | no_license | use super::{Event, Observer};
pub struct Score(u64);
impl Score {
pub fn new() -> Score {
let score = Score(0);
score
}
pub fn increment(&mut self) {
self.0 += 1;
}
pub fn get(&self) -> u64 {
self.0
}
pub fn reset(&mut self) {
self.0 = 0;
}
}... | true |
386b034ae9befabe67ec23fdbab09a6a8e3b1aa8 | Rust | isgasho/leetcode-1 | /src/index_61_70/mod.rs | UTF-8 | 180 | 2.5625 | 3 | [
"MIT"
] | permissive | // 70
pub fn climb_stairs(n: i32) -> i32 {
let mut a = 0;
let mut b = 1;
for _ in 0..n {
let prev_a = a;
a = b;
b = prev_a + b;
}
b
}
| true |
e08f8d9208e24e8e863ed448d8f7458c9899b81a | Rust | darknight/kv.rs | /src/engine.rs | UTF-8 | 2,040 | 2.984375 | 3 | [] | no_license | use std::io;
use std::result;
use std::sync::{RwLock, RwLockReadGuard};
///
/// define customized error type
/// refer to this awesome article: https://blog.burntsushi.net/rust-error-handling/
///
#[derive(Debug)]
pub enum KvError {
/// io error
IoErr(io::Error),
/// error from serde_json
SerdeJsonErro... | true |
cb63a4a785427446deb0465e0f3618a5acb5c00d | Rust | dgollub/dkg-webserver | /src/threadpool/worker.rs | UTF-8 | 949 | 3.09375 | 3 | [
"MIT"
] | permissive | use std::sync::Arc;
use std::sync::mpsc;
use std::sync::Mutex;
use std::thread;
use super::job::Message;
pub struct Worker {
pub id: usize,
pub thread: Option<thread::JoinHandle<()>>,
}
impl Worker {
pub fn new(id: usize, receiver: Arc<Mutex<mpsc::Receiver<Message>>>) -> Worker {
let thread = th... | true |
bc35618a652b51642e27f250d1d4c814c347a57a | Rust | whalelephant/algo2 | /src/scc.rs | UTF-8 | 3,641 | 2.953125 | 3 | [] | no_license | use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::Path;
pub fn scc() -> Vec<u32> {
let input = scc_input();
println!("got input");
// fin_times is map key = finishing_time, value = n
let mut fin_times = HashMap::new();
// leaders is n... | true |
a32ce3c9143ab2eb99fc0ed056a45f263b2cce1d | Rust | juicycleff/guardian-rust | /backend/src/data/models/accounts_model.rs | UTF-8 | 1,758 | 2.640625 | 3 | [] | no_license | //! Account model crate
use chrono::{DateTime, Utc};
use mongodb::bson::serde_helpers::*;
use serde::{Deserialize, Deserializer, Serialize};
use std::fmt::Debug;
fn string_from_object_id<'de, D>(deserializer: D) -> Result<String, D::Error>
where
D: Deserializer<'de>,
{
let s: bson::oid::ObjectId = Deserialize:... | true |
f71546ffe145e0ab43a9e4b557723604513ca30b | Rust | steveklabnik/rustless | /src/server/request.rs | UTF-8 | 3,130 | 2.671875 | 3 | [
"MIT"
] | permissive | use url::{Url};
use std::io::{Reader, IoResult};
use std::fmt::{Show, Formatter, FormatError};
use std::io::net::ip::SocketAddr;
use anymap::AnyMap;
use server_backend::method::Method;
use server_backend::header;
use server_backend::header::Headers;
use server_backend::server::Request as RawRequest;
use server_backen... | true |
0a9c5a2017715642fbe77a2354e88784fe34a215 | Rust | benjamingroeber/adventofcode20 | /day10/src/main.rs | UTF-8 | 5,134 | 3.421875 | 3 | [] | no_license | use helpers::parse_lines_file;
use itertools::Itertools;
use std::collections::HashMap;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let adapters: Vec<Jolts> = parse_lines_file("./assets/days/day10.txt")?;
let adapters = SortedAdapters::new(adapters);
let rating = adapters.chain_output... | true |
f888ab4f2cd8cfc998586802b063641c38c5470f | Rust | pickjob/rust-starter | /doc/标准库_集合.rs | UTF-8 | 3,748 | 3.25 | 3 | [
"MIT"
] | permissive | //
// Collections
// Sequences:
// Vec: 尾端插入, 通用数组集合, Stack
// VecDeque: 两端高效插入, Queue, Deque
// LinkedList: 高效插入、拆分
// Maps:
// HashMap: key-value, cache
// BTreeMap: 排序 Key-value
// Sets: HashSet, BTreeSet
// Misc:
// BinaryHeap: 最大最小堆
// 迭代器... | true |
206ac2cb59446db16e953e4ab3d6a10c27758180 | Rust | CJ13th/programmingbitcoin-rust | /src/programmingbitcoin/messagedigest.rs | UTF-8 | 1,110 | 3.328125 | 3 | [] | no_license | //! Message digest helpers
use hmac::{Hmac, Mac};
use rug::Integer;
use rug::integer::Order;
use sha2::{Digest, Sha256};
/// Shorthand for HMAC_SHA256 algorithm
type HmacSha256 = Hmac<Sha256>;
/// Returns the SHA-256 hash of the given data
pub fn sha256(data: &[u8]) -> Vec<u8> {
Sha256::digest(data).to_vec()
}
/... | true |
9d45985a6ab391dd5dd9761060cc73d7aec853b2 | Rust | chromium/chromium | /third_party/rust/clap/v4/crate/src/_features.rs | UTF-8 | 1,955 | 2.671875 | 3 | [
"GPL-1.0-or-later",
"MIT",
"LGPL-2.0-or-later",
"Apache-2.0",
"BSD-3-Clause"
] | permissive | //! ## Documentation: Feature Flags
//!
//! Available [compile-time feature flags](https://doc.rust-lang.org/cargo/reference/features.html#dependency-features)
//!
//! #### Default Features
//!
//! * **std**: _Not Currently Used._ Placeholder for supporting `no_std` environments in a backwards compatible manner.
//! * ... | true |
b53b0d5a27f5caaf1bcd54fa7c449b144ef9ee13 | Rust | dennisss/dacha | /pkg/crypto/src/tls/parsing.rs | UTF-8 | 2,579 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | // TLS specific helpers for parsing binary packets.
use std::vec::Vec;
use common::bytes::Bytes;
use common::errors::*;
use parsing::binary::*;
use parsing::*;
pub const U8_LIMIT: usize = u8::max_value() as usize;
pub const U16_LIMIT: usize = u16::max_value() as usize;
pub const U24_LIMIT: usize = 1 << 24;
pub const... | true |
4f4cce6fe112e20edb0d857be85463871db43a90 | Rust | Nukesor/pueue | /pueue/src/client/display/log/mod.rs | UTF-8 | 7,160 | 2.9375 | 3 | [
"MIT"
] | permissive | use std::collections::BTreeMap;
use comfy_table::{Attribute as ComfyAttribute, Cell, CellAlignment, Table};
use crossterm::style::Color;
use pueue_lib::network::message::TaskLogMessage;
use pueue_lib::settings::Settings;
use pueue_lib::task::{Task, TaskResult, TaskStatus};
use super::OutputStyle;
use crate::client::... | true |
845d4780bcf2734cf1a56b5d3c1fe0923084d83c | Rust | WinLinux1028/passmaker | /src/main.rs | UTF-8 | 1,483 | 2.78125 | 3 | [] | no_license | #[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
use rand::Rng;
use std::io::Write;
const CHARACTERS: &str = r##"0123456789QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ "##;
fn main() -> ! {
println!("パスワード生成ウィザード passmaker 0.1.2");
loop {
... | true |
99f976e8497daa533586bf0bc4e468fce1c6f565 | Rust | cormacrelf/allocators-rs | /object-alloc/src/lib.rs | UTF-8 | 8,997 | 3.0625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Copyright 2017-2018 the authors. See the 'Copyright and license' section of the
// README.md file at the top-level directory of this repository.
//
// Licensed under the Apache License, Version 2.0 (the LICENSE-APACHE file) or
// the MIT license (the LICENSE-MIT file) at your option. This file may not be
// copied, ... | true |
394d32fa092cdc9da850c7e3fae86df113a4f2a7 | Rust | iwataka/google-code-jam | /2017/qualification_round/bathroom_stalls.rs | UTF-8 | 1,782 | 3.25 | 3 | [] | no_license | use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
let mut line_iter = stdin.lock().lines();
let n_tests: i64 = line_iter.next().unwrap().unwrap().parse().unwrap();
for i in 0..n_tests {
let test_line = line_iter.next().unwrap().unwrap();
let mut splitted_line = test_lin... | true |
c0279e7d3991b419f0300f233dd34c4fbe25e0c7 | Rust | shifteight/rust | /tao_of_rust/drop.rs | UTF-8 | 301 | 3.140625 | 3 | [] | no_license | use std::ops::Drop;
#[derive(Debug)]
struct S(i32);
impl Drop for S {
fn drop(&mut self) {
println!("drop {}", self.0);
}
}
fn main() {
let x = S(1);
println!("create x: {:?}", x);
{
let y = S(2);
println!("create y: {:?}", y);
println!("exit inner scope");
}
println!("exit main");
} | true |
ab38fde6d06e02c00c9590691bb6ad6080097308 | Rust | StevenL2015/indy-sdk | /libindy/src/services/signus/types.rs | UTF-8 | 2,852 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | use utils::json::{JsonEncodable, JsonDecodable};
#[derive(Serialize, Deserialize, Clone)]
pub struct MyDidInfo {
pub did: Option<String>,
pub seed: Option<String>,
pub crypto_type: Option<String>,
pub cid: Option<bool>
}
impl MyDidInfo {
pub fn new(did: Option<String>, seed: Option<String>,
... | true |
693c7f44de268314cd9ee3d86660bfe90dc0812a | Rust | AlexApps99/egui | /egui_demo_lib/src/easy_mark/easy_mark_editor.rs | UTF-8 | 6,015 | 2.8125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use egui::*;
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct EasyMarkEditor {
code: String,
highlight_editor: bool,
show_rendered: bool,
#[cfg_attr(feature = "serde", serde(skip))]
highlighter: crate::easy_mark:... | true |
489dc38e052405c47a74f6725626643b5a860d77 | Rust | nacho-vlad/chess-engine | /chess/src/position.rs | UTF-8 | 26,987 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::hash::Hash;
use std::collections::HashMap;
use std::str::FromStr;
use crate::constants::*;
use crate::repr::*;
use crate::ChessError;
type Board = Colored<Pieces>;
#[derive(Copy, Clone, Debug, Hash, Eq)]
pub struct Position {
pub board: Board,
pub turn: Color,
pub castling_rights: Colored<Cas... | true |
3f48071cd5e48a002f6b78403a2f63477bacb57b | Rust | nikomatsakis/gnome-class | /src/errors.rs | UTF-8 | 893 | 2.515625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use syn::synom::ParseError;
error_chain! {
// The type defined for this error. These are the conventional
// and recommended names, but they can be arbitrarily chosen.
//
// It is also possible to leave this section out entirely, or
// leave it empty, and these names will be used automatically.
... | true |
c89bbf02155e7b04bf830907e02007072ea93f08 | Rust | MaikKlein/Wyre | /examples/linear_pipe.rs | UTF-8 | 677 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | extern mod wyre;
use wyre::pipe::*;
use wyre::wire::*;
fn main(){
let pipe = do LinearPipe::new()|p|{
single_wire(|x| fmt!("%?",x) ,
single_wire(|x| x as float ,
single_wire(|x: int| x * 2 ,
p
)
)
... | true |
5de4f02a744064649c6853a6256ee762cbb64ed5 | Rust | aero530/fpapp | /src-tauri/src/accounts/src/college.rs | UTF-8 | 9,312 | 2.65625 | 3 | [] | no_license | //! College savings account (529)
use serde::{Deserialize, Serialize};
use std::error::Error;
use ts_rs::TS;
use image::{ImageBuffer, Rgba};
use crate::inputs::fixed_with_inflation;
use account_savings_derive::AccountSavings;
use super::*;
/// College savings accounts specifically designed to represent 529 accounts
... | true |
d14ed4849c8bcb8abccffb4f522635245405fa65 | Rust | aszecsei/hex | /src/byte_unit/mod.rs | UTF-8 | 11,628 | 2.796875 | 3 | [
"MIT"
] | permissive | mod error;
pub use error::*;
/// KB
pub const KILOBYTE: u128 = 1_000;
/// KiB
pub const KIBIBYTE: u128 = 1 << 10;
/// MB
pub const MEGABYTE: u128 = 1_000_000;
/// MiB
pub const MEBIBYTE: u128 = 1 << 20;
/// GB
pub const GIGABYTE: u128 = 1_000_000_000;
/// GiB
pub const GIBIBYTE: u128 = 1 << 30;
/// TB
pub const TERABY... | true |
f9eded6bf1643a8d05bd7a1f761ab971b0f5177f | Rust | MarkSuckerberg/auxmos | /src/gas/mixture.rs | UTF-8 | 20,157 | 2.796875 | 3 | [] | no_license | use itertools::{
Either,
EitherOrBoth::{Both, Left, Right},
Itertools,
};
use std::{
cell::Cell,
sync::atomic::{AtomicU64, Ordering::Relaxed},
};
use tinyvec::TinyVec;
use crate::reaction::ReactionIdentifier;
use super::{
constants::*, gas_visibility, total_num_gases, with_reactions, with_specific_heats, GasI... | true |
917bca83595ff48a077ec5a8d345a83a409b040d | Rust | bernardoamc/kvs | /src/error.rs | UTF-8 | 1,126 | 2.9375 | 3 | [] | no_license | use failure::Fail;
use std::io;
use std::result;
/// The error type for our key value store.
#[derive(Fail, Debug)]
pub enum KvsError {
/// Triggered when the provided key cannot be found.
#[fail(display = "Key not found error")]
KeyNotFound,
/// Triggered when the provided command cannot be found.
... | true |
7c0f20fbda88a1b23bd04112e02654dbb9a0055a | Rust | rcore-os/arceos | /crates/axfs_ramfs/src/file.rs | UTF-8 | 1,617 | 2.640625 | 3 | [
"Apache-2.0",
"AGPL-3.0-only",
"LicenseRef-scancode-mulanpubl-2.0",
"AGPL-3.0-or-later",
"GPL-3.0-only",
"MulanPSL-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-mulanpsl-2.0-en"
] | permissive | use alloc::vec::Vec;
use axfs_vfs::{impl_vfs_non_dir_default, VfsNodeAttr, VfsNodeOps, VfsResult};
use spin::RwLock;
/// The file node in the RAM filesystem.
///
/// It implements [`axfs_vfs::VfsNodeOps`].
pub struct FileNode {
content: RwLock<Vec<u8>>,
}
impl FileNode {
pub(super) const fn new() -> Self {
... | true |
d2802b20e9d31e42487f999f2d3a5b81362bc187 | Rust | tbmreza/iridium | /src/assembler/opcode_parsers.rs | UTF-8 | 1,621 | 2.84375 | 3 | [] | no_license | use super::Token;
use crate::instruction::Opcode;
use nom::types::CompleteStr;
use nom::{alpha1, do_parse, tag_no_case};
nom::named!(pub opcode<CompleteStr, Token>,
do_parse!(
opcode: alpha1 >>
({Token::Op {
code: Opcode::from(opcode)}
})
)
);
nom::named!(pub ... | true |
625878ad7c746681e1af3f180f1d36bd6dd0552f | Rust | AlterionX/benxu-dev | /crypto/src/token/paseto/v2/public/decryption.rs | UTF-8 | 1,932 | 2.578125 | 3 | [
"MIT"
] | permissive | use super::local_prelude::*;
pub(super) struct SeparatedToken {
source: Vec<u8>,
footer: Option<Vec<u8>>,
}
pub(super) struct VerifiedToken {
msg: Vec<u8>,
footer: Option<Vec<u8>>,
}
impl SeparatedToken {
fn sig_msg_boundary(&self) -> usize {
self.source.len() - 64
}
fn sig(&self) ... | true |
557dc975aad42406008be34d0eff6a8aeebf1453 | Rust | youngqqcn/RustNotes | /examples/ch08/practice_ch8.rs | UTF-8 | 4,586 | 3.390625 | 3 | [] | no_license |
use std::collections::HashMap;
fn get_average_num(vct: &Vec<i32>) -> f64 {
let mut sum = 0;
for n in vct {
sum += n;
}
let size = vct.len() as u32;
let avr = f64::from(sum) / f64::from( size );
avr
}
//获取中位数
fn get_middle_number(vct: &Vec<i32>) -> i32 {
// vct.sort();
let... | true |
c12d8820db656e74fb4db8fa0e19ead88a71a7fa | Rust | qeeg/kind-nes | /nes/src/cpu_mapped_registers.rs | UTF-8 | 1,795 | 3.0625 | 3 | [] | no_license | use memory::Memory;
use std::cell::RefCell;
use std::rc::Rc;
// https://wiki.nesdev.com/w/index.php/2A03
pub struct CPUMappedRegisters {
ppu: Rc<RefCell<dyn Memory>>,
apu: Rc<RefCell<dyn Memory>>,
joy1: Rc<RefCell<dyn Memory>>,
joy2: Rc<RefCell<dyn Memory>>,
}
impl CPUMappedRegisters {
pub fn new(... | true |
9a5f0c35e4ec087da0c502ba0c0d9a8ab459bf12 | Rust | madwareru/rom-media-rs | /src/image_rendering/ingame_sprite_decorators.rs | UTF-8 | 16,470 | 2.625 | 3 | [] | no_license | use rom_loaders_rs::images::ingame_sprite::{ImageData, ImageType};
use crate::image_rendering::blittable::{Blittable, Rect};
use std::ops::Range;
pub struct PalettedSpriteRenderingScope<'a> {
pub palette: &'a [u32],
pub image_data: &'a ImageData,
pub img_id: usize
}
pub struct SpriteRenderingScope<'a> {
... | true |
ce3823feb1ee530e3b415eab2b247391a9a7d8e5 | Rust | nebula-os/npk | /src/commands/pack.rs | UTF-8 | 2,996 | 3 | 3 | [
"MIT"
] | permissive | use crate::directory::Directory;
use crate::package::manifest::MANIFEST_DEFAULT_FILE;
use crate::package::PACKAGE_EXTENSION;
use clap::ArgMatches;
use std::path::{Path, PathBuf};
use std::thread::current;
pub struct PackCommand {}
impl PackCommand {
pub fn new() -> Self {
PackCommand {}
}
}
impl<'a, ... | true |
9be5a37ef760238d5206617998e82e9e9c3895b2 | Rust | KlasafGeijerstam/Kattis | /rust/unreadmessages.rs | UTF-8 | 564 | 2.625 | 3 | [] | no_license | mod fast_input;
use fast_input::{FastInput, FastParse};
use std::collections::HashMap;
fn main() {
let inp = FastInput::new();
let (people, messages): (usize, usize) = inp.next();
let mut senders = HashMap::new();
for i in 1..=messages {
let sender: usize = inp.next_parsed();
sende... | true |
0fd8fb4c24e3ddac9253fca79666a1a8f8a252a1 | Rust | den-mentiei/apparatus | /src/cli/il.rs | UTF-8 | 15,288 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::Result;
use crate::error::Error;
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum OperandType {
None,
U8,
U16,
I32,
I64,
F32,
F64,
/// III.1.7.2 Contains u8 offset from the next instruction offset.
ShortBranchTarget,
/// III.1.7.2 Contains u32 offset from the next instruction offset.
BranchT... | true |
49ea1cda5f1c490cb718d5630a019ebfab796c3f | Rust | kiwiyou/DeliveryTracker | /src/couriers/mod.rs | UTF-8 | 2,574 | 2.96875 | 3 | [] | no_license | use anyhow::{anyhow, Result};
pub mod cainiao;
pub mod cjlogistics;
pub mod cupost;
pub mod epost;
pub mod gspostbox;
pub mod hanjin;
pub mod ilogen;
pub mod lotte;
pub struct Courier {
pub tracking_number: String,
pub kind: CourierKind,
}
macro_rules! define_couriers {
($($module:ident :: $name:ident),+... | true |
c698e9b1a000bb347facdc0f3e1828cb8a813d99 | Rust | pontem-network/move-language-server | /crates/test_utils/src/fixture.rs | UTF-8 | 4,168 | 3.265625 | 3 | [] | no_license | //! Defines `Fixture` -- a convenient way to describe the initial state of
//! rust-analyzer database from a single string.
//!
//! Fixtures are strings containing rust source code with optional metadata.
//! A fixture without metadata is parsed into a single source file.
//! Use this to test functionality local to one... | true |
01364ad8171cfc721d3c90b680fce7bf96562330 | Rust | tomarrell/rust-hands-on | /exercises/best-travel/src/test.rs | UTF-8 | 391 | 2.953125 | 3 | [] | no_license | fn testing(t: i32, k: i32, ls: &Vec<i32>, exp: i32) -> () {
assert_eq!(choose_best_sum(t, k, ls), exp)
}
#[test]
fn basics_choose_best_sum() {
let ts = &vec![50, 55, 56, 57, 58];
testing(163, 3, ts, 163);
let ts = &vec![50];
testing(163, 3, ts, -1);
let ts = &vec![91, 74, 73, 85, 73, 81, 8... | true |
fc71a5654adb6d93248c6e81d97b0b3b4cb81511 | Rust | brunohadlich/Programming-Studies | /rust/src/functions.rs | UTF-8 | 454 | 3.5625 | 4 | [] | no_license | pub fn run() {
greeting("Hello", "Trotsky");
let v1 = 3;
let v2 = 7;
println!("v1 + v2 = {}", add(v1, v2));
println!("v1 + v2 = {}", add2(v1, v2));
//Closure
let sum = |n1: i32, n2: i32| n1 + n2;
println!("v1 + v2 = {}", sum(v1, v2));
}
fn greeting(greet: &str, name: &str) {
printl... | true |
783cd6b5c9e4d9710bcfc402700f0927d769cff4 | Rust | Its-its/pixel-circuits | /frontend/src/canvas/pixels/util.rs | UTF-8 | 4,511 | 2.71875 | 3 | [] | no_license | use circuit_sim_common::{NodeDirection, Side, object::NodeValue};
use wasm_bindgen::JsValue;
use web_sys::CanvasRenderingContext2d;
use crate::Result;
use crate::canvas::{PIXEL_NODE, PIXEL_OBJECT};
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct PixelColor(pub u16, pub u16, pub u16);
impl PixelColor {
pub fn... | true |
663d851ec4667cae68e263a333cecec6984487aa | Rust | domain-independent-dp/didp-rs | /dypdl-heuristic-search/src/search_algorithm/util.rs | UTF-8 | 11,386 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! A module for utility.
use dypdl::{variable_type::Numeric, Model, Transition, TransitionInterface};
use super::{
data_structure::{exceed_bound, GetTransitions},
Solution,
};
use std::time;
/// Data structure to maintain the elapsed time.
///
/// The time keeper starts when it is created.
/// It can be sto... | true |
89e023497b464fe0f11a903a6987388f6bdc4d0a | Rust | Mariii-23/caracol_tobias | /src/commands/general.rs | UTF-8 | 11,683 | 2.703125 | 3 | [] | no_license | extern crate serenity;
use serenity::{framework::standard::{
help_commands,
macros::{ command, group, help},
Args,
CommandGroup, CommandResult, HelpOptions,
}, model::{channel::{Message,ReactionType}, id::UserId }, prelude::*};
use serenity::utils::Colour;
// use serenity::model::appli... | true |
3450e98981009afc5748d492e83138355fa33f12 | Rust | NyxCode/Ketamine | /interpreter/src/values/boolean.rs | UTF-8 | 655 | 3.46875 | 3 | [] | no_license | use crate::values::{Object, Value};
impl Object for bool {
fn type_name(&self) -> &'static str {
"boolean"
}
fn into_value(self) -> Value {
Value::Boolean(self)
}
fn to_string(&self) -> String {
ToString::to_string(self)
}
fn equal(&self, other: &Value) -> bool {
... | true |
50a8e8662a781f7a303da9eb4d3b76e57656d068 | Rust | wampiedriessen/adventofcode | /archive/2019/src/day11.rs | UTF-8 | 3,393 | 3.09375 | 3 | [] | no_license | use super::intcode::{IntcodeProg, Intcode};
use super::Day;
use std::collections::HashMap;
use std::cmp::{min, max};
pub struct Day11 {
program: IntcodeProg
}
impl Day for Day11 {
fn new(program: &str) -> Day11 {
Day11 {
program: Intcode::read_input(program),
}
}
fn part1(&self) -> Box<dyn std... | true |
6a14786ee8a096ef229440f55b81599bc74be0a2 | Rust | pierrechevalier83/unicode_types | /src/generated/arabic_mathematical_alphabetic_symbols.rs | UTF-8 | 36,891 | 3.28125 | 3 | [
"LicenseRef-scancode-unicode"
] | permissive |
/// An enum to represent all characters in the ArabicMathematicalAlphabeticSymbols block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum ArabicMathematicalAlphabeticSymbols {
/// \u{1ee00}: '𞸀'
ArabicMathematicalAlef,
/// \u{1ee01}: '𞸁'
ArabicMathematicalBeh,
/// \u{1ee02}: '𞸂'
... | true |
1ce81ff9daf3226e88bdebf1de6758612f923136 | Rust | octoon/imgui | /src/context.rs | UTF-8 | 2,691 | 2.796875 | 3 | [] | no_license | use std::any::Any;
use octoon_math::float2;
#[derive(Debug, Clone)]
pub struct DrawVert{
pos:float2,
uv:float2,
color:u32,
}
impl DrawVert{
pub fn new() -> DrawVert{
pos:float2::new(0.0, 0.0),
uv:float2::new(0.0, 0.0),
color:0
}
}
pub type DrawIdx = u16;
#[derive(Debug, C... | true |
1390d98baf5ffba3c1f86722cba6d2c39e94d5af | Rust | alex-dukhno/rust-tdd-katas | /old-katas-iteration-02/algebraic_expression_parser_kata/src/day_11.rs | UTF-8 | 4,848 | 3.8125 | 4 | [
"MIT"
] | permissive | use std::borrow::Cow;
use std::iter::Peekable;
use std::num::ParseFloatError;
use std::str::Chars;
#[derive(PartialEq, Debug)]
pub enum Ast {
Num(Result<f64, ParseFloatError>),
Operand(char, Box<Ast>, Box<Ast>),
}
pub struct Parser<'p> {
iter: Peekable<Chars<'p>>
}
impl<'p> Parser<'p> {
pub fn new<'s... | true |
da3bebed0224fb42b5ee05243118d1723153653a | Rust | haxdds/rust-practice | /src/basic_reference/loops.rs | UTF-8 | 680 | 3.96875 | 4 | [] | no_license | // Loops = used to iterate until a condition is met
pub fn run() {
let mut count = 0;
// infintie loop
loop {
count += 1;
println!("number: {}", count);
// need break condition
if count == 20 {
break;
}
}
count = 0;
// while loop
wh... | true |
3ae79c7e9065dbff0a7940ddfaeb04d776516e91 | Rust | bpandreotti/rose | /rose/src/main.rs | UTF-8 | 4,472 | 2.765625 | 3 | [
"MIT"
] | permissive | #[cfg(test)]
extern crate rand;
extern crate structopt;
use rose::*;
use config::*;
use geometry::*;
use svg::*;
use std::fs::File;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(name = "rose", about = "A Penrose tiling generator")]
struct RoseArguments {
/// Number of decomposition steps. A ... | true |
0df5663ed618daf30bc378ab50a7d21414c43b38 | Rust | moratorium08/osmium | /kernel/src/syscall.rs | UTF-8 | 13,232 | 2.6875 | 3 | [
"MIT"
] | permissive | use crate::elf;
use crate::files;
use crate::kernel;
use crate::memlayout;
use crate::paging;
use crate::proc;
use crate::trap;
use crate::uart;
use core::convert;
use core::slice;
use core::str;
use osmium_syscall::errors::SyscallError;
use osmium_syscall::number;
use osmium_syscall::perm;
#[derive(Copy, Clone, Debug... | true |
08081a0b1d44bc365f663b36c1e344ae9f868375 | Rust | pimox/proxmox-backup | /src/server/command_socket.rs | UTF-8 | 7,270 | 2.609375 | 3 | [] | no_license | use anyhow::{bail, format_err, Error};
use std::collections::HashMap;
use std::os::unix::io::AsRawFd;
use std::path::PathBuf;
use std::sync::Arc;
use futures::*;
use tokio::net::UnixListener;
use serde_json::Value;
use nix::sys::socket;
/// Listens on a Unix Socket to handle simple command asynchronously
fn create_c... | true |
0595874530107dd6359846272658ce63d29e9f60 | Rust | johannhof/markdown.rs | /src/parser/span/br.rs | UTF-8 | 668 | 3.09375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use parser::Span;
use parser::Span::Break;
use regex::Regex;
pub fn parse_break(text: &str) -> Option<(Span, usize)> {
lazy_static! {
static ref BR: Regex = Regex::new(r"^ {2}$").unwrap();
}
if BR.is_match(text) {
return Some((Break, 2));
}
None
}
#[cfg(test)]
mod test {
use s... | true |
d97569dc042103e5be22869a6e1f7b32ba57a1a8 | Rust | EFanZh/LeetCode | /src/problem_0728_self_dividing_numbers/brute_force.rs | UTF-8 | 1,084 | 3.078125 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
impl Solution {
pub fn self_dividing_numbers(left: i32, right: i32) -> Vec<i32> {
(left..=right)
.filter(|&x| {
let mut k = x;
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.