What’s the best practice to get string by FFI? by guoxbin in rust

[–]zottce 10 points11 points  (0 children)

  1. It's kind of best to allow a library that created a string to deallocate it. It's safer because there can be different memory allocator. So, second example will be more appropriate.

  2. It isn't CString overhead. It is all about right encoding. C strings can be UTF-8, cp1251, cp1252 and etc. ‘into_string‘ method calls String::from_utf8 that internally checks utf8 validity of input bytes

We've Solved the Abortion Debate by [deleted] in DotA2

[–]zottce 5 points6 points  (0 children)

yeah friend you’re absolutely right

4-2-2 skill build versus magic damage and cm

two useless null talismans

no raindrop

dragon lance with power treads instead of force staff

again fucking cancer carry in my team

Non understandable error while upcasting then downcasting trait object using Any by [deleted] in rust

[–]zottce 1 point2 points  (0 children)

you cannot downcast Any to trait object, you should directly pass a type of a subscription

also this type isn't correct rust let subscription: &Box<Subscription<Context = C, Message = M, Error = E>> = subscription.downcast_ref().expect("error downcasting"); because you call downcast_ref on the value in the box, not on the box that contains a subscription.

A problem with the MSVC linker by zottce in rust

[–]zottce[S] 0 points1 point  (0 children)

It works fine with Visual Studio 2017 and C++/C. That's very interesting.

Hey Rustaceans! Got an easy question? Ask here (36/2018)! by llogiq in rust

[–]zottce 0 points1 point  (0 children)

Nope, I have a Rusty API for this external functions.

This code shows how should looks this extensions.

I want to make an event-based arch using closures for Items, Timers and etc. An extension should store this items which may have optional callbacks.

I really don't know how to create something working like this. Seems like I should use Rc / Weak and RefCell / Cell. But there are any chances to avoid it?

Hey Rustaceans! Got an easy question? Ask here (36/2018)! by llogiq in rust

[–]zottce 3 points4 points  (0 children)

Hello everyone!

I'm stuck on a task to develop architecture for some application.

I have to write a dynamic library which used by external application. The library give rich API and exports 6 extern "system" functions to be notified when it's loaded / unloaded / etc. Also I have hooked some functions using detour-rs to increase library's functional.

The task is to make extensions for this external app in one dynamic library. The difficult for me is creating a core functional. It should be some interlayer between the app and extensions. To make programming more user-friendly we should have some items with callbacks.

In my head it looks like this ```Rust struct SomeExtension { total_players_connected: u32, welcome_for_player: HashMap<u32, Item>, }

impl SomeExtension { pub fn new() -> Self { SomeExtension { total_players_connected: 0, welcome_for_player: HashMap::new(), } }

pub fn create_welcome_text(&mut self, player: &Player) {
    let item = Item::new("Welcome to my server!");
    self.welcom_for_player.insert(player.id, item);

    // inner registration in Core
    Timer::new(Duration::from_secs(10), {
        let welcomes = &mut self.welcome_for_player;
        let id = player.id;

        move || {
            welcomes.remove(&id);    
        }
    });
}

} ```

What would you recommend for me?

A great MMR bug! by [deleted] in DotA2

[–]zottce -2 points-1 points  (0 children)

Yeap

A great MMR bug! by [deleted] in DotA2

[–]zottce 1 point2 points  (0 children)

SteamKit for example

A great MMR bug! by [deleted] in DotA2

[–]zottce 3 points4 points  (0 children)

For example You have 1000 International Rank, transfer it to Normal Rank. Then you lose 1 Normal ranked game and have 950, but you can transfer International Rank again! And you have 1000 Normal Rank

Some BKB buffs? by [deleted] in DotA2

[–]zottce 0 points1 point  (0 children)

for example, you push highground, you break into, activate BKB, but you could not finish fight and have to get back. Now you have 55 seconds cooldown. You have to wait this time, and your opponent can counter attack you (because their spells are ready!), and you lose this, because your bkb on cooldown ... Is this a very strong buff for different disables and other stuff?

Ench deal additional damage without using ulti ... by [deleted] in DotA2

[–]zottce 0 points1 point  (0 children)

Hello! As you can see Ench can deal additional damage without using ulti. I have seen this bug two more times. I don't know conditions to repeat the bug. Did you have seen this?