file_name large_stringlengths 4 69 | prefix large_stringlengths 0 26.7k | suffix large_stringlengths 0 24.8k | middle large_stringlengths 0 2.12k | fim_type large_stringclasses 4
values |
|---|---|---|---|---|
mod.rs | //! Implementations of the Wayland backends using the system `libwayland`
use crate::protocol::ArgumentType;
use wayland_sys::common::{wl_argument, wl_array};
#[cfg(any(test, feature = "client_system"))] | #[cfg(any(test, feature = "server_system"))]
pub mod server;
/// Magic static for wayland objects managed by wayland-client or wayland-server
///
/// This static serves no purpose other than existing at a stable address.
static RUST_MANAGED: u8 = 42;
unsafe fn free_arrays(signature: &[ArgumentType], arglist: &[wl_arg... | pub mod client; | random_line_split |
mod.rs | //! Implementations of the Wayland backends using the system `libwayland`
use crate::protocol::ArgumentType;
use wayland_sys::common::{wl_argument, wl_array};
#[cfg(any(test, feature = "client_system"))]
pub mod client;
#[cfg(any(test, feature = "server_system"))]
pub mod server;
/// Magic static for wayland objects... | (signature: &[ArgumentType], arglist: &[wl_argument]) {
for (typ, arg) in signature.iter().zip(arglist.iter()) {
if let ArgumentType::Array(_) = typ {
// Safety: the arglist provided arglist must be valid for associated signature
// and contains pointers to boxed arrays as appropriat... | free_arrays | identifier_name |
error.rs | use std::error::Error;
use std::fmt;
use std::io;
use crate::credential::CredentialsError;
use super::proto::xml::util::XmlParseError;
use super::request::{BufferedHttpResponse, HttpDispatchError};
use crate::client::SignAndDispatchError;
/// Generic error type returned by all rusoto requests.
#[derive(Debug, Partia... | (err: io::Error) -> Self {
RusotoError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl<E: Error +'static> fmt::Display for RusotoError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
RusotoError::Service(ref err) => write!(f, "{}", err),
Ru... | from | identifier_name |
error.rs | use std::error::Error;
use std::fmt;
use std::io;
use crate::credential::CredentialsError;
use super::proto::xml::util::XmlParseError;
use super::request::{BufferedHttpResponse, HttpDispatchError};
use crate::client::SignAndDispatchError;
/// Generic error type returned by all rusoto requests.
#[derive(Debug, Partia... |
}
impl<E: Error +'static> fmt::Display for RusotoError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
RusotoError::Service(ref err) => write!(f, "{}", err),
RusotoError::Validation(ref cause) => write!(f, "{}", cause),
RusotoError::Credentials... | {
RusotoError::HttpDispatch(HttpDispatchError::from(err))
} | identifier_body |
error.rs | use std::error::Error;
use std::fmt;
use std::io;
use crate::credential::CredentialsError;
use super::proto::xml::util::XmlParseError;
use super::request::{BufferedHttpResponse, HttpDispatchError};
use crate::client::SignAndDispatchError;
/// Generic error type returned by all rusoto requests.
#[derive(Debug, Partia... | }
}
} | RusotoError::Service(ref err) => Some(err),
RusotoError::Credentials(ref err) => Some(err),
RusotoError::HttpDispatch(ref err) => Some(err),
_ => None, | random_line_split |
nohup.rs | #![crate_name = "uu_nohup"]
/*
* This file is part of the uutils coreutils package.
*
* (c) 2014 Vsevolod Velichko <torkvemada@sorokdva.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate getopts;
extern crate libc;... |
}
fn find_stdout() -> File {
match OpenOptions::new()
.write(true)
.create(true)
.append(true)
.open(Path::new("nohup.out"))
{
Ok(t) => {
show_warning!("Output is redirected to: nohup.out");
t
}
Err(e) => {
let home = matc... | {
if unsafe { dup2(1, 2) } != 2 {
crash!(2, "Cannot replace STDERR: {}", Error::last_os_error())
}
} | conditional_block |
nohup.rs | #![crate_name = "uu_nohup"]
/*
* This file is part of the uutils coreutils package.
*
* (c) 2014 Vsevolod Velichko <torkvemada@sorokdva.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate getopts;
extern crate libc;... | show_error!("{}", f);
show_usage(&opts);
return 1;
}
};
if matches.opt_present("V") {
println!("{} {}", NAME, VERSION);
return 0;
}
if matches.opt_present("h") {
show_usage(&opts);
return 0;
}
if matches.free.is_empty(... |
let matches = match opts.parse(&args[1..]) {
Ok(m) => m,
Err(f) => { | random_line_split |
nohup.rs | #![crate_name = "uu_nohup"]
/*
* This file is part of the uutils coreutils package.
*
* (c) 2014 Vsevolod Velichko <torkvemada@sorokdva.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate getopts;
extern crate libc;... | () {
if is_stdin_interactive() {
let new_stdin = match File::open(Path::new("/dev/null")) {
Ok(t) => t,
Err(e) => crash!(2, "Cannot replace STDIN: {}", e),
};
if unsafe { dup2(new_stdin.as_raw_fd(), 0) }!= 0 {
crash!(2, "Cannot replace STDIN: {}", Error::l... | replace_fds | identifier_name |
nohup.rs | #![crate_name = "uu_nohup"]
/*
* This file is part of the uutils coreutils package.
*
* (c) 2014 Vsevolod Velichko <torkvemada@sorokdva.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate getopts;
extern crate libc;... | if is_stderr_interactive() {
if unsafe { dup2(1, 2) }!= 2 {
crash!(2, "Cannot replace STDERR: {}", Error::last_os_error())
}
}
}
fn find_stdout() -> File {
match OpenOptions::new()
.write(true)
.create(true)
.append(true)
.open(Path::new("nohup.out")... | {
if is_stdin_interactive() {
let new_stdin = match File::open(Path::new("/dev/null")) {
Ok(t) => t,
Err(e) => crash!(2, "Cannot replace STDIN: {}", e),
};
if unsafe { dup2(new_stdin.as_raw_fd(), 0) } != 0 {
crash!(2, "Cannot replace STDIN: {}", Error::las... | identifier_body |
crate.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
fn flag(&self, flag: ~str) -> Crate {
Crate {
flags: vec::append(self.flags.clone(), [flag]),
.. (*self).clone()
}
}
fn flags(&self, flags: ~[~str]) -> Crate {
Crate {
flags: vec::append(self.flags.clone(), flags),
.. (*self).clone()
... | {
Crate {
file: (*p).clone(),
flags: ~[],
cfgs: ~[]
}
} | identifier_body |
crate.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | }
impl Crate {
pub fn new(p: &Path) -> Crate {
Crate {
file: (*p).clone(),
flags: ~[],
cfgs: ~[]
}
}
fn flag(&self, flag: ~str) -> Crate {
Crate {
flags: vec::append(self.flags.clone(), [flag]),
.. (*self).clone()
... | pub struct Crate {
file: Path,
flags: ~[~str],
cfgs: ~[~str] | random_line_split |
crate.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (&self, flags: ~[~str]) -> Crate {
Crate {
flags: vec::append(self.flags.clone(), flags),
.. (*self).clone()
}
}
fn cfg(&self, cfg: ~str) -> Crate {
Crate {
cfgs: vec::append(self.cfgs.clone(), [cfg]),
.. (*self).clone()
}
}
... | flags | identifier_name |
prune_hidden_pass.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn run(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
let fold = Fold {
ctxt: srv.clone(),
fold_mod: fold_mod,
.. fold::default_any_fold(srv)
};
(fold.fold_doc)(&fold, doc)
}
fn fold_mod(
fold: &fold::Fold<astsrv::Srv>,
doc: doc::ModDoc
) -> doc::ModDoc {
let doc = ... | {
Pass {
name: ~"prune_hidden",
f: run
}
} | identifier_body |
prune_hidden_pass.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (srv: astsrv::Srv, doc: doc::ItemDoc) -> bool {
use syntax::ast_map;
let id = doc.id;
do astsrv::exec(srv) |ctxt| {
let attrs = match *ctxt.ast_map.get(&id) {
ast_map::node_item(item, _) => copy item.attrs,
_ => ~[]
};
attr_parser::parse_hidden(attrs)
}
}
#[... | is_hidden | identifier_name |
prune_hidden_pass.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | use pass::Pass;
pub fn mk_pass() -> Pass {
Pass {
name: ~"prune_hidden",
f: run
}
}
pub fn run(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
let fold = Fold {
ctxt: srv.clone(),
fold_mod: fold_mod,
.. fold::default_any_fold(srv)
};
(fold.fold_doc)(&fold, doc... | random_line_split | |
julian_time.rs | /*
* The MIT License (MIT)
*
* Copyright (c) 2015 Andres Vahter (andres.vahter@gmail.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limit... |
/// Astronomical Formulae for Calculators, Jean Meeus, pages 23-25.
/// Calculate Julian Date of 0.0 Jan year
fn julian_date_of_year(yr: i32) -> f64 {
let year: u64 = yr as u64 -1;
let mut i: f64 = (year as f64 / 100.).trunc();
let a: f64 = i;
i = (a / 4.).trunc();
let b: f64 = (2. - a + i).trunc(... | {
(h as f64 + (m as f64 + s as f64 / 60.0) / 60.0) / 24.0
} | identifier_body |
julian_time.rs | /*
* The MIT License (MIT)
*
* Copyright (c) 2015 Andres Vahter (andres.vahter@gmail.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limit... | (yr: i32) -> f64 {
let year: u64 = yr as u64 -1;
let mut i: f64 = (year as f64 / 100.).trunc();
let a: f64 = i;
i = (a / 4.).trunc();
let b: f64 = (2. - a + i).trunc();
i = (365.25 * year as f64).trunc();
i += (30.6001_f64 * 14.0_f64).trunc();
i + 1720994.5 + b
}
/// Calculates the day... | julian_date_of_year | identifier_name |
julian_time.rs | /*
* The MIT License (MIT)
*
* Copyright (c) 2015 Andres Vahter (andres.vahter@gmail.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limit... | *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILI... | *
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software. | random_line_split |
julian_time.rs | /*
* The MIT License (MIT)
*
* Copyright (c) 2015 Andres Vahter (andres.vahter@gmail.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limit... |
day
}
#[test]
fn test_julian_timestamp() {
// http://en.wikipedia.org/wiki/Julian_day#Converting_Julian_or_Gregorian_calendar_date_to_Julian_Day_Number
let t = time::strptime("2000-1-1 12:00:00", "%Y-%m-%d %H:%M:%S").unwrap();
assert_eq!(julian_timestamp(t), 2451545.0);
let t = time::strptime("1... | {
day += 1;
} | conditional_block |
scale_button.rs | // Copyright 2013-2015, The Rust-GNOME Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
//! A button which pops up a scale
use libc::c_double;
use std::ptr;
use ffi;
/// Scal... | ize: i32, min: f64, max: f64, step: f64) -> Option<ScaleButton> {
let tmp_pointer = unsafe { ffi::gtk_scale_button_new(size, min as c_double, max as c_double, step as c_double, ptr::null_mut()) };
check_pointer!(tmp_pointer, ScaleButton)
}
}
impl_drop!(ScaleButton);
impl_TraitWidget!(ScaleButton);
... | w(s | identifier_name |
scale_button.rs | // Copyright 2013-2015, The Rust-GNOME Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
//! A button which pops up a scale
use libc::c_double;
use std::ptr;
use ffi;
/// Scal... |
impl_drop!(ScaleButton);
impl_TraitWidget!(ScaleButton);
impl ::ContainerTrait for ScaleButton {}
impl ::ButtonTrait for ScaleButton {}
impl ::ScaleButtonTrait for ScaleButton {}
impl ::OrientableTrait for ScaleButton {}
| let tmp_pointer = unsafe { ffi::gtk_scale_button_new(size, min as c_double, max as c_double, step as c_double, ptr::null_mut()) };
check_pointer!(tmp_pointer, ScaleButton)
}
} | identifier_body |
scale_button.rs | // Copyright 2013-2015, The Rust-GNOME Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
//! A button which pops up a scale
use libc::c_double;
use std::ptr;
use ffi;
/// Scal... | impl ::ContainerTrait for ScaleButton {}
impl ::ButtonTrait for ScaleButton {}
impl ::ScaleButtonTrait for ScaleButton {}
impl ::OrientableTrait for ScaleButton {} | random_line_split | |
newtypes.rs | //! Newtype structures.
//!
//! Mostly implementation of a fixed point Km representation.
use std::ops::{Add, Sub, Mul, Div};
use num::Zero;
use std::f64;
/// Distance measure in kilometers
#[derive(Clone, Copy, PartialEq, Debug, Eq, PartialOrd, Ord)]
pub struct Km(u64);
const POINT : usize = 32;
/// Can be cast to... | (self, other: Km) -> Km {
Km(self.0 + other.0)
}
}
impl Sub<Km> for Km {
type Output = Km;
fn sub(self, other: Km) -> Km {
Km(self.0 - other.0)
}
}
impl Mul<f64> for Km {
type Output = Km;
fn mul(self, other: f64) -> Km {
Km::from_f64(self.to_f64() * other)
}
}
imp... | add | identifier_name |
newtypes.rs | //! Newtype structures.
//!
//! Mostly implementation of a fixed point Km representation.
use std::ops::{Add, Sub, Mul, Div};
use num::Zero;
use std::f64;
/// Distance measure in kilometers
#[derive(Clone, Copy, PartialEq, Debug, Eq, PartialOrd, Ord)]
pub struct Km(u64);
const POINT : usize = 32;
/// Can be cast to... |
}
impl ToF64 for Option<Km> {
fn to_f64(&self) -> f64 {
self.map(|Km(u)| u as f64/((1u64 << POINT) as f64)).unwrap_or(f64::INFINITY)
}
}
impl Add<Km> for Km {
type Output = Km;
fn add(self, other: Km) -> Km {
Km(self.0 + other.0)
}
}
impl Sub<Km> for Km {
type Output = Km;
... | {
self.0 as f64/((1u64 << POINT) as f64)
} | identifier_body |
newtypes.rs | //! Newtype structures.
//!
//! Mostly implementation of a fixed point Km representation.
use std::ops::{Add, Sub, Mul, Div};
use num::Zero;
use std::f64;
/// Distance measure in kilometers
#[derive(Clone, Copy, PartialEq, Debug, Eq, PartialOrd, Ord)]
pub struct Km(u64);
const POINT : usize = 32;
/// Can be cast to... | /// use std::u32;
/// let valid = Km::from_f64_checked(0.0);
/// assert!(valid.is_some());
/// let invalid = Km::from_f64_checked(u32::MAX as f64 + 1.0);
/// assert_eq!(invalid, None, "Failed at 1");
/// let invalid = Km::from_f64_checked(-1.0);
/// assert_eq!(invalid, None, "Failed at 2");
... | /// # Examples
/// ```
/// use newtypes::Km; | random_line_split |
lib.rs | extern crate libc;
extern crate disasm6502;
use libc::*;
use std::ffi::CString;
const MY_NAME : *const c_char = b"6502.rs\0" as *const [u8] as *const c_char;
const R2_VERSION: &'static [u8] = b"1.2.0-git\0";
const MY_ARCH : &'static [u8] = b"6502\0";
const MY_DESC : &'static [u8] = b"6502 disassembler in Rust\0";
con... |
let opstr = ins.as_str();
let hexstr = ins.as_hex_str().replace(" ", "");
let inslen = (hexstr.len() / 2) as c_int;
(*asmop).size = inslen;
(*asmop).payload = 0;
(*asmop).buf_asm[0] = 0;
let opstrlen = std::... | {
(*asmop).payload = 0;
(*asmop).size = 1;
return -1;
} | conditional_block |
lib.rs | extern crate libc;
extern crate disasm6502;
use libc::*;
use std::ffi::CString;
const MY_NAME : *const c_char = b"6502.rs\0" as *const [u8] as *const c_char;
const R2_VERSION: &'static [u8] = b"1.2.0-git\0";
const MY_ARCH : &'static [u8] = b"6502\0";
const MY_DESC : &'static [u8] = b"6502 disassembler in Rust\0";
con... | {
RLibTypeIo = 0,
RLibTypeDbg = 1,
RLibTypeLang = 2,
RLibTypeAsm = 3,
RLibTypeAnal = 4,
RLibTypeParse = 5,
RLibTypeBin = 6,
RLibTypeBinXtr = 7,
RLibTypeBp = 8,
RLibTypeSyscall = 9,
RLibTypeFastcall = 10,
RLibTypeCrypto = 11,
RLibTypeCore = 12,
RLibTypeEgg = 13,
... | RLibType | identifier_name |
lib.rs | extern crate libc;
extern crate disasm6502;
use libc::*;
use std::ffi::CString;
const MY_NAME : *const c_char = b"6502.rs\0" as *const [u8] as *const c_char;
const R2_VERSION: &'static [u8] = b"1.2.0-git\0";
const MY_ARCH : &'static [u8] = b"6502\0";
const MY_DESC : &'static [u8] = b"6502 disassembler in Rust\0";
con... | return inslen;
}
}
}
-1
}
/*
extern "C" fn _init (foo: *mut c_void) -> bool {
true
}
extern "C" fn _mnemonics (foo: *const c_void, bar: c_int, cow: bool) -> *mut c_char {
b"\0".as_ptr() as *mut c_char
}
extern "C" fn _assemble (asm: *const c_void, str: *const c_ch... | opstrlen);
std::ptr::copy(
&buf, // as *const [u8] as *const c_char,
&mut (*asmop).buf as *mut [c_char] as *mut *const u8,
opstrlen); | random_line_split |
marking.rs | use crate::gc::root::Slot;
use crate::gc::{Address, Region};
pub fn start(rootset: &[Slot], heap: Region, perm: Region) {
let mut marking_stack: Vec<Address> = Vec::new();
for root in rootset {
let root_ptr = root.get();
if heap.contains(root_ptr) {
let root_obj = root_ptr.to_mut_... | else {
debug_assert!(field_addr.is_null() || perm.contains(field_addr));
}
});
}
}
| {
let field_obj = field_addr.to_mut_obj();
if !field_obj.header().is_marked_non_atomic() {
marking_stack.push(field_addr);
field_obj.header_mut().mark_non_atomic();
}
} | conditional_block |
marking.rs | use crate::gc::root::Slot;
use crate::gc::{Address, Region};
pub fn start(rootset: &[Slot], heap: Region, perm: Region) {
let mut marking_stack: Vec<Address> = Vec::new();
for root in rootset {
let root_ptr = root.get();
if heap.contains(root_ptr) {
let root_obj = root_ptr.to_mut_... | marking_stack.push(field_addr);
field_obj.header_mut().mark_non_atomic();
}
} else {
debug_assert!(field_addr.is_null() || perm.contains(field_addr));
}
});
}
} | if heap.contains(field_addr) {
let field_obj = field_addr.to_mut_obj();
if !field_obj.header().is_marked_non_atomic() { | random_line_split |
marking.rs | use crate::gc::root::Slot;
use crate::gc::{Address, Region};
pub fn start(rootset: &[Slot], heap: Region, perm: Region) | let object = object_addr.to_mut_obj();
object.visit_reference_fields(|field| {
let field_addr = field.get();
if heap.contains(field_addr) {
let field_obj = field_addr.to_mut_obj();
if!field_obj.header().is_marked_non_atomic() {
... | {
let mut marking_stack: Vec<Address> = Vec::new();
for root in rootset {
let root_ptr = root.get();
if heap.contains(root_ptr) {
let root_obj = root_ptr.to_mut_obj();
if !root_obj.header().is_marked_non_atomic() {
marking_stack.push(root_ptr);
... | identifier_body |
marking.rs | use crate::gc::root::Slot;
use crate::gc::{Address, Region};
pub fn | (rootset: &[Slot], heap: Region, perm: Region) {
let mut marking_stack: Vec<Address> = Vec::new();
for root in rootset {
let root_ptr = root.get();
if heap.contains(root_ptr) {
let root_obj = root_ptr.to_mut_obj();
if!root_obj.header().is_marked_non_atomic() {
... | start | identifier_name |
value.rs | /* This module collects value functions. */
use std::str::FromStr;
use game;
use game::{LineState, Position3, Position2};
#[derive(Clone, Copy, Debug)]
pub enum Simple {
Subsets,
WinOnly,
}
impl Simple {
pub fn value_of(self, state: &game::State, my_color: game::Color) -> i32 {
match self {
... |
/* New idea/project for a value function. Give each point a value, then each
column and in conclusion, give one to the whole board (if desired). This can also
be used to pick which actions to inspect further. */
// How much a particular action is worth to a player. The LastMissingPiece
// variant indicates that playi... | }
}
| random_line_split |
value.rs | /* This module collects value functions. */
use std::str::FromStr;
use game;
use game::{LineState, Position3, Position2};
#[derive(Clone, Copy, Debug)]
pub enum Simple {
Subsets,
WinOnly,
}
impl Simple {
pub fn value_of(self, state: &game::State, my_color: game::Color) -> i32 {
match self {
... | (state: &game::State, position: Position3) -> Option<(SideValue, SideValue)> {
use game::Color::White;
// This is only defined for empty positions.
if let game::PointState::Piece(_) = state.at(position) {
return None;
}
let mut white_value = 0;
let mut black_value = 0;
let mut last... | point_value | identifier_name |
value.rs | /* This module collects value functions. */
use std::str::FromStr;
use game;
use game::{LineState, Position3, Position2};
#[derive(Clone, Copy, Debug)]
pub enum Simple {
Subsets,
WinOnly,
}
impl Simple {
pub fn value_of(self, state: &game::State, my_color: game::Color) -> i32 {
match self {
... |
/* New idea/project for a value function. Give each point a value, then each
column and in conclusion, give one to the whole board (if desired). This can also
be used to pick which actions to inspect further. */
// How much a particular action is worth to a player. The LastMissingPiece
// variant indicates that pla... | {
if let game::VictoryState::Win { winner, .. } = state.victory_state {
if winner == my_color {
return 1;
} else {
return -1;
}
} else {
0
}
} | identifier_body |
graph_builder.rs | use std::rc::Rc;
use dl;
use graphics;
use matrix;
use piston::input;
use opengl_graphics::GlGraphics;
use super::dl_ui::Mouse;
use super::node::{Node, NodeAction, NodeResponse};
use super::op::Operation;
use super::var_store::{VarIndex, VarStore};
pub enum GraphAction {
SelectNode(NodeId),
SelectVariable(Va... | new_action = Some((NodeId(i), action));
break;
}
}
if let Some((old_node, old_action)) = self.node_action {
if let Some((new_node, _new_action)) = new_action {
if let Some(response) = old_action.happened_before(&_new_action,
... | for (i, node) in self.nodes.iter_mut().enumerate() {
node.event(event, mouse);
if let Some(action) = node.action { | random_line_split |
graph_builder.rs | use std::rc::Rc;
use dl;
use graphics;
use matrix;
use piston::input;
use opengl_graphics::GlGraphics;
use super::dl_ui::Mouse;
use super::node::{Node, NodeAction, NodeResponse};
use super::op::Operation;
use super::var_store::{VarIndex, VarStore};
pub enum | {
SelectNode(NodeId),
SelectVariable(VarIndex),
}
pub struct GraphBuilder {
pub graph: dl::Graph,
pub vars: VarStore,
dim_vars: Vec<usize>,
nodes: Vec<Node>,
edges: Vec<(NodeId, usize, NodeId, usize)>,
node_action: Option<(NodeId, NodeAction)>,
}
impl GraphBuilder {
pub fn new() -... | GraphAction | identifier_name |
wrapping_mul.rs | use num::arithmetic::traits::{WrappingMul, WrappingMulAssign};
macro_rules! impl_wrapping_mul {
($t:ident) => {
impl WrappingMul<$t> for $t {
type Output = $t;
#[inline]
fn wrapping_mul(self, other: $t) -> $t {
$t::wrapping_mul(self, other)
}... |
impl WrappingMulAssign<$t> for $t {
/// Replaces `self` with `self * other`, wrapping around at the boundary of the type.
///
/// $x \gets z$, where $z \equiv xy \mod 2^W$ and $W$ is `$t::WIDTH`.
///
/// # Worst-case complexity
/// Constan... | random_line_split | |
issue-42956.rs | // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {}
| main | identifier_name |
issue-42956.rs | // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-pass
#![allow(dead_code)]
#![allow(stable_features)]
#![feature(associated_co... | //
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | random_line_split |
issue-42956.rs | // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {} | identifier_body | |
zap.rs | use std::{fmt, mem, ptr, str, Seek};
use super::from_bytes::FromBytes;
const MZAP_ENT_LEN: usize = 64;
const MZAP_NAME_LEN: usize = MZAP_ENT_LEN - 8 - 4 - 2;
#[repr(u64)]
#[derive(Copy, Clone, Debug)]
pub enum ZapObjectType { | Micro = (1 << 63) + 3,
Header = (1 << 63) + 1,
Leaf = 1 << 63,
}
/// Microzap
#[repr(packed)]
pub struct MZapPhys {
pub block_type: ZapObjectType, // ZapObjectType::Micro
pub salt: u64,
pub norm_flags: u64,
pad: [u64; 5],
}
pub struct MZapWrapper {
pub phys: MZapPhys,
pub chunks: V... | random_line_split | |
zap.rs | use std::{fmt, mem, ptr, str, Seek};
use super::from_bytes::FromBytes;
const MZAP_ENT_LEN: usize = 64;
const MZAP_NAME_LEN: usize = MZAP_ENT_LEN - 8 - 4 - 2;
#[repr(u64)]
#[derive(Copy, Clone, Debug)]
pub enum | {
Micro = (1 << 63) + 3,
Header = (1 << 63) + 1,
Leaf = 1 << 63,
}
/// Microzap
#[repr(packed)]
pub struct MZapPhys {
pub block_type: ZapObjectType, // ZapObjectType::Micro
pub salt: u64,
pub norm_flags: u64,
pad: [u64; 5],
}
pub struct MZapWrapper {
pub phys: MZapPhys,
pub chunks... | ZapObjectType | identifier_name |
zap.rs | use std::{fmt, mem, ptr, str, Seek};
use super::from_bytes::FromBytes;
const MZAP_ENT_LEN: usize = 64;
const MZAP_NAME_LEN: usize = MZAP_ENT_LEN - 8 - 4 - 2;
#[repr(u64)]
#[derive(Copy, Clone, Debug)]
pub enum ZapObjectType {
Micro = (1 << 63) + 3,
Header = (1 << 63) + 1,
Leaf = 1 << 63,
}
/// Microzap
... | else {
Err("Error: needs a proper error message".to_string())
}
}
}
impl fmt::Debug for MZapWrapper {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f,
"MZapPhys {{\nblock_type: {:?},\nsalt: {:X},\nnorm_flags: {:X},\nchunk: [\n",
... | {
// Read the first part of the mzap -- its base phys struct
let mzap_phys = unsafe { ptr::read(data.as_ptr() as *const MZapPhys) };
// Read the mzap entries, aka chunks
let mut mzap_entries = Vec::new();
let num_entries = (data.len() - mem::size_of::<MZapPhys... | conditional_block |
zap.rs | use std::{fmt, mem, ptr, str, Seek};
use super::from_bytes::FromBytes;
const MZAP_ENT_LEN: usize = 64;
const MZAP_NAME_LEN: usize = MZAP_ENT_LEN - 8 - 4 - 2;
#[repr(u64)]
#[derive(Copy, Clone, Debug)]
pub enum ZapObjectType {
Micro = (1 << 63) + 3,
Header = (1 << 63) + 1,
Leaf = 1 << 63,
}
/// Microzap
... |
}
/// Fatzap
#[repr(packed)]
pub struct ZapPhys {
pub block_type: ZapObjectType, // ZapObjectType::Header
pub magic: u64,
pub ptr_table: ZapTablePhys,
pub free_block: u64,
pub num_leafs: u64,
pub num_entries: u64,
pub salt: u64,
pub pad: [u64; 8181],
pub leafs: [u64; 8192],
}
#[re... | {
try!(write!(f,
"MZapEntPhys {{\nvalue: {:X},\ncd: {:X},\nname: ",
self.value,
self.cd));
for i in 0..MZAP_NAME_LEN {
if self.name[i] == 0 {
break;
}
try!(write!(f, "{}", self.name[i] as char... | identifier_body |
mod.rs | //! Run-time feature detection on Linux
mod auxvec;
#[cfg(feature = "std_detect_file_io")]
mod cpuinfo;
cfg_if! {
if #[cfg(target_arch = "aarch64")] {
mod aarch64;
pub use self::aarch64::check_for;
} else if #[cfg(target_arch = "arm")] {
mod arm;
pub use self::arm::check_for;
... | }
} | } | random_line_split |
tempfile.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {
let path = Path::new("./frob/baz");
let cwd = os::getcwd();
println!("recursive_mkdir_rel_2: Making: {} in cwd {} [{:?}]", path.display(),
cwd.display(), path.exists());
fs::mkdir_recursive(&path, io::UserRWX);
assert!(path.is_dir());
assert!(path.dir_path().is_dir());
let pa... | recursive_mkdir_rel_2 | identifier_name |
tempfile.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
// Ideally this would be in core, but needs TempFile
pub fn test_rmdir_recursive_ok() {
let rwx = io::UserRWX;
let tmpdir = TempDir::new("test").expect("test_rmdir_recursive_ok: \
couldn't create temp dir");
let tmpdir = tmpdir.path();
let root = tmpdir.j... | {
let path = Path::new("./frob/baz");
let cwd = os::getcwd();
println!("recursive_mkdir_rel_2: Making: {} in cwd {} [{:?}]", path.display(),
cwd.display(), path.exists());
fs::mkdir_recursive(&path, io::UserRWX);
assert!(path.is_dir());
assert!(path.dir_path().is_dir());
let path2... | identifier_body |
tempfile.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | fail!("fail to unwind past `tmp`");
};
task::try(f);
let path = rx.recv();
assert!(!path.exists());
let tmp = TempDir::new("test_rm_tempdir").unwrap();
let path = tmp.path().clone();
let f: proc():Send = proc() {
let _tmp = tmp;
fail!("fail to unwind past `tmp`");
... | fn test_rm_tempdir() {
let (tx, rx) = channel();
let f: proc():Send = proc() {
let tmp = TempDir::new("test_rm_tempdir").unwrap();
tx.send(tmp.path().clone()); | random_line_split |
point.rs | use std::ops::{Add, Sub, Neg};
use num::{ToPrimitive, Num};
use drawable::Drawable;
use canvas::{Canvas, Colour};
use std::fmt::Debug;
#[derive(Copy, Clone, Debug)]
pub struct Point2D<T> {
pub x: T,
pub y: T
}
impl<T> Point2D<T> where T: Num {
pub fn new(x: T, y: T) -> Point2D<T> {
Point2D {
x: x, y: y
}
}... |
}
impl<T> Neg for Point2D<T> where T: Num + Neg<Output=T> + Debug {
type Output = Point2D<T>;
fn neg(self) -> Point2D<T> {
Point2D::new(-self.x, -self.y)
}
}
impl<T> Drawable for Point2D<T> where T: Copy + Num + ToPrimitive + Debug{
fn draw(&self, colour: Colour, canvas: &mut Canvas) {
canvas.set(self.x,... | {
Point2D::new(self.x - other.x, self.y - other.y)
} | identifier_body |
point.rs | use std::ops::{Add, Sub, Neg};
use num::{ToPrimitive, Num};
use drawable::Drawable;
use canvas::{Canvas, Colour};
use std::fmt::Debug;
#[derive(Copy, Clone, Debug)]
pub struct | <T> {
pub x: T,
pub y: T
}
impl<T> Point2D<T> where T: Num {
pub fn new(x: T, y: T) -> Point2D<T> {
Point2D {
x: x, y: y
}
}
}
impl<T> Add for Point2D<T> where T: Num + Add<T, Output=T> + Debug {
type Output = Point2D<T>;
fn add(self, other: Point2D<T>) -> Point2D<T> {
Point2D::new(self.x + other.x, ... | Point2D | identifier_name |
point.rs | use std::ops::{Add, Sub, Neg};
use num::{ToPrimitive, Num};
use drawable::Drawable;
use canvas::{Canvas, Colour};
use std::fmt::Debug;
#[derive(Copy, Clone, Debug)]
pub struct Point2D<T> {
pub x: T,
pub y: T
}
impl<T> Point2D<T> where T: Num {
pub fn new(x: T, y: T) -> Point2D<T> {
Point2D {
x: x, y: y
}
} | type Output = Point2D<T>;
fn add(self, other: Point2D<T>) -> Point2D<T> {
Point2D::new(self.x + other.x, self.y + other.y)
}
}
impl<T> Sub for Point2D<T> where T: Num + Sub<T, Output=T> + Debug {
type Output = Point2D<T>;
fn sub(self, other: Point2D<T>) -> Point2D<T> {
Point2D::new(self.x - other.x, self.y -... | }
impl<T> Add for Point2D<T> where T: Num + Add<T, Output=T> + Debug { | random_line_split |
mod.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | pub mod spec;
pub mod seal;
pub mod engine;
pub mod state;
pub mod ethash;
pub mod validator_set;
pub mod instant_seal;
pub mod basic_authority;
pub mod authority_round;
pub mod tendermint;
pub use self::account::Account;
pub use self::builtin::{Builtin, Pricing, Linear};
pub use self::genesis::Genesis;
pub use self::... | pub mod account;
pub mod builtin;
pub mod genesis;
pub mod params; | random_line_split |
super-fast-paren-parsing.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn main() {} | )))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))
; | random_line_split |
super-fast-paren-parsing.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {}
| main | identifier_name |
super-fast-paren-parsing.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {} | identifier_body | |
iter_cloned_collect.rs | use crate::methods::utils::derefs_to_slice;
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::ty::is_type_diagnostic_item; | use rustc_lint::LateContext;
use rustc_span::sym;
use super::ITER_CLONED_COLLECT;
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, recv: &'tcx hir::Expr<'_>) {
if_chain! {
if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(expr), sym::Vec);
if let Some(slice) = deref... | use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir as hir; | random_line_split |
iter_cloned_collect.rs | use crate::methods::utils::derefs_to_slice;
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_lint::LateContext;
use rustc_span::sym;
use super::ITER_CLONED_COLLECT;
pub(super) fn c... | {
if_chain! {
if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(expr), sym::Vec);
if let Some(slice) = derefs_to_slice(cx, recv, cx.typeck_results().expr_ty(recv));
if let Some(to_replace) = expr.span.trim_start(slice.span.source_callsite());
then {
span_lint_an... | identifier_body | |
iter_cloned_collect.rs | use crate::methods::utils::derefs_to_slice;
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_lint::LateContext;
use rustc_span::sym;
use super::ITER_CLONED_COLLECT;
pub(super) fn | <'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, recv: &'tcx hir::Expr<'_>) {
if_chain! {
if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(expr), sym::Vec);
if let Some(slice) = derefs_to_slice(cx, recv, cx.typeck_results().expr_ty(recv));
if let Some(to_replace) = expr.span.tr... | check | identifier_name |
renderer.rs |
use sdl2;
use sdl2::pixels;
use sdl2::rect::Rect;
use sdl2::image::LoadTexture;
use sdl2::video::{Window, WindowContext};
use sdl2::render::TextureCreator;
use std::path::Path;
use terminal::Terminal;
use font::FontDefinition;
use sprites::SpriteSheet;
pub struct Renderer {
sdl_canvas: sdl2::render::Canvas<Window... | cell.bg.a));
let _t = self.sdl_canvas
.fill_rect(Rect::new(px as i32,
py as i32,
sprite.size.width(),
spri... | {
let total_cells = terminal.columns * terminal.rows;
for i in 0..total_cells {
let mut cell = &mut terminal.grid[i as usize];
if cell.dirty {
self.sprite_sheet.texture.set_color_mod(cell.fg.r, cell.fg.g, cell.fg.b);
let sprite = self.sprite_shee... | identifier_body |
renderer.rs |
use sdl2;
use sdl2::pixels;
use sdl2::rect::Rect;
use sdl2::image::LoadTexture;
use sdl2::video::{Window, WindowContext};
use sdl2::render::TextureCreator;
use std::path::Path;
use terminal::Terminal;
use font::FontDefinition;
use sprites::SpriteSheet;
pub struct Renderer {
sdl_canvas: sdl2::render::Canvas<Window... |
// draw the actual character
sprite.draw(px as i32, py as i32, &mut self.sdl_canvas);
cell.dirty = false;
}
}
self.sdl_canvas.present();
}
}
| {
self.sprite_sheet.texture.set_color_mod(cell.fg.r, cell.fg.g, cell.fg.b);
let sprite = self.sprite_sheet.get_sprite((cell.glyph as u8) as usize);
let x = i % terminal.columns;
let y = i / terminal.columns;
let px = x * self.font.width;
... | conditional_block |
renderer.rs |
use sdl2;
use sdl2::pixels;
use sdl2::rect::Rect;
use sdl2::image::LoadTexture;
use sdl2::video::{Window, WindowContext};
use sdl2::render::TextureCreator;
use std::path::Path;
use terminal::Terminal;
use font::FontDefinition;
use sprites::SpriteSheet;
pub struct Renderer {
sdl_canvas: sdl2::render::Canvas<Window... | (terminal: &Terminal, font: FontDefinition) -> Self {
let video_subsystem = terminal.sdl_context.video().unwrap();
let window = video_subsystem.window("davokar-rl",
(terminal.columns * font.width) as u32,
(terminal.rows * font.height) as u32)
.position... | new | identifier_name |
renderer.rs | use sdl2;
use sdl2::pixels;
use sdl2::rect::Rect;
use sdl2::image::LoadTexture;
use sdl2::video::{Window, WindowContext};
use sdl2::render::TextureCreator;
use std::path::Path;
use terminal::Terminal;
use font::FontDefinition;
use sprites::SpriteSheet;
pub struct Renderer {
sdl_canvas: sdl2::render::Canvas<Window>... | let texture_result = texture_creator.load_texture(Path::new(font.image_path));
match texture_result {
Ok(texture) => Ok(SpriteSheet::new(texture, font.width, font.height, font.padding)),
Err(_) => Err("failed to load font texture"),
}
}
pub fn draw(&mut self, t... | fn load_font_sheet(font: &FontDefinition,
texture_creator: &TextureCreator<WindowContext>)
-> Result<SpriteSheet, &'static str> { | random_line_split |
config.in.rs | /*
Copyright (c) 2015, Alex Frappier Lachapelle
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
... | () -> TrelloBSTConfig {
TrelloBSTConfig {
key_val_map: BTreeMap::new(),
config_mode: Option::None
}
}
pub fn load(&mut self, config_mode: Option<PathBuf>) -> Result<(), &'static str> {
self.config_mode = config_mode;
//Parse if we're using a config file... | new | identifier_name |
config.in.rs | /*
Copyright (c) 2015, Alex Frappier Lachapelle
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
... |
use std::collections::BTreeMap;
use std::error::Error;
use std::fs::{File, OpenOptions};
use std::io::{Read, Write};
use std::path::PathBuf;
extern crate term;
use serde_json::Value;
////////////////////////////////////////////////////////////
// Macros //
/////////... | */ | random_line_split |
config.in.rs | /*
Copyright (c) 2015, Alex Frappier Lachapelle
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
... | self.config_mode = Option::None;
return Err("Error: Failed to gather metadata of the configuration file, TrelloBST will continue without saving inputted values into the configuration file.")
}
};
//Parse config file
let file_le... | {
self.config_mode = config_mode;
//Parse if we're using a config file, silently skip if were not
if self.config_mode.is_some() {
//Load file
let mut file = match File::open(self.clone().config_mode.unwrap().as_path()) {
Ok(file) => file,
... | identifier_body |
huffman.rs | use std::fmt;
use crate::decoders::basics::*;
const DECODE_CACHE_BITS: u32 = 13;
pub struct HuffTable {
// These two fields directly represent the contents of a JPEG DHT marker
pub bits: [u32;17],
pub huffval: [u32;256],
// Represent the weird shifts that are needed for some NEF files
pub shiftval: [u32;25... | nbits: u32,
}
impl MockPump {
pub fn empty() -> Self {
MockPump {
bits: 0,
nbits: 0,
}
}
pub fn set(&mut self, bits: u32, nbits: u32) {
self.bits = (bits as u64) << 32;
self.nbits = nbits + 32;
}
pub fn validbits(&self) -> i32 {
self.nbits as i32 - 32
}
}
impl BitPump f... | random_line_split | |
huffman.rs | use std::fmt;
use crate::decoders::basics::*;
const DECODE_CACHE_BITS: u32 = 13;
pub struct HuffTable {
// These two fields directly represent the contents of a JPEG DHT marker
pub bits: [u32;17],
pub huffval: [u32;256],
// Represent the weird shifts that are needed for some NEF files
pub shiftval: [u32;25... |
pub fn initialize(&mut self) -> Result<(), String> {
// Find out the max code length and allocate a table with that size
self.nbits = 16;
for i in 0..16 {
if self.bits[16-i]!= 0 {
break;
}
self.nbits -= 1;
}
self.hufftable = vec![(0,0,0); 1 << self.nbits];
// Fill ... | {
let mut tbl = HuffTable {
bits: bits,
huffval: huffval,
shiftval: [0;256],
dng_bug: dng_bug,
disable_cache: false,
nbits: 0,
hufftable: Vec::new(),
decodecache: [None; 1 << DECODE_CACHE_BITS],
initialized: false,
};
tbl.initialize()?;
Ok(tbl)
} | identifier_body |
huffman.rs | use std::fmt;
use crate::decoders::basics::*;
const DECODE_CACHE_BITS: u32 = 13;
pub struct HuffTable {
// These two fields directly represent the contents of a JPEG DHT marker
pub bits: [u32;17],
pub huffval: [u32;256],
// Represent the weird shifts that are needed for some NEF files
pub shiftval: [u32;25... | (&mut self) -> Result<(), String> {
// Find out the max code length and allocate a table with that size
self.nbits = 16;
for i in 0..16 {
if self.bits[16-i]!= 0 {
break;
}
self.nbits -= 1;
}
self.hufftable = vec![(0,0,0); 1 << self.nbits];
// Fill in the table itself
... | initialize | identifier_name |
cube.rs | use vec3::Vec3;
use ray::Ray;
use model::bvh::{AABB, BoundingBox};
use model::hitable::{HitRecord, Hitable};
use model::hitable::flip_normals;
use model::rect::Rect;
pub struct Cube {
min: Vec3,
max: Vec3,
sides: Vec<Box<Hitable>>
}
impl Cube {
// Cube of size dimensions
pub fn new(dimensions: Vec... |
}
| {
AABB {
min: self.min,
max: self.max,
}
} | identifier_body |
cube.rs | use vec3::Vec3;
use ray::Ray;
use model::bvh::{AABB, BoundingBox};
use model::hitable::{HitRecord, Hitable};
use model::hitable::flip_normals;
use model::rect::Rect;
pub struct Cube {
min: Vec3,
max: Vec3,
sides: Vec<Box<Hitable>>
}
impl Cube {
// Cube of size dimensions
pub fn new(dimensions: Vec... | () -> Cube {
Cube::new_from_min_max(Vec3::new(-1.0,-1.0,-1.0), Vec3::new(1.0,1.0,1.0))
}
}
impl Hitable for Cube {
fn hit(&self, r: &Ray, t_min: f64, t_max: f64) -> Option<HitRecord> {
self.sides.hit(r,t_min,t_max)
}
}
impl BoundingBox for Cube {
fn bounding_box(&self) -> AABB {
... | unit_cube | identifier_name |
cube.rs | use vec3::Vec3;
use ray::Ray;
use model::bvh::{AABB, BoundingBox};
use model::hitable::{HitRecord, Hitable};
use model::hitable::flip_normals;
use model::rect::Rect;
pub struct Cube {
min: Vec3,
max: Vec3,
sides: Vec<Box<Hitable>>
}
impl Cube {
// Cube of size dimensions
pub fn new(dimensions: Vec... | sides.push(Box::new(Rect::xy_rect(p0.x, p1.x, p0.y, p1.y, p1.z)));
sides.push(Box::new(flip_normals(Rect::xy_rect(p0.x, p1.x, p0.y, p1.y, p0.z))));
sides.push(Box::new(Rect::xz_rect(p0.x, p1.x, p0.z, p1.z, p1.y)));
sides.push(Box::new(flip_normals(Rect::xz_rect(p0.x, p1.x, p0.z, p1.z, p0... | random_line_split | |
main.rs | extern crate orbital;
use std::fs::File;
use std::env;
use std::io::{Read, Write};
use wav::WavFile;
use orbital::*;
mod wav;
fn main() {
let url = match env::args().nth(1) {
Some(arg) => arg.clone(),
None => "none:",
};
let mut vec: Vec<u8> = Vec::new();
if let Ok(mut file) = File... |
}
while let Some(event) = window.poll() {
if let EventOption::Key(key_event) = event.to_option() {
if key_event.pressed && key_event.scancode == K_ESC {
break;
}
}
if let EventOption::Quit(_) = event.to_option() {
break;
}
... | {
audio.write(&wav.data);
} | conditional_block |
main.rs | extern crate orbital;
use std::fs::File;
use std::env;
use std::io::{Read, Write};
use wav::WavFile;
use orbital::*;
mod wav;
fn main() {
let url = match env::args().nth(1) {
Some(arg) => arg.clone(),
None => "none:",
};
let mut vec: Vec<u8> = Vec::new();
if let Ok(mut file) = File... | if!wav.data.is_empty() {
if let Ok(mut audio) = File::open("audio://") {
audio.write(&wav.data);
}
}
while let Some(event) = window.poll() {
if let EventOption::Key(key_event) = event.to_option() {
if key_event.pressed && key_event.scancode == K_ESC {
... | random_line_split | |
main.rs | extern crate orbital;
use std::fs::File;
use std::env;
use std::io::{Read, Write};
use wav::WavFile;
use orbital::*;
mod wav;
fn main() | }
while let Some(event) = window.poll() {
if let EventOption::Key(key_event) = event.to_option() {
if key_event.pressed && key_event.scancode == K_ESC {
break;
}
}
if let EventOption::Quit(_) = event.to_option() {
break;
}
... | {
let url = match env::args().nth(1) {
Some(arg) => arg.clone(),
None => "none:",
};
let mut vec: Vec<u8> = Vec::new();
if let Ok(mut file) = File::open(&url) {
file.read_to_end(&mut vec);
}
let mut window = Window::new(-1, -1, 320, 0, &("Player (".to_string() + &url + ... | identifier_body |
main.rs | extern crate orbital;
use std::fs::File;
use std::env;
use std::io::{Read, Write};
use wav::WavFile;
use orbital::*;
mod wav;
fn | () {
let url = match env::args().nth(1) {
Some(arg) => arg.clone(),
None => "none:",
};
let mut vec: Vec<u8> = Vec::new();
if let Ok(mut file) = File::open(&url) {
file.read_to_end(&mut vec);
}
let mut window = Window::new(-1, -1, 320, 0, &("Player (".to_string() + &url... | main | identifier_name |
types.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the F... | v: &Value) -> Result<Self> {
v.as_table()
.ok_or_else(|| Error::from(EM::EntryHeaderTypeError))
.and_then(|t| {
let get = |m: &Map<_, _>, what: &'static str, ek: &'static str| -> Result<GPSValue> {
m.get(what)
.ok_or_else(|| anyhow... | rom_value( | identifier_name |
types.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the F... | // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Result as FmtResult;
use toml::V... | // Lesser General Public License for more details.
// | random_line_split |
types.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the F... | }
|
write!(f, "longitude = {}\nlatitude = {}", self.longitude, self.latitude)
}
| identifier_body |
imagedata.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::ImageDataBinding;
use crate::dom::bindings::codegen::Bindings::Image... |
// https://html.spec.whatwg.org/multipage/#dom-imagedata-height
fn Height(&self) -> u32 {
self.height
}
#[allow(unsafe_code)]
// https://html.spec.whatwg.org/multipage/#dom-imagedata-data
unsafe fn Data(&self, _: *mut JSContext) -> NonNull<JSObject> {
NonNull::new(self.data.ge... | {
self.width
} | identifier_body |
imagedata.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::ImageDataBinding;
use crate::dom::bindings::codegen::Bindings::Image... | } else {
opt_height = Some(height);
}
}
let height = opt_height.unwrap();
if height == 0 {
return Err(Error::IndexSize);
}
let imagedata = Box::new(ImageData {
reflector_: Reflector::new(),
width: widt... | {
let cx = global.get_cx();
typedarray!(in(cx) let array_res: Uint8ClampedArray = jsobject);
let array = array_res.map_err(|_| {
Error::Type("Argument to Image data is not an Uint8ClampedArray".to_owned())
})?;
let byte_len = array.as_slice().... | conditional_block |
imagedata.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::ImageDataBinding;
use crate::dom::bindings::codegen::Bindings::Image... | {
reflector_: Reflector,
width: u32,
height: u32,
#[ignore_malloc_size_of = "mozjs"]
data: Heap<*mut JSObject>,
}
impl ImageData {
#[allow(unsafe_code)]
pub fn new(
global: &GlobalScope,
width: u32,
height: u32,
mut data: Option<Vec<u8>>,
) -> Fallible<D... | ImageData | identifier_name |
imagedata.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::ImageDataBinding;
use crate::dom::bindings::codegen::Bindings::Image... | assert!(!self.data.get().is_null());
let cx = Runtime::get();
assert!(!cx.is_null());
typedarray!(in(cx) let array: Uint8ClampedArray = self.data.get());
let array = array.as_ref().unwrap();
// NOTE(nox): This is just as unsafe as `as_slice` itself even though we
... |
/// Nothing must change the array on the JS side while the slice is live.
#[allow(unsafe_code)]
pub unsafe fn as_slice(&self) -> &[u8] { | random_line_split |
lib.rs | use std::thread;
#[no_mangle]
pub extern fn process(){
let handles: Vec<_> = (0..10).map(|_| {
thread::spawn(|| {
let mut _x = 0;
for _ in (0..10_000_001) {
_x += 1
}
})
}).collect();
for h in handles {
h.join()
.ok()
... |
}
#[no_mangle]
pub extern fn iterative_fibonacci(x: i64) -> i64{
if x <= 2 {
return x
}
let mut fib_prev: i64 = 1;
let mut fib: i64 = 1;
for _num in (0..x) {
let i: i64 = fib;
fib = fib + fib_prev;
fib_prev = i;
}
return fib;
}
#[test]
fn process() {
}
#[... | {
return fibonacci(x - 1) + fibonacci(x - 2);
} | conditional_block |
lib.rs | use std::thread;
#[no_mangle]
pub extern fn process(){
let handles: Vec<_> = (0..10).map(|_| {
thread::spawn(|| {
let mut _x = 0;
for _ in (0..10_000_001) {
_x += 1
}
})
}).collect();
for h in handles {
h.join()
.ok()
... | fib = fib + fib_prev;
fib_prev = i;
}
return fib;
}
#[test]
fn process() {
}
#[test]
fn fibonacci() {
}
#[test]
fn iterative_fibonacci() {
}
// cargo build --release which builds with optimizations on.
// We want this to be as fast as possible!
// You can find the output of the library i... | let mut fib: i64 = 1;
for _num in (0..x) {
let i: i64 = fib; | random_line_split |
lib.rs | use std::thread;
#[no_mangle]
pub extern fn process(){
let handles: Vec<_> = (0..10).map(|_| {
thread::spawn(|| {
let mut _x = 0;
for _ in (0..10_000_001) {
_x += 1
}
})
}).collect();
for h in handles {
h.join()
.ok()
... |
#[no_mangle]
pub extern fn iterative_fibonacci(x: i64) -> i64{
if x <= 2 {
return x
}
let mut fib_prev: i64 = 1;
let mut fib: i64 = 1;
for _num in (0..x) {
let i: i64 = fib;
fib = fib + fib_prev;
fib_prev = i;
}
return fib;
}
#[test]
fn process() {
}
#[te... | {
if x <= 2 {
return 1;
} else {
return fibonacci(x - 1) + fibonacci(x - 2);
}
} | identifier_body |
lib.rs | use std::thread;
#[no_mangle]
pub extern fn | (){
let handles: Vec<_> = (0..10).map(|_| {
thread::spawn(|| {
let mut _x = 0;
for _ in (0..10_000_001) {
_x += 1
}
})
}).collect();
for h in handles {
h.join()
.ok()
.expect("could not join a thread.");
... | process | identifier_name |
region.rs | use native;
use rustrt::rtio;
use rustrt::rtio::RtioFileStream;
use std::cell::Cell;
use std::os;
use array::*;
use chunk::{
BiomeId,
BlockState,
Chunk,
ChunkColumn,
EMPTY_CHUNK,
LightLevel,
SIZE
};
use minecraft::nbt::Nbt;
pub struct Region {
mmap: os::MemoryMap
}
impl Region {
p... | <T>(
f: |uint, uint, uint| -> T
) -> [[[T,..SIZE],..SIZE],..SIZE] {
Array::from_fn(|y| -> [[T,..SIZE],..SIZE]
Array::from_fn(|z| -> [T,..16]
Array::from_fn(|x| f(x, y, z))
)
)
}
... | array_16x16x16 | identifier_name |
region.rs | use native;
use rustrt::rtio;
use rustrt::rtio::RtioFileStream;
use std::cell::Cell;
use std::os;
use array::*;
use chunk::{
BiomeId,
BlockState,
Chunk,
ChunkColumn,
EMPTY_CHUNK,
LightLevel,
SIZE
};
use minecraft::nbt::Nbt;
pub struct Region {
mmap: os::MemoryMap
}
impl Region {
p... | blocks: array_16x16x16(|x, y, z| {
let i = (y * SIZE + z) * SIZE + x;
let top = match blocks_top {
Some(blocks_top) => {
(blocks_top[i >> 1] >> ((i & 1) * 4)) & 0x0f
}
... | let chunk = Chunk { | random_line_split |
region.rs | use native;
use rustrt::rtio;
use rustrt::rtio::RtioFileStream;
use std::cell::Cell;
use std::os;
use array::*;
use chunk::{
BiomeId,
BlockState,
Chunk,
ChunkColumn,
EMPTY_CHUNK,
LightLevel,
SIZE
};
use minecraft::nbt::Nbt;
pub struct Region {
mmap: os::MemoryMap
}
impl Region {
p... |
pub fn get_chunk_column(&self, x: u8, z: u8) -> Option<ChunkColumn> {
let locations = self.as_slice().slice_to(4096);
let i = 4 * ((x % 32) as uint + (z % 32) as uint * 32);
let start = (locations[i] as uint << 16)
| (locations[i + 1] as uint << 8)
| loc... | {
use std::mem;
use std::raw::Slice;
let slice = Slice {
data: self.mmap.data() as *const u8,
len: self.mmap.len()
};
unsafe { mem::transmute(slice) }
} | identifier_body |
lib.rs | //! A fast, low-level IO library for Rust focusing on non-blocking APIs, event
//! notification, and other useful utilities for building high performance IO
//! apps.
//!
//! # Goals
//!
//! * Fast - minimal overhead over the equivalent OS facilities (epoll, kqueue, etc...)
//! * Zero allocations
//! * A scalable readi... | (duration: Duration) -> u64 {
// Round up.
let millis = (duration.subsec_nanos() + NANOS_PER_MILLI - 1) / NANOS_PER_MILLI;
duration.as_secs().saturating_mul(MILLIS_PER_SEC).saturating_add(millis as u64)
}
}
| millis | identifier_name |
lib.rs | //! A fast, low-level IO library for Rust focusing on non-blocking APIs, event
//! notification, and other useful utilities for building high performance IO
//! apps.
//!
//! # Goals
//!
//! * Fast - minimal overhead over the equivalent OS facilities (epoll, kqueue, etc...)
//! * Zero allocations
//! * A scalable readi... | //! _ => unreachable!(),
//! }
//! }
//! }
//!
//! ```
#![doc(html_root_url = "https://docs.rs/mio/0.6.1")]
#![crate_name = "mio"]
#![cfg_attr(unix, deny(warnings))]
extern crate lazycell;
extern crate net2;
extern crate slab;
#[cfg(unix)]
extern crate libc;
#[cfg(windows)]
extern crate miow... | //! // The server just shuts down the socket, let's just exit
//! // from our event loop.
//! return;
//! } | random_line_split |
lib.rs | //! A fast, low-level IO library for Rust focusing on non-blocking APIs, event
//! notification, and other useful utilities for building high performance IO
//! apps.
//!
//! # Goals
//!
//! * Fast - minimal overhead over the equivalent OS facilities (epoll, kqueue, etc...)
//! * Zero allocations
//! * A scalable readi... |
}
| {
// Round up.
let millis = (duration.subsec_nanos() + NANOS_PER_MILLI - 1) / NANOS_PER_MILLI;
duration.as_secs().saturating_mul(MILLIS_PER_SEC).saturating_add(millis as u64)
} | identifier_body |
create-role.rs | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_iam::{Client, Error, Region, PKG_VERSION};
use std::fs;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
struct Opt {
/// The AWS... |
/// Whether to display additional information.
#[structopt(short, long)]
verbose: bool,
}
// Creates a role.
// snippet-start:[iam.rust.create-role]
async fn make_role(client: &Client, policy_file: &str, name: &str) -> Result<(), Error> {
// Read policy doc from file as a string
let doc = fs::read... |
/// The name of the file containing the policy document.
#[structopt(short, long)]
policy_file: String, | random_line_split |
create-role.rs | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_iam::{Client, Error, Region, PKG_VERSION};
use std::fs;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
struct Opt {
/// The AWS... |
// snippet-end:[iam.rust.create-role]
/// Creates an IAM role in the Region.
///
/// # Arguments
///
/// * `-a ACCOUNT-ID` - Your account ID.
/// * `-b BUCKET` - The name of the bucket where Config stores information about resources.
/// * `-n NAME` - The name of the role.
/// * `-p POLICY-NAME` - The name of the JSO... | {
// Read policy doc from file as a string
let doc = fs::read_to_string(policy_file).expect("Unable to read file");
let resp = client
.create_role()
.assume_role_policy_document(doc)
.role_name(name)
.send()
.await?;
println!(
"Created role with ARN {}",... | identifier_body |
create-role.rs | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_iam::{Client, Error, Region, PKG_VERSION};
use std::fs;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
struct Opt {
/// The AWS... |
let shared_config = aws_config::from_env().region(region_provider).load().await;
let client = Client::new(&shared_config);
make_role(&client, &policy_file, &name).await
}
| {
println!("IAM client version: {}", PKG_VERSION);
println!(
"Region: {}",
region_provider.region().await.unwrap().as_ref()
);
println!("Role name: {}", &name);
println!("Policy doc filename {}", &policy_file);
println!();
... | conditional_block |
create-role.rs | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_iam::{Client, Error, Region, PKG_VERSION};
use std::fs;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
struct Opt {
/// The AWS... | (client: &Client, policy_file: &str, name: &str) -> Result<(), Error> {
// Read policy doc from file as a string
let doc = fs::read_to_string(policy_file).expect("Unable to read file");
let resp = client
.create_role()
.assume_role_policy_document(doc)
.role_name(name)
.send()
... | make_role | identifier_name |
task_resolvers.rs | use chrono::{prelude::*};
use async_graphql::{Context, FieldResult, ID};
use eyre::{
eyre,
// Result,
// Context as _,
};
use super::{Task, TaskStatus, task_status::TaskStatusGQL};
use crate::{MachineMap, machine::{
MachineData,
messages::GetData,
}};
/// A spooled set of gcodes to be executed by... | ;
let mut duration = print_time + self.time_paused + self.time_blocked;
if let TaskStatus::Paused(paused_status) = &self.status {
duration += (Utc::now() - paused_status.paused_at).to_std()?;
} else if let Some(blocked_at) = machine_data.blocked_at {
if self.status.is_p... | {
return Ok(None)
} | conditional_block |
task_resolvers.rs | use chrono::{prelude::*};
use async_graphql::{Context, FieldResult, ID};
use eyre::{
eyre,
// Result,
// Context as _,
};
use super::{Task, TaskStatus, task_status::TaskStatusGQL};
use crate::{MachineMap, machine::{
MachineData,
messages::GetData,
}};
/// A spooled set of gcodes to be executed by... |
#[graphql(name = "settled")]
async fn _settled(&self) -> bool { self.status.is_settled() }
async fn total_lines(&self) -> u64 { self.total_lines }
async fn despooled_line_number(&self) -> &Option<u64> { &self.despooled_line_number }
async fn percent_complete(
&self,
#[graphql(de... | async fn _status(&self) -> TaskStatusGQL { (&self.status).into() }
#[graphql(name = "paused")]
async fn _paused(&self) -> bool { self.status.is_paused() } | random_line_split |
task_resolvers.rs | use chrono::{prelude::*};
use async_graphql::{Context, FieldResult, ID};
use eyre::{
eyre,
// Result,
// Context as _,
};
use super::{Task, TaskStatus, task_status::TaskStatusGQL};
use crate::{MachineMap, machine::{
MachineData,
messages::GetData,
}};
/// A spooled set of gcodes to be executed by... |
async fn eta<'ctx>(&self, ctx: &'ctx Context<'_>) -> FieldResult<Option<DateTime<Utc>>> {
let machines: &MachineMap = ctx.data()?;
let machines = machines.load();
let machine_id = (&self.machine_id).into();
let addr = machines.get(&machine_id)
.ok_or_else(|| eyre!("Unab... | {
self.estimated_print_time.map(|print_time| {
let millis = print_time.as_millis();
// Saturating conversion to u64
std::cmp::min(millis, std::u64::MAX as u128) as u64
})
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.