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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1d2c9df0cff82ca66c884810be0e87b7083e7f2c | Rust | HerringtonDarkholme/leetcode | /src/68_full_justify.rs | UTF-8 | 1,780 | 3.265625 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn full_justify(words: Vec<String>, max_width: i32) -> Vec<String> {
let mut ret = vec![];
let max = max_width as usize;
let mut i = 0;
while i < words.len() {
let next = divide(&words, i, max);
let line = print_one_line(&w... | true |
f4f14cae6421f45bd39db5f982104c08b988a7a2 | Rust | sundflux/wppr | /src/pipeline.rs | UTF-8 | 9,270 | 2.8125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! # Pipeline
//!
//! Defines an upgrade pipeline that can be used to upgrade and gitify single
//! WordPress plugins.
use fs_extra;
use std::{
fs::write,
path::PathBuf
};
use config::RuntimeConfig;
use git::Git;
use wordpress::{Plugin, WpCli, get_plugin_version};
/// Data for an upgrade pipeline.
pub stru... | true |
963f8551d6a188d855b1e46fae3f45abaf7141fa | Rust | panther-king/koyomi | /src/era.rs | UTF-8 | 7,723 | 3.828125 | 4 | [
"MIT"
] | permissive | //! # 和暦定義
//!
//! 西暦に対応する元号(和暦)の定義。
//! 天皇即位日に元号が変わり、在位中は変わらない。
use crate::Date;
/// 明治以降の和暦
const ERA: [(&str, i32, u32, u32, Option<(i32, u32, u32)>); 5] = [
("令和", 2019, 5, 1, None),
("平成", 1989, 1, 8, Some((2019, 4, 30))),
("昭和", 1926, 12, 25, Some((1989, 1, 7))),
("大正", 1912, 7, 30, Some((1926, 1... | true |
b3b26bfb4c5944cd8ad64fb54e4666bc96476cb9 | Rust | talliberman/lrpeg | /lrpeg-test/src/lib.rs | UTF-8 | 6,515 | 2.796875 | 3 | [
"MIT"
] | permissive | #![cfg_attr(not(test), allow(dead_code, unused_imports))]
use std::env;
use std::path::PathBuf;
include!(concat!(env!("OUT_DIR"), "/calculator.rs"));
include!(concat!(env!("OUT_DIR"), "/direct_left_recursive.rs"));
include!(concat!(env!("OUT_DIR"), "/indirect_left_recursive.rs"));
include!(concat!(env!("OUT_DIR"), "/... | true |
c847ded1edbbb2210a4ca5a1a94e62c5528b68f9 | Rust | MinusKelvin/game-util-rs | /src/web/glutil.rs | UTF-8 | 2,021 | 2.609375 | 3 | [
"MIT"
] | permissive | use crate::prelude::*;
use wasm_bindgen_futures::JsFuture;
use web_sys::HtmlImageElement;
#[derive(Clone)]
pub struct Gl(std::rc::Rc<(glow::Context, web_sys::WebGl2RenderingContext)>);
impl Gl {
pub(crate) fn new(gl: web_sys::WebGl2RenderingContext) -> Self {
Gl(std::rc::Rc::new((
glow::Contex... | true |
82e33ef829bc86c5b36e37b8910b4689bec44d49 | Rust | rust-rosetta/rust-rosetta | /tasks/strip-comments-from-a-string/src/main.rs | UTF-8 | 669 | 3.25 | 3 | [
"Unlicense"
] | permissive | fn strip_comments(s: &str) -> &str {
let markers = ['#', ';'];
s.find(&markers[..]).map_or(s, |i| &s[..i]).trim()
}
#[test]
fn test_strip_comments() {
let inputs = [
"apples, pears # and bananas",
"apples, pears ; and bananas",
" apples, pears ",
];
let output = "apples, pe... | true |
90fa8eaa58db86724df3ecaba84f2bd2b916959a | Rust | mabruckner/inventory | /client/src/main.rs | UTF-8 | 4,143 | 2.75 | 3 | [
"MIT"
] | permissive | #[macro_use] extern crate yew;
extern crate serde;
#[macro_use] extern crate serde_derive;
use yew::html::*;
use yew::services::console::ConsoleService;
use yew::services::fetch::{Method, FetchService};
use yew::format::Json;
use std::collections::HashMap;
#[derive(Debug, Serialize, Clone, Deserialize)]
pub struct Cl... | true |
60bc4717fd8fa54144486f20cd0686a79143d37e | Rust | therealprof/mkw41z | /src/mcm/placr/mod.rs | UTF-8 | 23,888 | 2.671875 | 3 | [
"BSD-3-Clause",
"0BSD"
] | permissive | #[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::PLACR {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut... | true |
5cec0de5a7decf0b4edf9cda31a7ec1838adb18d | Rust | hansihe/prom-attire-rs | /prom-attire-impl/src/errors.rs | UTF-8 | 940 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use syn;
error_chain! {
errors {
StructBody {
description("can only be applied to normal structs")
}
TyParams(ty_params: Vec<syn::TyParam>) {
description("cannot have type parameters on the struct")
}
Lifetimes(lifetimes: Vec<syn::LifetimeDef>) {
... | true |
676da5517596a02d38a3367433ec559412fd1468 | Rust | korneliuszw/ontime | /src/config.rs | UTF-8 | 2,209 | 3.046875 | 3 | [] | no_license | use std::path::PathBuf;
use clap::Clap;
#[derive(Clap, Debug)]
#[clap(version = "1.0", author = "Korneliusz W.")]
pub struct Config {
#[clap(short, long, about="Maximum time distance between current time and unexecuted event, in which the pending event will be executed (in minutes)", default_value = "90")]
pu... | true |
35c2027669520e6b5389546ded6ca5a49747d750 | Rust | vmasdani/rs2dart-proto | /rustdart/src/lib.rs | UTF-8 | 5,392 | 2.59375 | 3 | [] | no_license | extern crate proc_macro;
use std::{any::type_name, fs};
use proc_macro::{Ident, TokenStream};
use syn::{parse_macro_input, Data, DataStruct, DeriveInput, Fields};
// use syn::{DeriveInput, Field, ItemEnum, Token, braced, parse::{ParseStream, Parse}, parse_macro_input, punctuated::Punctuated, token};
#[proc_macro_attr... | true |
761eb07dfbd7f9321b1f6d3ec9d450c6b8ce9be2 | Rust | minus3theta/contest | /cargo/abc162/src/bin/d.rs | UTF-8 | 950 | 2.59375 | 3 | [] | no_license | #[allow(unused_imports)]
use std::cmp;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use itertools::Itertools;
#[fastout]
fn main() {
input! {
... | true |
bb4538a4b2c03463edd34ec737a8433dcd79dc66 | Rust | jmpargana/exercism | /rust/atbash-cipher/src/lib.rs | UTF-8 | 743 | 3.46875 | 3 | [] | no_license | static ALPHABET: &'static str = "abcdefghijklmnopqrstuvwxyz";
pub fn encode(plain: &str) -> String {
plain
.to_ascii_lowercase()
.chars()
.filter(char::is_ascii_alphanumeric)
.map(swap)
.enumerate()
.map(|(i, c)| match (i + 1) % 5 {
0 => format!("{} ", c)... | true |
4986885b8e7ec0e3042fd2223c115742dd9de41a | Rust | boulanlo/ABR | /src/bencher.rs | UTF-8 | 2,950 | 2.859375 | 3 | [] | no_license | use crate::abr::ABR;
use std::fs::File;
use std::io::{BufWriter, Error, Write};
use std::path::Path;
use std::time::Duration;
use time::precise_time_ns;
const ITERATIONS: usize = 100;
pub struct Bencher<'a, S, F> {
path: &'a Path,
setup: S,
function: F,
}
impl<'a, S, F> Bencher<'a, S, F>
where
S: Fn(... | true |
3739674a7f39859d377bf1da54aa0988cb7db689 | Rust | ristew/map-game | /src/settlement.rs | UTF-8 | 2,499 | 2.640625 | 3 | [] | no_license | use bevy::{ecs::system::SystemParam, prelude::*};
use crate::prelude::*;
use crate::constant::DAY_LABEL;
use crate::pops::*;
use crate::map::*;
use crate::province::*;
use crate::factor::*;
use crate::stage::DayStage;
use crate::time::Date;
use serde::{Serialize, Deserialize};
#[derive(Clone, Copy, Debug, Serialize, D... | true |
e0afb134336886561be7c56b50c41855a8480092 | Rust | benbrunton/pusoy_dos_server | /project/src/api/controller/my_cards.rs | UTF-8 | 2,659 | 2.703125 | 3 | [] | no_license | use iron::prelude::*;
use iron::status;
use iron::middleware::Handler;
use iron::mime::Mime;
use router::Router;
use std::collections::BTreeMap;
use serde_json;
use helpers;
use helpers::DCard;
use data_access::round::Round as RoundData;
use pusoy_dos::game::game::Game;
#[derive(Clone)]
pub struct MyCards{
rou... | true |
c98b07d93ddc2ed6f571a3c3fc46ffe424aa9df6 | Rust | sile/Khora | /plumcast_used/hyparview/src/lib.rs | UTF-8 | 6,000 | 2.625 | 3 | [
"MIT"
] | permissive | //! A Rust implementation of [HyParView] algorithm.
//!
//! # References
//!
//! - [HyParView: a membership protocol for reliable gossip-based broadcast][HyParView]
//!
//! [HyParView]: http://asc.di.fct.unl.pt/~jleitao/pdf/dsn07-leitao.pdf
#![warn(missing_docs)]
pub use action::Action;
pub use event::Event;
pub use no... | true |
75c8e1d5d059c515f087327a98eb1dd4ed42d77e | Rust | qingwei91/rust-eulers | /src/solutions.rs | UTF-8 | 1,908 | 3.28125 | 3 | [] | no_license | pub mod solutions {
pub fn problem1() -> i32 {
let mut x = 0;
for n in 1..1000 {
match n {
of5 if of5 % 5 == 0 => x = x + of5,
of3 if of3 % 3 == 0 => x = x + of3,
_ => ()
}
}
return x;
}
pub fn problem2(... | true |
37dadc21070a78be59a399bc6b4c1aca62be70eb | Rust | tdcare/eventmill | /eventmill-derive/tests/event_struct_all_attributes.rs | UTF-8 | 561 | 2.96875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use eventmill_derive::EventType;
#[derive(EventType, Debug)]
#[event_type("turtle-turned")]
#[event_type_version("V2")]
#[event_source("https://github.com/innoave/eventmill/examples/turtle")]
pub struct TurtleTurned {
angle: f32,
}
#[test]
fn main() {
use eventmill::EventType;
let turtle = TurtleTurned {... | true |
8444446ea1b1c46da31eb9500105be2027221a3d | Rust | jacklund/cryptopals_old | /src/challenges/set_1/challenge2.rs | UTF-8 | 526 | 3.078125 | 3 | [] | no_license | #[cfg(test)]
mod tests {
use crate::util::xor;
// Second cryptopals challenge - https://cryptopals.com/sets/1/challenges/2
#[test]
fn challenge2() {
assert_eq!(
hex::encode(
xor(
&hex::decode("1c0111001f010100061a024b53535009181c").unwrap(),
... | true |
33454240afe1dc39e19e4e5388b98579f76b4665 | Rust | mishaszu/RUST-INTRO | /src/ex2/structs_04/src/basic_struct.rs | UTF-8 | 907 | 3.234375 | 3 | [] | no_license | struct User {
username: String,
email: String,
sign_in_count: u64,
active: bool,
}
struct Color(i32, i32, i32);
struct Point(i32, i32, i32);
fn build_user(username: String, email: String) -> User {
User {
username,
email,
active: true,
sign_in_count: 1,
}
}
fn ... | true |
590b2a6a8d3ec1bf1748c39c69b90707c60e1e7e | Rust | fewensa/rtdlib | /src/types/connected_websites.rs | UTF-8 | 1,792 | 2.875 | 3 | [
"MIT"
] | permissive |
use crate::types::*;
use crate::errors::*;
use uuid::Uuid;
/// Contains a list of websites the current user is logged in with Telegram
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ConnectedWebsites {
#[doc(hidden)]
#[serde(rename(serialize = "@type", deserialize = "@type"))]
td_name: S... | true |
27aa2f0e337d34c85b2f373ebfa2e53a624221ed | Rust | sueken5/resea | /libs/resea/utils.rs | UTF-8 | 1,775 | 3.3125 | 3 | [
"MIT",
"CC0-1.0"
] | permissive | pub unsafe fn strlen(mut c_str: *const u8) -> usize {
let mut len = 0;
while *c_str != 0 {
len += 1;
c_str = c_str.add(1);
}
len
}
pub unsafe fn c_str_to_str<'a>(c_str: *const u8) -> &'a str {
let slice = core::slice::from_raw_parts(c_str, strlen(c_str));
core::str::from_utf8_un... | true |
6c5e31862002200a27fbf7206c9a22d9b7b9aa73 | Rust | ivfranco/notes | /OS/process/vermont-bridge/src/main.rs | UTF-8 | 857 | 2.65625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | use rand::random;
use std::{env, process, thread};
use vermont_bridge::{north_villager, south_villager, BridgeLock};
fn main() {
let mut args = env::args();
args.next();
let villagers = args
.next()
.and_then(|arg| arg.parse::<u32>().ok())
.unwrap_or_else(|| {
eprintln!... | true |
47ab8bf4537907b4ab16d515f71ca2cfc3f50ba8 | Rust | zakarumych/bitsetium | /src/difference.rs | UTF-8 | 3,545 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use {
crate::{ops::*, union::Union},
core::fmt::{self, Display},
};
/// Bit-set wrapper that acts like set complement.
///
/// Effectively inverses all bits in the underlying bit-set.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct Difference<T, U>(pub T, pub U);
impl<T, U> Display for ... | true |
f225fbabf0c8bb2de90e6e47a7b710b0d94431b5 | Rust | Axect/Rust | /Tutorial/Essential/Chap3/ifelse.rs | UTF-8 | 573 | 3.578125 | 4 | [] | no_license | fn main() {
let dead = false;
let health = 48;
if dead {
println!("Game over!");
} else {
println!("You still have a chance to win!");
}
if health >= 50 {
println!("Continue to fight!");
} else if health >= 20 {
println!("Stop the battle and gain strength!");... | true |
a6446f2ff6498e78dd13dbfd6bcfb852b92576c4 | Rust | xpe/rs_bandit_testbed | /src/bandit.rs | UTF-8 | 1,363 | 3.34375 | 3 | [] | no_license | use arm::Arm;
use rand::Rng;
/// Setup parameters
#[derive(Clone, Debug)]
pub struct Bandit {
/// Bandit arms
pub arms: Vec<Arm>
}
impl Bandit {
/// Returns a randomly initialized bandit.
pub fn new<R: Rng>(rng: &mut R, num_arms: usize, bias: f64) -> Bandit {
assert!(num_arms > 0);
let... | true |
dd399fa2eaee3e657e33e1e70c77a4bad0093bbc | Rust | JimFawcett/RustBasicDemos | /logger/examples/test1.rs | UTF-8 | 2,088 | 2.921875 | 3 | [] | no_license | /// -------------------------------------------------------
/// RustBasicDemos::Logger::examples::test1.rs
/// Jim Fawcett, https://JimFawcett.github.io, 17 Mar 2020
/// -------------------------------------------------------
extern crate logger;
use logger::{*};
use display::{*};
use std::fs::File;
fn main() {
... | true |
2b37294dc1a559e0c03d615f0488c87725fcf05b | Rust | SametSisartenep/rusting | /variables/src/underlaws.rs | UTF-8 | 41 | 2.59375 | 3 | [
"MIT"
] | permissive | fn main() {
let mut x = 5;
x = 10;
}
| true |
2e88d8280f0acf7cc9ae049caf1d62d3e44e7d66 | Rust | jeizsm/actix-telegram | /src/types/input_media_video.rs | UTF-8 | 2,205 | 3.09375 | 3 | [
"MIT"
] | permissive | use crate::types::{InputFileOrString, Integer, ParseMode};
/// Represents a video to be sent.
#[derive(Debug, Serialize, Setters, New)]
#[new(vis = "pub")]
#[set(vis = "pub")]
pub struct InputMediaVideo {
/// Type of the result, must be video
#[serde(rename = "type")]
pub(crate) type_: String,
/// File... | true |
fc225ad77fa4f59917c0dd5ec5f773efbf8a6e20 | Rust | alamb/arrow2 | /src/compute/sort/primitive/sort.rs | UTF-8 | 5,426 | 2.765625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | 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 |
d5938efd422dfe442eec857c3cd4ba7d29c677c9 | Rust | gnoliyil/fuchsia | /src/sys/component_manager/src/model/addable_directory.rs | UTF-8 | 4,866 | 2.8125 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::model::error::ModelError,
moniker::AbsoluteMoniker,
std::sync::Arc,
vfs::directory::{entry::DirectoryEntry, helper::DirectlyMu... | true |
ec0f4b73197193f94af580bdf2695e75dc03804c | Rust | magiclen/benchmarking | /src/lib.rs | UTF-8 | 19,884 | 3.609375 | 4 | [
"MIT"
] | permissive | //! # Benchmarking
//!
//! This crate can be used to execute something and measure the execution time. It does not output anything to screens and filesystems.
//!
//! ## Examples
//!
//! ```rust
//! const VEC_LENGTH: usize = 100;
//!
//! benchmarking::warm_up();
//!
//! let bench_result = benchmarking::measure_function... | true |
6916302163cee712a08050abaa73e5a22cf433a1 | Rust | chromium/chromium | /third_party/rust/rand/v0_8/crate/src/distributions/distribution.rs | UTF-8 | 8,381 | 3.375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"GPL-1.0-or-later",
"LGPL-2.0-or-later"
] | permissive | // Copyright 2018 Developers of the Rand project.
// Copyright 2013-2017 The Rust Project Developers.
//
// 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
// option. Thi... | true |
a4851d418e9ecafab9c589e6029c000e2478e9d1 | Rust | tglanz/amethyst-snake | /game/src/resources/config.rs | UTF-8 | 808 | 2.578125 | 3 | [
"MIT"
] | permissive | use std::time::Duration;
use serde::{Deserialize, Serialize};
#[derive(Default, Debug, Deserialize, Serialize)]
pub struct GridConfig {
pub offset: (f32, f32),
pub tile_size: f32,
pub tile_scale: f32,
pub tile_margin: f32,
}
#[derive(Default, Debug, Deserialize, Serialize)]
pub struct SpriteConfig {
... | true |
5bb32f961b9f59533009d6ab879f2990a22b67a4 | Rust | rowans329/calculator | /src/main.rs | UTF-8 | 5,388 | 3.140625 | 3 | [] | no_license | #[macro_use]
extern crate clap;
use dialoguer::Input;
use regex::Regex;
use std::fmt::{self, Display};
use std::str::FromStr;
fn main() {
let matches = clap_app!(calculator =>
(version: crate_version!())
(author: crate_authors!())
(about: crate_description!())
(@arg expr: "The expr... | true |
2d85eb3f042441b4d7990ddb1181111092e18406 | Rust | smilerobotics/dobot_client | /src/protocol.rs | UTF-8 | 5,661 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | use failure::format_err;
use failure::Error;
use std::fmt;
use std::num::Wrapping;
#[repr(u8)]
#[derive(Clone, Debug, PartialEq)]
pub enum ReadWrite {
READ,
WRITE,
}
impl From<u8> for ReadWrite {
fn from(rw: u8) -> ReadWrite {
if rw == 1 {
ReadWrite::WRITE
} else {
... | true |
a4e91ae9ba56c38d4a35a3076d09fffa72423a54 | Rust | guygastineau/roxmltree-example | /src/main.rs | UTF-8 | 1,550 | 3 | 3 | [] | no_license | use std::fs;
use roxmltree::{Document, Node as XmlNode};
// these are pretty ugly otherwise ;)
type RowStats = (usize, Vec<usize>);
type TableStats = (usize, Vec<(usize, Vec<usize>)>);
const DOCUMENT: &str = "document.xml";
const NS: &str =
"http://schemas.openxmlformats.org/wordprocessingml/2006/main";
// Mat... | true |
15be6f83304a07a3dc19b2770720dcca57943ae4 | Rust | Marwes/ice | /src/lib.rs | UTF-8 | 850 | 2.59375 | 3 | [] | no_license | #[macro_use]
extern crate combine;
use combine::*;
type RedisError = ();
type RedisResult<T> = Result<T, ()>;
struct ResultExtend(Result<Vec<i32>, RedisError>);
impl Default for ResultExtend {
fn default() -> Self {
ResultExtend(Ok(Vec::new()))
}
}
impl ::std::iter::FromIterator<RedisResult<i32>> f... | true |
55221f823c7bef026820ccdcc06ae622ef85729b | Rust | RedL0tus/rust-learn | /chapter-15/15.4-rc_the_reference_counted_smart_pointer/src/main.rs | UTF-8 | 738 | 3.28125 | 3 | [] | no_license | use std::rc::Rc;
#[derive(Debug)]
enum List {
Cons(i32, Rc<List>),
Nil,
}
use List::{Cons, Nil};
fn main() {
let a = Rc::new(Cons(5,
Rc::new(Cons(10,
Rc::new(Nil)))));
println!("The value of a is: {:?}", a);
println!(">>> Count after creating a is: {}.", Rc::strong_count(&a));... | true |
f4f9140fe4df19c69088b8e2fe9f71b9e87d8c2a | Rust | weirdan/rust-knight-tour | /src/main.rs | UTF-8 | 4,425 | 3.5 | 4 | [] | no_license | use threadpool::ThreadPool;
use std::time::Instant;
type Point = (i32, i32);
#[derive(Debug, Clone)]
struct Board {
cells: Vec<Vec<bool>>,
}
impl Board {
fn new(size: usize) -> Board {
Board {
cells: vec![vec![false; size]; size],
}
}
fn visit(&mut self, &(x, y): &Point) {... | true |
5add54b0cea0166b21e9ce72b91f1f9a04c1a3cc | Rust | liona24/wasm-tetris | /src/lib.rs | UTF-8 | 8,976 | 2.6875 | 3 | [
"MIT"
] | permissive | mod utils;
extern crate js_sys;
use utils::set_panic_hook;
use wasm_bindgen::prelude::*;
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
type Grid = [[u8; 10]; 40];... | true |
39f45a5e2cdf224dc1c6538c58f66ce599326028 | Rust | awoimbee/rsr | /src/file_transformer.rs | UTF-8 | 3,536 | 3.125 | 3 | [] | no_license | use std::borrow::Cow;
use std::fmt::Write as FmtWrite;
use std::fs::{File, OpenOptions};
use std::io::prelude::*;
use std::mem::transmute;
use std::path::Path;
use std::pin::Pin;
#[derive(Debug)]
pub struct FileTransformer<'a> {
txt: Pin<String>,
unread_txt: &'a str,
new_txt: Vec<Cow<'a, str>>,
modifie... | true |
e23d920ae4f4e986838f32bebf2e75502ac2e4e0 | Rust | sergiu-paraschiv/ttf_loader | /src/lib.rs | UTF-8 | 983 | 2.71875 | 3 | [] | no_license | use structview::{u32_be, u16_be, View};
#[derive(Clone, Copy, View)]
#[repr(C)]
pub struct TTFHeader {
pub sfnt_version: u32_be,
pub num_tables: u16_be,
pub search_range: u16_be,
pub entry_selector: u16_be,
pub range_shift: u16_be,
}
impl TTFHeader {
pub fn from_bytes(data: &[u8]) -> Result<&T... | true |
9ce0350b3f5f312edf0fce688c036b64fbcb4beb | Rust | AcamTech/langcraft | /tests/fibonacci.rs | UTF-8 | 457 | 2.765625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use langcraft::{Datapack, Interpreter};
use std::path::Path;
#[test]
pub fn fibonacci() {
let datapack = Datapack::from_bc(Path::new("./tests/fibonacci.bc")).unwrap();
let idx = datapack.functions.iter().enumerate().find(|(_, f)| f.id.name == "run").unwrap().0;
let mut interp = Interpreter::new(datapack,... | true |
5ddc9c07bc375bb060814474af269b2ec6946283 | Rust | rune-rs/rune | /crates/rune/src/fmt/comments.rs | UTF-8 | 3,211 | 3.03125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Extract comments from source code.
#[cfg(test)]
mod tests;
use core::str::CharIndices;
use crate::no_std::prelude::*;
use crate::ast::Span;
use crate::fmt::FormattingError;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub(super) enum CommentKind {
Line,
Block,
}
#[derive(Debug, Clone, PartialEq,... | true |
64aaeaeec82c34056772fa2c90e195279b849e5a | Rust | hawkw/ysh | /src/main.rs | UTF-8 | 2,864 | 3.09375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::{
str,
process::exit,
};
use failure::{
Error,
};
use crossterm::{
Screen,
input,
};
use std::io::Write;
use duct::cmd;
mod term;
mod st;
fn main() {
// Put it in raw mode
let mut screen = Screen::new(true);
st::init(&mut screen).unwrap_or_else(|e| {
eprintln!("{}", e... | true |
e9a9882bfc475e3e765d97ebc7fd35683b6e2316 | Rust | KyMann/RustTutorial | /src/main.rs | UTF-8 | 8,708 | 3.6875 | 4 | [] | no_license | mod random_info;
use random_info::*;
#[allow(non_snake_case)]
#[allow(unused_variables)]
fn main() {
println!("Hello World");
data_types_follow_along();
}
fn data_types_follow_along() {
let some_data: bool = true; //or false
let implied_data = false; //Rust assumes you want a boolean
//rust ass... | true |
2488815bdf69de4c47ffc86f4a255ed1e78b3dce | Rust | grogers0/advent_of_code | /2015/day19/src/main.rs | UTF-8 | 1,899 | 3.265625 | 3 | [
"MIT"
] | permissive | use std::collections::{BTreeMap, BTreeSet};
use std::io::{self, Read};
use regex::Regex;
fn parse(input: &str) -> (BTreeMap<String, Vec<String>>, String) {
let re = Regex::new("^([A-Za-z]+) => ([A-Za-z]+)$").unwrap();
let mut replacements: BTreeMap<_, Vec<_>> = BTreeMap::new();
let mut molecule = String::... | true |
c231e4d1202d30acb85aac5d2c8f19f8cf69db09 | Rust | celialewis3/pokerust | /src/pokemon.rs | UTF-8 | 4,050 | 3.453125 | 3 | [] | no_license | #[macro_use(lazy_static)]
use std::collections::HashMap;
use rand::Rng;
use lazy_static::lazy_static;
use std::io::*;
#[derive(Debug, Clone)]
struct PokeGroup {
pokemon: Vec<Pokemon>,
size: u32,
}
#[derive(Debug, Clone)]
struct Pokemon {
name: String,
_type: Type,
level: u32,
health: u32,
... | true |
aa4d709076108295ffe6a3c95f9e98f208aa5b6a | Rust | k0pernicus/rust-progressbar | /src/lib.rs | UTF-8 | 1,867 | 3.53125 | 4 | [] | no_license | use std::io::prelude::*;
use std::io;
/// ProgressBar is a simple object to represent a basic time computation progression.
/// Currently, this object has not been published in "Cargo". Also, there's few risk of bugs..;
/// ## Example
/// ```
/// let current_value = 0;
/// let max_value = 100;
/// let current_characte... | true |
3729d017f4ee6dd4173315637378fb262e5da44f | Rust | clumsyme/learn-rust | /function/src/main.rs | UTF-8 | 342 | 3.578125 | 4 | [
"MIT"
] | permissive | fn main() {
println!("Hello, world!");
another_function();
let y = {
let x = 3;
x + 1
};
let x = 9 + 7;
println!("x is {}", x);
println!("y is {}", y);
println!("power(8): {}", power(8));
}
fn another_function() {
println!("Another called!");
}
fn power(n: i32)... | true |
7d41c105a532044919e8547384fbe94ff69d020e | Rust | b-r-u/osmpbf | /src/block.rs | UTF-8 | 12,605 | 3.296875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! `HeaderBlock`, `PrimitiveBlock` and `PrimitiveGroup`s
use crate::dense::DenseNodeIter;
use crate::elements::{Element, Node, Relation, Way};
use crate::error::{new_error, ErrorKind, Result};
use crate::proto::osmformat;
use std;
/// A `HeaderBlock`. It contains metadata about following [`PrimitiveBlock`]s.
#[deriv... | true |
857cbcc8aba055419cfa342021ae625f9bdf8577 | Rust | markhildreth/space-trouble | /st_core/src/common/mod.rs | UTF-8 | 4,969 | 2.609375 | 3 | [] | no_license | mod control_values;
mod messaging;
mod time;
use heapless::consts::*;
use heapless::spsc::Queue;
pub use control_values::*;
pub use messaging::*;
pub use time::*;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Events {
SystemStarted(SystemStartedEvent),
Tick(TickEvent),
AwaitingInput(AwaitingInput... | true |
49130eefc68a50892bf2c11d4e9dd5d3ff897774 | Rust | rust-chainblock/mitrid-core | /src/util/regex.rs | UTF-8 | 1,248 | 3.328125 | 3 | [
"Apache-2.0"
] | permissive | //! # Regex
//!
//! `regex` is the module providing the regex utility functions.
use regex::Regex;
use std::collections::HashMap;
use base::Result;
/// Returns if the target string matches the regex pattern.
pub fn is_match(pattern: &str, target: &str) -> Result<bool> {
let reg = Regex::new(pattern).map_err(|e|... | true |
f061a1bcb03f78731a43709c320ea722167b4dc1 | Rust | ysgard/rust-lazy-foo | /lesson18/src/main.rs | UTF-8 | 4,395 | 3.171875 | 3 | [] | no_license | extern crate sdl2;
extern crate sdl2_image;
use std::collections::HashMap;
use std::path::Path;
use sdl2::Sdl;
use sdl2::video::{Window, WindowPos, OPENGL};
use sdl2::render::{RenderDriverIndex, ACCELERATED, Renderer, Texture};
use sdl2::event::Event;
use sdl2::scancode::ScanCode;
use sdl2::keyboard::get_keyboard_sta... | true |
a3226502f35dd3b778b6032a24ca7c4844c20eaf | Rust | nical/pathfinder | /pathfinder-classic/src/util.rs | UTF-8 | 3,036 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | // Copyright 2017 The Servo 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... | true |
024414b897bfb1dbbd96339992b7fd0849612bd3 | Rust | billmcchesney1/linkerd2-proxy | /linkerd/buffer/src/dispatch.rs | UTF-8 | 3,953 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | use crate::error::{IdleError, ServiceError};
use crate::InFlight;
use futures::{prelude::*, select_biased};
use linkerd_channel as mpsc;
use linkerd_error::Error;
use std::sync::Arc;
use tower::util::ServiceExt;
use tracing::trace;
pub(crate) async fn idle(max: std::time::Duration) -> IdleError {
tokio::time::slee... | true |
bcca36f4c0fd89258373a7afeb23b1ecdf42f86f | Rust | emrsmsrli/phosphorus | /src/camera.rs | UTF-8 | 1,875 | 3.015625 | 3 | [
"MIT"
] | permissive | use nalgebra::{Point3, Vector3};
use crate::ray::Ray;
use rand::Rng;
pub const ASPECT_RATIO: f64 = 16.0 / 9.0;
pub struct Camera {
position: Point3<f64>,
lower_left_corner: Point3<f64>,
horizontal: Vector3<f64>,
vertical: Vector3<f64>,
u: Vector3<f64>,
v: Vector3<f64>,
lens_radius: f64,
}
... | true |
fffc7b1834e3e2c8339e5e4362fe31de80274567 | Rust | Michael-F-Bryan/tokio | /tokio-threadpool/src/task.rs | UTF-8 | 15,212 | 2.90625 | 3 | [
"MIT"
] | permissive | use notifier::Notifier;
use sender::Sender;
use futures::{self, future, Future, Async};
use futures::executor::{self, Spawn};
use std::{fmt, mem, panic, ptr};
use std::cell::Cell;
use std::sync::Arc;
use std::sync::atomic::{self, AtomicUsize, AtomicPtr};
use std::sync::atomic::Ordering::{AcqRel, Acquire, Release, Rel... | true |
e3297fa7f4621860f48cc42d85bb00ffa8c7d1e1 | Rust | andrewflbarnes/advent-of-code-2020 | /22/src/main.rs | UTF-8 | 3,850 | 2.875 | 3 | [] | no_license | use std::env;
use std::fs;
use std::collections::VecDeque;
use std::collections::HashSet;
fn main() {
let args: Vec<String> = env::args().collect();
let filename = &args[1];
let mut player_1 = false;
let mut p1_deck_start = VecDeque::new();
let mut p2_deck_start = VecDeque::new();
fs::read_to_... | true |
051e3e2f96a6d4c659b493231ac061041ba8aa7e | Rust | herwigstuetz/open-here | /src/main.rs | UTF-8 | 1,438 | 2.53125 | 3 | [
"MIT"
] | permissive | use open_here::cli;
use open_here::client;
use open_here::server;
use open_here::setup_logger;
use open_here::OpenTarget;
use envconfig::Envconfig;
use structopt::StructOpt;
pub fn serve(config: server::Config) -> Result<(), String> {
let server = server::Server::new(config)?;
let res = server.run();
if... | true |
a2b05d0d4e26a4894149fe93ca77c1c490255c59 | Rust | kalou/whe.re | /backend/osm/src/poi.rs | UTF-8 | 271 | 2.53125 | 3 | [] | no_license | /* Save some memory and get rid of tags.. Autogen ?*/
enum Poi {
Bar,
Parking,
Billiards,
Unknown
}
fn poi_type(s: &str) -> Poi {
match s {
"bar" | "pub" => Poi::Bar,
"billiards" => Poi::Billiards,
_ => Poi::Unknown
}
}
| true |
4b37eb79b93c330c8435b98f194b0d67dea08ca8 | Rust | andresattler/bubble_harrier | /src/bundles/kiss/draw.rs | UTF-8 | 1,956 | 2.765625 | 3 | [] | no_license | use super::SharedWindow;
use crate::{components::*, util::*};
use kiss3d::scene::SceneNode;
use specs::prelude::*;
use std::collections::{BTreeMap, BTreeSet};
pub struct DrawSystem {
win: SharedWindow,
nodes: BTreeMap<Entity, SceneNode>,
}
impl DrawSystem {
pub fn new(win: SharedWindow) -> Self {
... | true |
67c238218896b1603d99e508b4cda2a4cf2ac692 | Rust | mrnugget/dora | /dora/src/semck/flowck.rs | UTF-8 | 2,753 | 2.671875 | 3 | [
"MIT"
] | permissive | use crate::error::msg::SemError;
use crate::vm::{Fct, FctSrc, VM};
use dora_parser::ast::visit::*;
use dora_parser::ast::Stmt::*;
use dora_parser::ast::*;
pub fn check<'ast>(vm: &VM<'ast>) {
for fct in vm.fcts.iter() {
let fct = fct.read();
if !fct.is_src() {
continue;
}
... | true |
10581d57f9f79586f7bff1113da427e0fa285ecf | Rust | robn/jmap-rs | /src/parse.rs | UTF-8 | 7,570 | 3.234375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::string::ToString;
use std::collections::BTreeMap;
use std::error::Error;
use std::fmt;
use std::{i32,i64,usize};
use rustc_serialize::json::{Json,ToJson};
use parse::Presence::*;
#[derive(Clone, PartialEq, Debug)]
pub enum ParseError {
InvalidJsonType(String),
InvalidStructure(String),
MissingFie... | true |
21d7cb1506c112d30fc4e0fb237c665179452b6e | Rust | davetttt/ttt_rust_2 | /src/minimax.rs | UTF-8 | 1,305 | 2.875 | 3 | [] | no_license | use super::token::Token;
use super::rules;
use super::board;
fn get_score(board: &Vec<Token>) -> isize {
let absolute_value_score = board.len() as isize + 1;
match rules::get_winner(board) {
Some(Token::X) => absolute_value_score,
Some(Token::O) => -absolute_value_score,
_ ... | true |
cb777f762123f68ccf2dde3a9212aed1cf6ea1be | Rust | Murasame233/casper-event | /contract/src/user.rs | UTF-8 | 1,467 | 3.015625 | 3 | [] | no_license | //! [For Event User]
//!
//! use
//! ```
//! set_event_callback("event_name".into(),contract_hash,callback_entry,target_hash);
//! unset_event_callback("event_name".into(),contract_hash,callback_entry,target_hash);
//! ```
extern crate alloc;
use alloc::string::String;
use casper_contract::contract_api::runtime::call_... | true |
d042fafb49770471cd81ecb315a940ef5726df87 | Rust | itang/tests | /test-rusts/test-futures/src/main.rs | UTF-8 | 1,451 | 2.65625 | 3 | [] | no_license | extern crate futures;
extern crate futures_io;
extern crate futures_mio;
extern crate futures_tls;
use std::net::ToSocketAddrs;
use std::thread;
use std::time::Duration;
use futures::Future;
use futures_mio::Loop;
use futures_tls::ClientContext;
fn main() {
let mut lp = Loop::new().unwrap();
let addr = "www.... | true |
e78635b5dfc812b052828c0dac94180d5571fe68 | Rust | tailhook/unshare | /src/linux.rs | UTF-8 | 11,065 | 2.796875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::ffi::OsStr;
use std::io;
use std::os::unix::io::AsRawFd;
use std::path::Path;
use nix::sys::signal::{Signal};
use crate::ffi_util::ToCString;
use crate::{Command, Namespace};
use crate::idmap::{UidMap, GidMap};
use crate::stdio::dup_file_cloexec;
use crate::namespace::to_clone_flag;
use crate::caps::Capabili... | true |
a97b8f89e03ee84f8b7b1cf43d098e3a64167f12 | Rust | typst/typst | /crates/typst-library/src/meta/link.rs | UTF-8 | 4,269 | 3.453125 | 3 | [
"Apache-2.0",
"Bitstream-Vera",
"CC-BY-4.0",
"OFL-1.1",
"LicenseRef-scancode-gust-font-1.0",
"BSD-3-Clause",
"LicenseRef-scancode-ubuntu-font-1.0",
"0BSD",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-public-domain",
"MIT",
"LicenseRef-scancode-public-domain-disclaimer"
] | permissive | use crate::prelude::*;
use crate::text::{Hyphenate, TextElem};
/// Links to a URL or a location in the document.
///
/// By default, links are not styled any different from normal text. However,
/// you can easily apply a style of your choice with a show rule.
///
/// ## Example { #example }
/// ```example
/// #show l... | true |
29e3789c2f9356f53ec7ed273311f468cf6c992b | Rust | Orange-OpenSource/hurl | /packages/hurl/src/http/request_spec_curl_args.rs | UTF-8 | 15,701 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | /*
* Hurl (https://hurl.dev)
* Copyright (C) 2023 Orange
*
* 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 ... | true |
b615095fba2b05abdd000fde3740bb7520c63c40 | Rust | mattsse/extrablatt | /src/main.rs | UTF-8 | 5,832 | 2.609375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::path::PathBuf;
use futures::{stream, StreamExt};
use structopt::StructOpt;
use url::Url;
use extrablatt::article::PureArticle;
use extrablatt::{Article, Category, Config, Extrablatt};
#[allow(missing_docs)]
#[derive(Debug, StructOpt)]
#[structopt(name = "extrablatt", about = "News article scraping and curat... | true |
71703b5d621b983166a8112b6836e33705cfff6f | Rust | pierd/advent-of-code-2018 | /src/bin/day11ab.rs | UTF-8 | 1,829 | 3.4375 | 3 | [
"MIT"
] | permissive | use std::env;
fn power_level(x: usize, y: usize, serial_number: usize) -> isize {
let rack_id = x + 10;
let hundreds = (rack_id * y + serial_number) * rack_id / 100 % 10;
hundreds as isize - 5
}
fn main() {
let mut args = env::args();
args.next(); // skip program name
let serial_number: usize ... | true |
7e3dbd65695b9c9400460af35129bafe5d06fbdd | Rust | MrToph/spacecamp-hackathon-msig | /src/query.rs | UTF-8 | 5,596 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::fmt;
use cosmwasm_std::{CosmosMsg, Empty};
use crate::expiration::Expiration;
use crate::msg::Vote;
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum Cw3QueryMsg {
/// Returns... | true |
b1a024032edc72347649b2ee2fc4cbc3637a074d | Rust | alakahakai/vector | /src/transforms/util/runtime_transform.rs | UTF-8 | 5,961 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use crate::{event::Event, stream::VecStreamExt, transforms::Transform};
use futures::{
compat::Stream01CompatExt,
future,
stream::{self, BoxStream},
FutureExt, StreamExt, TryStreamExt,
};
use futures01::Stream;
use std::time::Duration;
/// A structure representing user-defined timer.
#[derive(Clone, Co... | true |
205fcb79903b22eee337072e5e9a154dd764953f | Rust | harpsword/tex-rs | /src/tex_the_program/section_0597.rs | UTF-8 | 1,025 | 2.671875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! @ The actual output of |dvi_buf[a..b]| to |dvi_file| is performed by calling
//! |write_dvi(a,b)|. For best results, this procedure should be optimized to
//! run as fast as possible on each particular system, since it is part of
//! \TeX's inner loop. It is safe to assume that |a| and |b+1| will both be
//! multip... | true |
34ce427ac4e889efbaf23ceb418d99c3281f1511 | Rust | ytyaru/Rust.fmt.Display.20190616123837 | /src/1/main.rs | UTF-8 | 995 | 3.78125 | 4 | [
"CC0-1.0"
] | permissive | /*
* 構造体や列挙の独自表示を実装する。
* CreatedAt: 2019-06-16
* https://stackoverflow.com/questions/28024373/is-there-a-way-to-print-enum-values
*/
use std::fmt;
fn main() {
// #[derive(Debug)]と{:?}{:#?}があればimplがなくとも名前を表示できる
// println!("{:?}", Suit::Heart);
// implすれば#[derive(Debug)], {:?}, {:#?}不要で指定の表示ができる
print... | true |
445120273aab375ef490abed782ce2f16525da32 | Rust | srir/advent-2020 | /src/day18.rs | UTF-8 | 2,599 | 3.171875 | 3 | [] | no_license | use aoc_runner_derive::aoc;
#[derive(Debug, PartialEq, Eq)]
enum Op {
Add,
Mul
}
struct ParseResult {
result: usize,
bytes_parsed: usize
}
fn parse_expr(slice: &[u8]) -> ParseResult {
let mut result = 0;
let mut op = Op::Add;
let mut idx = 0;
while idx < slice.len() {
let c ... | true |
646bbc1c8ed03ac9cc906998af1c120e71ed6e01 | Rust | BerenMillidge/RustTutorials | /src/enums.rs | UTF-8 | 1,735 | 3.765625 | 4 | [] | no_license | // so just some stuff abuot enums
// power of mathc comes from its pattern matching syntax and the fact that compiler ensures that all eventualities are coered - which is a very nice guarantee
// i.e. something like
enum Coin {
Penny,
Nickel,
Dime,
Quarter,
}
fn value_in_cents(coin: Coin) -> u32 {
match coin {
... | true |
846d13cb6717d7570541bddab21c0758a39ca42b | Rust | greenladiesadmin/clonerio | /src/renderer/texture.rs | UTF-8 | 1,763 | 2.828125 | 3 | [] | no_license | use std::{ffi::c_void, path::Path};
use image::{DynamicImage, GenericImageView};
#[derive(Debug)]
pub struct Texture {
pub id: u32,
pub width: u32,
pub height: u32,
}
impl Texture {
pub unsafe fn new(image: DynamicImage, flip_vertical: bool) -> Self {
let image = if flip_vertical { image.flip... | true |
f1d63b209d06867866c602f2210382d8fd4f6f9c | Rust | cogciprocate/ocl | /ocl-core/src/tests/vector_types.rs | UTF-8 | 10,288 | 2.859375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! [INCOMPLETE]: [TODO]: Test various types with an assortment of operations.
//!
#![cfg(feature = "ocl-core-vector")]
use crate::tests::get_available_contexts;
use crate::{CommandQueue, Context, Kernel, Mem, OclVec};
use std::ffi::CString;
const DATASET_SIZE: usize = 1 << 14;
const DIMS: [usize; 3] = [DATASET_SIZE... | true |
031bfab17fbb9dc8954d706108be96f40c837c30 | Rust | piedoom/stry | /src/drawing/screen.rs | UTF-8 | 425 | 2.609375 | 3 | [] | no_license | use crate::drawing::frame::Frame;
use amethyst::ecs::Entity;
use amethyst::prelude::{Builder, World};
/// Adds a `Frame` to the `World` and returns the newly attached `Entity`
///
/// * `frame` - the `Frame` that should attach to the world
/// * `world` - a mutable reference to the `World` to attach a frame upon
pub f... | true |
c2a2d9de5fbf058dd5209a99935ed5f5d97d0600 | Rust | odidev/advent-of-code | /crates/core/src/year2017/day10.rs | UTF-8 | 2,205 | 3.21875 | 3 | [
"MIT"
] | permissive | pub fn solution(input_string: &str, part1: bool) -> Result<String, String> {
const SIZE: usize = 256;
let mut list: Vec<u8> = (0..SIZE).map(|i| i as u8).collect();
let mut current_position = 0;
let mut skip_size = 0;
let input = if part1 {
input_string
.split(',')
.... | true |
386f18622b4196fbf00d639ff7cf7b19e4a50118 | Rust | GustavoKatel/interpolation_algorithms | /rust/lagrange/src/lib.rs | UTF-8 | 1,068 | 3.03125 | 3 | [] | no_license | pub mod lagrange {
pub fn interpolation(points: &[(f64, f64)], x : f64) -> f64 {
let mut i : i32 = -1;
let res = points
.iter()
.fold(0.0 as f64, |acc, &(xi, yi)| {
i+=1;
return acc + yi * lsum(points, i, x);
... | true |
a6b6b39f45a3a72e12cd6683a07679282b9862d7 | Rust | gnoliyil/fuchsia | /src/lib/assembly/fvm/src/nand.rs | UTF-8 | 4,064 | 2.765625 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use anyhow::Result;
use assembly_tool::Tool;
use camino::Utf8PathBuf;
/// A builder that receives a sparse FVM, and prepares it for nand flashing.
///
///... | true |
42c6c6be4c7591d8135138c0b47e4dace1a13d3f | Rust | ruma/ruma | /crates/ruma-events/src/key/verification/ready.rs | UTF-8 | 5,232 | 2.671875 | 3 | [
"MIT"
] | permissive | //! Types for the [`m.key.verification.ready`] event.
//!
//! [`m.key.verification.ready`]: https://spec.matrix.org/latest/client-server-api/#mkeyverificationready
use ruma_common::{OwnedDeviceId, OwnedTransactionId};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use super::VerificationMethod;
u... | true |
c148fbe9d2cfd4617bf8276d39d00638afc1adb5 | Rust | casey/RustRoguelike | /roguelike_core/src/map.rs | UTF-8 | 34,086 | 2.8125 | 3 | [] | no_license | use std::ops::{Index, IndexMut};
use std::collections::HashSet;
use std::iter;
use rand::prelude::*;
use pathfinding::directed::astar::astar;
use smallvec::SmallVec;
use itertools::Itertools;
use log::trace;
use doryen_fov::{MapData, FovAlgorithm, FovRestrictive};
use euclid::*;
use serde_derive::*;
use crate:... | true |
bd313dd0bc7d0abdb936d2d99b77089f0fc766d5 | Rust | keithyin/weather_spider_rust | /src/main.rs | UTF-8 | 3,409 | 2.71875 | 3 | [] | no_license | // use http::Uri;
use hyper::body::HttpBody;
use hyper::client::HttpConnector;
use hyper::{Body, Client, Response, Uri};
use reqwest;
use serde_json;
use serde_json::Value;
use std::str;
use std::time::{SystemTime, UNIX_EPOCH};
use url::Url;
fn parse_json(mut body: &str) -> Result<Value, Box<dyn std::error::Error + Se... | true |
7eb15ee5f05da1d8082676bcca8c6a714b004bb3 | Rust | rogusdev/onetime-downloader | /src/storage/util.rs | UTF-8 | 575 | 2.875 | 3 | [
"MIT"
] | permissive |
use std::convert::TryFrom;
//use std::fmt::Display;
use crate::models::MyError;
// https://users.rust-lang.org/t/impl-tryinto-as-an-argument-in-a-function-complains-about-the-error-conversion/34004
pub fn try_from_vec<T, U: TryFrom<T, Error=MyError>> (items: Vec<T>, name: &'static str) -> Result<Vec<U>, MyError> {... | true |
0c577e99e4642b949aadd16ea373184649925a7a | Rust | bluss/itertools-num | /tests/tests.rs | UTF-8 | 991 | 2.921875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate itertools_num;
extern crate itertools;
use itertools_num::linspace;
use itertools::assert_equal;
#[test]
fn test_linspace() {
let iter = linspace::<f32>(0., 2., 3);
assert_equal(iter, vec![0., 1., 2.]);
let iter = linspace::<f32>(0., 1.0, 11);
for (a, b) in iter.zip(vec![ 0., 0.1, 0.2, 0... | true |
c30a9b121ae7d9aac92110ec7da4d89e4df8f8ff | Rust | yynlove/rust_study | /src/my_mod/suoyouquan.rs | UTF-8 | 845 | 3.921875 | 4 | [] | no_license | pub fn test_suoyouquan() {
//s值移入到函数中 之后不在有效
let s = String ::from("hello");
takes_ownership(s);
//返回值转移所有权
let s2 = String::from("abc");
let s3 = takes_and_give_back(s2);
println!("s3:{}",s3);
//转移返回值的所有权
let s1 = String::from("word");
let (s2, len) = calculate_length(s1);
p... | true |
3bdcee04b170e16958cef93f7e3ec914a12cef62 | Rust | memoryruins/const_format_crates | /const_format/src/fmt/std_type_impls.rs | UTF-8 | 5,950 | 2.859375 | 3 | [
"Zlib"
] | permissive | #![allow(missing_docs)]
use crate::{
fmt::{Error, Formatter},
marker_traits::IsStdKind,
wrapper_types::PWrapper,
};
mod ranges;
////////////////////////////////////////////////////////////////////////////////
impl PWrapper<&str> {
pub const fn const_display_fmt(&self, f: &mut Formatter<'_>) -> Resul... | true |
4c18c61eb777770b7ee198e58e8e486772fb5bdd | Rust | Andlon/embed-doc-image | /src/lib.rs | UTF-8 | 14,875 | 3.75 | 4 | [
"MIT"
] | permissive | //! Embed images in documentation.
//!
//! This crate enables the portable embedding of images in
//! `rustdoc`-generated documentation. Standard
//! web-compatible image formats should be supported. Please [file an issue][issue-tracker]
//! if you have problems. Read on to learn how it works.
//!
//! # Showcase
//!
//... | true |
891c541f71607eecb8ef9397fbd22e545663e1b7 | Rust | azreika/RAT | /src/formula.rs | UTF-8 | 10,151 | 3.671875 | 4 | [] | no_license | use std::fmt;
use crate::cnf;
/// Represents a general propositional formula.
/// Used to model any well-formed input formula.
pub enum Formula {
And(Box<Formula>, Box<Formula>),
Or(Box<Formula>, Box<Formula>),
Not(Box<Formula>),
Var(String),
Constant(bool),
}
impl fmt::Display for Formula {
f... | true |
f9ca9e3bb5a067e2ee99794edc278d04c508161f | Rust | akazukin5151/koneko-rs | /koneko-rs/src/files.rs | UTF-8 | 3,745 | 2.671875 | 3 | [
"MIT"
] | permissive | use std::io::{self, Read};
use std::collections::HashSet;
use std::path::{Path, PathBuf};
use std::fs::{self, DirEntry, File};
use crate::pure;
use crate::KONEKODIR;
use crate::data::{Data, UserData};
fn read_dir_to_string(d: io::Result<DirEntry>) -> String {
d.unwrap().file_name().to_str().unwrap().to_string()
}... | true |
bbd1058778f5639cb3b85d2fd1a4ff17dee1404b | Rust | robinzigmond/Advent-of-Code-2020 | /src/solutions/day19.rs | UTF-8 | 5,530 | 3.28125 | 3 | [] | no_license | use itertools::Itertools;
use nom::{
branch::alt, character::complete::char, combinator::map, multi::many1, sequence::tuple, IResult,
};
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
#[allow(dead_code)]
enum Parser {
ParseA,
ParseB,
Single(usize),
Pair(usize, usize),
... | true |
c2e45d1094d60f3a2169b6c56a64a59fda65949c | Rust | lazareviczoran/advent-of-code-2018 | /009-marble-mania/src/main.rs | UTF-8 | 1,476 | 3.484375 | 3 | [] | no_license | use std::collections::VecDeque;
fn main() {
// Input:
// 459 players; last marble is worth 72103 points
println!(
"Day 9: Marble Mania part1 solution\n {}",
find_high_score(72103, 459)
);
println!(
"Day 9: Marble Mania part2 solution\n {}",
find_high_score(7210300, 459)
);
}
fn find_high... | true |
8f093ca130ab8f8672f7e1ecd8231b7e7a71eb56 | Rust | tttanikawa/competitive-programming-rs | /src/data_structure/segment_tree.rs | UTF-8 | 2,734 | 3.59375 | 4 | [
"CC0-1.0"
] | permissive | /// Segment Tree for range queries
pub struct SegmentTree<T, F> {
seg: Vec<T>,
n: usize,
f: F,
initial_value: T,
}
impl<T: Copy, F> SegmentTree<T, F>
where
F: Fn(T, T) -> T,
{
pub fn new(size: usize, initial_value: T, f: F) -> SegmentTree<T, F> {
let mut m = 1;
while m <= size {... | true |
d4a561b3738219075811c39f7c63f5138f6fe134 | Rust | komu/gib2sgf | /src/go.rs | UTF-8 | 4,621 | 3.375 | 3 | [
"MIT"
] | permissive | //! Common Go specific definitions without dependencies to any file format
use std::fmt::{Debug, Formatter, Display};
use std::fmt;
use crate::go::GoMove::PlaceStone;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PlayerColor {
Black,
White,
}
#[derive(Clone, Copy, Eq, PartialEq)]
pub struct BoardCoord... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.